From c05a38c45dd5d492a1789a5ebc8cbc07316bd7c3 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Thu, 17 Sep 2020 20:26:15 +0200 Subject: [PATCH] remember most recently selected path/file --- main.cpp | 4 ++++ mainwindow.cpp | 14 +++++++++++++- settingkeys.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index b48f94e..2d9b1d0 100644 --- a/main.cpp +++ b/main.cpp @@ -7,5 +7,9 @@ int main(int argc, char *argv[]) MainWindow w; w.show(); + a.setApplicationName("Speech-To-Text"); + a.setOrganizationName("Lantia IT"); + a.setOrganizationDomain("lantia-it.de"); + return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 6900500..2012ee4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -148,12 +148,24 @@ void MainWindow::handleInitialSettings(){ } void MainWindow::importFile(){ + + QString startDir = QDir::currentPath(); + if(mySettings->contains(SETTING_MOST_RECENT_PATH)){ + startDir = mySettings->value(SETTING_MOST_RECENT_PATH).toString(); + } + QString filename = QFileDialog::getOpenFileName( this, "Open Document", - QDir::currentPath(), + startDir, "All files (*.*) ;; Document files (*.doc *.rtf);; PNG files (*.png)"); + /* set most recent path */ + QFileInfo* fi = new QFileInfo(filename); + QDir dirInfo = fi->absoluteDir(); + QString dirPath = dirInfo.absolutePath(); + mySettings->setValue(SETTING_MOST_RECENT_PATH, dirPath); + if(filename.isNull()){ return; }else{ diff --git a/settingkeys.h b/settingkeys.h index 02cea0b..a19b62f 100644 --- a/settingkeys.h +++ b/settingkeys.h @@ -11,5 +11,6 @@ #define SETTING_USER "user" #define SETTING_PASS "pass" #define SETTING_LINUX_EXPLORER "linux-explorer" +#define SETTING_MOST_RECENT_PATH "most-recent-path" #endif // SETTINGKEYS_H