Skip to content

Commit

Permalink
GUI: Remeber last path where project file was opened from.
Browse files Browse the repository at this point in the history
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: danmar#3493 (GUI: remember last path in Open Project File)
  • Loading branch information
kimmov committed Jan 10, 2012
1 parent 362c5f6 commit c74e246
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions gui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
#define PROGRESS_MAX 1024.0

#define SETTINGS_CHECKED_PLATFORM "Checked platform"
#define SETTINGS_LAST_PROJECT_PATH "Last project path"

/// @}
#endif
15 changes: 10 additions & 5 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit c74e246

Please sign in to comment.