130 void OverlayDialog::slot_dimensionsChanged() { |
137 void OverlayDialog::slot_dimensionsChanged() { |
131 bool enable = (ui->width->value() != 0) || (ui->height->value() != 0); |
138 bool enable = (ui->width->value() != 0) || (ui->height->value() != 0); |
132 ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (enable); |
139 ui->buttonBox->button (QDialogButtonBox::Ok)->setEnabled (enable); |
133 } |
140 } |
134 |
141 |
135 // ================================================================================================= |
142 // ============================================================================= |
|
143 // ----------------------------------------------------------------------------- |
136 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) : |
144 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) : |
137 QDialog (parent, f), |
145 QDialog (parent, f), |
138 m_validDefault (validDefault) { |
146 m_validDefault (validDefault) |
139 |
147 { |
140 ui = new Ui_LDPathUI; |
148 ui = new Ui_LDPathUI; |
141 ui->setupUi (this); |
149 ui->setupUi (this); |
142 ui->status->setText ("---"); |
150 ui->status->setText ("---"); |
143 |
151 |
144 if (validDefault) |
152 if (validDefault) |
179 |
189 |
180 str LDrawPathDialog::filename() const { |
190 str LDrawPathDialog::filename() const { |
181 return ui->path->text(); |
191 return ui->path->text(); |
182 } |
192 } |
183 |
193 |
|
194 // ============================================================================= |
|
195 // ----------------------------------------------------------------------------- |
184 void LDrawPathDialog::slot_findPath() { |
196 void LDrawPathDialog::slot_findPath() { |
185 str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); |
197 str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); |
186 |
198 |
187 if (newpath.length() > 0 && newpath != filename()) { |
199 if (newpath.length() > 0 && newpath != filename()) { |
188 setPath (newpath); |
200 setPath (newpath); |
189 slot_tryConfigure(); |
201 slot_tryConfigure(); |
190 } |
202 } |
191 } |
203 } |
192 |
204 |
|
205 // ============================================================================= |
|
206 // ----------------------------------------------------------------------------- |
193 void LDrawPathDialog::slot_exit() { |
207 void LDrawPathDialog::slot_exit() { |
194 exit (1); |
208 exit (1); |
195 } |
209 } |
196 |
210 |
|
211 // ============================================================================= |
|
212 // ----------------------------------------------------------------------------- |
197 void LDrawPathDialog::slot_tryConfigure() { |
213 void LDrawPathDialog::slot_tryConfigure() { |
198 if (LDPaths::tryConfigure (filename()) == false) { |
214 if (LDPaths::tryConfigure (filename()) == false) { |
199 ui->status->setText (fmt ("<span style=\"color:#700; \">%1</span>", LDPaths::getError())); |
215 ui->status->setText (fmt ("<span style=\"color:#700; \">%1</span>", LDPaths::getError())); |
200 okButton()->setEnabled (false); |
216 okButton()->setEnabled (false); |
201 return; |
217 return; |
202 } |
218 } |
203 |
219 |
204 ui->status->setText ("<span style=\"color: #270; \">OK!</span>"); |
220 ui->status->setText ("<span style=\"color: #270; \">OK!</span>"); |
205 okButton()->setEnabled (true); |
221 okButton()->setEnabled (true); |
206 } |
222 } |
207 |
223 |
|
224 // ============================================================================= |
|
225 // ----------------------------------------------------------------------------- |
208 void LDrawPathDialog::slot_accept() { |
226 void LDrawPathDialog::slot_accept() { |
209 config::save(); |
227 config::save(); |
210 accept(); |
228 accept(); |
211 } |
229 } |
212 |
230 |
213 // ============================================================================= |
231 // ============================================================================= |
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
232 // ----------------------------------------------------------------------------- |
215 // ============================================================================= |
|
216 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
233 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
217 ui = new Ui_OpenProgressUI; |
234 ui = new Ui_OpenProgressUI; |
218 ui->setupUi (this); |
235 ui->setupUi (this); |
219 ui->progressText->setText ("Parsing..."); |
236 ui->progressText->setText ("Parsing..."); |
220 |
237 |
221 setNumLines (0); |
238 setNumLines (0); |
222 m_progress = 0; |
239 m_progress = 0; |
223 } |
240 } |
224 |
241 |
|
242 // ============================================================================= |
|
243 // ----------------------------------------------------------------------------- |
225 OpenProgressDialog::~OpenProgressDialog() { |
244 OpenProgressDialog::~OpenProgressDialog() { |
226 delete ui; |
245 delete ui; |
227 } |
246 } |
228 |
247 |
|
248 // ============================================================================= |
|
249 // ----------------------------------------------------------------------------- |
229 READ_ACCESSOR (ulong, OpenProgressDialog::numLines) { |
250 READ_ACCESSOR (ulong, OpenProgressDialog::numLines) { |
230 return m_numLines; |
251 return m_numLines; |
231 } |
252 } |
232 |
253 |
|
254 // ============================================================================= |
|
255 // ----------------------------------------------------------------------------- |
233 SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines) { |
256 SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines) { |
234 m_numLines = val; |
257 m_numLines = val; |
235 ui->progressBar->setRange (0, numLines()); |
258 ui->progressBar->setRange (0, numLines()); |
236 updateValues(); |
259 updateValues(); |
237 } |
260 } |
238 |
261 |
|
262 // ============================================================================= |
|
263 // ----------------------------------------------------------------------------- |
239 void OpenProgressDialog::updateValues() { |
264 void OpenProgressDialog::updateValues() { |
240 ui->progressText->setText (fmt ("Parsing... %1 / %2", progress(), numLines())); |
265 ui->progressText->setText (fmt ("Parsing... %1 / %2", progress(), numLines())); |
241 ui->progressBar->setValue (progress()); |
266 ui->progressBar->setValue (progress()); |
242 } |
267 } |
243 |
268 |
|
269 // ============================================================================= |
|
270 // ----------------------------------------------------------------------------- |
244 void OpenProgressDialog::updateProgress (int progress) { |
271 void OpenProgressDialog::updateProgress (int progress) { |
245 m_progress = progress; |
272 m_progress = progress; |
246 updateValues(); |
273 updateValues(); |
247 } |
274 } |
248 |
275 |
|
276 // ============================================================================= |
|
277 // ----------------------------------------------------------------------------- |
249 ExtProgPathPrompt::ExtProgPathPrompt (str progName, QWidget* parent, Qt::WindowFlags f) : |
278 ExtProgPathPrompt::ExtProgPathPrompt (str progName, QWidget* parent, Qt::WindowFlags f) : |
250 QDialog (parent, f), |
279 QDialog (parent, f), |
251 ui (new Ui_ExtProgPath) |
280 ui (new Ui_ExtProgPath) |
252 { |
281 { |
253 ui->setupUi (this); |
282 ui->setupUi (this); |
257 ui->m_label->setText (labelText); |
286 ui->m_label->setText (labelText); |
258 |
287 |
259 connect (ui->m_findPath, SIGNAL (clicked (bool)), this, SLOT (findPath())); |
288 connect (ui->m_findPath, SIGNAL (clicked (bool)), this, SLOT (findPath())); |
260 } |
289 } |
261 |
290 |
|
291 // ============================================================================= |
|
292 // ----------------------------------------------------------------------------- |
262 ExtProgPathPrompt::~ExtProgPathPrompt() { |
293 ExtProgPathPrompt::~ExtProgPathPrompt() { |
263 delete ui; |
294 delete ui; |
264 } |
295 } |
265 |
296 |
|
297 // ============================================================================= |
|
298 // ----------------------------------------------------------------------------- |
266 void ExtProgPathPrompt::findPath() { |
299 void ExtProgPathPrompt::findPath() { |
267 str path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); |
300 str path = QFileDialog::getOpenFileName (null, "", "", g_extProgPathFilter); |
268 |
301 |
269 if (!path.isEmpty()) |
302 if (!path.isEmpty()) |
270 ui->m_path->setText (path); |
303 ui->m_path->setText (path); |
271 } |
304 } |
272 |
305 |
|
306 // ============================================================================= |
|
307 // ----------------------------------------------------------------------------- |
273 str ExtProgPathPrompt::getPath() const { |
308 str ExtProgPathPrompt::getPath() const { |
274 return ui->m_path->text(); |
309 return ui->m_path->text(); |
275 } |
310 } |