13
13
#include < QComboBox>
14
14
#include < QLineEdit>
15
15
#include < QFileDialog>
16
+ #include < QMessageBox>
16
17
17
18
RtiPlanRow::RtiPlanRow (RtiParameters ¶m, QFrame *parent): QFrame(parent), parameters(param) {
18
19
QHBoxLayout *layout = new QHBoxLayout (this );
@@ -321,17 +322,44 @@ RtiExportRow::RtiExportRow(RtiParameters ¶meters, QFrame *parent): RtiPlanRo
321
322
label->help ->setId (" rti/export" );
322
323
323
324
path_edit = new QLineEdit;
325
+ connect (path_edit, &QLineEdit::editingFinished,this , &RtiExportRow::verifyPath);
324
326
buttons->addWidget (path_edit);
325
327
QPushButton *path_button = new QPushButton (" ..." );
326
328
buttons->addWidget (path_button);
329
+ connect (path_button, &QPushButton::clicked, this , &RtiExportRow::selectOutput);
327
330
}
328
331
329
332
void RtiExportRow::setPath (QString path, bool emitting) {
330
333
path_edit->setText (path);
334
+ parameters.path = path;
335
+ }
336
+
337
+ void RtiExportRow::verifyPath () {
338
+ parameters.path = QString ();
339
+ QString path = path_edit->text ();
340
+ QDir path_dir (path);
341
+ path_dir.cdUp ();
342
+ if (!path_dir.exists ()) {
343
+ QMessageBox::warning (this , " Invalid output path" , " The specified path is not valid" );
344
+ return ;
345
+ }
346
+ QString extension;
347
+ if (parameters.format == RtiParameters::RTI) {
348
+ extension = parameters.basis == Rti::HSH ? " .rti" : " .ptm" ;
349
+ } else if (parameters.format == RtiParameters::IIP) {
350
+ extension = " .tif" ;
351
+ }
352
+ if (!path.endsWith (extension)) {
353
+ path += extension;
354
+ path_edit->setText (path);
355
+ }
356
+ parameters.path = path;
331
357
}
332
358
333
359
void RtiExportRow::selectOutput () {
334
360
// get folder if not legacy.
361
+ QString output_parent = qRelightApp->lastOutputDir ();
362
+
335
363
QString output;
336
364
if (parameters.format == RtiParameters::RTI) {
337
365
QString extension;
@@ -344,17 +372,20 @@ void RtiExportRow::selectOutput() {
344
372
extension = " .ptm" ;
345
373
label = " PTM file (*.ptm)" ;
346
374
}
347
- output = QFileDialog::getSaveFileName (this , " Select a file name" , QString () , label);
375
+ output = QFileDialog::getSaveFileName (this , " Select a file name" , output_parent , label);
348
376
if (output.isNull ()) return ;
349
377
350
378
if (!output.endsWith (extension))
351
379
output += extension;
352
380
353
381
} else {
354
- output = QFileDialog::getSaveFileName (this , " Select an output folder" , QString () );
382
+ output = QFileDialog::getSaveFileName (this , " Select an output folder" , output_parent );
355
383
if (output.isNull ()) return ;
356
384
}
357
- parameters.path = output;
385
+ QDir output_parent_dir (output);
386
+ output_parent_dir.cdUp ();
387
+ qRelightApp->setLastOutputDir (output_parent_dir.absolutePath ());
388
+ setPath (output);
358
389
}
359
390
360
391
void RtiExportRow::suggestPath () {
0 commit comments