diff --git a/gui/common.h b/gui/common.h index c4471ff26..802d7178b 100644 --- a/gui/common.h +++ b/gui/common.h @@ -81,6 +81,7 @@ #define PROGRESS_MAX 1024.0 #define SETTINGS_CHECKED_PLATFORM "Checked platform" +#define SETTINGS_LAST_PROJECT_PATH "Last project path" /// @} #endif diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 209e6b7ad..5c91754ce 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -848,14 +848,19 @@ void MainWindow::OpenOnlineHelp() void MainWindow::OpenProjectFile() { + const QString lastPath = mSettings->value(SETTINGS_LAST_PROJECT_PATH, QString()).toString(); const QString filter = tr("Project files (*.cppcheck);;All files(*.*)"); - QString filepath = QFileDialog::getOpenFileName(this, - tr("Select Project File"), - QString(), - filter); + const QString filepath = QFileDialog::getOpenFileName(this, + tr("Select Project File"), + lastPath, + filter); if (!filepath.isEmpty()) { - LoadProjectFile(filepath); + const QFileInfo fi(filepath); + if (fi.exists() && fi.isFile() && fi.isReadable()) { + mSettings->setValue(SETTINGS_LAST_PROJECT_PATH, fi.path()); + LoadProjectFile(filepath); + } } }