GUI: Remeber last path where project file was opened from.

It is handy to remember the last location of the opened project file.
Currently the Open Project -dialog was always opened to location of
the executable file. Which is never the correct place. But last
opened project file location might at least be near the location user
wants to open next.

Ticket: #3493 (GUI: remember last path in Open Project File)
This commit is contained in:
Kimmo Varis 2012-01-10 21:40:11 +02:00
parent 362c5f604c
commit c74e246e9b
2 changed files with 11 additions and 5 deletions

View File

@ -81,6 +81,7 @@
#define PROGRESS_MAX 1024.0 #define PROGRESS_MAX 1024.0
#define SETTINGS_CHECKED_PLATFORM "Checked platform" #define SETTINGS_CHECKED_PLATFORM "Checked platform"
#define SETTINGS_LAST_PROJECT_PATH "Last project path"
/// @} /// @}
#endif #endif

View File

@ -848,16 +848,21 @@ void MainWindow::OpenOnlineHelp()
void MainWindow::OpenProjectFile() void MainWindow::OpenProjectFile()
{ {
const QString lastPath = mSettings->value(SETTINGS_LAST_PROJECT_PATH, QString()).toString();
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)"); const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
QString filepath = QFileDialog::getOpenFileName(this, const QString filepath = QFileDialog::getOpenFileName(this,
tr("Select Project File"), tr("Select Project File"),
QString(), lastPath,
filter); filter);
if (!filepath.isEmpty()) { if (!filepath.isEmpty()) {
const QFileInfo fi(filepath);
if (fi.exists() && fi.isFile() && fi.isReadable()) {
mSettings->setValue(SETTINGS_LAST_PROJECT_PATH, fi.path());
LoadProjectFile(filepath); LoadProjectFile(filepath);
} }
} }
}
void MainWindow::LoadProjectFile(const QString &filePath) void MainWindow::LoadProjectFile(const QString &filePath)
{ {