forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
30
src/plugins/projectexplorer/buildaspects.cpp
Normal file
30
src/plugins/projectexplorer/buildaspects.cpp
Normal file
@@ -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
|
33
src/plugins/projectexplorer/buildaspects.h
Normal file
33
src/plugins/projectexplorer/buildaspects.h
Normal file
@@ -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
|
@@ -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.
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 \
|
||||
|
@@ -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",
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -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();
|
||||
|
@@ -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));
|
||||
|
@@ -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);
|
||||
};
|
||||
|
@@ -31,7 +31,7 @@
|
||||
|
||||
namespace QtSupport {
|
||||
|
||||
class QTSUPPORT_EXPORT QmlDebuggingAspect : public ProjectExplorer::BaseBoolAspect
|
||||
class QTSUPPORT_EXPORT QmlDebuggingAspect : public ProjectExplorer::BaseTriStateAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
Reference in New Issue
Block a user