@@ -177,8 +177,17 @@ MainWindow::MainWindow(QWidget *parent) :
177
177
settings = new QSettings (QSettings::IniFormat, QSettings::UserScope, " pcb2gcodeGUI" , " " , this );
178
178
179
179
ui->actionAutomatically_generate_previews ->setChecked (settings->value (" autoPreview" , true ).toBool ());
180
- lastDir = settings->value (" lastDir" , QStandardPaths::writableLocation (QStandardPaths::HomeLocation)).toString ();
181
- if (lastDir.isEmpty ())
180
+ lastGcodeDir = settings->value (" lastGcodeDir" , QStandardPaths::writableLocation (QStandardPaths::HomeLocation)).toString ();
181
+ if (lastGcodeDir.isEmpty ())
182
+ QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve home location" ));
183
+ lastPreambleDir = settings->value (" lastPreambleDir" , QStandardPaths::writableLocation (QStandardPaths::HomeLocation)).toString ();
184
+ if (lastPreambleDir.isEmpty ())
185
+ QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve home location" ));
186
+ lastOutputDir = settings->value (" lastOutputDir" , QStandardPaths::writableLocation (QStandardPaths::HomeLocation)).toString ();
187
+ if (lastOutputDir.isEmpty ())
188
+ QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve home location" ));
189
+ lastConfigDir = settings->value (" lastConfigDir" , QStandardPaths::writableLocation (QStandardPaths::HomeLocation)).toString ();
190
+ if (lastConfigDir.isEmpty ())
182
191
QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve home location" ));
183
192
184
193
this ->resize (settings->value (" Window/width" , this ->width ()).toInt (),
@@ -282,17 +291,17 @@ void MainWindow::getDrillFile()
282
291
283
292
void MainWindow::getPreambleFile ()
284
293
{
285
- getFilename (ui->preambleLineEdit , tr (" preamble file" ), gcode_file_filter);
294
+ getPreFilename (ui->preambleLineEdit , tr (" preamble file" ), gcode_file_filter);
286
295
}
287
296
288
297
void MainWindow::getPreambletextFile ()
289
298
{
290
- getFilename (ui->preambletextLineEdit , tr (" preamble text file" ), text_file_filter);
299
+ getPreFilename (ui->preambletextLineEdit , tr (" preamble text file" ), text_file_filter);
291
300
}
292
301
293
302
void MainWindow::getPostambleFile ()
294
303
{
295
- getFilename (ui->postambleLineEdit , tr (" postamble file" ), gcode_file_filter);
304
+ getPreFilename (ui->postambleLineEdit , tr (" postamble file" ), gcode_file_filter);
296
305
}
297
306
298
307
void MainWindow::generateImages ()
@@ -427,13 +436,29 @@ bool MainWindow::getFilename(QLineEdit *saveTo, const QString name, QString filt
427
436
{
428
437
QString filename;
429
438
430
- filename = QFileDialog::getOpenFileName (this , tr (" Select the " ) + name, lastDir, filter );
439
+ filename = QFileDialog::getOpenFileName (this , tr (" Select the " ) + name, lastGcodeDir, filter );
440
+
441
+ if ( filename.isEmpty () )
442
+ return false ;
443
+ else
444
+ {
445
+ lastGcodeDir = QFileInfo (filename).path ();
446
+ saveTo->setText ( filename );
447
+ return true ;
448
+ }
449
+ }
450
+
451
+ bool MainWindow::getPreFilename (QLineEdit *saveTo, const QString name, QString filter)
452
+ {
453
+ QString filename;
454
+
455
+ filename = QFileDialog::getOpenFileName (this , tr (" Select the " ) + name, lastPreambleDir, filter );
431
456
432
457
if ( filename.isEmpty () )
433
458
return false ;
434
459
else
435
460
{
436
- lastDir = QFileInfo (filename).path ();
461
+ lastPreambleDir = QFileInfo (filename).path ();
437
462
saveTo->setText ( filename );
438
463
return true ;
439
464
}
@@ -443,10 +468,10 @@ void MainWindow::getOutputDirectory()
443
468
{
444
469
QString dirname;
445
470
446
- dirname = QFileDialog::getExistingDirectory (this , tr (" Select the output directory" ), lastDir );
471
+ dirname = QFileDialog::getExistingDirectory (this , tr (" Select the output directory" ), lastOutputDir );
447
472
if ( !dirname.isEmpty () )
448
473
{
449
- lastDir = dirname;
474
+ lastOutputDir = dirname;
450
475
ui->outputDirLineEdit ->setText ( dirname );
451
476
}
452
477
}
@@ -734,10 +759,10 @@ void MainWindow::askAndLoadConfFile()
734
759
{
735
760
QString filename;
736
761
737
- filename = QFileDialog::getOpenFileName (this , tr (" Select a configuration file" ), lastDir );
762
+ filename = QFileDialog::getOpenFileName (this , tr (" Select a configuration file" ), lastConfigDir );
738
763
if ( !filename.isEmpty () )
739
764
{
740
- lastDir = QFileInfo (filename).path ();
765
+ lastConfigDir = QFileInfo (filename).path ();
741
766
if ( !loadConfFile (filename) )
742
767
QMessageBox::information (this , tr (" Error" ), tr (" The selected file can't be opened" ));
743
768
}
@@ -819,10 +844,10 @@ void MainWindow::askAndSaveConfFile()
819
844
{
820
845
QString filename;
821
846
822
- filename = QFileDialog::getSaveFileName (this , tr (" Save configuration file" ), lastDir );
847
+ filename = QFileDialog::getSaveFileName (this , tr (" Save configuration file" ), lastConfigDir );
823
848
if ( !filename.isEmpty () )
824
849
{
825
- lastDir = QFileInfo (filename).path ();
850
+ lastConfigDir = QFileInfo (filename).path ();
826
851
saveConfFile (filename);
827
852
}
828
853
}
@@ -930,7 +955,10 @@ void MainWindow::closeEvent(QCloseEvent *)
930
955
QDir ().rmdir (imagesFolder);
931
956
932
957
settings->setValue (" autoPreview" , ui->actionAutomatically_generate_previews ->isChecked ());
933
- settings->setValue (" lastDir" , lastDir);
958
+ settings->setValue (" lastGcodeDir" , lastGcodeDir);
959
+ settings->setValue (" lastPreambleDir" , lastPreambleDir);
960
+ settings->setValue (" lastOutputDir" , lastOutputDir);
961
+ settings->setValue (" lastConfigDir" , lastConfigDir);
934
962
935
963
settings->setValue (" Window/width" , this ->width ());
936
964
settings->setValue (" Window/height" , this ->height ());
0 commit comments