diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-11-25 13:31:27 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-11-25 13:25:02 +0000 |
commit | 6c66af5c233dafe40d4c4e53c6ef506aaec704cd (patch) | |
tree | 0bf28994c0dd9d5f0875dfe293f7d9a4f19041f1 | |
parent | 9811f95aa7a4384d5fe21233b9019dd13a01c979 (diff) |
ProjectExplorer: Add a base class for build aspects
... and make use of it in the QmlDebuggingAspect.
A build setting is conceptually not a boolean, but a tri-state, as we
need to support force-switching a feature on and off as well as
specifying that it is to be left at its default value.
Change-Id: I15552614c5cf4f5187c026909d233c13e3487e81
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/plugins/projectexplorer/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildaspects.cpp | 30 | ||||
-rw-r--r-- | src/plugins/projectexplorer/buildaspects.h | 33 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectconfiguration.h | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectconfigurationaspects.cpp | 42 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectconfigurationaspects.h | 17 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.pro | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.qbs | 1 | ||||
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsbuildconfiguration.h | 2 | ||||
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsbuildstep.cpp | 21 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtbuildaspects.cpp | 14 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtbuildaspects.h | 2 |
13 files changed, 153 insertions, 24 deletions
diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index a2ccaa1170..b05fa30315 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -12,6 +12,7 @@ add_qtc_plugin(ProjectExplorer applicationlauncher.cpp applicationlauncher.h appoutputpane.cpp appoutputpane.h baseprojectwizarddialog.cpp baseprojectwizarddialog.h + buildaspects.cpp buildaspects.h buildconfiguration.cpp buildconfiguration.h buildenvironmentwidget.cpp buildenvironmentwidget.h buildinfo.cpp buildinfo.h diff --git a/src/plugins/projectexplorer/buildaspects.cpp b/src/plugins/projectexplorer/buildaspects.cpp new file mode 100644 index 0000000000..0b77b82e3d --- /dev/null +++ b/src/plugins/projectexplorer/buildaspects.cpp @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "buildaspects.h" + +namespace ProjectExplorer { + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/buildaspects.h b/src/plugins/projectexplorer/buildaspects.h new file mode 100644 index 0000000000..b294664a47 --- /dev/null +++ b/src/plugins/projectexplorer/buildaspects.h @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include "projectexplorer_export.h" +#include "projectconfigurationaspects.h" + +namespace ProjectExplorer { + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index 6377e55df8..c6134f6ed8 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -112,6 +112,8 @@ signals: void changed(); protected: + virtual void setVisibleDynamic(bool visible) { Q_UNUSED(visible) } // TODO: Better name? Merge with setVisible() somehow? + Core::Id m_id; QString m_displayName; QString m_settingsKey; // Name of data in settings. diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index 7549c49801..6e958e3f15 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -76,6 +76,7 @@ public: // These are all owned by the configuration widget. QList<QPointer<QRadioButton>> m_buttons; QPointer<QComboBox> m_comboBox; + QPointer<QLabel> m_label; QPointer<QButtonGroup> m_buttonGroup; }; @@ -400,11 +401,6 @@ void BaseBoolAspect::toMap(QVariantMap &data) const data.insert(settingsKey(), d->m_value); } -QCheckBox *BaseBoolAspect::checkBox() const -{ - return d->m_checkBox; -} - bool BaseBoolAspect::defaultValue() const { return d->m_defaultValue; @@ -473,13 +469,14 @@ void BaseSelectionAspect::addToLayout(LayoutBuilder &builder) } break; case DisplayStyle::ComboBox: + d->m_label = new QLabel(displayName()); d->m_comboBox = new QComboBox; for (int i = 0, n = d->m_options.size(); i < n; ++i) d->m_comboBox->addItem(d->m_options.at(i).displayName); connect(d->m_comboBox.data(), QOverload<int>::of(&QComboBox::activated), this, [this](int index) { d->m_value = index; emit changed(); }); d->m_comboBox->setCurrentIndex(d->m_value); - builder.addItems(new QLabel(displayName()), d->m_comboBox.data()); + builder.addItems(d->m_label.data(), d->m_comboBox.data()); break; } } @@ -494,6 +491,16 @@ void BaseSelectionAspect::toMap(QVariantMap &data) const data.insert(settingsKey(), d->m_value); } +void BaseSelectionAspect::setVisibleDynamic(bool visible) +{ + if (d->m_label) + d->m_label->setVisible(visible); + if (d->m_comboBox) + d->m_comboBox->setVisible(visible); + for (QRadioButton * const button : qAsConst(d->m_buttons)) + button->setVisible(visible); +} + int BaseSelectionAspect::defaultValue() const { return d->m_defaultValue; @@ -613,4 +620,27 @@ void BaseIntegerAspect::setDisplayScaleFactor(qint64 factor) d->m_displayScaleFactor = factor; } +BaseTriStateAspect::BaseTriStateAspect() +{ + setDisplayStyle(DisplayStyle::ComboBox); + setDefaultValue(2); + addOption(tr("Enable")); + addOption(tr("Disable")); + addOption(tr("Leave at Default")); +} + +BaseTriStateAspect::Value BaseTriStateAspect::setting() const +{ + if (value() == 0) + return Value::Enabled; + if (value() == 1) + return Value::Disabled; + return Value::Default; +} + +void BaseTriStateAspect::setSetting(BaseTriStateAspect::Value setting) +{ + setValue(setting == Value::Enabled ? 0 : setting == Value::Disabled ? 1 : 2); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index 8b572e4b67..4fe4ac3011 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -68,9 +68,6 @@ public: void fromMap(const QVariantMap &map) override; void toMap(QVariantMap &map) const override; -protected: - QCheckBox *checkBox() const; - private: std::unique_ptr<Internal::BaseBoolAspectPrivate> d; }; @@ -99,6 +96,9 @@ public: void fromMap(const QVariantMap &map) override; void toMap(QVariantMap &map) const override; +protected: + void setVisibleDynamic(bool visible) override; + private: std::unique_ptr<Internal::BaseSelectionAspectPrivate> d; }; @@ -179,4 +179,15 @@ private: std::unique_ptr<Internal::BaseIntegerAspectPrivate> d; }; +class PROJECTEXPLORER_EXPORT BaseTriStateAspect : public BaseSelectionAspect +{ + Q_OBJECT +public: + BaseTriStateAspect(); + + enum class Value { Enabled, Disabled, Default }; + Value setting() const; + void setSetting(Value setting); +}; + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 6fbc74ea24..d3fd40904c 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -12,6 +12,7 @@ HEADERS += projectexplorer.h \ abiwidget.h \ addrunconfigdialog.h \ ansifilterparser.h \ + buildaspects.h \ buildinfo.h \ buildsystem.h \ buildtargettype.h \ @@ -171,6 +172,7 @@ SOURCES += projectexplorer.cpp \ abiwidget.cpp \ addrunconfigdialog.cpp \ ansifilterparser.cpp \ + buildaspects.cpp \ buildinfo.cpp \ buildsystem.cpp \ clangparser.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 9a4131d0fd..2536dd0d6d 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -31,6 +31,7 @@ Project { "applicationlauncher.cpp", "applicationlauncher.h", "appoutputpane.cpp", "appoutputpane.h", "baseprojectwizarddialog.cpp", "baseprojectwizarddialog.h", + "buildaspects.cpp", "buildaspects.h", "buildconfiguration.cpp", "buildconfiguration.h", "buildenvironmentwidget.cpp", "buildenvironmentwidget.h", "buildinfo.cpp", "buildinfo.h", diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp index 7acbaccccb..c49bf6bc20 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.cpp @@ -45,7 +45,6 @@ #include <projectexplorer/target.h> #include <projectexplorer/toolchain.h> -#include <qtsupport/qtbuildaspects.h> #include <qtsupport/qtkitinformation.h> #include <utils/mimetypes/mimedatabase.h> @@ -150,8 +149,6 @@ void QbsBuildConfiguration::initialize() + '_' + kitHash.toHex().left(16); m_configurationName->setValue(uniqueConfigName); - if (initialBuildType() == Release) - aspect<QtSupport::QmlDebuggingAspect>()->setDefaultValue(false); BuildStepList *buildSteps = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); auto bs = new QbsBuildStep(buildSteps); @@ -377,7 +374,12 @@ QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep) bool QbsBuildConfiguration::isQmlDebuggingEnabled() const { - return aspect<QtSupport::QmlDebuggingAspect>()->value(); + return qmlDebuggingSetting() == QtSupport::QmlDebuggingAspect::Value::Enabled; +} + +BaseTriStateAspect::Value QbsBuildConfiguration::qmlDebuggingSetting() const +{ + return aspect<QtSupport::QmlDebuggingAspect>()->setting(); } // --------------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h index 01edafc321..ee33ef729f 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h +++ b/src/plugins/qbsprojectmanager/qbsbuildconfiguration.h @@ -31,6 +31,7 @@ #include <projectexplorer/buildconfiguration.h> #include <qtsupport/baseqtversion.h> +#include <qtsupport/qtbuildaspects.h> namespace ProjectExplorer { class BuildStep; } @@ -75,6 +76,7 @@ public: QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const; bool isQmlDebuggingEnabled() const; + QtSupport::QmlDebuggingAspect::Value qmlDebuggingSetting() const; signals: void qbsConfigurationChanged(); diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 45d9b4f63d..d47f3671f0 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -213,10 +213,17 @@ QVariantMap QbsBuildStep::qbsConfiguration(VariableHandling variableHandling) co { QVariantMap config = m_qbsConfiguration; config.insert(Constants::QBS_FORCE_PROBES_KEY, m_forceProbes); - if (static_cast<QbsBuildConfiguration *>(buildConfiguration())->isQmlDebuggingEnabled()) + switch (static_cast<QbsBuildConfiguration *>(buildConfiguration())->qmlDebuggingSetting()) { + case QtSupport::QmlDebuggingAspect::Value::Enabled: config.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, true); - else + break; + case QtSupport::QmlDebuggingAspect::Value::Disabled: + config.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, false); + break; + default: config.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY); + break; + } if (variableHandling == ExpandVariables) { const MacroExpander * const expander = buildConfiguration()->macroExpander(); for (auto it = config.begin(), end = config.end(); it != end; ++it) { @@ -667,8 +674,16 @@ void QbsBuildStepConfigWidget::updateState() command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue; } - if (qbsBuildConfig->isQmlDebuggingEnabled()) + switch (qbsBuildConfig->qmlDebuggingSetting()) { + case QtSupport::QmlDebuggingAspect::Value::Enabled: command.append(' ').append(Constants::QBS_CONFIG_QUICK_DEBUG_KEY).append(":true"); + break; + case QtSupport::QmlDebuggingAspect::Value::Disabled: + command.append(' ').append(Constants::QBS_CONFIG_QUICK_DEBUG_KEY).append(":false"); + break; + default: + break; + } commandLineTextEdit->setPlainText(command); setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); diff --git a/src/plugins/qtsupport/qtbuildaspects.cpp b/src/plugins/qtsupport/qtbuildaspects.cpp index 5c8a400499..093905c8c7 100644 --- a/src/plugins/qtsupport/qtbuildaspects.cpp +++ b/src/plugins/qtsupport/qtbuildaspects.cpp @@ -38,15 +38,15 @@ using namespace ProjectExplorer; namespace QtSupport { -QmlDebuggingAspect::QmlDebuggingAspect() : BaseBoolAspect("EnableQmlDebugging") +QmlDebuggingAspect::QmlDebuggingAspect() { - setDefaultValue(true); - setLabel(tr("Enable QML debugging and profiling")); + setSettingsKey("EnableQmlDebugging"); + setDisplayName(tr("QML debugging and profiling")); } void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder) { - BaseBoolAspect::addToLayout(builder); + BaseSelectionAspect::addToLayout(builder); const auto warningIconLabel = new QLabel; warningIconLabel->setAlignment(Qt::AlignTop); warningIconLabel->setPixmap(Utils::Icons::WARNING.pixmap()); @@ -57,13 +57,13 @@ void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder) QString warningText; const bool supported = m_kit && BaseQtVersion::isQmlDebuggingSupported(m_kit, &warningText); if (!supported) { - setValue(false); - } else if (value()) { + setSetting(Value::Default); + } else if (setting() == Value::Enabled) { warningText = tr("Might make your application vulnerable.<br/>" "Only use in a safe environment."); } warningTextLabel->setText(warningText); - checkBox()->setVisible(supported); + setVisibleDynamic(supported); warningIconLabel->setVisible(supported && !warningText.isEmpty()); warningTextLabel->setVisible(supported); }; diff --git a/src/plugins/qtsupport/qtbuildaspects.h b/src/plugins/qtsupport/qtbuildaspects.h index 20c29fc895..73d1160173 100644 --- a/src/plugins/qtsupport/qtbuildaspects.h +++ b/src/plugins/qtsupport/qtbuildaspects.h @@ -31,7 +31,7 @@ namespace QtSupport { -class QTSUPPORT_EXPORT QmlDebuggingAspect : public ProjectExplorer::BaseBoolAspect +class QTSUPPORT_EXPORT QmlDebuggingAspect : public ProjectExplorer::BaseTriStateAspect { Q_OBJECT public: |