forked from qt-creator/qt-creator
ProjectExplorer: Add possibility to keep link visible
Added possibility to keep link to global settings visible when checkbox is invisible. Change-Id: I724f1c1997b640b2277c4004acd24d5f6cca9faa Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -38,6 +38,7 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : ProjectSett
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
setUseGlobalSettingsCheckBoxVisible(false);
|
||||
setUseGlobalSettingsLabelVisible(false);
|
||||
|
||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <a href=\"dummy\">global settings</a>");
|
||||
settingsLabel->setContentsMargins(CONTENTS_MARGIN, 0, 0, 0);
|
||||
|
||||
const QString labelText = widget->isUseGlobalSettingsCheckBoxVisible()
|
||||
? QStringLiteral("Use <a href=\"dummy\">global settings</a>")
|
||||
: QStringLiteral("<a href=\"dummy\">Global settings</a>");
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user