forked from qt-creator/qt-creator
Utils: Use value/setValue instead of settings also for TriStateAspects
Change-Id: I3d0a58917cd6682e14894e4320d166a1c8de6a9a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -1361,21 +1361,26 @@ TriStateAspect::TriStateAspect(const QString onString, const QString &offString,
|
|||||||
const QString &defaultString)
|
const QString &defaultString)
|
||||||
{
|
{
|
||||||
setDisplayStyle(DisplayStyle::ComboBox);
|
setDisplayStyle(DisplayStyle::ComboBox);
|
||||||
setSetting(TriState::Default);
|
setValue(TriState::Default);
|
||||||
setDefaultValue(2);
|
setDefaultValue(TriState::Default);
|
||||||
addOption(onString);
|
addOption(onString);
|
||||||
addOption(offString);
|
addOption(offString);
|
||||||
addOption(defaultString);
|
addOption(defaultString);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState TriStateAspect::setting() const
|
TriState TriStateAspect::value() const
|
||||||
{
|
{
|
||||||
return TriState::fromVariant(value());
|
return TriState::fromVariant(BaseAspect::value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriStateAspect::setSetting(TriState setting)
|
void TriStateAspect::setValue(TriState value)
|
||||||
{
|
{
|
||||||
setValue(setting.toVariant().toInt());
|
BaseAspect::setValue(value.toVariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriStateAspect::setDefaultValue(TriState value)
|
||||||
|
{
|
||||||
|
BaseAspect::setDefaultValue(value.toVariant());
|
||||||
}
|
}
|
||||||
|
|
||||||
const TriState TriState::Enabled{TriState::EnabledValue};
|
const TriState TriState::Enabled{TriState::EnabledValue};
|
||||||
|
@@ -365,8 +365,9 @@ public:
|
|||||||
const QString &offString = tr("Disable"),
|
const QString &offString = tr("Disable"),
|
||||||
const QString &defaultString = tr("Leave at Default"));
|
const QString &defaultString = tr("Leave at Default"));
|
||||||
|
|
||||||
TriState setting() const;
|
TriState value() const;
|
||||||
void setSetting(TriState setting);
|
void setValue(TriState setting);
|
||||||
|
void setDefaultValue(TriState setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT StringListAspect : public BaseAspect
|
class QTCREATOR_UTILS_EXPORT StringListAspect : public BaseAspect
|
||||||
|
@@ -503,10 +503,10 @@ void CMakeBuildSettingsWidget::updateFromKit()
|
|||||||
CMakeConfig CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
|
CMakeConfig CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
|
||||||
{
|
{
|
||||||
const auto aspect = m_buildConfiguration->aspect<QtSupport::QmlDebuggingAspect>();
|
const auto aspect = m_buildConfiguration->aspect<QtSupport::QmlDebuggingAspect>();
|
||||||
const TriState qmlDebuggingState = aspect->setting();
|
const TriState qmlDebuggingState = aspect->value();
|
||||||
if (qmlDebuggingState == TriState::Default) // don't touch anything
|
if (qmlDebuggingState == TriState::Default) // don't touch anything
|
||||||
return {};
|
return {};
|
||||||
const bool enable = aspect->setting() == TriState::Enabled;
|
const bool enable = aspect->value() == TriState::Enabled;
|
||||||
|
|
||||||
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
||||||
const QByteArrayList cxxFlags{"CMAKE_CXX_FLAGS", "CMAKE_CXX_FLAGS_DEBUG",
|
const QByteArrayList cxxFlags{"CMAKE_CXX_FLAGS", "CMAKE_CXX_FLAGS_DEBUG",
|
||||||
|
@@ -249,7 +249,7 @@ bool DebuggerRunConfigurationAspect::useQmlDebugger() const
|
|||||||
// Try to find a build configuration to check whether qml debugging is enabled there
|
// Try to find a build configuration to check whether qml debugging is enabled there
|
||||||
if (BuildConfiguration *bc = m_target->activeBuildConfiguration()) {
|
if (BuildConfiguration *bc = m_target->activeBuildConfiguration()) {
|
||||||
const auto aspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
|
const auto aspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
|
||||||
return aspect && aspect->setting() == TriState::Enabled;
|
return aspect && aspect->value() == TriState::Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !languages.contains(ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
return !languages.contains(ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
|
@@ -136,7 +136,7 @@ SeparateDebugInfoAspect::SeparateDebugInfoAspect()
|
|||||||
{
|
{
|
||||||
setDisplayName(tr("Separate debug info:"));
|
setDisplayName(tr("Separate debug info:"));
|
||||||
setSettingsKey("SeparateDebugInfo");
|
setSettingsKey("SeparateDebugInfo");
|
||||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().separateDebugInfo);
|
setValue(ProjectExplorerPlugin::buildPropertiesSettings().separateDebugInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -317,17 +317,17 @@ QString QbsBuildConfiguration::equivalentCommandLine(const QbsBuildStepData &ste
|
|||||||
|
|
||||||
TriState QbsBuildConfiguration::qmlDebuggingSetting() const
|
TriState QbsBuildConfiguration::qmlDebuggingSetting() const
|
||||||
{
|
{
|
||||||
return aspect<QtSupport::QmlDebuggingAspect>()->setting();
|
return aspect<QtSupport::QmlDebuggingAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState QbsBuildConfiguration::qtQuickCompilerSetting() const
|
TriState QbsBuildConfiguration::qtQuickCompilerSetting() const
|
||||||
{
|
{
|
||||||
return aspect<QtSupport::QtQuickCompilerAspect>()->setting();
|
return aspect<QtSupport::QtQuickCompilerAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState QbsBuildConfiguration::separateDebugInfoSetting() const
|
TriState QbsBuildConfiguration::separateDebugInfoSetting() const
|
||||||
{
|
{
|
||||||
return aspect<SeparateDebugInfoAspect>()->setting();
|
return aspect<SeparateDebugInfoAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@@ -143,9 +143,9 @@ QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, Utils::Id id)
|
|||||||
if (!additionalArguments.isEmpty())
|
if (!additionalArguments.isEmpty())
|
||||||
qmakeStep->setUserArguments(additionalArguments);
|
qmakeStep->setUserArguments(additionalArguments);
|
||||||
|
|
||||||
aspect<SeparateDebugInfoAspect>()->setSetting(qmakeExtra.config.separateDebugInfo);
|
aspect<SeparateDebugInfoAspect>()->setValue(qmakeExtra.config.separateDebugInfo);
|
||||||
aspect<QmlDebuggingAspect>()->setSetting(qmakeExtra.config.linkQmlDebuggingQQ2);
|
aspect<QmlDebuggingAspect>()->setValue(qmakeExtra.config.linkQmlDebuggingQQ2);
|
||||||
aspect<QtQuickCompilerAspect>()->setSetting(qmakeExtra.config.useQtQuickCompiler);
|
aspect<QtQuickCompilerAspect>()->setValue(qmakeExtra.config.useQtQuickCompiler);
|
||||||
|
|
||||||
setQMakeBuildConfiguration(config);
|
setQMakeBuildConfiguration(config);
|
||||||
|
|
||||||
@@ -422,44 +422,43 @@ bool QmakeBuildConfiguration::isBuildDirAtSafeLocation() const
|
|||||||
|
|
||||||
TriState QmakeBuildConfiguration::separateDebugInfo() const
|
TriState QmakeBuildConfiguration::separateDebugInfo() const
|
||||||
{
|
{
|
||||||
return aspect<SeparateDebugInfoAspect>()->setting();
|
return aspect<SeparateDebugInfoAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeBuildConfiguration::forceSeparateDebugInfo(bool sepDebugInfo)
|
void QmakeBuildConfiguration::forceSeparateDebugInfo(bool sepDebugInfo)
|
||||||
{
|
{
|
||||||
aspect<SeparateDebugInfoAspect>()->setSetting(sepDebugInfo
|
aspect<SeparateDebugInfoAspect>()->setValue(sepDebugInfo
|
||||||
? TriState::Enabled
|
? TriState::Enabled
|
||||||
: TriState::Disabled);
|
: TriState::Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState QmakeBuildConfiguration::qmlDebugging() const
|
TriState QmakeBuildConfiguration::qmlDebugging() const
|
||||||
{
|
{
|
||||||
return aspect<QmlDebuggingAspect>()->setting();
|
return aspect<QmlDebuggingAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeBuildConfiguration::forceQmlDebugging(bool enable)
|
void QmakeBuildConfiguration::forceQmlDebugging(bool enable)
|
||||||
{
|
{
|
||||||
aspect<QmlDebuggingAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
|
aspect<QmlDebuggingAspect>()->setValue(enable ? TriState::Enabled : TriState::Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriState QmakeBuildConfiguration::useQtQuickCompiler() const
|
TriState QmakeBuildConfiguration::useQtQuickCompiler() const
|
||||||
{
|
{
|
||||||
return aspect<QtQuickCompilerAspect>()->setting();
|
return aspect<QtQuickCompilerAspect>()->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeBuildConfiguration::forceQtQuickCompiler(bool enable)
|
void QmakeBuildConfiguration::forceQtQuickCompiler(bool enable)
|
||||||
{
|
{
|
||||||
aspect<QtQuickCompilerAspect>()->setSetting(enable ? TriState::Enabled : TriState::Disabled);
|
aspect<QtQuickCompilerAspect>()->setValue(enable ? TriState::Enabled : TriState::Disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeBuildConfiguration::runSystemFunction() const
|
bool QmakeBuildConfiguration::runSystemFunction() const
|
||||||
{
|
{
|
||||||
switch (aspect<RunSystemAspect>()->value()) {
|
const TriState runSystem = aspect<RunSystemAspect>()->value();
|
||||||
case 0:
|
if (runSystem == TriState::Enabled)
|
||||||
return true;
|
return true;
|
||||||
case 1:
|
if (runSystem == TriState::Disabled)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return QmakeSettings::runSystemFunction();
|
return QmakeSettings::runSystemFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@ QmlDebuggingAspect::QmlDebuggingAspect()
|
|||||||
{
|
{
|
||||||
setSettingsKey("EnableQmlDebugging");
|
setSettingsKey("EnableQmlDebugging");
|
||||||
setDisplayName(tr("QML debugging and profiling:"));
|
setDisplayName(tr("QML debugging and profiling:"));
|
||||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().qmlDebugging);
|
setValue(ProjectExplorerPlugin::buildPropertiesSettings().qmlDebugging);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
|
void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
|
||||||
@@ -59,8 +59,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(TriState::Default);
|
setValue(TriState::Default);
|
||||||
} else if (setting() == TriState::Enabled) {
|
} else if (value() == 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.");
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ QtQuickCompilerAspect::QtQuickCompilerAspect()
|
|||||||
{
|
{
|
||||||
setSettingsKey("QtQuickCompiler");
|
setSettingsKey("QtQuickCompiler");
|
||||||
setDisplayName(tr("Qt Quick Compiler:"));
|
setDisplayName(tr("Qt Quick Compiler:"));
|
||||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().qtQuickCompiler);
|
setValue(ProjectExplorerPlugin::buildPropertiesSettings().qtQuickCompiler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
|
void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
|
||||||
@@ -92,9 +92,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(TriState::Default);
|
setValue(TriState::Default);
|
||||||
if (setting() == TriState::Enabled
|
if (value() == TriState::Enabled
|
||||||
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->setting() == TriState::Enabled) {
|
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->value() == TriState::Enabled) {
|
||||||
warningText = tr("Disables QML debugging. QML profiling will still work.");
|
warningText = tr("Disables QML debugging. QML profiling will still work.");
|
||||||
}
|
}
|
||||||
warningLabel->setText(warningText);
|
warningLabel->setText(warningText);
|
||||||
|
Reference in New Issue
Block a user