GUI: Add Setting for global include paths.
This commit adds new setting and GUI for global include dirs. When project file with include dirs is loaded, global includes dirs are added first and after them the include dirs from project file.
This commit is contained in:
parent
88a1448a07
commit
2dfa1d540e
|
@ -66,6 +66,7 @@ ShowTypes;
|
|||
#define SETTINGS_LOG_VIEW_WIDTH "Log/View width"
|
||||
#define SETTINGS_LOG_VIEW_HEIGHT "Log/View height"
|
||||
#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state"
|
||||
#define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
|
||||
|
||||
/// @}
|
||||
#endif
|
||||
|
|
|
@ -341,6 +341,27 @@ bool MainWindow::GetCheckProject()
|
|||
Settings MainWindow::GetCppcheckSettings()
|
||||
{
|
||||
Settings result;
|
||||
|
||||
QString globalIncludes = mSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString();
|
||||
if (!globalIncludes.isEmpty())
|
||||
{
|
||||
QStringList includes = globalIncludes.split(";");
|
||||
QString dir;
|
||||
foreach(dir, includes)
|
||||
{
|
||||
QString incdir;
|
||||
if (!QDir::isAbsolutePath(dir))
|
||||
incdir = mCurrentDirectory + "/";
|
||||
incdir += dir;
|
||||
incdir = QDir::cleanPath(incdir);
|
||||
|
||||
// include paths must end with '/'
|
||||
if (!incdir.endsWith("/"))
|
||||
incdir += "/";
|
||||
result._includePaths.push_back(incdir.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
bool projectRead = GetCheckProject();
|
||||
if (projectRead)
|
||||
{
|
||||
|
@ -417,7 +438,7 @@ void MainWindow::ProgramSettings()
|
|||
SettingsDialog dialog(mSettings, mApplications, this);
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
dialog.SaveCheckboxValues();
|
||||
dialog.SaveSettingValues();
|
||||
mUI.mResults->UpdateSettings(dialog.ShowFullPath(),
|
||||
dialog.SaveFullPath(),
|
||||
dialog.SaveAllErrors(),
|
||||
|
|
122
gui/settings.ui
122
gui/settings.ui
|
@ -23,66 +23,96 @@
|
|||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Number of threads: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mJobs"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mForce">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Check all #ifdef configurations</string>
|
||||
<string>Include paths:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mEditIncludePaths</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowFullPath">
|
||||
<property name="text">
|
||||
<string>Show full path of files</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mEditIncludePaths"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowNoErrorsMessage">
|
||||
<widget class="QPushButton" name="mBtnAddIncludePath">
|
||||
<property name="text">
|
||||
<string>Show "No errors found" message when no errors found</string>
|
||||
<string>Add...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowDebugWarnings">
|
||||
<property name="text">
|
||||
<string>Show internal warnings in log</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Number of threads: </string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>mJobs</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mJobs">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mForce">
|
||||
<property name="text">
|
||||
<string>Check all #ifdef configurations</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowFullPath">
|
||||
<property name="text">
|
||||
<string>Show full path of files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowNoErrorsMessage">
|
||||
<property name="text">
|
||||
<string>Show "No errors found" message when no errors found</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mShowDebugWarnings">
|
||||
<property name="text">
|
||||
<string>Show internal warnings in log</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
|
@ -173,6 +203,8 @@
|
|||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>mEditIncludePaths</tabstop>
|
||||
<tabstop>mBtnAddIncludePath</tabstop>
|
||||
<tabstop>mJobs</tabstop>
|
||||
<tabstop>mForce</tabstop>
|
||||
<tabstop>mShowFullPath</tabstop>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QListWidgetItem>
|
||||
#include <QTabWidget>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
#include "settingsdialog.h"
|
||||
#include "applicationdialog.h"
|
||||
#include "applicationlist.h"
|
||||
|
@ -41,36 +42,33 @@ SettingsDialog::SettingsDialog(QSettings *programSettings,
|
|||
mUI.setupUi(this);
|
||||
mTempApplications->Copy(list);
|
||||
|
||||
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok()));
|
||||
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
mUI.mEditIncludePaths->setText(programSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString());
|
||||
mUI.mJobs->setText(programSettings->value(SETTINGS_CHECK_THREADS, 1).toString());
|
||||
mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool()));
|
||||
mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
|
||||
mUI.mShowNoErrorsMessage->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_NO_ERRORS, false).toBool()));
|
||||
mUI.mShowDebugWarnings->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool()));
|
||||
mUI.mSaveAllErrors->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
|
||||
mUI.mSaveFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
|
||||
|
||||
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok()));
|
||||
connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(mUI.mButtonAdd, SIGNAL(clicked()),
|
||||
this, SLOT(AddApplication()));
|
||||
|
||||
connect(mUI.mButtonDelete, SIGNAL(clicked()),
|
||||
this, SLOT(DeleteApplication()));
|
||||
|
||||
connect(mUI.mButtonModify, SIGNAL(clicked()),
|
||||
this, SLOT(ModifyApplication()));
|
||||
|
||||
connect(mUI.mButtonDefault, SIGNAL(clicked()),
|
||||
this, SLOT(DefaultApplication()));
|
||||
|
||||
connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
|
||||
this, SLOT(ModifyApplication()));
|
||||
connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()),
|
||||
this, SLOT(AddIncludePath()));
|
||||
|
||||
mUI.mListWidget->setSortingEnabled(false);
|
||||
PopulateListWidget();
|
||||
|
||||
mUI.mSaveAllErrors->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_ALL_ERRORS, false).toBool()));
|
||||
mUI.mSaveFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SAVE_FULL_PATH, false).toBool()));
|
||||
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
|
@ -110,7 +108,7 @@ void SettingsDialog::SaveSettings()
|
|||
mSettings->setValue(SETTINGS_CHECK_DIALOG_HEIGHT, size().height());
|
||||
}
|
||||
|
||||
void SettingsDialog::SaveCheckboxValues()
|
||||
void SettingsDialog::SaveSettingValues()
|
||||
{
|
||||
int jobs = mUI.mJobs->text().toInt();
|
||||
if (jobs <= 0)
|
||||
|
@ -125,6 +123,7 @@ void SettingsDialog::SaveCheckboxValues()
|
|||
SaveCheckboxValue(mUI.mShowFullPath, SETTINGS_SHOW_FULL_PATH);
|
||||
SaveCheckboxValue(mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS);
|
||||
SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
|
||||
mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, mUI.mEditIncludePaths->text());
|
||||
}
|
||||
|
||||
void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
|
||||
|
@ -229,5 +228,18 @@ bool SettingsDialog::ShowNoErrorsMessage()
|
|||
return CheckStateToBool(mUI.mShowNoErrorsMessage->checkState());
|
||||
}
|
||||
|
||||
void SettingsDialog::AddIncludePath()
|
||||
{
|
||||
QString selectedDir = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select include directory"),
|
||||
QString());
|
||||
|
||||
|
||||
if (!selectedDir.isEmpty())
|
||||
{
|
||||
QString text = mUI.mEditIncludePaths->text();
|
||||
if (!text.isEmpty())
|
||||
text += ';';
|
||||
text += selectedDir;
|
||||
mUI.mEditIncludePaths->setText(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
* @brief Save all values to QSettings
|
||||
*
|
||||
*/
|
||||
void SaveCheckboxValues();
|
||||
void SaveSettingValues();
|
||||
|
||||
/**
|
||||
* @brief Get checkbox value for mShowFullPath
|
||||
|
@ -109,6 +109,13 @@ protected slots:
|
|||
*
|
||||
*/
|
||||
void DefaultApplication();
|
||||
|
||||
/**
|
||||
* @brief Slot for adding new include path
|
||||
*
|
||||
*/
|
||||
void AddIncludePath();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue