GUI: Reverted 'GUI while opening FileDialog now remembers last path used'

This commit is contained in:
Daniel Marjamäki 2013-02-10 08:15:32 +01:00
parent 6fdb24b7e7
commit e4b8512bc7
4 changed files with 15 additions and 22 deletions

View File

@ -59,7 +59,7 @@
#define SETTINGS_STD_POSIX "Platform Posix"
// Other settings
#define SETTINGS_LAST_USED_PATH "Last used path"
#define SETTINGS_CHECK_PATH "Check path"
#define SETTINGS_CHECK_FORCE "Check force"
#define SETTINGS_CHECK_THREADS "Check threads"
#define SETTINGS_SHOW_FULL_PATH "Show full path"
@ -82,6 +82,7 @@
#define PROGRESS_MAX 1024.0
#define SETTINGS_CHECKED_PLATFORM "Checked platform"
#define SETTINGS_LAST_PROJECT_PATH "Last project path"
/// @}
#endif

View File

@ -332,11 +332,12 @@ void MainWindow::DoCheckFiles(const QStringList &files)
mUI.mResults->CheckingStarted(fileNames.count());
mThread->SetFiles(fileNames);
QDir inf(mCurrentDirectory);
const QString checkPath = inf.canonicalPath();
mSettings->setValue(SETTINGS_CHECK_PATH, checkPath);
CheckLockDownUI(); // lock UI while checking
QDir inf(mCurrentDirectory);
const QString checkPath = inf.canonicalPath();
mUI.mResults->SetCheckDirectory(checkPath);
Settings checkSettings = GetCppcheckSettings();
@ -392,7 +393,7 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
if (mode == QFileDialog::ExistingFiles) {
selected = QFileDialog::getOpenFileNames(this,
tr("Select files to check"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString());
mSettings->value(SETTINGS_CHECK_PATH, "").toString());
if (selected.isEmpty())
mCurrentDirectory.clear();
else {
@ -403,7 +404,7 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
} else if (mode == QFileDialog::DirectoryOnly) {
QString dir = QFileDialog::getExistingDirectory(this,
tr("Select directory to check"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString());
mSettings->value(SETTINGS_CHECK_PATH, "").toString());
if (!dir.isEmpty()) {
qDebug() << "Setting current directory to: " << dir;
mCurrentDirectory = dir;
@ -413,8 +414,6 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
}
}
mSettings->setValue(SETTINGS_LAST_USED_PATH, selected);
return selected;
}
@ -672,7 +671,7 @@ void MainWindow::OpenResults()
const QString filter(tr("XML files (*.xml)"));
QString selectedFile = QFileDialog::getOpenFileName(this,
tr("Open the report file"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
QString(),
filter,
&selectedFilter);
@ -686,7 +685,6 @@ void MainWindow::LoadResults(const QString selectedFile)
if (!selectedFile.isEmpty()) {
mUI.mResults->Clear(true);
mUI.mResults->ReadErrorsXml(selectedFile);
mSettings->setValue(SETTINGS_LAST_USED_PATH, selectedFile);
}
}
@ -818,7 +816,7 @@ void MainWindow::Save()
const QString filter(tr("XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)"));
QString selectedFile = QFileDialog::getSaveFileName(this,
tr("Save the report file"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
QString(),
filter,
&selectedFilter);
@ -850,7 +848,6 @@ void MainWindow::Save()
}
mUI.mResults->Save(selectedFile, type);
mSettings->setValue(SETTINGS_LAST_USED_PATH, selectedFile);
}
}
@ -935,16 +932,17 @@ 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(*.*)");
const QString filepath = QFileDialog::getOpenFileName(this,
tr("Select Project File"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
lastPath,
filter);
if (!filepath.isEmpty()) {
const QFileInfo fi(filepath);
if (fi.exists() && fi.isFile() && fi.isReadable()) {
mSettings->setValue(SETTINGS_LAST_USED_PATH, fi.path());
mSettings->setValue(SETTINGS_LAST_PROJECT_PATH, fi.path());
LoadProjectFile(filepath);
}
}
@ -1021,14 +1019,12 @@ void MainWindow::NewProjectFile()
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
QString filepath = QFileDialog::getSaveFileName(this,
tr("Select Project Filename"),
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
QString(),
filter);
if (filepath.isEmpty())
return;
mSettings->setValue(SETTINGS_LAST_USED_PATH, filepath);
EnableProjectActions(true);
QFileInfo inf(filepath);
const QString filename = inf.fileName();

View File

@ -694,12 +694,10 @@ QString ResultsTree::AskFileDir(const QString &file)
msgbox.setIcon(QMessageBox::Warning);
msgbox.exec();
QSettings settings;
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
settings.value(SETTINGS_LAST_USED_PATH, "").toString(),
"",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
mCheckPath = dir;
settings.setValue(SETTINGS_LAST_USED_PATH, dir);
return dir;
}

View File

@ -308,14 +308,12 @@ bool SettingsDialog::ShowErrorId() const
void SettingsDialog::AddIncludePath()
{
QSettings settings;
QString selectedDir = QFileDialog::getExistingDirectory(this,
tr("Select include directory"),
settings.value(SETTINGS_LAST_USED_PATH, "").toString());
QString());
if (!selectedDir.isEmpty()) {
AddIncludePath(selectedDir);
settings.setValue(SETTINGS_LAST_USED_PATH, selectedDir);
}
}