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))
|
, m_projectSettings(GitLabPlugin::projectSettings(project))
|
||||||
{
|
{
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
|
setUseGlobalSettingsLabelVisible(false);
|
||||||
// setup ui
|
// setup ui
|
||||||
auto verticalLayout = new QVBoxLayout(this);
|
auto verticalLayout = new QVBoxLayout(this);
|
||||||
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
verticalLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : ProjectSett
|
|||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
|
setUseGlobalSettingsLabelVisible(false);
|
||||||
|
|
||||||
const EditorConfiguration *config = m_project->editorConfiguration();
|
const EditorConfiguration *config = m_project->editorConfiguration();
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ DependenciesWidget::DependenciesWidget(Project *project, QWidget *parent) : Proj
|
|||||||
m_model(new DependenciesModel(project, this))
|
m_model(new DependenciesModel(project, this))
|
||||||
{
|
{
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
|
setUseGlobalSettingsLabelVisible(false);
|
||||||
auto vbox = new QVBoxLayout(this);
|
auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
m_detailsContainer = new Utils::DetailsWidget(this);
|
m_detailsContainer = new Utils::DetailsWidget(this);
|
||||||
|
|||||||
@@ -143,40 +143,49 @@ void PanelsWidget::addWidget(QWidget *widget)
|
|||||||
|
|
||||||
void PanelsWidget::addGlobalSettingsProperties(ProjectSettingsWidget *widget)
|
void PanelsWidget::addGlobalSettingsProperties(ProjectSettingsWidget *widget)
|
||||||
{
|
{
|
||||||
if (!widget->isUseGlobalSettingsCheckBoxVisible())
|
if (!widget->isUseGlobalSettingsCheckBoxVisible() && !widget->isUseGlobalSettingsLabelVisible())
|
||||||
return;
|
return;
|
||||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||||
const auto useGlobalSettingsCheckBox = new QCheckBox;
|
const auto useGlobalSettingsCheckBox = new QCheckBox;
|
||||||
useGlobalSettingsCheckBox->setChecked(widget->useGlobalSettings());
|
useGlobalSettingsCheckBox->setChecked(widget->useGlobalSettings());
|
||||||
useGlobalSettingsCheckBox->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled());
|
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());
|
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);
|
|
||||||
|
|
||||||
auto separator = new QFrame(m_root);
|
const auto horizontalLayout = new QHBoxLayout;
|
||||||
separator->setFrameShape(QFrame::HLine);
|
horizontalLayout->setContentsMargins(0, CONTENTS_MARGIN, 0, CONTENTS_MARGIN);
|
||||||
m_layout->addWidget(separator);
|
horizontalLayout->setSpacing(CONTENTS_MARGIN);
|
||||||
|
|
||||||
connect(widget, &ProjectSettingsWidget::useGlobalSettingsCheckBoxEnabledChanged, this,
|
if (widget->isUseGlobalSettingsCheckBoxVisible()) {
|
||||||
[useGlobalSettingsCheckBox, settingsLabel] (bool enabled) {
|
horizontalLayout->addWidget(useGlobalSettingsCheckBox);
|
||||||
|
|
||||||
|
connect(widget, &ProjectSettingsWidget::useGlobalSettingsCheckBoxEnabledChanged,
|
||||||
|
this, [useGlobalSettingsCheckBox, settingsLabel](bool enabled) {
|
||||||
useGlobalSettingsCheckBox->setEnabled(enabled);
|
useGlobalSettingsCheckBox->setEnabled(enabled);
|
||||||
settingsLabel->setEnabled(enabled);
|
settingsLabel->setEnabled(enabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(useGlobalSettingsCheckBox, &QCheckBox::stateChanged,
|
connect(useGlobalSettingsCheckBox, &QCheckBox::stateChanged,
|
||||||
widget, &ProjectSettingsWidget::setUseGlobalSettings);
|
widget, &ProjectSettingsWidget::setUseGlobalSettings);
|
||||||
connect(widget, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
connect(widget, &ProjectSettingsWidget::useGlobalSettingsChanged,
|
||||||
useGlobalSettingsCheckBox, &QCheckBox::setChecked);
|
useGlobalSettingsCheckBox, &QCheckBox::setChecked);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget->isUseGlobalSettingsLabelVisible()) {
|
||||||
|
horizontalLayout->addWidget(settingsLabel);
|
||||||
connect(settingsLabel, &QLabel::linkActivated, this, [widget] {
|
connect(settingsLabel, &QLabel::linkActivated, this, [widget] {
|
||||||
Core::ICore::showOptionsDialog(widget->globalSettingsId());
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // ProjectExplorer
|
} // ProjectExplorer
|
||||||
|
|||||||
@@ -395,6 +395,7 @@ public:
|
|||||||
explicit ProjectEnvironmentWidget(Project *project) : NamedWidget(tr("Project Environment"))
|
explicit ProjectEnvironmentWidget(Project *project) : NamedWidget(tr("Project Environment"))
|
||||||
{
|
{
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
|
setUseGlobalSettingsLabelVisible(false);
|
||||||
const auto vbox = new QVBoxLayout(this);
|
const auto vbox = new QVBoxLayout(this);
|
||||||
vbox->setContentsMargins(0, 0, 0, 0);
|
vbox->setContentsMargins(0, 0, 0, 0);
|
||||||
const auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal);
|
const auto envWidget = new EnvironmentWidget(this, EnvironmentWidget::TypeLocal);
|
||||||
|
|||||||
@@ -67,6 +67,16 @@ void ProjectSettingsWidget::setUseGlobalSettingsCheckBoxVisible(bool visible)
|
|||||||
m_useGlobalSettingsCheckBoxVisibleVisible = visible;
|
m_useGlobalSettingsCheckBoxVisibleVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectSettingsWidget::isUseGlobalSettingsLabelVisible() const
|
||||||
|
{
|
||||||
|
return m_useGlobalSettingsLabelVisibleVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsWidget::setUseGlobalSettingsLabelVisible(bool visible)
|
||||||
|
{
|
||||||
|
m_useGlobalSettingsLabelVisibleVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
Utils::Id ProjectSettingsWidget::globalSettingsId() const
|
Utils::Id ProjectSettingsWidget::globalSettingsId() const
|
||||||
{
|
{
|
||||||
return m_globalSettingsId;
|
return m_globalSettingsId;
|
||||||
|
|||||||
@@ -46,10 +46,12 @@ public:
|
|||||||
bool isUseGlobalSettingsCheckBoxEnabled() const;
|
bool isUseGlobalSettingsCheckBoxEnabled() const;
|
||||||
|
|
||||||
bool isUseGlobalSettingsCheckBoxVisible() const;
|
bool isUseGlobalSettingsCheckBoxVisible() const;
|
||||||
|
bool isUseGlobalSettingsLabelVisible() const;
|
||||||
Utils::Id globalSettingsId() const;
|
Utils::Id globalSettingsId() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setUseGlobalSettingsCheckBoxVisible(bool visible);
|
void setUseGlobalSettingsCheckBoxVisible(bool visible);
|
||||||
|
void setUseGlobalSettingsLabelVisible(bool visible);
|
||||||
void setGlobalSettingsId(Utils::Id globalId);
|
void setGlobalSettingsId(Utils::Id globalId);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -60,6 +62,7 @@ private:
|
|||||||
bool m_useGlobalSettings = true;
|
bool m_useGlobalSettings = true;
|
||||||
bool m_useGlobalSettingsCheckBoxEnabled = true;
|
bool m_useGlobalSettingsCheckBoxEnabled = true;
|
||||||
bool m_useGlobalSettingsCheckBoxVisibleVisible = true;
|
bool m_useGlobalSettingsCheckBoxVisibleVisible = true;
|
||||||
|
bool m_useGlobalSettingsLabelVisibleVisible = true;
|
||||||
Utils::Id m_globalSettingsId;
|
Utils::Id m_globalSettingsId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user