@@ -137,6 +137,10 @@ MainWindow::MainWindow(QWidget *parent) :
137137 connect (&pcb2gcodeProcess, SIGNAL (readyReadStandardError ()), this , SLOT (printOutput ()));
138138 connect (&pcb2gcodeProcess, SIGNAL (stateChanged (QProcess::ProcessState)), this , SLOT (changeKillCloseButtonText (QProcess::ProcessState)));
139139
140+ lastDir = QStandardPaths::writableLocation (QStandardPaths::HomeLocation);
141+ if ( lastDir.isEmpty () )
142+ QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve home location" ));
143+
140144 appDataLocation = QStandardPaths::writableLocation (QStandardPaths::DataLocation);
141145 if ( appDataLocation.isEmpty () )
142146 QMessageBox::information (this , tr (" Error" ), tr (" Can't retrieve standard folder location" ));
@@ -188,9 +192,12 @@ void MainWindow::getFilename(QLineEdit *saveTo, const QString name)
188192{
189193 QString filename;
190194
191- filename = QFileDialog::getOpenFileName (this , tr (" Select the" ) + name, lastDir );
195+ filename = QFileDialog::getOpenFileName (this , tr (" Select the " ) + name, lastDir );
192196 if ( !filename.isEmpty () )
193- saveTo->setText ( filename );
197+ {
198+ lastDir = QFileInfo (filename).path ();
199+ saveTo->setText ( filename );
200+ }
194201}
195202
196203void MainWindow::getOutputDirectory ()
@@ -199,7 +206,10 @@ void MainWindow::getOutputDirectory()
199206
200207 dirname = QFileDialog::getExistingDirectory (this , tr (" Select the output directory" ), lastDir );
201208 if ( !dirname.isEmpty () )
209+ {
210+ lastDir = dirname;
202211 ui->outputDirLineEdit ->setText ( dirname );
212+ }
203213}
204214
205215void MainWindow::changeMetricInputUnits (bool metric)
@@ -482,8 +492,11 @@ void MainWindow::askAndLoadConfFile()
482492
483493 filename = QFileDialog::getOpenFileName (this , tr (" Select a configuration file" ), lastDir );
484494 if ( !filename.isEmpty () )
495+ {
496+ lastDir = QFileInfo (filename).path ();
485497 if ( !loadConfFile (filename) )
486498 QMessageBox::information (this , tr (" Error" ), tr (" The selected file can't be opened" ));
499+ }
487500}
488501
489502bool MainWindow::loadConfFile (const QString filename)
@@ -549,7 +562,10 @@ void MainWindow::askAndSaveConfFile()
549562
550563 filename = QFileDialog::getSaveFileName (this , tr (" Save configuration file" ), lastDir);
551564 if ( !filename.isEmpty () )
565+ {
566+ lastDir = QFileInfo (filename).path ();
552567 saveConfFile (filename);
568+ }
553569}
554570
555571void MainWindow::saveConfFile (const QString filename)
0 commit comments