src/dialogs.cpp

Fri, 24 May 2013 15:23:56 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 24 May 2013 15:23:56 +0300
changeset 251
c4b96bc41298
parent 250
6e80f038e8df
child 258
f9c48d4481e1
permissions
-rw-r--r--

Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.

198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QDialog>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QLineEdit>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QSpinBox>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QDialogButtonBox>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QFileDialog>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include <QLabel>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include <QPushButton>
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
26 #include <QBoxLayout>
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
27 #include <QGridLayout>
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
28 #include <qprogressbar.h>
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "dialogs.h"
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
31 #include "widgets.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 #include "gui.h"
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include "gldraw.h"
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #include "docs.h"
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
35 #include "file.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 #include "dialogs.h"
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
38 extern_cfg (str, io_ldpath);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
39
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 // =============================================================================
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 for (int i = 0; i < 6; ++i) {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 if (i == 3)
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 rb_camera->rowBreak ();
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 rb_camera->addButton (g_CameraNames[i]);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 GL::Camera cam = g_win->R ()->camera ();
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 if (cam != GL::Free)
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 rb_camera->setValue ((int) cam);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 QGroupBox* gb_image = new QGroupBox ("Image", this);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 QLabel* lb_fpath = new QLabel ("File:");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 le_fpath = new QLineEdit;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 le_fpath->setFocus ();
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 QLabel* lb_ofs = new QLabel ("Origin:");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 btn_fpath = new QPushButton;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 btn_fpath->setIcon (getIcon ("folder"));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 connect (btn_fpath, SIGNAL (clicked ()), this, SLOT (slot_fpath ()));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 sb_ofsx = new QSpinBox;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 sb_ofsy = new QSpinBox;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 sb_ofsx->setRange (0, 10000);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 sb_ofsy->setRange (0, 10000);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 sb_ofsx->setSuffix (" px");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71 sb_ofsy->setSuffix (" px");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 QLabel* lb_dimens = new QLabel ("Dimensions:");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 dsb_lwidth = new QDoubleSpinBox;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 dsb_lheight = new QDoubleSpinBox;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 dsb_lwidth->setRange (0.0f, 10000.0f);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 dsb_lheight->setRange (0.0f, 10000.0f);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 dsb_lwidth->setSuffix (" LDU");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 dsb_lheight->setSuffix (" LDU");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
80 dsb_lwidth->setSpecialValueText ("Automatic");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 dsb_lheight->setSpecialValueText ("Automatic");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 dbb_buttons = makeButtonBox (*this);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 dbb_buttons->addButton (QDialogButtonBox::Help);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 connect (dbb_buttons, SIGNAL (helpRequested ()), this, SLOT (slot_help()));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 QHBoxLayout* fpathlayout = new QHBoxLayout;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
88 fpathlayout->addWidget (lb_fpath);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 fpathlayout->addWidget (le_fpath);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 fpathlayout->addWidget (btn_fpath);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 QGridLayout* metalayout = new QGridLayout;
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 metalayout->addWidget (lb_ofs, 0, 0);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 metalayout->addWidget (sb_ofsx, 0, 1);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95 metalayout->addWidget (sb_ofsy, 0, 2);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 metalayout->addWidget (lb_dimens, 1, 0);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 metalayout->addWidget (dsb_lwidth, 1, 1);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 metalayout->addWidget (dsb_lheight, 1, 2);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 QVBoxLayout* imagelayout = new QVBoxLayout (gb_image);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 imagelayout->addLayout (fpathlayout);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 imagelayout->addLayout (metalayout);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 QVBoxLayout* layout = new QVBoxLayout (this);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 layout->addWidget (rb_camera);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 layout->addWidget (gb_image);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 layout->addWidget (dbb_buttons);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ()));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110 connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ()));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 connect (rb_camera, SIGNAL (valueChanged (int)), this, SLOT (fillDefaults (int)));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 slot_dimensionsChanged ();
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 fillDefaults (cam);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 void OverlayDialog::fillDefaults (int newcam) {
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
118 overlayMeta& info = g_win->R ()->getOverlay (newcam);
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120 if (info.img != null) {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 le_fpath->setText (info.fname);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 sb_ofsx->setValue (info.ox);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 sb_ofsy->setValue (info.oy);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 dsb_lwidth->setValue (info.lw);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 dsb_lheight->setValue (info.lh);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126 } else {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
127 le_fpath->setText ("");
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
128 sb_ofsx->setValue (0);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 sb_ofsy->setValue (0);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130 dsb_lwidth->setValue (0.0f);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
131 dsb_lheight->setValue (0.0f);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135 str OverlayDialog::fpath () const { return le_fpath->text (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 ushort OverlayDialog::ofsx () const { return sb_ofsx->value (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137 ushort OverlayDialog::ofsy () const { return sb_ofsy->value (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 double OverlayDialog::lwidth () const { return dsb_lwidth->value (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 double OverlayDialog::lheight () const { return dsb_lheight->value (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 int OverlayDialog::camera () const { return rb_camera->value (); }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 void OverlayDialog::slot_fpath () {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143 le_fpath->setText (QFileDialog::getOpenFileName (null, "Overlay image"));
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 void OverlayDialog::slot_help () {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 showDocumentation (g_docs_overlays);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 void OverlayDialog::slot_dimensionsChanged () {
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0);
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable);
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
153 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
154
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
155 ReplaceCoordsDialog::ReplaceCoordsDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
156 cbg_axes = makeAxesBox ();
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
157
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
158 lb_search = new QLabel ("Search:");
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
159 lb_replacement = new QLabel ("Replacement:");
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
160
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
161 dsb_search = new QDoubleSpinBox;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
162 dsb_search->setRange (-10000.0f, 10000.0f);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
163
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
164 dsb_replacement = new QDoubleSpinBox;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
165 dsb_replacement->setRange (-10000.0f, 10000.0f);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
166
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
167 QGridLayout* valueLayout = new QGridLayout;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
168 valueLayout->setColumnStretch (1, 1);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
169 valueLayout->addWidget (lb_search, 0, 0);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
170 valueLayout->addWidget (dsb_search, 0, 1);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
171 valueLayout->addWidget (lb_replacement, 1, 0);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
172 valueLayout->addWidget (dsb_replacement, 1, 1);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
173
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
174 QVBoxLayout* layout = new QVBoxLayout;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
175 layout->addWidget (cbg_axes);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
176 layout->addLayout (valueLayout);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
177 layout->addWidget (makeButtonBox (*this));
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
178 setLayout (layout);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
179 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
180
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
181 double ReplaceCoordsDialog::searchValue () const {
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
182 return dsb_search->value ();
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
183 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
184
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
185 double ReplaceCoordsDialog::replacementValue () const {
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
186 return dsb_replacement->value ();
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
187 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
188
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
189 vector<int> ReplaceCoordsDialog::axes () const {
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
190 return cbg_axes->checkedValues ();
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
191 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
192
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
193 // =============================================================================
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
195 // =============================================================================
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
196 SetContentsDialog::SetContentsDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
197 setWindowTitle (APPNAME ": Set Contents");
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
198
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
199 lb_error = new QLabel;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
200 lb_errorIcon = new QLabel;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
201 lb_contents = new QLabel ("Set contents:", parent);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
202
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
203 le_contents = new QLineEdit (parent);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
204 le_contents->setWhatsThis ("The LDraw code of this object. The code written "
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
205 "here is expected to be valid LDraw code, invalid code here results "
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
206 "the object being turned into an error object. Please do refer to the "
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
207 "<a href=\"http://www.ldraw.org/article/218.html\">official file format "
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
208 "standard</a> for further information.");
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
209 le_contents->setMinimumWidth (384);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
210
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
211 QHBoxLayout* bottomRow = new QHBoxLayout;
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
212 bottomRow->addWidget (lb_errorIcon);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
213 bottomRow->addWidget (lb_error);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
214 bottomRow->addWidget (makeButtonBox (*this));
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
215
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
216 QVBoxLayout* layout = new QVBoxLayout (this);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
217 layout->addWidget (lb_contents);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
218 layout->addWidget (le_contents);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
219 layout->addLayout (bottomRow);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
220
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
221 setWindowTitle ("Set Contents");
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
222 setWindowIcon (getIcon ("set-contents"));
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
223 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
224
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
225 void SetContentsDialog::setObject (LDObject* obj) {
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
226 le_contents->setText (obj->getContents ().chars());
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
227
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
228 if (obj->getType() == LDObject::Gibberish) {
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
229 lb_error->setText (fmt ("<span style=\"color: #900\">%s</span>",
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
230 static_cast<LDGibberish*> (obj)->reason.chars()));
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
231
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
232 QPixmap errorPixmap = getIcon ("error").scaledToHeight (16);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
233 lb_errorIcon->setPixmap (errorPixmap);
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
234 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
235 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
236
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
237 str SetContentsDialog::text () const {
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
238 return le_contents->text ();
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
239 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
240
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
241 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
242 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f)
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
243 : QDialog (parent, f), m_validDefault (validDefault)
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
244 {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
245 QLabel* lb_description = null;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
246 lb_resolution = new QLabel ("---");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
247
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
248 if (validDefault == false)
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
249 lb_description = new QLabel ("Please input your LDraw directory");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
250
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
251 QLabel* lb_path = new QLabel ("LDraw path:");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
252 le_path = new QLineEdit;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
253 btn_findPath = new QPushButton;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
254 btn_findPath->setIcon (getIcon ("folder"));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
255
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
256 btn_tryConfigure = new QPushButton ("Configure");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
257 btn_tryConfigure->setIcon (getIcon ("settings"));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
258
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
259 btn_cancel = new QPushButton;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
260
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
261 if (validDefault == false) {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
262 btn_cancel->setText ("Exit");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
263 btn_cancel->setIcon (getIcon ("exit"));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
264 } else {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
265 btn_cancel->setText ("Cancel");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
266 btn_cancel->setIcon (getIcon ("cancel"));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
267 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
268
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
269 dbb_buttons = new QDialogButtonBox (QDialogButtonBox::Ok);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
270 dbb_buttons->addButton (btn_tryConfigure, QDialogButtonBox::ActionRole);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
271 dbb_buttons->addButton (btn_cancel, QDialogButtonBox::RejectRole);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
272 okButton ()->setEnabled (false);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
273
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
274 QHBoxLayout* inputLayout = new QHBoxLayout;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
275 inputLayout->addWidget (lb_path);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
276 inputLayout->addWidget (le_path);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
277 inputLayout->addWidget (btn_findPath);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
278
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
279 QVBoxLayout* mainLayout = new QVBoxLayout;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
280
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
281 if (validDefault == false)
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
282 mainLayout->addWidget (lb_description);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
283
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
284 mainLayout->addLayout (inputLayout);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
285 mainLayout->addWidget (lb_resolution);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
286 mainLayout->addWidget (dbb_buttons);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
287 setLayout (mainLayout);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
288
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
289 connect (le_path, SIGNAL (textEdited ()), this, SLOT (slot_tryConfigure ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
290 connect (btn_findPath, SIGNAL (clicked ()), this, SLOT (slot_findPath ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
291 connect (btn_tryConfigure, SIGNAL (clicked ()), this, SLOT (slot_tryConfigure ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
292 connect (dbb_buttons, SIGNAL (accepted ()), this, SLOT (accept ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
293 connect (dbb_buttons, SIGNAL (rejected ()), this, (validDefault) ? SLOT (reject ()) : SLOT (slot_exit ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
294
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
295 setPath (io_ldpath);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
296 if (validDefault)
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
297 slot_tryConfigure ();
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
298 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
299
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
300 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
301 QPushButton* LDrawPathDialog::okButton () {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
302 return dbb_buttons->button (QDialogButtonBox::Ok);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
303 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
304
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
305 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
306 void LDrawPathDialog::setPath (str path) {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
307 le_path->setText (path);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
308 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
309
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
310 // ========================================================================================================================================
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 249
diff changeset
311 str LDrawPathDialog::filename () const {
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
312 return le_path->text ();
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
313 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
314
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
315 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
316 void LDrawPathDialog::slot_findPath () {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
317 str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
318
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 249
diff changeset
319 if (~newpath > 0 && newpath != filename ()) {
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
320 setPath (newpath);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
321 slot_tryConfigure ();
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
322 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
323 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
324
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
325
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
326 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
327 void LDrawPathDialog::slot_exit () {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
328 exit (1);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
329 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
330
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
331 // ========================================================================================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
332 void LDrawPathDialog::slot_tryConfigure () {
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 249
diff changeset
333 if (LDPaths::tryConfigure (filename ()) == false) {
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
334 lb_resolution->setText (fmt ("<span style=\"color:red; font-weight: bold;\">%s</span>", LDPaths::getError().chars ()));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
335 okButton ()->setEnabled (false);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
336 return;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
337 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
338
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
339 lb_resolution->setText ("<span style=\"color: #7A0; font-weight: bold;\">OK!</span>");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
340 okButton ()->setEnabled (true);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
341 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
342
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
343 // =============================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
345 // =============================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
346 NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
347 lb_brickIcon = new QLabel;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
348 lb_brickIcon->setPixmap (getIcon ("brick"));
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
349
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
350 lb_name = new QLabel ("Name:");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
351 le_name = new QLineEdit;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
352 le_name->setMinimumWidth (320);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
353
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
354 lb_author = new QLabel ("Author:");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
355 le_author = new QLineEdit;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
356
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
357 rb_license = new RadioBox ("License", {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
358 "CCAL Redistributable",
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
359 "Non-redistributable",
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
360 "None",
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
361 }, CCAL);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
362
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
363 rb_BFC = new RadioBox ("BFC Winding", {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
364 "CCW",
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
365 "CW",
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
366 "None"
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
367 }, CCW);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
368
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
369 QHBoxLayout* boxes = new QHBoxLayout;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
370 boxes->addWidget (rb_license);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
371 boxes->addWidget (rb_BFC);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
372
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
373 QGridLayout* layout = new QGridLayout;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
374 layout->addWidget (lb_brickIcon, 0, 0);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
375 layout->addWidget (lb_name, 0, 1);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
376 layout->addWidget (le_name, 0, 2);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
377 layout->addWidget (lb_author, 1, 1);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
378 layout->addWidget (le_author, 1, 2);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
379 layout->addLayout (boxes, 2, 1, 1, 2);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
380 layout->addWidget (makeButtonBox (*this), 3, 2);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
381
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
382 setLayout (layout);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
383 setWindowTitle ("New Part");
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
384 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
385
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
386 // =============================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
388 // =============================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
389 void NewPartDialog::StaticDialog () {
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
390 NewPartDialog dlg (g_win);
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
391 if (dlg.exec () == false)
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
392 return;
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
393
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
394 newFile ();
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
395
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
396 short idx;
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
397 str author = dlg.le_author->text ();
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 249
diff changeset
398 vector<LDObject*>& objs = g_curfile->objs ();
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
399
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
400 idx = dlg.rb_BFC->value ();
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
401 const LDBFC::Type BFCType =
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
402 (idx == CCW) ? LDBFC::CertifyCCW :
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
403 (idx == CW) ? LDBFC::CertifyCW :
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
404 LDBFC::NoCertify;
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
405
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
406 idx = dlg.rb_license->value ();
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
407 const char* license =
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
408 (idx == CCAL) ? "Redistributable under CCAL version 2.0 : see CAreadme.txt" :
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
409 (idx == NonCA) ? "Not redistributable : see NonCAreadme.txt" :
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
410 null;
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
411
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
412 objs << new LDComment (dlg.le_name->text ());
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
413 objs << new LDComment ("Name: <untitled>.dat");
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
414 objs << new LDComment (fmt ("Author: %s", author.chars()));
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
415 objs << new LDComment (fmt ("!LDRAW_ORG Unofficial_Part"));
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
416
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
417 if (license != null)
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
418 objs << new LDComment (fmt ("!LICENSE %s", license));
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
419
251
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
420 objs << new LDEmpty;
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
421 objs << new LDBFC (BFCType);
c4b96bc41298 Made a vector class which wraps around std::vector... finally I have an operator<< for the thing.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
422 objs << new LDEmpty;
226
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
423
3dd9e63698cd Prompt for unsaved changes before loading or creating a new file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 212
diff changeset
424 g_win->fullRefresh ();
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
425 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
426
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
427 // =============================================================================
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
429 // =============================================================================
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
430 RotationPointDialog::RotationPointDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
431 rb_rotpoint = new RadioBox ("Rotation Point", { "Object center", "Custom" }, 0, Qt::Vertical, this);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
432 connect (rb_rotpoint, SIGNAL (valueChanged (int)), this, SLOT (radioBoxChanged ()));
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
433
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
434 gb_customPos = new QGroupBox ("Custom point", this);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
435 dsb_customX = new QDoubleSpinBox;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
436 dsb_customY = new QDoubleSpinBox;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
437 dsb_customZ = new QDoubleSpinBox;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
438
212
79c5205b807c Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
439 for (auto x : initlist<QDoubleSpinBox*> ({dsb_customX, dsb_customY, dsb_customZ}))
79c5205b807c Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
440 x->setRange (-10000.0f, 10000.0f);
79c5205b807c Fixed: rotation point dialog didn't accept negative custom coords; objects were rotated by the grid angle's half
Santeri Piippo <crimsondusk64@gmail.com>
parents: 211
diff changeset
441
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
442 QGridLayout* customLayout = new QGridLayout (gb_customPos);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
443 customLayout->setColumnStretch (1, 1);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
444 customLayout->addWidget (new QLabel ("X"), 0, 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
445 customLayout->addWidget (dsb_customX, 0, 1);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
446 customLayout->addWidget (new QLabel ("Y"), 1, 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
447 customLayout->addWidget (dsb_customY, 1, 1);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
448 customLayout->addWidget (new QLabel ("Z"), 2, 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
449 customLayout->addWidget (dsb_customZ, 2, 1);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
450
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
451 QVBoxLayout* layout = new QVBoxLayout (this);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
452 layout->addWidget (rb_rotpoint);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
453 layout->addWidget (gb_customPos);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
454 layout->addWidget (makeButtonBox (*this));
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
455 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
456
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
457 bool RotationPointDialog::custom () const {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
458 return rb_rotpoint->value () == 1;
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
459 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
460
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
461 vertex RotationPointDialog::customPos () const {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
462 return vertex (dsb_customX->value (), dsb_customY->value (), dsb_customZ->value ());
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
463 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
464
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
465 void RotationPointDialog::setCustom (bool custom) {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
466 rb_rotpoint->setValue (custom == true ? 1 : 0);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
467 gb_customPos->setEnabled (custom);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
468 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
469
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
470 void RotationPointDialog::setCustomPos (const vertex& pos) {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
471 dsb_customX->setValue (pos[X]);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
472 dsb_customY->setValue (pos[Y]);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
473 dsb_customZ->setValue (pos[Z]);
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
474 }
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
475
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
476 void RotationPointDialog::radioBoxChanged () {
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
477 setCustom (rb_rotpoint->value ());
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
478 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
479
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
480 // =============================================================================
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
481 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
482 // =============================================================================
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
483 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
484 progressBar = new QProgressBar;
250
6e80f038e8df Make LDOpenFile's members PROPERTIES
Santeri Piippo <crimsondusk64@gmail.com>
parents: 249
diff changeset
485 progressText = new QLabel ("Parsing...");
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
486 setNumLines (0);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
487 m_progress = 0;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
488
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
489 QDialogButtonBox* dbb_buttons = new QDialogButtonBox;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
490 dbb_buttons->addButton (QDialogButtonBox::Cancel);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
491 connect (dbb_buttons, SIGNAL (rejected ()), this, SLOT (reject ()));
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
492
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
493 QVBoxLayout* layout = new QVBoxLayout (this);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
494 layout->addWidget (progressText);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
495 layout->addWidget (progressBar);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
496 layout->addWidget (dbb_buttons);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
497 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
498
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
499 void OpenProgressDialog::callback_setNumLines () {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
500 progressBar->setRange (0, numLines ());
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
501 updateValues ();
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
502 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
503
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
504 void OpenProgressDialog::updateValues () {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
505 progressBar->setValue (progress ());
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
506 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
507
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
508 void OpenProgressDialog::updateProgress (int progress) {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
509 m_progress = progress;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
510 updateValues ();
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
511 }

mercurial