summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Helio Chissini de Castro <helio@kde.org>2013-06-08 00:03:58 -0300
committerGravatar Helio Chissini de Castro <helio@kde.org>2013-06-08 00:03:58 -0300
commit1262a7c0bc307d36720354b90ca8ac7f24147268 (patch)
tree85c43fed131a09036176980eb0fbe96ccca71627 /qt-ui/mainwindow.cpp
parent3677f4e5ead410d4023668420ca4f062c4223888 (diff)
downloadsubsurface-1262a7c0bc307d36720354b90ca8ac7f24147268.tar.gz
Keep last open dives directory
Last open dives directory is stored in settings, so no need to walk through all subdirectories all the time. Signed-off-by: Helio Chissini de Castro <helio@kde.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-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 286aba43e..b2baa8c26 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -86,10 +86,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();