GUI while opening FileDialog now remembers last path used
This commit is contained in:
parent
463121be71
commit
013de4857c
|
@ -59,7 +59,7 @@
|
||||||
#define SETTINGS_STD_POSIX "Platform Posix"
|
#define SETTINGS_STD_POSIX "Platform Posix"
|
||||||
|
|
||||||
// Other settings
|
// Other settings
|
||||||
#define SETTINGS_CHECK_PATH "Check path"
|
#define SETTINGS_LAST_USED_PATH "Last used path"
|
||||||
#define SETTINGS_CHECK_FORCE "Check force"
|
#define SETTINGS_CHECK_FORCE "Check force"
|
||||||
#define SETTINGS_CHECK_THREADS "Check threads"
|
#define SETTINGS_CHECK_THREADS "Check threads"
|
||||||
#define SETTINGS_SHOW_FULL_PATH "Show full path"
|
#define SETTINGS_SHOW_FULL_PATH "Show full path"
|
||||||
|
@ -82,7 +82,6 @@
|
||||||
#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
|
||||||
|
|
|
@ -314,12 +314,11 @@ void MainWindow::DoCheckFiles(const QStringList &files)
|
||||||
mUI.mResults->CheckingStarted(fileNames.count());
|
mUI.mResults->CheckingStarted(fileNames.count());
|
||||||
|
|
||||||
mThread->SetFiles(fileNames);
|
mThread->SetFiles(fileNames);
|
||||||
QDir inf(mCurrentDirectory);
|
|
||||||
const QString checkPath = inf.canonicalPath();
|
|
||||||
mSettings->setValue(SETTINGS_CHECK_PATH, checkPath);
|
|
||||||
|
|
||||||
CheckLockDownUI(); // lock UI while checking
|
CheckLockDownUI(); // lock UI while checking
|
||||||
|
|
||||||
|
QDir inf(mCurrentDirectory);
|
||||||
|
const QString checkPath = inf.canonicalPath();
|
||||||
mUI.mResults->SetCheckDirectory(checkPath);
|
mUI.mResults->SetCheckDirectory(checkPath);
|
||||||
Settings checkSettings = GetCppcheckSettings();
|
Settings checkSettings = GetCppcheckSettings();
|
||||||
|
|
||||||
|
@ -375,7 +374,7 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
|
||||||
if (mode == QFileDialog::ExistingFiles) {
|
if (mode == QFileDialog::ExistingFiles) {
|
||||||
selected = QFileDialog::getOpenFileNames(this,
|
selected = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Select files to check"),
|
tr("Select files to check"),
|
||||||
mSettings->value(SETTINGS_CHECK_PATH, "").toString());
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString());
|
||||||
if (selected.isEmpty())
|
if (selected.isEmpty())
|
||||||
mCurrentDirectory.clear();
|
mCurrentDirectory.clear();
|
||||||
else {
|
else {
|
||||||
|
@ -386,7 +385,7 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
|
||||||
} else if (mode == QFileDialog::DirectoryOnly) {
|
} else if (mode == QFileDialog::DirectoryOnly) {
|
||||||
QString dir = QFileDialog::getExistingDirectory(this,
|
QString dir = QFileDialog::getExistingDirectory(this,
|
||||||
tr("Select directory to check"),
|
tr("Select directory to check"),
|
||||||
mSettings->value(SETTINGS_CHECK_PATH, "").toString());
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString());
|
||||||
if (!dir.isEmpty()) {
|
if (!dir.isEmpty()) {
|
||||||
qDebug() << "Setting current directory to: " << dir;
|
qDebug() << "Setting current directory to: " << dir;
|
||||||
mCurrentDirectory = dir;
|
mCurrentDirectory = dir;
|
||||||
|
@ -396,6 +395,8 @@ QStringList MainWindow::SelectFilesToCheck(QFileDialog::FileMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSettings->setValue(SETTINGS_LAST_USED_PATH, selected);
|
||||||
|
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,13 +654,14 @@ void MainWindow::OpenXML()
|
||||||
const QString filter(tr("XML files (*.xml)"));
|
const QString filter(tr("XML files (*.xml)"));
|
||||||
QString selectedFile = QFileDialog::getOpenFileName(this,
|
QString selectedFile = QFileDialog::getOpenFileName(this,
|
||||||
tr("Open the report file"),
|
tr("Open the report file"),
|
||||||
QString(),
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
|
||||||
filter,
|
filter,
|
||||||
&selectedFilter);
|
&selectedFilter);
|
||||||
|
|
||||||
if (!selectedFile.isEmpty()) {
|
if (!selectedFile.isEmpty()) {
|
||||||
mUI.mResults->Clear(true);
|
mUI.mResults->Clear(true);
|
||||||
mUI.mResults->ReadErrorsXml(selectedFile);
|
mUI.mResults->ReadErrorsXml(selectedFile);
|
||||||
|
mSettings->setValue(SETTINGS_LAST_USED_PATH, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +787,7 @@ void MainWindow::Save()
|
||||||
const QString filter(tr("XML files version 2 (*.xml);;XML files version 1 (*.xml);;Text files (*.txt);;CSV files (*.csv)"));
|
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,
|
QString selectedFile = QFileDialog::getSaveFileName(this,
|
||||||
tr("Save the report file"),
|
tr("Save the report file"),
|
||||||
QString(),
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
|
||||||
filter,
|
filter,
|
||||||
&selectedFilter);
|
&selectedFilter);
|
||||||
|
|
||||||
|
@ -817,6 +819,7 @@ void MainWindow::Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
mUI.mResults->Save(selectedFile, type);
|
mUI.mResults->Save(selectedFile, type);
|
||||||
|
mSettings->setValue(SETTINGS_LAST_USED_PATH, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,17 +904,16 @@ 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(*.*)");
|
||||||
const QString filepath = QFileDialog::getOpenFileName(this,
|
const QString filepath = QFileDialog::getOpenFileName(this,
|
||||||
tr("Select Project File"),
|
tr("Select Project File"),
|
||||||
lastPath,
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
const QFileInfo fi(filepath);
|
const QFileInfo fi(filepath);
|
||||||
if (fi.exists() && fi.isFile() && fi.isReadable()) {
|
if (fi.exists() && fi.isFile() && fi.isReadable()) {
|
||||||
mSettings->setValue(SETTINGS_LAST_PROJECT_PATH, fi.path());
|
mSettings->setValue(SETTINGS_LAST_USED_PATH, fi.path());
|
||||||
LoadProjectFile(filepath);
|
LoadProjectFile(filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,12 +990,14 @@ void MainWindow::NewProjectFile()
|
||||||
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
|
const QString filter = tr("Project files (*.cppcheck);;All files(*.*)");
|
||||||
QString filepath = QFileDialog::getSaveFileName(this,
|
QString filepath = QFileDialog::getSaveFileName(this,
|
||||||
tr("Select Project Filename"),
|
tr("Select Project Filename"),
|
||||||
QString(),
|
mSettings->value(SETTINGS_LAST_USED_PATH, "").toString(),
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
if (filepath.isEmpty())
|
if (filepath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mSettings->setValue(SETTINGS_LAST_USED_PATH, filepath);
|
||||||
|
|
||||||
EnableProjectActions(true);
|
EnableProjectActions(true);
|
||||||
QFileInfo inf(filepath);
|
QFileInfo inf(filepath);
|
||||||
const QString filename = inf.fileName();
|
const QString filename = inf.fileName();
|
||||||
|
|
|
@ -690,10 +690,12 @@ QString ResultsTree::AskFileDir(const QString &file)
|
||||||
msgbox.setIcon(QMessageBox::Warning);
|
msgbox.setIcon(QMessageBox::Warning);
|
||||||
msgbox.exec();
|
msgbox.exec();
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
|
||||||
"",
|
settings.value(SETTINGS_LAST_USED_PATH, "").toString(),
|
||||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
mCheckPath = dir;
|
mCheckPath = dir;
|
||||||
|
settings.setValue(SETTINGS_LAST_USED_PATH, dir);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -308,12 +308,14 @@ bool SettingsDialog::ShowErrorId() const
|
||||||
|
|
||||||
void SettingsDialog::AddIncludePath()
|
void SettingsDialog::AddIncludePath()
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
||||||
tr("Select include directory"),
|
tr("Select include directory"),
|
||||||
QString());
|
settings.value(SETTINGS_LAST_USED_PATH, "").toString());
|
||||||
|
|
||||||
if (!selectedDir.isEmpty()) {
|
if (!selectedDir.isEmpty()) {
|
||||||
AddIncludePath(selectedDir);
|
AddIncludePath(selectedDir);
|
||||||
|
settings.setValue(SETTINGS_LAST_USED_PATH, selectedDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue