ProjectExplorer: Use full class for TriState value

Allows more compact code on the user side in most cases and
can hide the internal 'int-ness' from user code by wrapping
Variant conversions in the TriState class itself.

Change-Id: I4c91e0cd798ee988a0b9cb057749251a4efebaff
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-11-15 16:20:33 +01:00
parent 3b9ce98865
commit ce434ccb5d
14 changed files with 151 additions and 162 deletions

View File

@@ -33,9 +33,9 @@ namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT BuildPropertiesSettings class PROJECTEXPLORER_EXPORT BuildPropertiesSettings
{ {
public: public:
BaseTriStateAspect::Value separateDebugInfo = BaseTriStateAspect::Value::Default; TriState separateDebugInfo;
BaseTriStateAspect::Value qmlDebugging = BaseTriStateAspect::Value::Default; TriState qmlDebugging;
BaseTriStateAspect::Value qtQuickCompiler = BaseTriStateAspect::Value::Default; TriState qtQuickCompiler;
bool showQtSettings = false; bool showQtSettings = false;
}; };

View File

@@ -43,16 +43,16 @@ public:
const BuildPropertiesSettings &settings = ProjectExplorerPlugin::buildPropertiesSettings(); const BuildPropertiesSettings &settings = ProjectExplorerPlugin::buildPropertiesSettings();
for (QComboBox * const comboBox : {&m_separateDebugInfoComboBox, &m_qmlDebuggingComboBox, for (QComboBox * const comboBox : {&m_separateDebugInfoComboBox, &m_qmlDebuggingComboBox,
&m_qtQuickCompilerComboBox}) { &m_qtQuickCompilerComboBox}) {
comboBox->addItem(tr("Enable"), int(BaseTriStateAspect::Value::Enabled)); comboBox->addItem(tr("Enable"), TriState::Enabled.toVariant());
comboBox->addItem(tr("Disable"), int(BaseTriStateAspect::Value::Disabled)); comboBox->addItem(tr("Disable"),TriState::Disabled.toVariant());
comboBox->addItem(tr("Use Project Default"), int(BaseTriStateAspect::Value::Default)); comboBox->addItem(tr("Use Project Default"), TriState::Default.toVariant());
} }
m_separateDebugInfoComboBox.setCurrentIndex(m_separateDebugInfoComboBox m_separateDebugInfoComboBox.setCurrentIndex(m_separateDebugInfoComboBox
.findData(int(settings.separateDebugInfo))); .findData(settings.separateDebugInfo.toVariant()));
m_qmlDebuggingComboBox.setCurrentIndex(m_qmlDebuggingComboBox m_qmlDebuggingComboBox.setCurrentIndex(m_qmlDebuggingComboBox
.findData(int(settings.qmlDebugging))); .findData(settings.qmlDebugging.toVariant()));
m_qtQuickCompilerComboBox.setCurrentIndex(m_qtQuickCompilerComboBox m_qtQuickCompilerComboBox.setCurrentIndex(m_qtQuickCompilerComboBox
.findData(int(settings.qtQuickCompiler))); .findData(settings.qtQuickCompiler.toVariant()));
const auto layout = new QFormLayout(this); const auto layout = new QFormLayout(this);
layout->addRow(tr("Separate debug info:"), &m_separateDebugInfoComboBox); layout->addRow(tr("Separate debug info:"), &m_separateDebugInfoComboBox);
if (settings.showQtSettings) { if (settings.showQtSettings) {
@@ -67,12 +67,9 @@ public:
BuildPropertiesSettings settings() const BuildPropertiesSettings settings() const
{ {
BuildPropertiesSettings s; BuildPropertiesSettings s;
s.separateDebugInfo = static_cast<BaseTriStateAspect::Value>( s.separateDebugInfo = TriState::fromVariant(m_separateDebugInfoComboBox.currentData());
m_separateDebugInfoComboBox.currentData().toInt()); s.qmlDebugging = TriState::fromVariant(m_qmlDebuggingComboBox.currentData());
s.qmlDebugging = static_cast<BaseTriStateAspect::Value>( s.qtQuickCompiler = TriState::fromVariant(m_qtQuickCompilerComboBox.currentData());
m_qmlDebuggingComboBox.currentData().toInt());
s.qtQuickCompiler = static_cast<BaseTriStateAspect::Value>(
m_qtQuickCompilerComboBox.currentData().toInt());
return s; return s;
} }

View File

@@ -688,18 +688,25 @@ BaseTriStateAspect::BaseTriStateAspect()
addOption(tr("Leave at Default")); addOption(tr("Leave at Default"));
} }
BaseTriStateAspect::Value BaseTriStateAspect::setting() const TriState BaseTriStateAspect::setting() const
{ {
if (value() == 0) return TriState::fromVariant(value());
return Value::Enabled;
if (value() == 1)
return Value::Disabled;
return Value::Default;
} }
void BaseTriStateAspect::setSetting(BaseTriStateAspect::Value setting) void BaseTriStateAspect::setSetting(TriState setting)
{ {
setValue(setting == Value::Enabled ? 0 : setting == Value::Disabled ? 1 : 2); setValue(setting.toVariant().toInt());
}
const TriState TriState::Enabled{TriState::EnabledValue};
const TriState TriState::Disabled{TriState::DisabledValue};
const TriState TriState::Default{TriState::DefaultValue};
TriState TriState::fromVariant(const QVariant &variant)
{
int v = variant.toInt();
QTC_ASSERT(v == EnabledValue || v == DisabledValue || v == DefaultValue, v = DefaultValue);
return TriState(Value(v));
} }
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -190,15 +190,36 @@ private:
std::unique_ptr<Internal::BaseIntegerAspectPrivate> d; std::unique_ptr<Internal::BaseIntegerAspectPrivate> d;
}; };
class PROJECTEXPLORER_EXPORT TriState
{
enum Value { EnabledValue, DisabledValue, DefaultValue };
explicit TriState(Value v) : m_value(v) {}
public:
TriState() = default;
QVariant toVariant() const { return int(m_value); }
static TriState fromVariant(const QVariant &variant);
static const TriState Enabled;
static const TriState Disabled;
static const TriState Default;
friend bool operator==(TriState a, TriState b) { return a.m_value == b.m_value; }
friend bool operator!=(TriState a, TriState b) { return a.m_value != b.m_value; }
private:
Value m_value = DefaultValue;
};
class PROJECTEXPLORER_EXPORT BaseTriStateAspect : public BaseSelectionAspect class PROJECTEXPLORER_EXPORT BaseTriStateAspect : public BaseSelectionAspect
{ {
Q_OBJECT Q_OBJECT
public: public:
BaseTriStateAspect(); BaseTriStateAspect();
enum class Value { Enabled, Disabled, Default }; TriState setting() const;
Value setting() const; void setSetting(TriState setting);
void setSetting(Value setting);
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -1426,8 +1426,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd->m_projectExplorerSettings.buildDirectoryTemplate = Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE; dd->m_projectExplorerSettings.buildDirectoryTemplate = Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE;
const auto loadTriStateValue = [&s](const QString &key) { const auto loadTriStateValue = [&s](const QString &key) {
return static_cast<BaseTriStateAspect::Value>( return TriState::fromVariant(s->value(key, TriState::Default.toVariant()));
s->value(key, int(BaseTriStateAspect::Value::Default)).toInt());
}; };
dd->m_buildPropertiesSettings.separateDebugInfo dd->m_buildPropertiesSettings.separateDebugInfo
= loadTriStateValue(Constants::SEPARATE_DEBUG_INFO_SETTINGS_KEY); = loadTriStateValue(Constants::SEPARATE_DEBUG_INFO_SETTINGS_KEY);
@@ -2049,11 +2048,11 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
s->setValue(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY, dd->m_projectExplorerSettings.buildDirectoryTemplate); s->setValue(Constants::DEFAULT_BUILD_DIRECTORY_TEMPLATE_KEY, dd->m_projectExplorerSettings.buildDirectoryTemplate);
s->setValue(Constants::SEPARATE_DEBUG_INFO_SETTINGS_KEY, s->setValue(Constants::SEPARATE_DEBUG_INFO_SETTINGS_KEY,
int(dd->m_buildPropertiesSettings.separateDebugInfo)); dd->m_buildPropertiesSettings.separateDebugInfo.toVariant());
s->setValue(Constants::QML_DEBUGGING_SETTINGS_KEY, s->setValue(Constants::QML_DEBUGGING_SETTINGS_KEY,
int(dd->m_buildPropertiesSettings.qmlDebugging)); dd->m_buildPropertiesSettings.qmlDebugging.toVariant());
s->setValue(Constants::QT_QUICK_COMPILER_SETTINGS_KEY, s->setValue(Constants::QT_QUICK_COMPILER_SETTINGS_KEY,
int(dd->m_buildPropertiesSettings.qtQuickCompiler)); dd->m_buildPropertiesSettings.qtQuickCompiler.toVariant());
} }
void ProjectExplorerPlugin::openProjectWelcomePage(const QString &fileName) void ProjectExplorerPlugin::openProjectWelcomePage(const QString &fileName)

View File

@@ -383,20 +383,20 @@ QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep)
bool QbsBuildConfiguration::isQmlDebuggingEnabled() const bool QbsBuildConfiguration::isQmlDebuggingEnabled() const
{ {
return qmlDebuggingSetting() == QtSupport::QmlDebuggingAspect::Value::Enabled; return qmlDebuggingSetting() == TriState::Enabled;
} }
BaseTriStateAspect::Value QbsBuildConfiguration::qmlDebuggingSetting() const TriState QbsBuildConfiguration::qmlDebuggingSetting() const
{ {
return aspect<QtSupport::QmlDebuggingAspect>()->setting(); return aspect<QtSupport::QmlDebuggingAspect>()->setting();
} }
BaseTriStateAspect::Value QbsBuildConfiguration::qtQuickCompilerSetting() const TriState QbsBuildConfiguration::qtQuickCompilerSetting() const
{ {
return aspect<QtSupport::QtQuickCompilerAspect>()->setting(); return aspect<QtSupport::QtQuickCompilerAspect>()->setting();
} }
BaseTriStateAspect::Value QbsBuildConfiguration::separateDebugInfoSetting() const TriState QbsBuildConfiguration::separateDebugInfoSetting() const
{ {
return aspect<SeparateDebugInfoAspect>()->setting(); return aspect<SeparateDebugInfoAspect>()->setting();
} }

View File

@@ -77,9 +77,9 @@ public:
QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const; QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const;
bool isQmlDebuggingEnabled() const; bool isQmlDebuggingEnabled() const;
QtSupport::QmlDebuggingAspect::Value qmlDebuggingSetting() const; ProjectExplorer::TriState qmlDebuggingSetting() const;
QtSupport::QtQuickCompilerAspect::Value qtQuickCompilerSetting() const; ProjectExplorer::TriState qtQuickCompilerSetting() const;
ProjectExplorer::SeparateDebugInfoAspect::Value separateDebugInfoSetting() const; ProjectExplorer::TriState separateDebugInfoSetting() const;
signals: signals:
void qbsConfigurationChanged(); void qbsConfigurationChanged();

View File

@@ -214,39 +214,25 @@ QVariantMap QbsBuildStep::qbsConfiguration(VariableHandling variableHandling) co
QVariantMap config = m_qbsConfiguration; QVariantMap config = m_qbsConfiguration;
const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(buildConfiguration()); const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(buildConfiguration());
config.insert(Constants::QBS_FORCE_PROBES_KEY, m_forceProbes); config.insert(Constants::QBS_FORCE_PROBES_KEY, m_forceProbes);
switch (qbsBuildConfig->separateDebugInfoSetting()) {
case SeparateDebugInfoAspect::Value::Enabled: const auto store = [&config](TriState ts, const QString &key) {
config.insert(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY, true); if (ts == TriState::Enabled)
break; config.insert(key, true);
case SeparateDebugInfoAspect::Value::Disabled: else if (ts == TriState::Disabled)
config.insert(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY, false); config.insert(key, false);
break; else
default: config.remove(key);
config.remove(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY); };
break;
} store(qbsBuildConfig->separateDebugInfoSetting(),
switch (qbsBuildConfig->qmlDebuggingSetting()) { Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
case QtSupport::QmlDebuggingAspect::Value::Enabled:
config.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, true); store(qbsBuildConfig->qmlDebuggingSetting(),
break; Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
case QtSupport::QmlDebuggingAspect::Value::Disabled:
config.insert(Constants::QBS_CONFIG_QUICK_DEBUG_KEY, false); store(qbsBuildConfig->qtQuickCompilerSetting(),
break; Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
default:
config.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
break;
}
switch (qbsBuildConfig->qtQuickCompilerSetting()) {
case QtSupport::QtQuickCompilerAspect::Value::Enabled:
config.insert(Constants::QBS_CONFIG_QUICK_COMPILER_KEY, true);
break;
case QtSupport::QtQuickCompilerAspect::Value::Disabled:
config.insert(Constants::QBS_CONFIG_QUICK_COMPILER_KEY, false);
break;
default:
config.remove(Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
break;
}
if (variableHandling == ExpandVariables) { if (variableHandling == ExpandVariables) {
const MacroExpander * const expander = buildConfiguration()->macroExpander(); const MacroExpander * const expander = buildConfiguration()->macroExpander();
for (auto it = config.begin(), end = config.end(); it != end; ++it) { for (auto it = config.begin(), end = config.end(); it != end; ++it) {
@@ -697,36 +683,23 @@ void QbsBuildStepConfigWidget::updateState()
command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue; command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue;
} }
switch (qbsBuildConfig->separateDebugInfoSetting()) { const auto addToCommand = [&command](TriState ts, const QString &key) {
case SeparateDebugInfoAspect::Value::Enabled: if (ts == TriState::Enabled)
command.append(' ').append(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY).append(":true"); command.append(' ').append(key).append(":true");
break; else if (ts == TriState::Disabled)
case SeparateDebugInfoAspect::Value::Disabled: command.append(' ').append(key).append(":false");
command.append(' ').append(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY).append(":false"); // Do nothing for TriState::Default
break; };
default:
break; addToCommand(qbsBuildConfig->separateDebugInfoSetting(),
} Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
switch (qbsBuildConfig->qmlDebuggingSetting()) {
case QtSupport::QmlDebuggingAspect::Value::Enabled: addToCommand(qbsBuildConfig->qmlDebuggingSetting(),
command.append(' ').append(Constants::QBS_CONFIG_QUICK_DEBUG_KEY).append(":true"); Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
break;
case QtSupport::QmlDebuggingAspect::Value::Disabled: addToCommand(qbsBuildConfig->qtQuickCompilerSetting(),
command.append(' ').append(Constants::QBS_CONFIG_QUICK_DEBUG_KEY).append(":false"); Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
break;
default:
break;
}
switch (qbsBuildConfig->qtQuickCompilerSetting()) {
case QtSupport::QtQuickCompilerAspect::Value::Enabled:
command.append(' ').append(Constants::QBS_CONFIG_QUICK_COMPILER_KEY).append(":true");
break;
case QtSupport::QtQuickCompilerAspect::Value::Disabled:
command.append(' ').append(Constants::QBS_CONFIG_QUICK_COMPILER_KEY).append(":false");
break;
default:
break;
}
commandLineTextEdit->setPlainText(command); commandLineTextEdit->setPlainText(command);
setSummaryText(tr("<b>Qbs:</b> %1").arg(command)); setSummaryText(tr("<b>Qbs:</b> %1").arg(command));

View File

@@ -38,10 +38,10 @@
using namespace QmakeProjectManager; using namespace QmakeProjectManager;
using namespace Internal; using namespace Internal;
using namespace ProjectExplorer;
using Utils::FilePath; using Utils::FilePath;
using Utils::QtcProcess; using Utils::QtcProcess;
using ProjectExplorer::BaseTriStateAspect;
using QtSupport::QtVersionManager; using QtSupport::QtVersionManager;
using QtSupport::BaseQtVersion; using QtSupport::BaseQtVersion;
@@ -192,14 +192,14 @@ void MakeFileParse::parseAssignments(QList<QMakeAssignment> *assignments)
m_config.osType = QMakeStepConfig::NoOsType; m_config.osType = QMakeStepConfig::NoOsType;
} else if (value == QLatin1String("qml_debug")) { } else if (value == QLatin1String("qml_debug")) {
if (qa.op == QLatin1String("+=")) if (qa.op == QLatin1String("+="))
m_config.linkQmlDebuggingQQ2 = BaseTriStateAspect::Value::Enabled; m_config.linkQmlDebuggingQQ2 = TriState::Enabled;
else else
m_config.linkQmlDebuggingQQ2 = BaseTriStateAspect::Value::Disabled; m_config.linkQmlDebuggingQQ2 = TriState::Disabled;
} else if (value == QLatin1String("qtquickcompiler")) { } else if (value == QLatin1String("qtquickcompiler")) {
if (qa.op == QLatin1String("+=")) if (qa.op == QLatin1String("+="))
m_config.useQtQuickCompiler = BaseTriStateAspect::Value::Enabled; m_config.useQtQuickCompiler = TriState::Enabled;
else else
m_config.useQtQuickCompiler = BaseTriStateAspect::Value::Disabled; m_config.useQtQuickCompiler = TriState::Disabled;
} else if (value == QLatin1String("force_debug_info")) { } else if (value == QLatin1String("force_debug_info")) {
if (qa.op == QLatin1String("+=")) if (qa.op == QLatin1String("+="))
foundForceDebugInfo = true; foundForceDebugInfo = true;
@@ -225,7 +225,7 @@ void MakeFileParse::parseAssignments(QList<QMakeAssignment> *assignments)
} }
if (foundForceDebugInfo && foundSeparateDebugInfo) { if (foundForceDebugInfo && foundSeparateDebugInfo) {
m_config.separateDebugInfo = ProjectExplorer::BaseTriStateAspect::Value::Enabled; m_config.separateDebugInfo = TriState::Enabled;
} else if (foundForceDebugInfo) { } else if (foundForceDebugInfo) {
// Found only force_debug_info, so readd it // Found only force_debug_info, so readd it
QMakeAssignment newQA; QMakeAssignment newQA;
@@ -376,11 +376,11 @@ void MakeFileParse::parseCommandLine(const QString &command, const QString &proj
qCDebug(logging()) << " TargetArch" << m_config.archConfig; qCDebug(logging()) << " TargetArch" << m_config.archConfig;
qCDebug(logging()) << " OsType" << m_config.osType; qCDebug(logging()) << " OsType" << m_config.osType;
qCDebug(logging()) << " LinkQmlDebuggingQQ2" qCDebug(logging()) << " LinkQmlDebuggingQQ2"
<< (m_config.linkQmlDebuggingQQ2 == BaseTriStateAspect::Value::Enabled); << (m_config.linkQmlDebuggingQQ2 == TriState::Enabled);
qCDebug(logging()) << " Qt Quick Compiler" qCDebug(logging()) << " Qt Quick Compiler"
<< (m_config.useQtQuickCompiler == BaseTriStateAspect::Value::Enabled); << (m_config.useQtQuickCompiler == TriState::Enabled);
qCDebug(logging()) << " Separate Debug Info" qCDebug(logging()) << " Separate Debug Info"
<< (m_config.separateDebugInfo == BaseTriStateAspect::Value::Enabled); << (m_config.separateDebugInfo == TriState::Enabled);
// Create command line of all unfiltered arguments // Create command line of all unfiltered arguments
foreach (const QMakeAssignment &qa, assignments) foreach (const QMakeAssignment &qa, assignments)
@@ -525,8 +525,8 @@ void QmakeProjectManagerPlugin::testMakefileParser()
const QMakeStepConfig qmsc = parser.config(); const QMakeStepConfig qmsc = parser.config();
QCOMPARE(qmsc.archConfig, static_cast<QMakeStepConfig::TargetArchConfig>(archConfig)); QCOMPARE(qmsc.archConfig, static_cast<QMakeStepConfig::TargetArchConfig>(archConfig));
QCOMPARE(qmsc.osType, static_cast<QMakeStepConfig::OsType>(osType)); QCOMPARE(qmsc.osType, static_cast<QMakeStepConfig::OsType>(osType));
QCOMPARE(qmsc.linkQmlDebuggingQQ2 == BaseTriStateAspect::Value::Enabled, linkQmlDebuggingQQ2); QCOMPARE(qmsc.linkQmlDebuggingQQ2 == TriState::Enabled, linkQmlDebuggingQQ2);
QCOMPARE(qmsc.useQtQuickCompiler == BaseTriStateAspect::Value::Enabled, useQtQuickCompiler); QCOMPARE(qmsc.useQtQuickCompiler == TriState::Enabled, useQtQuickCompiler);
QCOMPARE(qmsc.separateDebugInfo == BaseTriStateAspect::Value::Enabled, separateDebugInfo); QCOMPARE(qmsc.separateDebugInfo == TriState::Enabled, separateDebugInfo);
} }
#endif #endif

View File

@@ -179,16 +179,15 @@ void QmakeBuildConfiguration::initialize()
QString additionalArguments = qmakeExtra.additionalArguments; QString additionalArguments = qmakeExtra.additionalArguments;
if (!additionalArguments.isEmpty()) if (!additionalArguments.isEmpty())
qmakeStep->setUserArguments(additionalArguments); qmakeStep->setUserArguments(additionalArguments);
if (qmakeExtra.config.separateDebugInfo == SeparateDebugInfoAspect::Value::Enabled)
if (qmakeExtra.config.separateDebugInfo == TriState::Enabled)
forceSeparateDebugInfo(true); forceSeparateDebugInfo(true);
if (qmakeExtra.config.linkQmlDebuggingQQ2 != QmlDebuggingAspect::Value::Default) {
forceQmlDebugging(qmakeExtra.config.linkQmlDebuggingQQ2 if (qmakeExtra.config.linkQmlDebuggingQQ2 != TriState::Default)
== QmlDebuggingAspect::Value::Enabled); forceQmlDebugging(qmakeExtra.config.linkQmlDebuggingQQ2 == TriState::Enabled);
}
if (qmakeExtra.config.useQtQuickCompiler != QtQuickCompilerAspect::Value::Default) { if (qmakeExtra.config.useQtQuickCompiler != TriState::Default)
forceQtQuickCompiler(qmakeExtra.config.useQtQuickCompiler forceQtQuickCompiler(qmakeExtra.config.useQtQuickCompiler == TriState::Enabled);
== QtQuickCompilerAspect::Value::Enabled);
}
setQMakeBuildConfiguration(config); setQMakeBuildConfiguration(config);
@@ -418,7 +417,7 @@ bool QmakeBuildConfiguration::isBuildDirAtSafeLocation() const
buildDirectory().toString()); buildDirectory().toString());
} }
SeparateDebugInfoAspect::Value QmakeBuildConfiguration::separateDebugInfo() const TriState QmakeBuildConfiguration::separateDebugInfo() const
{ {
return aspect<SeparateDebugInfoAspect>()->setting(); return aspect<SeparateDebugInfoAspect>()->setting();
} }
@@ -426,37 +425,33 @@ SeparateDebugInfoAspect::Value QmakeBuildConfiguration::separateDebugInfo() cons
void QmakeBuildConfiguration::forceSeparateDebugInfo(bool sepDebugInfo) void QmakeBuildConfiguration::forceSeparateDebugInfo(bool sepDebugInfo)
{ {
aspect<SeparateDebugInfoAspect>()->setSetting(sepDebugInfo aspect<SeparateDebugInfoAspect>()->setSetting(sepDebugInfo
? SeparateDebugInfoAspect::Value::Enabled ? TriState::Enabled
: SeparateDebugInfoAspect::Value::Disabled); : TriState::Disabled);
} }
BaseTriStateAspect::Value QmakeBuildConfiguration::qmlDebugging() const TriState QmakeBuildConfiguration::qmlDebugging() const
{ {
return aspect<QmlDebuggingAspect>()->setting(); return aspect<QmlDebuggingAspect>()->setting();
} }
bool QmakeBuildConfiguration::linkQmlDebuggingLibrary() const bool QmakeBuildConfiguration::linkQmlDebuggingLibrary() const
{ {
return qmlDebugging() == QmlDebuggingAspect::Value::Enabled; return qmlDebugging() == TriState::Enabled;
} }
void QmakeBuildConfiguration::forceQmlDebugging(bool enable) void QmakeBuildConfiguration::forceQmlDebugging(bool enable)
{ {
aspect<QmlDebuggingAspect>()->setSetting(enable aspect<QmlDebuggingAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
? QmlDebuggingAspect::Value::Enabled
: QmlDebuggingAspect::Value::Disabled);
} }
BaseTriStateAspect::Value QmakeBuildConfiguration::useQtQuickCompiler() const TriState QmakeBuildConfiguration::useQtQuickCompiler() const
{ {
return aspect<QtQuickCompilerAspect>()->setting(); return aspect<QtQuickCompilerAspect>()->setting();
} }
void QmakeBuildConfiguration::forceQtQuickCompiler(bool enable) void QmakeBuildConfiguration::forceQtQuickCompiler(bool enable)
{ {
aspect<QtQuickCompilerAspect>()->setSetting(enable aspect<QtQuickCompilerAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
? QtQuickCompilerAspect::Value::Enabled
: QtQuickCompilerAspect::Value::Disabled);
} }
QStringList QmakeBuildConfiguration::configCommandLineArguments() const QStringList QmakeBuildConfiguration::configCommandLineArguments() const
@@ -743,7 +738,7 @@ BuildInfo QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
//: Non-ASCII characters in directory suffix may cause build issues. //: Non-ASCII characters in directory suffix may cause build issues.
suffix = tr("Release", "Shadow build directory suffix"); suffix = tr("Release", "Shadow build directory suffix");
if (version && version->isQtQuickCompilerSupported()) if (version && version->isQtQuickCompilerSupported())
extraInfo.config.useQtQuickCompiler = QtQuickCompilerAspect::Value::Enabled; extraInfo.config.useQtQuickCompiler = TriState::Enabled;
} else { } else {
if (type == BuildConfiguration::Debug) { if (type == BuildConfiguration::Debug) {
//: The name of the debug build configuration created by default for a qmake project. //: The name of the debug build configuration created by default for a qmake project.
@@ -755,12 +750,12 @@ BuildInfo QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
info.displayName = tr("Profile"); info.displayName = tr("Profile");
//: Non-ASCII characters in directory suffix may cause build issues. //: Non-ASCII characters in directory suffix may cause build issues.
suffix = tr("Profile", "Shadow build directory suffix"); suffix = tr("Profile", "Shadow build directory suffix");
extraInfo.config.separateDebugInfo = SeparateDebugInfoAspect::Value::Enabled; extraInfo.config.separateDebugInfo = TriState::Enabled;
if (version && version->isQtQuickCompilerSupported()) if (version && version->isQtQuickCompilerSupported())
extraInfo.config.useQtQuickCompiler = QtQuickCompilerAspect::Value::Enabled; extraInfo.config.useQtQuickCompiler = TriState::Enabled;
} }
if (version && version->isQmlDebuggingSupported()) if (version && version->isQmlDebuggingSupported())
extraInfo.config.linkQmlDebuggingQQ2 = QmlDebuggingAspect::Value::Enabled; extraInfo.config.linkQmlDebuggingQQ2 = TriState::Enabled;
} }
info.typeName = info.displayName; info.typeName = info.displayName;
// Leave info.buildDirectory unset; // Leave info.buildDirectory unset;
@@ -820,7 +815,7 @@ BuildConfiguration::BuildType QmakeBuildConfiguration::buildType() const
{ {
if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild) if (qmakeBuildConfiguration() & BaseQtVersion::DebugBuild)
return Debug; return Debug;
if (separateDebugInfo() == SeparateDebugInfoAspect::Value::Enabled) if (separateDebugInfo() == TriState::Enabled)
return Profile; return Profile;
return Release; return Release;
} }

View File

@@ -99,14 +99,14 @@ public:
static bool isBuildDirAtSafeLocation(const QString &sourceDir, const QString &buildDir); static bool isBuildDirAtSafeLocation(const QString &sourceDir, const QString &buildDir);
bool isBuildDirAtSafeLocation() const; bool isBuildDirAtSafeLocation() const;
ProjectExplorer::BaseTriStateAspect::Value separateDebugInfo() const; ProjectExplorer::TriState separateDebugInfo() const;
void forceSeparateDebugInfo(bool sepDebugInfo); void forceSeparateDebugInfo(bool sepDebugInfo);
ProjectExplorer::BaseTriStateAspect::Value qmlDebugging() const; ProjectExplorer::TriState qmlDebugging() const;
bool linkQmlDebuggingLibrary() const; bool linkQmlDebuggingLibrary() const;
void forceQmlDebugging(bool enable); void forceQmlDebugging(bool enable);
ProjectExplorer::BaseTriStateAspect::Value useQtQuickCompiler() const; ProjectExplorer::TriState useQtQuickCompiler() const;
void forceQtQuickCompiler(bool enable); void forceQtQuickCompiler(bool enable);
signals: signals:

View File

@@ -837,19 +837,19 @@ QStringList QMakeStepConfig::toArguments() const
else if (osType == IphoneOS) else if (osType == IphoneOS)
arguments << "CONFIG+=iphoneos" << "CONFIG+=device" /*since Qt 5.7*/; arguments << "CONFIG+=iphoneos" << "CONFIG+=device" /*since Qt 5.7*/;
if (linkQmlDebuggingQQ2 == BaseTriStateAspect::Value::Enabled) if (linkQmlDebuggingQQ2 == TriState::Enabled)
arguments << "CONFIG+=qml_debug"; arguments << "CONFIG+=qml_debug";
else if (linkQmlDebuggingQQ2 == BaseTriStateAspect::Value::Disabled) else if (linkQmlDebuggingQQ2 == TriState::Disabled)
arguments << "CONFIG-=qml_debug"; arguments << "CONFIG-=qml_debug";
if (useQtQuickCompiler == BaseTriStateAspect::Value::Enabled) if (useQtQuickCompiler == TriState::Enabled)
arguments << "CONFIG+=qtquickcompiler"; arguments << "CONFIG+=qtquickcompiler";
else if (useQtQuickCompiler == BaseTriStateAspect::Value::Disabled) else if (useQtQuickCompiler == TriState::Disabled)
arguments << "CONFIG-=qtquickcompiler"; arguments << "CONFIG-=qtquickcompiler";
if (separateDebugInfo == BaseTriStateAspect::Value::Enabled) if (separateDebugInfo == TriState::Enabled)
arguments << "CONFIG+=force_debug_info" << "CONFIG+=separate_debug_info"; arguments << "CONFIG+=force_debug_info" << "CONFIG+=separate_debug_info";
else if (separateDebugInfo == BaseTriStateAspect::Value::Disabled) else if (separateDebugInfo == TriState::Disabled)
arguments << "CONFIG-=separate_debug_info"; arguments << "CONFIG-=separate_debug_info";
if (!sysRoot.isEmpty()) { if (!sysRoot.isEmpty()) {

View File

@@ -84,12 +84,9 @@ public:
QString targetTriple; QString targetTriple;
TargetArchConfig archConfig = NoArch; TargetArchConfig archConfig = NoArch;
OsType osType = NoOsType; OsType osType = NoOsType;
ProjectExplorer::BaseTriStateAspect::Value separateDebugInfo ProjectExplorer::TriState separateDebugInfo;
= ProjectExplorer::BaseTriStateAspect::Value::Default; ProjectExplorer::TriState linkQmlDebuggingQQ2;
ProjectExplorer::BaseTriStateAspect::Value linkQmlDebuggingQQ2 ProjectExplorer::TriState useQtQuickCompiler;
= ProjectExplorer::BaseTriStateAspect::Value::Default;
ProjectExplorer::BaseTriStateAspect::Value useQtQuickCompiler
= ProjectExplorer::BaseTriStateAspect::Value::Default;
}; };
@@ -107,9 +104,9 @@ inline bool operator !=(const QMakeStepConfig &a, const QMakeStepConfig &b) {
inline QDebug operator<<(QDebug dbg, const QMakeStepConfig &c) inline QDebug operator<<(QDebug dbg, const QMakeStepConfig &c)
{ {
dbg << c.archConfig << c.osType dbg << c.archConfig << c.osType
<< (c.linkQmlDebuggingQQ2 == ProjectExplorer::BaseTriStateAspect::Value::Enabled) << (c.linkQmlDebuggingQQ2 == ProjectExplorer::TriState::Enabled)
<< (c.useQtQuickCompiler == ProjectExplorer::BaseTriStateAspect::Value::Enabled) << (c.useQtQuickCompiler == ProjectExplorer::TriState::Enabled)
<< (c.separateDebugInfo == ProjectExplorer::BaseTriStateAspect::Value::Enabled); << (c.separateDebugInfo == ProjectExplorer::TriState::Enabled);
return dbg; return dbg;
} }

View File

@@ -60,8 +60,8 @@ void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
QString warningText; QString warningText;
const bool supported = m_kit && BaseQtVersion::isQmlDebuggingSupported(m_kit, &warningText); const bool supported = m_kit && BaseQtVersion::isQmlDebuggingSupported(m_kit, &warningText);
if (!supported) { if (!supported) {
setSetting(Value::Default); setSetting(TriState::Default);
} else if (setting() == Value::Enabled) { } else if (setting() == TriState::Enabled) {
warningText = tr("Might make your application vulnerable.<br/>" warningText = tr("Might make your application vulnerable.<br/>"
"Only use in a safe environment."); "Only use in a safe environment.");
} }
@@ -97,9 +97,9 @@ void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
const bool supported = m_kit const bool supported = m_kit
&& BaseQtVersion::isQtQuickCompilerSupported(m_kit, &warningText); && BaseQtVersion::isQtQuickCompilerSupported(m_kit, &warningText);
if (!supported) if (!supported)
setSetting(Value::Default); setSetting(TriState::Default);
if (setting() == Value::Enabled if (setting() == TriState::Enabled
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->setting() == Value::Enabled) { && m_qmlDebuggingAspect && m_qmlDebuggingAspect->setting() == TriState::Enabled) {
warningText = tr("Disables QML debugging. QML profiling will still work."); warningText = tr("Disables QML debugging. QML profiling will still work.");
} }
warningTextLabel->setText(warningText); warningTextLabel->setText(warningText);