diff --git a/src/plugins/gitlab/gitlabprojectsettings.cpp b/src/plugins/gitlab/gitlabprojectsettings.cpp index cbd1688f909..7c1397b0751 100644 --- a/src/plugins/gitlab/gitlabprojectsettings.cpp +++ b/src/plugins/gitlab/gitlabprojectsettings.cpp @@ -135,6 +135,7 @@ GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Projec , m_projectSettings(GitLabPlugin::projectSettings(project)) { setUseGlobalSettingsCheckBoxVisible(false); + setUseGlobalSettingsLabelVisible(false); // setup ui auto verticalLayout = new QVBoxLayout(this); verticalLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp b/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp index bed166bdb9c..b31388b9f0c 100644 --- a/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/codestylesettingspropertiespage.cpp @@ -38,6 +38,7 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : ProjectSett { m_ui.setupUi(this); setUseGlobalSettingsCheckBoxVisible(false); + setUseGlobalSettingsLabelVisible(false); const EditorConfiguration *config = m_project->editorConfiguration(); diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp index 1f68eae1150..b5ec18b984c 100644 --- a/src/plugins/projectexplorer/dependenciespanel.cpp +++ b/src/plugins/projectexplorer/dependenciespanel.cpp @@ -215,6 +215,7 @@ DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent) : Proj m_model(new DependenciesModel(project, this)) { setUseGlobalSettingsCheckBoxVisible(false); + setUseGlobalSettingsLabelVisible(false); auto vbox = new QVBoxLayout(this); vbox->setContentsMargins(0, 0, 0, 0); m_detailsContainer = new Utils::DetailsWidget(this); diff --git a/src/plugins/projectexplorer/panelswidget.cpp b/src/plugins/projectexplorer/panelswidget.cpp index da2e7ba6610..8ab4d01a738 100644 --- a/src/plugins/projectexplorer/panelswidget.cpp +++ b/src/plugins/projectexplorer/panelswidget.cpp @@ -143,40 +143,49 @@ void PanelsWidget::addWidget(QWidget *widget) void PanelsWidget::addGlobalSettingsProperties(ProjectSettingsWidget *widget) { - if (!widget->isUseGlobalSettingsCheckBoxVisible()) + if (!widget->isUseGlobalSettingsCheckBoxVisible() && !widget->isUseGlobalSettingsLabelVisible()) return; m_layout->setContentsMargins(0, 0, 0, 0); const auto useGlobalSettingsCheckBox = new QCheckBox; useGlobalSettingsCheckBox->setChecked(widget->useGlobalSettings()); useGlobalSettingsCheckBox->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled()); - const auto settingsLabel = new QLabel("Use global settings"); - settingsLabel->setContentsMargins(CONTENTS_MARGIN, 0, 0, 0); + + const QString labelText = widget->isUseGlobalSettingsCheckBoxVisible() + ? QStringLiteral("Use global settings") + : QStringLiteral("Global settings"); + const auto settingsLabel = new QLabel(labelText); settingsLabel->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled()); - const auto horizontLayout = new QHBoxLayout; - horizontLayout->setContentsMargins(0, CONTENTS_MARGIN, 0, CONTENTS_MARGIN); - horizontLayout->addWidget(useGlobalSettingsCheckBox); - horizontLayout->addWidget(settingsLabel); - horizontLayout->addStretch(1); - m_layout->addLayout(horizontLayout); + + const auto horizontalLayout = new QHBoxLayout; + horizontalLayout->setContentsMargins(0, CONTENTS_MARGIN, 0, CONTENTS_MARGIN); + horizontalLayout->setSpacing(CONTENTS_MARGIN); + + if (widget->isUseGlobalSettingsCheckBoxVisible()) { + horizontalLayout->addWidget(useGlobalSettingsCheckBox); + + connect(widget, &ProjectSettingsWidget::useGlobalSettingsCheckBoxEnabledChanged, + this, [useGlobalSettingsCheckBox, settingsLabel](bool enabled) { + useGlobalSettingsCheckBox->setEnabled(enabled); + settingsLabel->setEnabled(enabled); + }); + connect(useGlobalSettingsCheckBox, &QCheckBox::stateChanged, + widget, &ProjectSettingsWidget::setUseGlobalSettings); + connect(widget, &ProjectSettingsWidget::useGlobalSettingsChanged, + useGlobalSettingsCheckBox, &QCheckBox::setChecked); + } + + if (widget->isUseGlobalSettingsLabelVisible()) { + horizontalLayout->addWidget(settingsLabel); + connect(settingsLabel, &QLabel::linkActivated, this, [widget] { + Core::ICore::showOptionsDialog(widget->globalSettingsId()); + }); + } + horizontalLayout->addStretch(1); + m_layout->addLayout(horizontalLayout); auto separator = new QFrame(m_root); separator->setFrameShape(QFrame::HLine); m_layout->addWidget(separator); - - connect(widget, &ProjectSettingsWidget::useGlobalSettingsCheckBoxEnabledChanged, this, - [useGlobalSettingsCheckBox, settingsLabel] (bool enabled) { - useGlobalSettingsCheckBox->setEnabled(enabled); - settingsLabel->setEnabled(enabled); - }); - - connect(useGlobalSettingsCheckBox, &QCheckBox::stateChanged, - widget, &ProjectSettingsWidget::setUseGlobalSettings); - connect(widget, &ProjectSettingsWidget::useGlobalSettingsChanged, - useGlobalSettingsCheckBox, &QCheckBox::setChecked); - - connect(settingsLabel, &QLabel::linkActivated, this, [widget] { - Core::ICore::showOptionsDialog(widget->globalSettingsId()); - }); } } // ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index b857468106a..27bdbcd8400 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -395,6 +395,7 @@ public: explicit ProjectEnvironmentWidget(Project *project) : NamedWidget(tr("Project Environment")) { setUseGlobalSettingsCheckBoxVisible(false); + setUseGlobalSettingsLabelVisible(false); const auto vbox = new QVBoxLayout(this); vbox->setContentsMargins(0, 0, 0, 0); const auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal); diff --git a/src/plugins/projectexplorer/projectsettingswidget.cpp b/src/plugins/projectexplorer/projectsettingswidget.cpp index 01c0df28f01..c7d9e07ce3f 100644 --- a/src/plugins/projectexplorer/projectsettingswidget.cpp +++ b/src/plugins/projectexplorer/projectsettingswidget.cpp @@ -67,6 +67,16 @@ void ProjectSettingsWidget::setUseGlobalSettingsCheckBoxVisible(bool visible) m_useGlobalSettingsCheckBoxVisibleVisible = visible; } +bool ProjectSettingsWidget::isUseGlobalSettingsLabelVisible() const +{ + return m_useGlobalSettingsLabelVisibleVisible; +} + +void ProjectSettingsWidget::setUseGlobalSettingsLabelVisible(bool visible) +{ + m_useGlobalSettingsLabelVisibleVisible = visible; +} + Utils::Id ProjectSettingsWidget::globalSettingsId() const { return m_globalSettingsId; diff --git a/src/plugins/projectexplorer/projectsettingswidget.h b/src/plugins/projectexplorer/projectsettingswidget.h index 903ac44c8a4..edc7a59c17b 100644 --- a/src/plugins/projectexplorer/projectsettingswidget.h +++ b/src/plugins/projectexplorer/projectsettingswidget.h @@ -46,10 +46,12 @@ public: bool isUseGlobalSettingsCheckBoxEnabled() const; bool isUseGlobalSettingsCheckBoxVisible() const; + bool isUseGlobalSettingsLabelVisible() const; Utils::Id globalSettingsId() const; protected: void setUseGlobalSettingsCheckBoxVisible(bool visible); + void setUseGlobalSettingsLabelVisible(bool visible); void setGlobalSettingsId(Utils::Id globalId); signals: @@ -60,6 +62,7 @@ private: bool m_useGlobalSettings = true; bool m_useGlobalSettingsCheckBoxEnabled = true; bool m_useGlobalSettingsCheckBoxVisibleVisible = true; + bool m_useGlobalSettingsLabelVisibleVisible = true; Utils::Id m_globalSettingsId; };