GUI: Renamed common functions
This commit is contained in:
parent
0d8b7af2b3
commit
252fab2181
|
@ -60,11 +60,11 @@ void ApplicationDialog::Browse()
|
||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
QString selectedFile = QFileDialog::getOpenFileName(this,
|
QString selectedFile = QFileDialog::getOpenFileName(this,
|
||||||
tr("Select viewer application"),
|
tr("Select viewer application"),
|
||||||
GetPath(SETTINGS_LAST_APP_PATH),
|
getPath(SETTINGS_LAST_APP_PATH),
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
if (!selectedFile.isEmpty()) {
|
if (!selectedFile.isEmpty()) {
|
||||||
SetPath(SETTINGS_LAST_APP_PATH, selectedFile);
|
setPath(SETTINGS_LAST_APP_PATH, selectedFile);
|
||||||
QString path(QDir::toNativeSeparators(selectedFile));
|
QString path(QDir::toNativeSeparators(selectedFile));
|
||||||
mUI.mPath->setText(path);
|
mUI.mPath->setText(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
QString GetPath(const QString &type)
|
QString getPath(const QString &type)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString path = settings.value(type, "").toString();
|
QString path = settings.value(type, "").toString();
|
||||||
|
@ -37,7 +37,7 @@ QString GetPath(const QString &type)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPath(const QString &type, const QString &value)
|
void setPath(const QString &type, const QString &value)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setValue(type, value);
|
settings.setValue(type, value);
|
||||||
|
|
|
@ -106,7 +106,7 @@
|
||||||
* @param type Type of path to obtain
|
* @param type Type of path to obtain
|
||||||
* @return Best path fo provided type
|
* @return Best path fo provided type
|
||||||
*/
|
*/
|
||||||
QString GetPath(const QString &type);
|
QString getPath(const QString &type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stores last used path of specified type
|
* @brief Stores last used path of specified type
|
||||||
|
@ -114,7 +114,7 @@ QString GetPath(const QString &type);
|
||||||
* @param type Type of the path to store
|
* @param type Type of the path to store
|
||||||
* @param value Path to store
|
* @param value Path to store
|
||||||
*/
|
*/
|
||||||
void SetPath(const QString &type, const QString &value);
|
void setPath(const QString &type, const QString &value);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -377,7 +377,7 @@ void MainWindow::doCheckProject(ImportProject p)
|
||||||
|
|
||||||
QDir inf(mCurrentDirectory);
|
QDir inf(mCurrentDirectory);
|
||||||
const QString checkPath = inf.canonicalPath();
|
const QString checkPath = inf.canonicalPath();
|
||||||
SetPath(SETTINGS_LAST_CHECK_PATH, checkPath);
|
setPath(SETTINGS_LAST_CHECK_PATH, checkPath);
|
||||||
|
|
||||||
checkLockDownUI(); // lock UI while checking
|
checkLockDownUI(); // lock UI while checking
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ void MainWindow::doCheckFiles(const QStringList &files)
|
||||||
mThread->SetFiles(fileNames);
|
mThread->SetFiles(fileNames);
|
||||||
QDir inf(mCurrentDirectory);
|
QDir inf(mCurrentDirectory);
|
||||||
const QString checkPath = inf.canonicalPath();
|
const QString checkPath = inf.canonicalPath();
|
||||||
SetPath(SETTINGS_LAST_CHECK_PATH, checkPath);
|
setPath(SETTINGS_LAST_CHECK_PATH, checkPath);
|
||||||
|
|
||||||
checkLockDownUI(); // lock UI while checking
|
checkLockDownUI(); // lock UI while checking
|
||||||
|
|
||||||
|
@ -501,7 +501,7 @@ QStringList MainWindow::selectFilesToCheck(QFileDialog::FileMode mode)
|
||||||
|
|
||||||
selected = QFileDialog::getOpenFileNames(this,
|
selected = QFileDialog::getOpenFileNames(this,
|
||||||
tr("Select files to check"),
|
tr("Select files to check"),
|
||||||
GetPath(SETTINGS_LAST_CHECK_PATH),
|
getPath(SETTINGS_LAST_CHECK_PATH),
|
||||||
tr("C/C++ Source, Compile database, Visual Studio (%1 %2 *.sln *.vcxproj)")
|
tr("C/C++ Source, Compile database, Visual Studio (%1 %2 *.sln *.vcxproj)")
|
||||||
.arg(FileList::getDefaultFilters().join(" "))
|
.arg(FileList::getDefaultFilters().join(" "))
|
||||||
.arg(compile_commands_json));
|
.arg(compile_commands_json));
|
||||||
|
@ -515,7 +515,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"),
|
||||||
GetPath(SETTINGS_LAST_CHECK_PATH));
|
getPath(SETTINGS_LAST_CHECK_PATH));
|
||||||
if (!dir.isEmpty()) {
|
if (!dir.isEmpty()) {
|
||||||
qDebug() << "Setting current directory to: " << dir;
|
qDebug() << "Setting current directory to: " << dir;
|
||||||
mCurrentDirectory = dir;
|
mCurrentDirectory = dir;
|
||||||
|
@ -525,7 +525,7 @@ QStringList MainWindow::selectFilesToCheck(QFileDialog::FileMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPath(SETTINGS_LAST_CHECK_PATH, mCurrentDirectory);
|
setPath(SETTINGS_LAST_CHECK_PATH, mCurrentDirectory);
|
||||||
|
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1002,7 @@ void MainWindow::openResults()
|
||||||
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"),
|
||||||
GetPath(SETTINGS_LAST_RESULT_PATH),
|
getPath(SETTINGS_LAST_RESULT_PATH),
|
||||||
filter,
|
filter,
|
||||||
&selectedFilter);
|
&selectedFilter);
|
||||||
|
|
||||||
|
@ -1021,7 +1021,7 @@ void MainWindow::loadResults(const QString selectedFile)
|
||||||
mUI.mActionRecheckModified->setEnabled(false);
|
mUI.mActionRecheckModified->setEnabled(false);
|
||||||
mUI.mActionRecheckAll->setEnabled(false);
|
mUI.mActionRecheckAll->setEnabled(false);
|
||||||
mUI.mResults->ReadErrorsXml(selectedFile);
|
mUI.mResults->ReadErrorsXml(selectedFile);
|
||||||
SetPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
|
setPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,7 +1160,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"),
|
||||||
GetPath(SETTINGS_LAST_RESULT_PATH),
|
getPath(SETTINGS_LAST_RESULT_PATH),
|
||||||
filter,
|
filter,
|
||||||
&selectedFilter);
|
&selectedFilter);
|
||||||
|
|
||||||
|
@ -1195,7 +1195,7 @@ void MainWindow::save()
|
||||||
}
|
}
|
||||||
|
|
||||||
mUI.mResults->Save(selectedFile, type);
|
mUI.mResults->Save(selectedFile, type);
|
||||||
SetPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
|
setPath(SETTINGS_LAST_RESULT_PATH, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1273,13 +1273,13 @@ void MainWindow::openProjectFile()
|
||||||
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"),
|
||||||
GetPath(SETTINGS_LAST_PROJECT_PATH),
|
getPath(SETTINGS_LAST_PROJECT_PATH),
|
||||||
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()) {
|
||||||
SetPath(SETTINGS_LAST_PROJECT_PATH, filepath);
|
setPath(SETTINGS_LAST_PROJECT_PATH, filepath);
|
||||||
loadProjectFile(filepath);
|
loadProjectFile(filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1367,13 +1367,13 @@ 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"),
|
||||||
GetPath(SETTINGS_LAST_PROJECT_PATH),
|
getPath(SETTINGS_LAST_PROJECT_PATH),
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
if (filepath.isEmpty())
|
if (filepath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetPath(SETTINGS_LAST_PROJECT_PATH, filepath);
|
setPath(SETTINGS_LAST_PROJECT_PATH, filepath);
|
||||||
|
|
||||||
enableProjectActions(true);
|
enableProjectActions(true);
|
||||||
QFileInfo inf(filepath);
|
QFileInfo inf(filepath);
|
||||||
|
|
|
@ -742,10 +742,10 @@ QString ResultsTree::AskFileDir(const QString &file)
|
||||||
msgbox.exec();
|
msgbox.exec();
|
||||||
|
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
|
||||||
GetPath(SETTINGS_LAST_SOURCE_PATH),
|
getPath(SETTINGS_LAST_SOURCE_PATH),
|
||||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
mCheckPath = dir;
|
mCheckPath = dir;
|
||||||
SetPath(SETTINGS_LAST_SOURCE_PATH, dir);
|
setPath(SETTINGS_LAST_SOURCE_PATH, dir);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,11 +322,11 @@ void SettingsDialog::AddIncludePath()
|
||||||
{
|
{
|
||||||
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
||||||
tr("Select include directory"),
|
tr("Select include directory"),
|
||||||
GetPath(SETTINGS_LAST_INCLUDE_PATH));
|
getPath(SETTINGS_LAST_INCLUDE_PATH));
|
||||||
|
|
||||||
if (!selectedDir.isEmpty()) {
|
if (!selectedDir.isEmpty()) {
|
||||||
AddIncludePath(selectedDir);
|
AddIncludePath(selectedDir);
|
||||||
SetPath(SETTINGS_LAST_INCLUDE_PATH, selectedDir);
|
setPath(SETTINGS_LAST_INCLUDE_PATH, selectedDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue