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

@@ -450,43 +450,35 @@ public:
ClangdProjectSettingsWidget::ClangdProjectSettingsWidget(const ClangdProjectSettings &settings)
: d(new Private(settings))
{
setGlobalSettingsId(Constants::CPP_CLANGD_SETTINGS_ID);
const auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
const auto globalSettingsLayout = new QHBoxLayout;
globalSettingsLayout->addWidget(&d->useGlobalSettingsCheckBox);
const auto globalSettingsLabel = new QLabel("Use <a href=\"dummy\">global settings</a>");
connect(globalSettingsLabel, &QLabel::linkActivated,
this, [] { Core::ICore::showOptionsDialog(Constants::CPP_CLANGD_SETTINGS_ID); });
globalSettingsLayout->addWidget(globalSettingsLabel);
globalSettingsLayout->addStretch(1);
layout->addLayout(globalSettingsLayout);
const auto separator = new QFrame;
separator->setFrameShape(QFrame::HLine);
layout->addWidget(separator);
layout->addWidget(&d->widget);
const auto updateGlobalSettingsCheckBox = [this] {
if (ClangdSettings::instance().granularity() == ClangdSettings::Granularity::Session) {
d->useGlobalSettingsCheckBox.setEnabled(false);
d->useGlobalSettingsCheckBox.setChecked(true);
setUseGlobalSettingsCheckBoxEnabled(false);
setUseGlobalSettings(true);
} else {
d->useGlobalSettingsCheckBox.setEnabled(true);
d->useGlobalSettingsCheckBox.setChecked(d->settings.useGlobalSettings());
setUseGlobalSettingsCheckBoxEnabled(true);
setUseGlobalSettings(d->settings.useGlobalSettings());
}
d->widget.setEnabled(!d->useGlobalSettingsCheckBox.isChecked());
d->widget.setEnabled(!useGlobalSettings());
};
updateGlobalSettingsCheckBox();
connect(&ClangdSettings::instance(), &ClangdSettings::changed,
this, updateGlobalSettingsCheckBox);
connect(&d->useGlobalSettingsCheckBox, &QCheckBox::clicked, [this](bool checked) {
d->widget.setEnabled(!checked);
d->settings.setUseGlobalSettings(checked);
if (!checked)
d->settings.setSettings(d->widget.settingsData());
});
connect(&d->widget, &ClangdSettingsWidget::settingsDataChanged, [this] {
connect(this, &ProjectSettingsWidget::useGlobalSettingsChanged, this,
[this](bool checked) {
d->widget.setEnabled(!checked);
d->settings.setUseGlobalSettings(checked);
if (!checked)
d->settings.setSettings(d->widget.settingsData());
});
connect(&d->widget, &ClangdSettingsWidget::settingsDataChanged, this, [this] {
d->settings.setSettings(d->widget.settingsData());
});
}