46 extern const char* g_extProgPathFilter; |
46 extern const char* g_extProgPathFilter; |
47 extern_cfg (String, io_ldpath); |
47 extern_cfg (String, io_ldpath); |
48 |
48 |
49 // ============================================================================= |
49 // ============================================================================= |
50 // ----------------------------------------------------------------------------- |
50 // ----------------------------------------------------------------------------- |
51 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
51 OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) |
52 ui = new Ui_OverlayUI; |
52 { ui = new Ui_OverlayUI; |
53 ui->setupUi (this); |
53 ui->setupUi (this); |
54 |
54 |
55 m_cameraArgs = { |
55 m_cameraArgs = |
56 { ui->top, GL::Top }, |
56 { { ui->top, GL::Top }, |
57 { ui->bottom, GL::Bottom }, |
57 { ui->bottom, GL::Bottom }, |
58 { ui->front, GL::Front }, |
58 { ui->front, GL::Front }, |
59 { ui->back, GL::Back }, |
59 { ui->back, GL::Back }, |
60 { ui->left, GL::Left }, |
60 { ui->left, GL::Left }, |
61 { ui->right, GL::Right } |
61 { ui->right, GL::Right } |
62 }; |
62 }; |
63 |
63 |
64 GL::Camera cam = g_win->R()->camera(); |
64 GL::Camera cam = g_win->R()->camera(); |
65 |
65 |
66 if (cam == GL::Free) |
66 if (cam == GL::Free) |
67 cam = GL::Top; |
67 cam = GL::Top; |
68 |
68 |
69 connect (ui->width, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged())); |
69 connect (ui->width, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged())); |
70 connect (ui->height, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged())); |
70 connect (ui->height, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged())); |
71 connect (ui->buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_help())); |
71 connect (ui->buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_help())); |
72 connect (ui->fileSearchButton, SIGNAL (clicked (bool)), this, SLOT (slot_fpath())); |
72 connect (ui->fileSearchButton, SIGNAL (clicked (bool)), this, SLOT (slot_fpath())); |
73 |
73 |
74 slot_dimensionsChanged(); |
74 slot_dimensionsChanged(); |
75 fillDefaults (cam); |
75 fillDefaults (cam); |
76 } |
76 } |
77 |
77 |
78 // ============================================================================= |
78 // ============================================================================= |
79 // ----------------------------------------------------------------------------- |
79 // ----------------------------------------------------------------------------- |
80 OverlayDialog::~OverlayDialog() { |
80 OverlayDialog::~OverlayDialog() |
81 delete ui; |
81 { delete ui; |
82 } |
82 } |
83 |
83 |
84 // ============================================================================= |
84 // ============================================================================= |
85 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
86 void OverlayDialog::fillDefaults (int newcam) { |
86 void OverlayDialog::fillDefaults (int newcam) |
87 overlayMeta& info = g_win->R()->getOverlay (newcam); |
87 { overlayMeta& info = g_win->R()->getOverlay (newcam); |
88 radioDefault<int> (newcam, m_cameraArgs); |
88 radioDefault<int> (newcam, m_cameraArgs); |
89 |
89 |
90 if (info.img != null) { |
90 if (info.img != null) |
91 ui->filename->setText (info.fname); |
91 { ui->filename->setText (info.fname); |
92 ui->originX->setValue (info.ox); |
92 ui->originX->setValue (info.ox); |
93 ui->originY->setValue (info.oy); |
93 ui->originY->setValue (info.oy); |
94 ui->width->setValue (info.lw); |
94 ui->width->setValue (info.lw); |
95 ui->height->setValue (info.lh); |
95 ui->height->setValue (info.lh); |
96 } else { |
96 } |
97 ui->filename->setText (""); |
97 else |
|
98 { ui->filename->setText (""); |
98 ui->originX->setValue (0); |
99 ui->originX->setValue (0); |
99 ui->originY->setValue (0); |
100 ui->originY->setValue (0); |
100 ui->width->setValue (0.0f); |
101 ui->width->setValue (0.0f); |
101 ui->height->setValue (0.0f); |
102 ui->height->setValue (0.0f); |
102 } |
103 } |
103 } |
104 } |
104 |
105 |
105 // ============================================================================= |
106 // ============================================================================= |
106 // ----------------------------------------------------------------------------- |
107 // ----------------------------------------------------------------------------- |
107 str OverlayDialog::fpath() const { |
108 str OverlayDialog::fpath() const |
108 return ui->filename->text(); |
109 { return ui->filename->text(); |
109 } |
110 } |
110 |
111 |
111 ushort OverlayDialog::ofsx() const { |
112 ushort OverlayDialog::ofsx() const |
112 return ui->originX->value(); |
113 { return ui->originX->value(); |
113 } |
114 } |
114 |
115 |
115 ushort OverlayDialog::ofsy() const { |
116 ushort OverlayDialog::ofsy() const |
116 return ui->originY->value(); |
117 { return ui->originY->value(); |
117 } |
118 } |
118 |
119 |
119 double OverlayDialog::lwidth() const { |
120 double OverlayDialog::lwidth() const |
120 return ui->width->value(); |
121 { return ui->width->value(); |
121 } |
122 } |
122 |
123 |
123 double OverlayDialog::lheight() const { |
124 double OverlayDialog::lheight() const |
124 return ui->height->value(); |
125 { return ui->height->value(); |
125 } |
126 } |
126 |
127 |
127 int OverlayDialog::camera() const { |
128 int OverlayDialog::camera() const |
128 return radioSwitch<int> (GL::Top, m_cameraArgs); |
129 { return radioSwitch<int> (GL::Top, m_cameraArgs); |
129 } |
130 } |
130 |
131 |
131 void OverlayDialog::slot_fpath() { |
132 void OverlayDialog::slot_fpath() |
132 ui->filename->setText (QFileDialog::getOpenFileName (null, "Overlay image")); |
133 { ui->filename->setText (QFileDialog::getOpenFileName (null, "Overlay image")); |
133 } |
134 } |
134 |
135 |
135 void OverlayDialog::slot_help() { |
136 void OverlayDialog::slot_help() |
136 showDocumentation (g_docs_overlays); |
137 { showDocumentation (g_docs_overlays); |
137 } |
138 } |
138 |
139 |
139 void OverlayDialog::slot_dimensionsChanged() { |
140 void OverlayDialog::slot_dimensionsChanged() |
140 bool enable = (ui->width->value() != 0) || (ui->height->value() != 0); |
141 { bool enable = (ui->width->value() != 0) || (ui->height->value() != 0); |
141 ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (enable); |
142 ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (enable); |
142 } |
143 } |
143 |
144 |
144 // ============================================================================= |
145 // ============================================================================= |
145 // ----------------------------------------------------------------------------- |
146 // ----------------------------------------------------------------------------- |
146 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) : |
147 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) : |
147 QDialog (parent, f), |
148 QDialog (parent, f), |
148 m_validDefault (validDefault) |
149 m_validDefault (validDefault) |
149 { |
150 { ui = new Ui_LDPathUI; |
150 ui = new Ui_LDPathUI; |
|
151 ui->setupUi (this); |
151 ui->setupUi (this); |
152 ui->status->setText ("---"); |
152 ui->status->setText ("---"); |
153 |
153 |
154 if (validDefault) |
154 if (validDefault) |
155 ui->heading->hide(); |
155 ui->heading->hide(); |
156 else { |
156 else |
157 cancelButton()->setText ("Exit"); |
157 { cancelButton()->setText ("Exit"); |
158 cancelButton()->setIcon (getIcon ("exit")); |
158 cancelButton()->setIcon (getIcon ("exit")); |
159 } |
159 } |
160 |
160 |
161 okButton()->setEnabled (false); |
161 okButton()->setEnabled (false); |
162 |
162 |
163 connect (ui->path, SIGNAL (textEdited (QString)), this, SLOT (slot_tryConfigure())); |
163 connect (ui->path, SIGNAL (textEdited (QString)), this, SLOT (slot_tryConfigure())); |
164 connect (ui->searchButton, SIGNAL (clicked()), this, SLOT (slot_findPath())); |
164 connect (ui->searchButton, SIGNAL (clicked()), this, SLOT (slot_findPath())); |
165 connect (ui->buttonBox, SIGNAL (rejected()), this, validDefault ? SLOT (reject()) : SLOT (slot_exit())); |
165 connect (ui->buttonBox, SIGNAL (rejected()), this, validDefault ? SLOT (reject()) : SLOT (slot_exit())); |
166 connect (ui->buttonBox, SIGNAL (accepted()), this, SLOT (slot_accept())); |
166 connect (ui->buttonBox, SIGNAL (accepted()), this, SLOT (slot_accept())); |
167 |
167 |
168 setPath (io_ldpath); |
168 setPath (io_ldpath); |
169 |
169 |
170 if (validDefault) |
170 if (validDefault) |
171 slot_tryConfigure(); |
171 slot_tryConfigure(); |
172 } |
172 } |
173 |
173 |
174 // ============================================================================= |
174 // ============================================================================= |
175 // ----------------------------------------------------------------------------- |
175 // ----------------------------------------------------------------------------- |
176 LDrawPathDialog::~LDrawPathDialog() { |
176 LDrawPathDialog::~LDrawPathDialog() |
177 delete ui; |
177 { delete ui; |
178 } |
178 } |
179 |
179 |
180 QPushButton* LDrawPathDialog::okButton() { |
180 QPushButton* LDrawPathDialog::okButton() |
181 return ui->buttonBox->button (QDialogButtonBox::Ok); |
181 { return ui->buttonBox->button (QDialogButtonBox::Ok); |
182 } |
182 } |
183 |
183 |
184 QPushButton* LDrawPathDialog::cancelButton() { |
184 QPushButton* LDrawPathDialog::cancelButton() |
185 return ui->buttonBox->button (QDialogButtonBox::Cancel); |
185 { return ui->buttonBox->button (QDialogButtonBox::Cancel); |
186 } |
186 } |
187 |
187 |
188 void LDrawPathDialog::setPath (str path) { |
188 void LDrawPathDialog::setPath (str path) |
189 ui->path->setText (path); |
189 { ui->path->setText (path); |
190 } |
190 } |
191 |
191 |
192 str LDrawPathDialog::filename() const { |
192 str LDrawPathDialog::filename() const |
193 return ui->path->text(); |
193 { return ui->path->text(); |
194 } |
194 } |
195 |
195 |
196 // ============================================================================= |
196 // ============================================================================= |
197 // ----------------------------------------------------------------------------- |
197 // ----------------------------------------------------------------------------- |
198 void LDrawPathDialog::slot_findPath() { |
198 void LDrawPathDialog::slot_findPath() |
199 str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); |
199 { str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); |
200 |
200 |
201 if (newpath.length() > 0 && newpath != filename()) { |
201 if (newpath.length() > 0 && newpath != filename()) |
202 setPath (newpath); |
202 { setPath (newpath); |
203 slot_tryConfigure(); |
203 slot_tryConfigure(); |
204 } |
204 } |
205 } |
205 } |
206 |
206 |
207 // ============================================================================= |
207 // ============================================================================= |
208 // ----------------------------------------------------------------------------- |
208 // ----------------------------------------------------------------------------- |
209 void LDrawPathDialog::slot_exit() { |
209 void LDrawPathDialog::slot_exit() |
210 exit (1); |
210 { exit (1); |
211 } |
211 } |
212 |
212 |
213 // ============================================================================= |
213 // ============================================================================= |
214 // ----------------------------------------------------------------------------- |
214 // ----------------------------------------------------------------------------- |
215 void LDrawPathDialog::slot_tryConfigure() { |
215 void LDrawPathDialog::slot_tryConfigure() |
216 if (LDPaths::tryConfigure (filename()) == false) { |
216 { if (LDPaths::tryConfigure (filename()) == false) |
217 ui->status->setText (fmt ("<span style=\"color:#700; \">%1</span>", LDPaths::getError())); |
217 { ui->status->setText (fmt ("<span style=\"color:#700; \">%1</span>", LDPaths::getError())); |
218 okButton()->setEnabled (false); |
218 okButton()->setEnabled (false); |
219 return; |
219 return; |
220 } |
220 } |
221 |
221 |
222 ui->status->setText ("<span style=\"color: #270; \">OK!</span>"); |
222 ui->status->setText ("<span style=\"color: #270; \">OK!</span>"); |
223 okButton()->setEnabled (true); |
223 okButton()->setEnabled (true); |
224 } |
224 } |
225 |
225 |
226 // ============================================================================= |
226 // ============================================================================= |
227 // ----------------------------------------------------------------------------- |
227 // ----------------------------------------------------------------------------- |
228 void LDrawPathDialog::slot_accept() { |
228 void LDrawPathDialog::slot_accept() |
229 Config::save(); |
229 { Config::save(); |
230 accept(); |
230 accept(); |
231 } |
231 } |
232 |
232 |
233 // ============================================================================= |
233 // ============================================================================= |
234 // ----------------------------------------------------------------------------- |
234 // ----------------------------------------------------------------------------- |
235 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
235 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) |
236 ui = new Ui_OpenProgressUI; |
236 { ui = new Ui_OpenProgressUI; |
237 ui->setupUi (this); |
237 ui->setupUi (this); |
238 ui->progressText->setText ("Parsing..."); |
238 ui->progressText->setText ("Parsing..."); |
239 |
239 |
240 setNumLines (0); |
240 setNumLines (0); |
241 m_progress = 0; |
241 m_progress = 0; |
242 } |
242 } |
243 |
243 |
244 // ============================================================================= |
244 // ============================================================================= |
245 // ----------------------------------------------------------------------------- |
245 // ----------------------------------------------------------------------------- |
246 OpenProgressDialog::~OpenProgressDialog() { |
246 OpenProgressDialog::~OpenProgressDialog() |
247 delete ui; |
247 { delete ui; |
248 } |
248 } |
249 |
249 |
250 // ============================================================================= |
250 // ============================================================================= |
251 // ----------------------------------------------------------------------------- |
251 // ----------------------------------------------------------------------------- |
252 READ_ACCESSOR (ulong, OpenProgressDialog::numLines) { |
252 READ_ACCESSOR (ulong, OpenProgressDialog::numLines) |
253 return m_numLines; |
253 { return m_numLines; |
254 } |
254 } |
255 |
255 |
256 // ============================================================================= |
256 // ============================================================================= |
257 // ----------------------------------------------------------------------------- |
257 // ----------------------------------------------------------------------------- |
258 SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines) { |
258 SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines) |
259 m_numLines = val; |
259 { m_numLines = val; |
260 ui->progressBar->setRange (0, numLines()); |
260 ui->progressBar->setRange (0, numLines()); |
261 updateValues(); |
261 updateValues(); |
262 } |
262 } |
263 |
263 |
264 // ============================================================================= |
264 // ============================================================================= |
265 // ----------------------------------------------------------------------------- |
265 // ----------------------------------------------------------------------------- |
266 void OpenProgressDialog::updateValues() { |
266 void OpenProgressDialog::updateValues() |
267 ui->progressText->setText (fmt ("Parsing... %1 / %2", progress(), numLines())); |
267 { ui->progressText->setText (fmt ("Parsing... %1 / %2", progress(), numLines())); |
268 ui->progressBar->setValue (progress()); |
268 ui->progressBar->setValue (progress()); |
269 } |
269 } |
270 |
270 |
271 // ============================================================================= |
271 // ============================================================================= |
272 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
273 void OpenProgressDialog::updateProgress (int progress) { |
273 void OpenProgressDialog::updateProgress (int progress) |
274 m_progress = progress; |
274 { m_progress = progress; |
275 updateValues(); |
275 updateValues(); |
276 } |
276 } |
277 |
277 |
278 // ============================================================================= |
278 // ============================================================================= |
279 // ----------------------------------------------------------------------------- |
279 // ----------------------------------------------------------------------------- |
280 ExtProgPathPrompt::ExtProgPathPrompt (str progName, QWidget* parent, Qt::WindowFlags f) : |
280 ExtProgPathPrompt::ExtProgPathPrompt (str progName, QWidget* parent, Qt::WindowFlags f) : |
281 QDialog (parent, f), |
281 QDialog (parent, f), |
282 ui (new Ui_ExtProgPath) |
282 ui (new Ui_ExtProgPath) |
283 { |
283 { ui->setupUi (this); |
284 ui->setupUi (this); |
284 |
285 |
|
286 str labelText = ui->m_label->text(); |
285 str labelText = ui->m_label->text(); |
287 labelText.replace ("<PROGRAM>", progName); |
286 labelText.replace ("<PROGRAM>", progName); |
288 ui->m_label->setText (labelText); |
287 ui->m_label->setText (labelText); |
289 |
288 |
290 connect (ui->m_findPath, SIGNAL (clicked (bool)), this, SLOT (findPath())); |
289 connect (ui->m_findPath, SIGNAL (clicked (bool)), this, SLOT (findPath())); |
291 } |
290 } |
292 |
291 |
293 // ============================================================================= |
292 // ============================================================================= |
294 // ----------------------------------------------------------------------------- |
293 // ----------------------------------------------------------------------------- |
295 ExtProgPathPrompt::~ExtProgPathPrompt() { |
294 ExtProgPathPrompt::~ExtProgPathPrompt() |
296 delete ui; |
295 { delete ui; |
297 } |
296 } |
298 |
297 |
299 // ============================================================================= |
298 // ============================================================================= |
300 // ----------------------------------------------------------------------------- |
299 // ----------------------------------------------------------------------------- |
301 void ExtProgPathPrompt::findPath() { |
300 void ExtProgPathPrompt::findPath() |
302 str path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); |
301 { str path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); |
303 |
302 |
304 if (!path.isEmpty()) |
303 if (!path.isEmpty()) |
305 ui->m_path->setText (path); |
304 ui->m_path->setText (path); |
306 } |
305 } |
307 |
306 |
308 // ============================================================================= |
307 // ============================================================================= |
309 // ----------------------------------------------------------------------------- |
308 // ----------------------------------------------------------------------------- |
310 str ExtProgPathPrompt::getPath() const { |
309 str ExtProgPathPrompt::getPath() const |
311 return ui->m_path->text(); |
310 { return ui->m_path->text(); |
312 } |
311 } |
313 |
312 |
314 // ============================================================================= |
313 // ============================================================================= |
315 // ----------------------------------------------------------------------------- |
314 // ----------------------------------------------------------------------------- |
316 AboutDialog::AboutDialog (QWidget* parent, Qt::WindowFlags f) : |
315 AboutDialog::AboutDialog (QWidget* parent, Qt::WindowFlags f) : |
317 QDialog (parent, f) |
316 QDialog (parent, f) |
318 { |
317 { Ui::AboutUI ui; |
319 Ui::AboutUI ui; |
|
320 ui.setupUi (this); |
318 ui.setupUi (this); |
321 ui.versionInfo->setText (fmt (tr ("LDForge %1"), fullVersionString())); |
319 ui.versionInfo->setText (fmt (tr ("LDForge %1"), fullVersionString())); |
322 |
320 |
323 QPushButton* mailButton = new QPushButton; |
321 QPushButton* mailButton = new QPushButton; |
324 mailButton->setText ("Contact"); |
322 mailButton->setText ("Contact"); |
325 mailButton->setIcon (getIcon ("mail")); |
323 mailButton->setIcon (getIcon ("mail")); |
326 ui.buttonBox->addButton (static_cast<QAbstractButton*> (mailButton), QDialogButtonBox::HelpRole); |
324 ui.buttonBox->addButton (static_cast<QAbstractButton*> (mailButton), QDialogButtonBox::HelpRole); |
327 connect (ui.buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_mail())); |
325 connect (ui.buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_mail())); |
328 |
326 |
329 setWindowTitle ("About " APPNAME); |
327 setWindowTitle ("About " APPNAME); |
330 } |
328 } |
331 |
329 |
332 // ============================================================================= |
330 // ============================================================================= |
333 // ----------------------------------------------------------------------------- |
331 // ----------------------------------------------------------------------------- |
334 void AboutDialog::slot_mail() { |
332 void AboutDialog::slot_mail() |
335 QDesktopServices::openUrl (QUrl ("mailto:Santeri Piippo <slatenails64@gmail.com>?subject=LDForge")); |
333 { QDesktopServices::openUrl (QUrl ("mailto:Santeri Piippo <slatenails64@gmail.com>?subject=LDForge")); |
336 } |
334 } |
337 #include "moc_dialogs.cpp" |
335 #include "moc_dialogs.cpp" |