diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-06-09 21:01:04 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-09 21:01:04 -0700 |
commit | bd8470ebcfe07a347c3c47d2a72e0b8cdd316630 (patch) | |
tree | 272ed89a91955b96804f277b93844d057216cc31 | |
parent | 4b0c053e48abc7a4e0a624d2b868e6f29e376610 (diff) | |
parent | 1262a7c0bc307d36720354b90ca8ac7f24147268 (diff) | |
download | subsurface-bd8470ebcfe07a347c3c47d2a72e0b8cdd316630.tar.gz |
Merge branch 'fileopen' of github.com:heliocastro/subsurface
-rw-r--r-- | qt-ui/mainwindow.cpp | 19 |
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(); |