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)
|
||||
{
|
||||
setDisplayStyle(DisplayStyle::ComboBox);
|
||||
setSetting(TriState::Default);
|
||||
setDefaultValue(2);
|
||||
setValue(TriState::Default);
|
||||
setDefaultValue(TriState::Default);
|
||||
addOption(onString);
|
||||
addOption(offString);
|
||||
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};
|
||||
|
@@ -365,8 +365,9 @@ public:
|
||||
const QString &offString = tr("Disable"),
|
||||
const QString &defaultString = tr("Leave at Default"));
|
||||
|
||||
TriState setting() const;
|
||||
void setSetting(TriState setting);
|
||||
TriState value() const;
|
||||
void setValue(TriState setting);
|
||||
void setDefaultValue(TriState setting);
|
||||
};
|
||||
|
||||
class QTCREATOR_UTILS_EXPORT StringListAspect : public BaseAspect
|
||||
|
@@ -503,10 +503,10 @@ void CMakeBuildSettingsWidget::updateFromKit()
|
||||
CMakeConfig CMakeBuildSettingsWidget::getQmlDebugCxxFlags()
|
||||
{
|
||||
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
|
||||
return {};
|
||||
const bool enable = aspect->setting() == TriState::Enabled;
|
||||
const bool enable = aspect->value() == TriState::Enabled;
|
||||
|
||||
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
||||
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
|
||||
if (BuildConfiguration *bc = m_target->activeBuildConfiguration()) {
|
||||
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);
|
||||
|
@@ -136,7 +136,7 @@ SeparateDebugInfoAspect::SeparateDebugInfoAspect()
|
||||
{
|
||||
setDisplayName(tr("Separate debug info:"));
|
||||
setSettingsKey("SeparateDebugInfo");
|
||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().separateDebugInfo);
|
||||
setValue(ProjectExplorerPlugin::buildPropertiesSettings().separateDebugInfo);
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -317,17 +317,17 @@ QString QbsBuildConfiguration::equivalentCommandLine(const QbsBuildStepData &ste
|
||||
|
||||
TriState QbsBuildConfiguration::qmlDebuggingSetting() const
|
||||
{
|
||||
return aspect<QtSupport::QmlDebuggingAspect>()->setting();
|
||||
return aspect<QtSupport::QmlDebuggingAspect>()->value();
|
||||
}
|
||||
|
||||
TriState QbsBuildConfiguration::qtQuickCompilerSetting() const
|
||||
{
|
||||
return aspect<QtSupport::QtQuickCompilerAspect>()->setting();
|
||||
return aspect<QtSupport::QtQuickCompilerAspect>()->value();
|
||||
}
|
||||
|
||||
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())
|
||||
qmakeStep->setUserArguments(additionalArguments);
|
||||
|
||||
aspect<SeparateDebugInfoAspect>()->setSetting(qmakeExtra.config.separateDebugInfo);
|
||||
aspect<QmlDebuggingAspect>()->setSetting(qmakeExtra.config.linkQmlDebuggingQQ2);
|
||||
aspect<QtQuickCompilerAspect>()->setSetting(qmakeExtra.config.useQtQuickCompiler);
|
||||
aspect<SeparateDebugInfoAspect>()->setValue(qmakeExtra.config.separateDebugInfo);
|
||||
aspect<QmlDebuggingAspect>()->setValue(qmakeExtra.config.linkQmlDebuggingQQ2);
|
||||
aspect<QtQuickCompilerAspect>()->setValue(qmakeExtra.config.useQtQuickCompiler);
|
||||
|
||||
setQMakeBuildConfiguration(config);
|
||||
|
||||
@@ -422,44 +422,43 @@ bool QmakeBuildConfiguration::isBuildDirAtSafeLocation() const
|
||||
|
||||
TriState QmakeBuildConfiguration::separateDebugInfo() const
|
||||
{
|
||||
return aspect<SeparateDebugInfoAspect>()->setting();
|
||||
return aspect<SeparateDebugInfoAspect>()->value();
|
||||
}
|
||||
|
||||
void QmakeBuildConfiguration::forceSeparateDebugInfo(bool sepDebugInfo)
|
||||
{
|
||||
aspect<SeparateDebugInfoAspect>()->setSetting(sepDebugInfo
|
||||
? TriState::Enabled
|
||||
: TriState::Disabled);
|
||||
aspect<SeparateDebugInfoAspect>()->setValue(sepDebugInfo
|
||||
? TriState::Enabled
|
||||
: TriState::Disabled);
|
||||
}
|
||||
|
||||
TriState QmakeBuildConfiguration::qmlDebugging() const
|
||||
{
|
||||
return aspect<QmlDebuggingAspect>()->setting();
|
||||
return aspect<QmlDebuggingAspect>()->value();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return aspect<QtQuickCompilerAspect>()->setting();
|
||||
return aspect<QtQuickCompilerAspect>()->value();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
switch (aspect<RunSystemAspect>()->value()) {
|
||||
case 0:
|
||||
const TriState runSystem = aspect<RunSystemAspect>()->value();
|
||||
if (runSystem == TriState::Enabled)
|
||||
return true;
|
||||
case 1:
|
||||
if (runSystem == TriState::Disabled)
|
||||
return false;
|
||||
}
|
||||
return QmakeSettings::runSystemFunction();
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ QmlDebuggingAspect::QmlDebuggingAspect()
|
||||
{
|
||||
setSettingsKey("EnableQmlDebugging");
|
||||
setDisplayName(tr("QML debugging and profiling:"));
|
||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().qmlDebugging);
|
||||
setValue(ProjectExplorerPlugin::buildPropertiesSettings().qmlDebugging);
|
||||
}
|
||||
|
||||
void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
|
||||
@@ -59,8 +59,8 @@ void QmlDebuggingAspect::addToLayout(LayoutBuilder &builder)
|
||||
QString warningText;
|
||||
const bool supported = m_kit && BaseQtVersion::isQmlDebuggingSupported(m_kit, &warningText);
|
||||
if (!supported) {
|
||||
setSetting(TriState::Default);
|
||||
} else if (setting() == TriState::Enabled) {
|
||||
setValue(TriState::Default);
|
||||
} else if (value() == TriState::Enabled) {
|
||||
warningText = tr("Might make your application vulnerable.<br/>"
|
||||
"Only use in a safe environment.");
|
||||
}
|
||||
@@ -78,7 +78,7 @@ QtQuickCompilerAspect::QtQuickCompilerAspect()
|
||||
{
|
||||
setSettingsKey("QtQuickCompiler");
|
||||
setDisplayName(tr("Qt Quick Compiler:"));
|
||||
setSetting(ProjectExplorerPlugin::buildPropertiesSettings().qtQuickCompiler);
|
||||
setValue(ProjectExplorerPlugin::buildPropertiesSettings().qtQuickCompiler);
|
||||
}
|
||||
|
||||
void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
|
||||
@@ -92,9 +92,9 @@ void QtQuickCompilerAspect::addToLayout(LayoutBuilder &builder)
|
||||
const bool supported = m_kit
|
||||
&& BaseQtVersion::isQtQuickCompilerSupported(m_kit, &warningText);
|
||||
if (!supported)
|
||||
setSetting(TriState::Default);
|
||||
if (setting() == TriState::Enabled
|
||||
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->setting() == TriState::Enabled) {
|
||||
setValue(TriState::Default);
|
||||
if (value() == TriState::Enabled
|
||||
&& m_qmlDebuggingAspect && m_qmlDebuggingAspect->value() == TriState::Enabled) {
|
||||
warningText = tr("Disables QML debugging. QML profiling will still work.");
|
||||
}
|
||||
warningLabel->setText(warningText);
|
||||
|
Reference in New Issue
Block a user