ProjectExplorer: Add a common template for project settings

- Added base widget class for common options among project settings tabs
- Added usage new template class to all pages used in project settings

ToDo
- Make CodeStyle tab standardized

Change-Id: I8f70413b6ee764c5e43fbeae104b9389237c582f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2022-04-14 15:51:18 +02:00
parent 6c05ed7920
commit 7954c4cc69
35 changed files with 630 additions and 206 deletions

View File

@@ -25,6 +25,7 @@
#include "projectsettingswidget.h"
#include "autotestconstants.h"
#include "autotestplugin.h"
#include "testframeworkmanager.h"
#include "testprojectsettings.h"
@@ -53,14 +54,12 @@ static QSpacerItem *createSpacer(QSizePolicy::Policy horizontal, QSizePolicy::Po
ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *project,
QWidget *parent)
: QWidget(parent)
: ProjectExplorer::ProjectSettingsWidget(parent)
, m_projectSettings(AutotestPlugin::projectSettings(project))
{
setGlobalSettingsId(Constants::AUTOTEST_SETTINGS_ID);
auto verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(0, 0, 0, 0);
m_useGlobalSettings = new QComboBox;
m_useGlobalSettings->addItem(tr("Global"));
m_useGlobalSettings->addItem(tr("Custom"));
auto generalWidget = new QWidget;
auto groupBoxLayout = new QVBoxLayout;
@@ -82,10 +81,6 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
groupBoxLayout->addLayout(horizontalLayout);
generalWidget->setLayout(groupBoxLayout);
horizontalLayout = new QHBoxLayout;
horizontalLayout->addWidget(m_useGlobalSettings);
horizontalLayout->addItem(createSpacer(QSizePolicy::Expanding, QSizePolicy::Minimum));
verticalLayout->addLayout(horizontalLayout);
horizontalLayout = new QHBoxLayout;
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Fixed));
horizontalLayout->addWidget(generalWidget);
@@ -93,19 +88,20 @@ ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *p
verticalLayout->addLayout(horizontalLayout);
verticalLayout->addItem(createSpacer(QSizePolicy::Minimum, QSizePolicy::Expanding));
m_useGlobalSettings->setCurrentIndex(m_projectSettings->useGlobalSettings() ? 0 : 1);
generalWidget->setDisabled(m_projectSettings->useGlobalSettings());
populateFrameworks(m_projectSettings->activeFrameworks(),
m_projectSettings->activeTestTools());
connect(m_useGlobalSettings, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this, generalWidget](int index) {
generalWidget->setEnabled(index != 0);
m_projectSettings->setUseGlobalSettings(index == 0);
m_syncTimer.start(3000);
m_syncType = ITestBase::Framework | ITestBase::Tool;
});
setUseGlobalSettings(m_projectSettings->useGlobalSettings());
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged,
this, [this, generalWidget](bool useGlobalSettings) {
generalWidget->setEnabled(!useGlobalSettings);
m_projectSettings->setUseGlobalSettings(useGlobalSettings);
m_syncTimer.start(3000);
m_syncType = ITestBase::Framework | ITestBase::Tool;
});
connect(m_activeFrameworks, &QTreeWidget::itemChanged,
this, &ProjectTestSettingsWidget::onActiveFrameworkChanged);
connect(m_runAfterBuild, QOverload<int>::of(&QComboBox::currentIndexChanged),