diff --git a/gui/applicationdialog.cpp b/gui/applicationdialog.cpp index 3adc2ec69..e9d6fe5c2 100644 --- a/gui/applicationdialog.cpp +++ b/gui/applicationdialog.cpp @@ -64,7 +64,7 @@ void ApplicationDialog::Browse() filter); if (!selectedFile.isEmpty()) { - SetPath(SETTINGS_LAST_APP_PATH, selectedFile, false); + SetPath(SETTINGS_LAST_APP_PATH, selectedFile); QString path(QDir::toNativeSeparators(selectedFile)); mUI.mPath->setText(path); } diff --git a/gui/common.cpp b/gui/common.cpp index 799721738..10b5beed9 100644 --- a/gui/common.cpp +++ b/gui/common.cpp @@ -26,24 +26,19 @@ QString GetPath(const QString &type) { QSettings settings; - const QString path = settings.value(type, "").toString(); - if (path.isEmpty()) - return settings.value(SETTINGS_LAST_USED_PATH, "").toString(); + QString path = settings.value(type, "").toString(); + if (path.isEmpty()) { + // if not set, fallback to last check path hoping that it will be close enough + path = settings.value(SETTINGS_LAST_CHECK_PATH, "").toString(); + if (path.isEmpty()) + // if not set, return user's home directory as the best we can do for now + return QDir::homePath(); + } return path; } -void SetPath(const QString &type, const QString &value, bool storeAsLastUsed /* = true */) +void SetPath(const QString &type, const QString &value) { QSettings settings; settings.setValue(type, value); - if (storeAsLastUsed) { - // file name and especially its extension is not portable between types so strip it - const QFileInfo fi(value); - if (fi.isFile()) { - settings.setValue(SETTINGS_LAST_USED_PATH, fi.dir().path()); - } - else { - settings.setValue(SETTINGS_LAST_USED_PATH, value); - } - } } diff --git a/gui/common.h b/gui/common.h index d5482c2ff..d13eddcf9 100644 --- a/gui/common.h +++ b/gui/common.h @@ -84,7 +84,6 @@ #define SETTINGS_CHECKED_PLATFORM "Checked platform" -#define SETTINGS_LAST_USED_PATH "Last used path" #define SETTINGS_LAST_CHECK_PATH "Last check path" #define SETTINGS_LAST_PROJECT_PATH "Last project path" #define SETTINGS_LAST_RESULT_PATH "Last result path" @@ -95,8 +94,8 @@ /** * @brief Obtains the path of specified type - * Returns the path of specifed type if not empty. Otherwise returns - * common last used path set previously by any other file dialog window. + * Returns the path of specified type if not empty. Otherwise returns last check + * path if valid or user's home directory. * @param type Type of path to obtain * @return Best path fo provided type */ @@ -104,15 +103,11 @@ QString GetPath(const QString &type); /** * @brief Stores last used path of specified type - * Stores provided path as last used path for specified type and if - * @p storeAsLastUsed is enabled its directory is also set as common last used - * path that will later be used to initialize the value of paths of other types. + * Stores provided path as last used path for specified type. * @param type Type of the path to store * @param value Path to store - * @param storeAsLastUsed Specifies if directory of that path should also be - * stored as common last used path. */ -void SetPath(const QString &type, const QString &value, bool storeAsLastUsed = true); +void SetPath(const QString &type, const QString &value); /// @} #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index a263993bf..c94352eb9 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -332,7 +332,7 @@ void MainWindow::DoCheckFiles(const QStringList &files) mThread->SetFiles(fileNames); QDir inf(mCurrentDirectory); const QString checkPath = inf.canonicalPath(); - mSettings->setValue(SETTINGS_CHECK_PATH, checkPath); + SetPath(SETTINGS_LAST_CHECK_PATH, checkPath); CheckLockDownUI(); // lock UI while checking