diff options
author | hjk <hjk@qt.io> | 2019-10-31 17:37:49 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-11-01 10:20:32 +0000 |
commit | 6908ecc0842a34e243052d957cf98ab3861353aa (patch) | |
tree | 58599c94e65dbeb8f97b6c740deb4ef22c6f2e63 /src/plugins/projectexplorer | |
parent | 0d9425b51b03a8db04bac82df3b0806622fad7d6 (diff) |
ProjectExlorer: Streamline creation of NamedWidgets
Change-Id: I67c1506ea4e2d7722c9ce38738e350418d725a0e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer')
-rw-r--r-- | src/plugins/projectexplorer/buildconfiguration.cpp | 3 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildenvironmentwidget.cpp | 12 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildsettingspropertiespage.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildstepspage.cpp | 6 | ||||
-rw-r--r-- | src/plugins/projectexplorer/namedwidget.cpp | 20 | ||||
-rw-r--r-- | src/plugins/projectexplorer/namedwidget.h | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/project.h | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/runsettingspropertiespage.h | 2 |
8 files changed, 15 insertions, 39 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 0f9d3171fb..9496ec76a1 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -166,8 +166,7 @@ void BuildConfiguration::setBuildDirectory(const Utils::FilePath &dir) NamedWidget *BuildConfiguration::createConfigWidget() { - NamedWidget *named = new NamedWidget; - named->setDisplayName(d->m_configWidgetDisplayName); + NamedWidget *named = new NamedWidget(d->m_configWidgetDisplayName); QWidget *widget = nullptr; diff --git a/src/plugins/projectexplorer/buildenvironmentwidget.cpp b/src/plugins/projectexplorer/buildenvironmentwidget.cpp index 4995d1bc50..68211385e8 100644 --- a/src/plugins/projectexplorer/buildenvironmentwidget.cpp +++ b/src/plugins/projectexplorer/buildenvironmentwidget.cpp @@ -33,10 +33,10 @@ #include <QVBoxLayout> #include <QCheckBox> -using namespace ProjectExplorer; +namespace ProjectExplorer { -BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) : - m_buildConfiguration(nullptr) +BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) + : NamedWidget(tr("Build Environment")), m_buildConfiguration(bc) { auto vbox = new QVBoxLayout(this); vbox->setContentsMargins(0, 0, 0, 0); @@ -52,8 +52,6 @@ BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) : connect(m_clearSystemEnvironmentCheckBox, &QAbstractButton::toggled, this, &BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked); - m_buildConfiguration = bc; - connect(m_buildConfiguration, &BuildConfiguration::environmentChanged, this, &BuildEnvironmentWidget::environmentChanged); @@ -61,8 +59,6 @@ BuildEnvironmentWidget::BuildEnvironmentWidget(BuildConfiguration *bc) : m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText()); m_buildEnvironmentWidget->setUserChanges(m_buildConfiguration->userEnvironmentChanges()); - - setDisplayName(tr("Build Environment")); } void BuildEnvironmentWidget::environmentModelUserChangesChanged() @@ -82,3 +78,5 @@ void BuildEnvironmentWidget::environmentChanged() m_buildEnvironmentWidget->setBaseEnvironment(m_buildConfiguration->baseEnvironment()); m_buildEnvironmentWidget->setBaseEnvironmentText(m_buildConfiguration->baseEnvironmentText()); } + +} // ProjectExplorer diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index 93720bab78..468d4751ac 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -143,8 +143,6 @@ void BuildSettingsWidget::addSubWidget(NamedWidget *widget) auto label = new QLabel(this); label->setText(widget->displayName()); - connect(widget, &NamedWidget::displayNameChanged, - label, &QLabel::setText); QFont f = label->font(); f.setBold(true); f.setPointSizeF(f.pointSizeF() * 1.2); diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index 579fbe9655..76fadceb68 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -192,7 +192,8 @@ BuildStepsWidgetData::~BuildStepsWidgetData() } BuildStepListWidget::BuildStepListWidget(BuildStepList *bsl, QWidget *parent) - : NamedWidget(parent), m_buildStepList(bsl) + //: %1 is the name returned by BuildStepList::displayName + : NamedWidget(tr("%1 Steps").arg(bsl->displayName()), parent), m_buildStepList(bsl) { setupUi(); @@ -200,9 +201,6 @@ BuildStepListWidget::BuildStepListWidget(BuildStepList *bsl, QWidget *parent) connect(bsl, &BuildStepList::stepRemoved, this, &BuildStepListWidget::removeBuildStep); connect(bsl, &BuildStepList::stepMoved, this, &BuildStepListWidget::stepMoved); - //: %1 is the name returned by BuildStepList::displayName - setDisplayName(tr("%1 Steps").arg(bsl->displayName())); - for (int i = 0; i < bsl->count(); ++i) { addBuildStep(i); // addBuilStep expands the config widget by default, which we don't want here diff --git a/src/plugins/projectexplorer/namedwidget.cpp b/src/plugins/projectexplorer/namedwidget.cpp index f3a0e4beb4..9aed84c73a 100644 --- a/src/plugins/projectexplorer/namedwidget.cpp +++ b/src/plugins/projectexplorer/namedwidget.cpp @@ -25,24 +25,16 @@ #include "namedwidget.h" -using namespace ProjectExplorer; +namespace ProjectExplorer { -/// -// NamedWidget -/// - -NamedWidget::NamedWidget(QWidget *parent) : QWidget(parent) -{ } +NamedWidget::NamedWidget(const QString &displayName, QWidget *parent) + : QWidget(parent), m_displayName(displayName) +{ +} QString NamedWidget::displayName() const { return m_displayName; } -void NamedWidget::setDisplayName(const QString &displayName) -{ - if (m_displayName == displayName) - return; - m_displayName = displayName; - emit displayNameChanged(m_displayName); -} +} // ProjectExplorer diff --git a/src/plugins/projectexplorer/namedwidget.h b/src/plugins/projectexplorer/namedwidget.h index 870941c73b..b1e80111e2 100644 --- a/src/plugins/projectexplorer/namedwidget.h +++ b/src/plugins/projectexplorer/namedwidget.h @@ -33,16 +33,10 @@ namespace ProjectExplorer { class PROJECTEXPLORER_EXPORT NamedWidget : public QWidget { - Q_OBJECT - public: - explicit NamedWidget(QWidget *parent = nullptr); + explicit NamedWidget(const QString &displayName, QWidget *parent = nullptr); QString displayName() const; - void setDisplayName(const QString &displayName); - -signals: - void displayNameChanged(const QString &); private: QString m_displayName; diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 5310be1aa7..326763bf8c 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -53,7 +53,6 @@ class BuildSystem; class ContainerNode; class EditorConfiguration; class FolderNode; -class NamedWidget; class Node; class ProjectConfiguration; class ProjectImporter; diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.h b/src/plugins/projectexplorer/runsettingspropertiespage.h index 12f1403c42..7db4db3e9a 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.h +++ b/src/plugins/projectexplorer/runsettingspropertiespage.h @@ -39,9 +39,7 @@ QT_END_NAMESPACE namespace ProjectExplorer { class DeployConfiguration; -class NamedWidget; class RunConfiguration; -class RunConfigWidget; class Target; namespace Internal { |