summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/mainwindow.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 9496f6160..ce9aadc62 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -87,10 +87,27 @@ void MainWindow::on_actionNew_triggered()
void MainWindow::on_actionOpen_triggered()
{
- QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath(), filter());
+ QSettings settings;
+ QString lastDir = QDir::homePath();
+
+ settings.beginGroup("FileDialog");
+ if (settings.contains("LastDir")) {
+ if(QDir::setCurrent(settings.value("LastDir").toString())) {
+ lastDir = settings.value("LastDir").toString();
+ }
+ }
+ settings.endGroup();
+
+ QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastDir, filter());
if (filename.isEmpty())
return;
+ // Keep last open dir
+ QFileInfo fileInfo(filename);
+ settings.beginGroup("FileDialog");
+ settings.setValue("LastDir",fileInfo.dir().path());
+ settings.endGroup();
+
// Needed to convert to char*
QByteArray fileNamePtr = filename.toLocal8Bit();