GUI: Add list control for include paths.
Instead of hard-to-use single line edit control, use list control for include paths. Have separate buttons for adding, editing and removing paths. Paths are still stored as one string where paths are separated with ";". Empty paths are ignored.
This commit is contained in:
parent
9bf6e67898
commit
51eee5f3a7
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>589</width>
|
<width>589</width>
|
||||||
<height>313</height>
|
<height>319</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -17,37 +17,13 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>General</string>
|
<string>General</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Include paths:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>mEditIncludePaths</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="mEditIncludePaths"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="mBtnAddIncludePath">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
|
@ -182,6 +158,69 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_5">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Paths</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Include paths:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="mListIncludePaths">
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnAddIncludePath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnEditIncludePath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="mBtnRemoveIncludePath">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<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>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="tab_2">
|
<widget class="QWidget" name="tab_2">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Applications</string>
|
<string>Applications</string>
|
||||||
|
@ -284,8 +323,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
<tabstop>mEditIncludePaths</tabstop>
|
|
||||||
<tabstop>mBtnAddIncludePath</tabstop>
|
|
||||||
<tabstop>mJobs</tabstop>
|
<tabstop>mJobs</tabstop>
|
||||||
<tabstop>mForce</tabstop>
|
<tabstop>mForce</tabstop>
|
||||||
<tabstop>mShowFullPath</tabstop>
|
<tabstop>mShowFullPath</tabstop>
|
||||||
|
|
|
@ -46,7 +46,6 @@ SettingsDialog::SettingsDialog(QSettings *programSettings,
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mTempApplications->Copy(list);
|
mTempApplications->Copy(list);
|
||||||
|
|
||||||
mUI.mEditIncludePaths->setText(programSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString());
|
|
||||||
mUI.mJobs->setText(programSettings->value(SETTINGS_CHECK_THREADS, 1).toString());
|
mUI.mJobs->setText(programSettings->value(SETTINGS_CHECK_THREADS, 1).toString());
|
||||||
mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool()));
|
mUI.mForce->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_CHECK_FORCE, false).toBool()));
|
||||||
mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
|
mUI.mShowFullPath->setCheckState(BoolToCheckState(programSettings->value(SETTINGS_SHOW_FULL_PATH, false).toBool()));
|
||||||
|
@ -70,6 +69,10 @@ SettingsDialog::SettingsDialog(QSettings *programSettings,
|
||||||
this, SLOT(ModifyApplication()));
|
this, SLOT(ModifyApplication()));
|
||||||
connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()),
|
connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()),
|
||||||
this, SLOT(AddIncludePath()));
|
this, SLOT(AddIncludePath()));
|
||||||
|
connect(mUI.mBtnRemoveIncludePath, SIGNAL(clicked()),
|
||||||
|
this, SLOT(RemoveIncludePath()));
|
||||||
|
connect(mUI.mBtnEditIncludePath, SIGNAL(clicked()),
|
||||||
|
this, SLOT(EditIncludePath()));
|
||||||
|
|
||||||
mUI.mListWidget->setSortingEnabled(false);
|
mUI.mListWidget->setSortingEnabled(false);
|
||||||
PopulateListWidget();
|
PopulateListWidget();
|
||||||
|
@ -82,6 +85,7 @@ SettingsDialog::SettingsDialog(QSettings *programSettings,
|
||||||
|
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
InitTranslationsList();
|
InitTranslationsList();
|
||||||
|
InitIncludepathsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialog::~SettingsDialog()
|
SettingsDialog::~SettingsDialog()
|
||||||
|
@ -89,6 +93,26 @@ SettingsDialog::~SettingsDialog()
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::AddIncludePath(const QString &path)
|
||||||
|
{
|
||||||
|
if (path.isNull() || path.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(path);
|
||||||
|
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||||
|
mUI.mListIncludePaths->addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::InitIncludepathsList()
|
||||||
|
{
|
||||||
|
const QString allPaths = mSettings->value(SETTINGS_GLOBAL_INCLUDE_PATHS).toString();
|
||||||
|
const QStringList paths = allPaths.split(";", QString::SkipEmptyParts);
|
||||||
|
foreach(QString path, paths)
|
||||||
|
{
|
||||||
|
AddIncludePath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsDialog::InitTranslationsList()
|
void SettingsDialog::InitTranslationsList()
|
||||||
{
|
{
|
||||||
const QString current = mTranslator->GetCurrentLanguage();
|
const QString current = mTranslator->GetCurrentLanguage();
|
||||||
|
@ -151,11 +175,20 @@ void SettingsDialog::SaveSettingValues()
|
||||||
SaveCheckboxValue(mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS);
|
SaveCheckboxValue(mUI.mShowNoErrorsMessage, SETTINGS_SHOW_NO_ERRORS);
|
||||||
SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
|
SaveCheckboxValue(mUI.mShowDebugWarnings, SETTINGS_SHOW_DEBUG_WARNINGS);
|
||||||
SaveCheckboxValue(mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
|
SaveCheckboxValue(mUI.mInlineSuppressions, SETTINGS_INLINE_SUPPRESSIONS);
|
||||||
mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, mUI.mEditIncludePaths->text());
|
|
||||||
|
|
||||||
QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
|
QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
|
||||||
const QString langcode = currentLang->data(LangCodeRole).toString();
|
const QString langcode = currentLang->data(LangCodeRole).toString();
|
||||||
mSettings->setValue(SETTINGS_LANGUAGE, langcode);
|
mSettings->setValue(SETTINGS_LANGUAGE, langcode);
|
||||||
|
|
||||||
|
const int count = mUI.mListIncludePaths->count();
|
||||||
|
QString includePaths;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = mUI.mListIncludePaths->item(i);
|
||||||
|
includePaths += item->text();
|
||||||
|
includePaths += ";";
|
||||||
|
}
|
||||||
|
mSettings->setValue(SETTINGS_GLOBAL_INCLUDE_PATHS, includePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
|
void SettingsDialog::SaveCheckboxValue(QCheckBox *box, const QString &name)
|
||||||
|
@ -268,10 +301,19 @@ void SettingsDialog::AddIncludePath()
|
||||||
|
|
||||||
if (!selectedDir.isEmpty())
|
if (!selectedDir.isEmpty())
|
||||||
{
|
{
|
||||||
QString text = mUI.mEditIncludePaths->text();
|
AddIncludePath(selectedDir);
|
||||||
if (!text.isEmpty())
|
|
||||||
text += ';';
|
|
||||||
text += selectedDir;
|
|
||||||
mUI.mEditIncludePaths->setText(text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::RemoveIncludePath()
|
||||||
|
{
|
||||||
|
const int row = mUI.mListIncludePaths->currentRow();
|
||||||
|
QListWidgetItem *item = mUI.mListIncludePaths->takeItem(row);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsDialog::EditIncludePath()
|
||||||
|
{
|
||||||
|
QListWidgetItem *item = mUI.mListIncludePaths->currentItem();
|
||||||
|
mUI.mListIncludePaths->editItem(item);
|
||||||
|
}
|
||||||
|
|
|
@ -118,8 +118,27 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void AddIncludePath();
|
void AddIncludePath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slot for removing an include path.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void RemoveIncludePath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slot for editing an include path.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void EditIncludePath();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add new include path to the list.
|
||||||
|
* @param path Path to add.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void AddIncludePath(const QString &path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clear all applications from the list and re insert them from mTempApplications
|
* @brief Clear all applications from the list and re insert them from mTempApplications
|
||||||
*
|
*
|
||||||
|
@ -165,6 +184,11 @@ protected:
|
||||||
*/
|
*/
|
||||||
bool CheckStateToBool(Qt::CheckState state) const;
|
bool CheckStateToBool(Qt::CheckState state) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Populate the include paths-list.
|
||||||
|
*/
|
||||||
|
void InitIncludepathsList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Populate the translations list.
|
* @brief Populate the translations list.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue