diff options
author | hjk <[email protected]> | 2023-06-26 11:02:42 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2023-06-29 11:25:44 +0000 |
commit | 379e7f906e6f1dd8656364f5a2cf4feed2127d0f (patch) | |
tree | 05a457b51212749f5e0622cf79c93b88b8bb8966 /src/plugins | |
parent | 900ea82fd1a4a629768b71abaf9117f90b7fd951 (diff) |
Utils: Rework aspect implementation
This avoids some repetition and could be a step towards
having type storage in (or rather accessible from) the base,
so we can have aspects for more complex data (treemodels...)
that are not easily converted to QVariant.
Change-Id: I9797b3d5646195705212db1830d2b415291ac651
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins')
28 files changed, 120 insertions, 169 deletions
diff --git a/src/plugins/autotest/gtest/gtestsettings.cpp b/src/plugins/autotest/gtest/gtestsettings.cpp index 7fa1e534797..32afb9a4a6b 100644 --- a/src/plugins/autotest/gtest/gtestsettings.cpp +++ b/src/plugins/autotest/gtest/gtestsettings.cpp @@ -111,9 +111,9 @@ GTestSettings::GTestSettings(Id settingsId) return edit && GTestUtils::isValidGTestFilter(edit->text()); }); - QObject::connect(&groupMode, &SelectionAspect::volatileValueChanged, - >estFilter, [this](int val) { - gtestFilter.setEnabled(groupMode.itemValueForIndex(val) == GTest::Constants::GTestFilter); + QObject::connect(&groupMode, &SelectionAspect::volatileValueChanged, >estFilter, [this] { + gtestFilter.setEnabled(groupMode.itemValueForIndex(groupMode.volatileValue()) + == GTest::Constants::GTestFilter); }); QObject::connect(this, &AspectContainer::applied, this, [] { diff --git a/src/plugins/beautifier/clangformat/clangformatsettings.cpp b/src/plugins/beautifier/clangformat/clangformatsettings.cpp index 6a31667edb7..92e175ac5fb 100644 --- a/src/plugins/beautifier/clangformat/clangformatsettings.cpp +++ b/src/plugins/beautifier/clangformat/clangformatsettings.cpp @@ -246,7 +246,7 @@ public: configurations, predefinedStyleButton] { const bool predefSelected = styleButtonGroup->checkedButton() == predefinedStyleButton; predefinedBlob->setEnabled(predefSelected); - fallbackBlob->setEnabled(predefSelected && s.predefinedStyle.volatileValue().toInt() == 5); // File + fallbackBlob->setEnabled(predefSelected && s.predefinedStyle.volatileValue() == 5); // File configurations->setEnabled(!predefSelected); }; updateEnabled(); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 56701f1413b..aa175406848 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -2114,12 +2114,10 @@ QString CMakeBuildSystem::cmakeBuildType() const void CMakeBuildSystem::setCMakeBuildType(const QString &cmakeBuildType, bool quiet) { auto aspect = buildConfiguration()->aspect<BuildTypeAspect>(); - if (quiet) { + if (quiet) aspect->setValueQuietly(cmakeBuildType); - aspect->update(); - } else { + else aspect->setValue(cmakeBuildType); - } } namespace Internal { @@ -2179,7 +2177,7 @@ void InitialCMakeArgumentsAspect::setAllValues(const QString &values, QStringLis // Display the unknown arguments in "Additional CMake Options" const QString additionalOptionsValue = ProcessArgs::joinArgs(additionalOptions); - BaseAspect::setValueQuietly(additionalOptionsValue); + setValueQuietly(additionalOptionsValue); } void InitialCMakeArgumentsAspect::setCMakeConfiguration(const CMakeConfig &config) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h index ff166133988..6d709d58a2e 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h @@ -135,7 +135,6 @@ class BuildTypeAspect final : public Utils::StringAspect public: BuildTypeAspect(); - using Utils::StringAspect::update; }; class ConfigureEnvironmentAspect final: public ProjectExplorer::EnvironmentAspect diff --git a/src/plugins/copilot/copilotoptionspage.cpp b/src/plugins/copilot/copilotoptionspage.cpp index 1d9a516d662..61e6d085dc4 100644 --- a/src/plugins/copilot/copilotoptionspage.cpp +++ b/src/plugins/copilot/copilotoptionspage.cpp @@ -79,10 +79,8 @@ public: auto updateAuthWidget = [authWidget]() { authWidget->updateClient( - FilePath::fromUserInput( - CopilotSettings::instance().nodeJsPath.volatileValue().toString()), - FilePath::fromUserInput( - CopilotSettings::instance().distPath.volatileValue().toString())); + FilePath::fromUserInput(CopilotSettings::instance().nodeJsPath.volatileValue()), + FilePath::fromUserInput(CopilotSettings::instance().distPath.volatileValue())); }; connect(CopilotSettings::instance().nodeJsPath.pathChooser(), diff --git a/src/plugins/copilot/copilotplugin.cpp b/src/plugins/copilot/copilotplugin.cpp index 1a554e13977..48a4dc89e82 100644 --- a/src/plugins/copilot/copilotplugin.cpp +++ b/src/plugins/copilot/copilotplugin.cpp @@ -142,10 +142,8 @@ void CopilotPlugin::initialize() requestAction->setEnabled(enabled); }; - connect(&CopilotSettings::instance().enableCopilot, - &BoolAspect::valueChanged, - this, - updateActions); + connect(&CopilotSettings::instance().enableCopilot, &BaseAspect::changed, + this, updateActions); updateActions(); diff --git a/src/plugins/copilot/copilotsettings.cpp b/src/plugins/copilot/copilotsettings.cpp index 5bdd3a54c3f..ec4cf1f61dc 100644 --- a/src/plugins/copilot/copilotsettings.cpp +++ b/src/plugins/copilot/copilotsettings.cpp @@ -92,8 +92,8 @@ CopilotProjectSettings::CopilotProjectSettings(ProjectExplorer::Project *project QVariantMap map = project->namedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID).toMap(); fromMap(map); - connect(&enableCopilot, &BoolAspect::valueChanged, this, [this, project] { save(project); }); - connect(&useGlobalSettings, &BoolAspect::valueChanged, this, [this, project] { save(project); }); + connect(&enableCopilot, &BaseAspect::changed, this, [this, project] { save(project); }); + connect(&useGlobalSettings, &BaseAspect::changed, this, [this, project] { save(project); }); } void CopilotProjectSettings::setUseGlobalSettings(bool useGlobal) diff --git a/src/plugins/debugger/commonoptionspage.cpp b/src/plugins/debugger/commonoptionspage.cpp index 97e9442266e..a007e96f48f 100644 --- a/src/plugins/debugger/commonoptionspage.cpp +++ b/src/plugins/debugger/commonoptionspage.cpp @@ -32,7 +32,7 @@ public: setOnApply([&s] { const bool originalPostMortem = s.registerForPostMortem->value(); - const bool currentPostMortem = s.registerForPostMortem->volatileValue().toBool(); + const bool currentPostMortem = s.registerForPostMortem->volatileValue(); // explicitly trigger setValue() to override the setValueSilently() and trigger the registration if (originalPostMortem != currentPostMortem) s.registerForPostMortem->setValue(currentPostMortem); diff --git a/src/plugins/debugger/console/console.cpp b/src/plugins/debugger/console/console.cpp index b1c3767f0e9..57810ef62bf 100644 --- a/src/plugins/debugger/console/console.cpp +++ b/src/plugins/debugger/console/console.cpp @@ -87,8 +87,8 @@ Console::Console() m_showDebug.setToolTip(Tr::tr("Show debug, log, and info messages.")); m_showDebug.setValue(true); m_showDebug.action()->setIcon(Utils::Icons::INFO_TOOLBAR.icon()); - connect(&m_showDebug, &Utils::BoolAspect::valueChanged, - proxyModel, &ConsoleProxyModel::setShowLogs); + connect(&m_showDebug, &Utils::BoolAspect::changed, + proxyModel, [this, proxyModel] { proxyModel->setShowLogs(m_showDebug()); }); m_showDebugButton->setDefaultAction(m_showDebug.action()); m_showWarningButton = new QToolButton(m_consoleWidget); @@ -100,7 +100,7 @@ Console::Console() m_showWarning.setValue(true); m_showWarning.action()->setIcon(Utils::Icons::WARNING_TOOLBAR.icon()); connect(m_showWarning.action(), &QAction::toggled, - proxyModel, &ConsoleProxyModel::setShowWarnings); + proxyModel, [this, proxyModel] { proxyModel->setShowWarnings(m_showWarning()); }); m_showWarningButton->setDefaultAction(m_showWarning.action()); m_showErrorButton = new QToolButton(m_consoleWidget); @@ -112,7 +112,7 @@ Console::Console() m_showError.setValue(true); m_showError.action()->setIcon(Utils::Icons::CRITICAL_TOOLBAR.icon()); connect(m_showError.action(), &QAction::toggled, - proxyModel, &ConsoleProxyModel::setShowErrors); + proxyModel, [this, proxyModel] { proxyModel->setShowErrors(m_showError()); }); m_showErrorButton->setDefaultAction(m_showError.action()); m_spacer = new QWidget(m_consoleWidget); diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index f83c6935818..9997d3f58c9 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -490,8 +490,8 @@ QString DebuggerSettings::dump() const int pos = key.indexOf('/'); if (pos >= 0) key = key.mid(pos); - const QString current = aspect->value().toString(); - const QString default_ = aspect->defaultValue().toString(); + const QString current = aspect->variantValue().toString(); + const QString default_ = aspect->defaultVariantValue().toString(); QString setting = key + ": " + current + " (default: " + default_ + ')'; if (current != default_) setting += " ***"; diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 843947ab905..1a27beae330 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -21,7 +21,7 @@ class SourcePathMapAspectPrivate; // Syntax: (/home/.*)/KnownSubdir -> /home/my/project using SourcePathMap = QMap<QString, QString>; -class SourcePathMapAspect : public Utils::BaseAspect +class SourcePathMapAspect : public Utils::TypedAspect<SourcePathMap> { public: SourcePathMapAspect(); @@ -32,15 +32,13 @@ public: void addToLayout(Layouting::LayoutItem &parent) override; - QVariant volatileValue() const override; - void setVolatileValue(const QVariant &val) override; - void readSettings(const QSettings *settings) override; void writeSettings(QSettings *settings) const override; - SourcePathMap value() const; - private: + void guiToInternal() override; + void internalToGui() override; + SourcePathMapAspectPrivate *d = nullptr; }; diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp index 0c98ba174b0..ad9aeb87391 100644 --- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp +++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp @@ -470,29 +470,22 @@ void SourcePathMapAspect::addToLayout(Layouting::LayoutItem &parent) parent.addItem(d->m_widget.data()); } -QVariant SourcePathMapAspect::volatileValue() const +void SourcePathMapAspect::guiToInternal() { - QTC_CHECK(!isAutoApply()); - QTC_ASSERT(d->m_widget, return {}); - return QVariant::fromValue(d->m_widget->sourcePathMap()); + if (d->m_widget) + m_internal = d->m_widget->sourcePathMap(); } -void SourcePathMapAspect::setVolatileValue(const QVariant &val) +void SourcePathMapAspect::internalToGui() { - QTC_CHECK(!isAutoApply()); if (d->m_widget) - d->m_widget->setSourcePathMap(val.value<SourcePathMap>()); + d->m_widget->setSourcePathMap(m_internal); } const char sourcePathMappingArrayNameC[] = "SourcePathMappings"; const char sourcePathMappingSourceKeyC[] = "Source"; const char sourcePathMappingTargetKeyC[] = "Target"; -SourcePathMap SourcePathMapAspect::value() const -{ - return BaseAspect::value().value<SourcePathMap>(); -} - void SourcePathMapAspect::writeSettings(QSettings *s) const { const SourcePathMap sourcePathMap = value(); @@ -528,7 +521,7 @@ void SourcePathMapAspect::readSettings(const QSettings *settings) } } s->endArray(); - setValue(QVariant::fromValue(sourcePathMap)); + setValue(sourcePathMap); } } // Debugger::Internal diff --git a/src/plugins/debugger/registerpostmortemaction.cpp b/src/plugins/debugger/registerpostmortemaction.cpp index cc2f6fccf5d..4afd0989eed 100644 --- a/src/plugins/debugger/registerpostmortemaction.cpp +++ b/src/plugins/debugger/registerpostmortemaction.cpp @@ -46,7 +46,7 @@ void RegisterPostMortemAction::registerNow(bool value) RegisterPostMortemAction::RegisterPostMortemAction() { - connect(this, &BoolAspect::valueChanged, this, &RegisterPostMortemAction::registerNow); + connect(this, &BaseAspect::changed, this, [this] { registerNow(value()); }); } void RegisterPostMortemAction::readSettings(const QSettings *) diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp index 916fea16097..2d4b5420328 100644 --- a/src/plugins/fakevim/fakevimactions.cpp +++ b/src/plugins/fakevim/fakevimactions.cpp @@ -28,30 +28,6 @@ using namespace Utils; namespace FakeVim::Internal { #ifdef FAKEVIM_STANDALONE -FvBaseAspect::FvBaseAspect() -{ -} - -void FvBaseAspect::setValue(const QVariant &value) -{ - m_value = value; -} - -QVariant FvBaseAspect::value() const -{ - return m_value; -} - -void FvBaseAspect::setDefaultValue(const QVariant &value) -{ - m_defaultValue = value; - m_value = value; -} - -QVariant FvBaseAspect::defaultValue() const -{ - return m_defaultValue; -} void FvBaseAspect::setSettingsKey(const QString &group, const QString &key) { @@ -294,7 +270,7 @@ QString FakeVimSettings::trySetValue(const QString &name, const QString &value) return Tr::tr("Argument must be positive: %1=%2") .arg(name).arg(value); } - aspect->setValue(value); + aspect->setVariantValue(value); return QString(); } @@ -305,7 +281,7 @@ void FakeVimSettings::setup(FvBaseAspect *aspect, const QString &labelText) { aspect->setSettingsKey("FakeVim", settingsKey); - aspect->setDefaultValue(value); + aspect->setDefaultVariantValue(value); #ifndef FAKEVIM_STANDALONE aspect->setLabelText(labelText); aspect->setAutoApply(false); diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h index e3b14b0d47a..a3907dc117f 100644 --- a/src/plugins/fakevim/fakevimactions.h +++ b/src/plugins/fakevim/fakevimactions.h @@ -19,13 +19,14 @@ namespace FakeVim::Internal { class FvBaseAspect { public: - FvBaseAspect(); - virtual ~FvBaseAspect() {} + FvBaseAspect() = default; + virtual ~FvBaseAspect() = default; + + virtual void setVariantValue(const QVariant &value) = 0; + virtual void setDefaultVariantValue(const QVariant &value) = 0; + virtual QVariant variantValue() const = 0; + virtual QVariant defaultVariantValue() const = 0; - void setValue(const QVariant &value); - QVariant value() const; - void setDefaultValue(const QVariant &value); - QVariant defaultValue() const; void setSettingsKey(const QString &group, const QString &key); QString settingsKey() const; void setCheckable(bool) {} @@ -33,32 +34,41 @@ public: void setToolTip(const QString &) {} private: - QVariant m_value; - QVariant m_defaultValue; QString m_settingsGroup; QString m_settingsKey; }; -class FvBoolAspect : public FvBaseAspect -{ -public: - bool value() const { return FvBaseAspect::value().toBool(); } - bool operator()() const { return value(); } -}; - -class FvIntegerAspect : public FvBaseAspect +template <class ValueType> +class FvTypedAspect : public FvBaseAspect { public: - qint64 value() const { return FvBaseAspect::value().toLongLong(); } - qint64 operator()() const { return value(); } + void setVariantValue(const QVariant &value) override + { + m_value = value.value<ValueType>(); + } + void setDefaultVariantValue(const QVariant &value) override + { + m_defaultValue = value.value<ValueType>(); + } + QVariant variantValue() const override + { + return QVariant::fromValue<ValueType>(m_value); + } + QVariant defaultVariantValue() const override + { + return QVariant::fromValue<ValueType>(m_defaultValue); + } + + ValueType value() const { return m_value; } + ValueType operator()() const { return m_value; } + + ValueType m_value; + ValueType m_defaultValue; }; -class FvStringAspect : public FvBaseAspect -{ -public: - QString value() const { return FvBaseAspect::value().toString(); } - QString operator()() const { return value(); } -}; +using FvBoolAspect = FvTypedAspect<bool>; +using FvIntegerAspect = FvTypedAspect<qint64>; +using FvStringAspect = FvTypedAspect<QString>; class FvAspectContainer : public FvBaseAspect { diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index edfa315af98..bb3586b6329 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -6139,13 +6139,13 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) FvBaseAspect *act = s.item(optionName); if (!act) { showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args); - } else if (act->defaultValue().type() == QVariant::Bool) { - bool oldValue = act->value().toBool(); + } else if (act->defaultVariantValue().type() == QVariant::Bool) { + bool oldValue = act->variantValue().toBool(); if (printOption) { showMessage(MessageInfo, QLatin1String(oldValue ? "" : "no") + act->settingsKey().toLower()); } else if (toggleOption || negateOption == oldValue) { - act->setValue(!oldValue); + act->setVariantValue(!oldValue); } } else if (negateOption && !printOption) { showMessage(MessageError, Tr::tr("Invalid argument:") + ' ' + cmd.args); @@ -6153,7 +6153,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) showMessage(MessageError, Tr::tr("Trailing characters:") + ' ' + cmd.args); } else { showMessage(MessageInfo, act->settingsKey().toLower() + "=" - + act->value().toString()); + + act->variantValue().toString()); } } updateEditor(); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 5b51cb5f969..fb3049a7b06 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -1089,16 +1089,16 @@ void FakeVimPluginPrivate::initialize() this, &FakeVimPluginPrivate::documentRenamed); FakeVimSettings &s = settings(); - connect(&s.useFakeVim, &FvBoolAspect::valueChanged, - this, &FakeVimPluginPrivate::setUseFakeVim); + connect(&s.useFakeVim, &FvBoolAspect::changed, + this, [this, &s] { setUseFakeVim(s.useFakeVim()); }); connect(&s.readVimRc, &FvBaseAspect::changed, this, &FakeVimPluginPrivate::maybeReadVimRc); connect(&s.vimRcPath, &FvBaseAspect::changed, this, &FakeVimPluginPrivate::maybeReadVimRc); - connect(&s.relativeNumber, &FvBoolAspect::valueChanged, - this, &FakeVimPluginPrivate::setShowRelativeLineNumbers); - connect(&s.blinkingCursor, &FvBoolAspect::valueChanged, - this, &FakeVimPluginPrivate::setCursorBlinking); + connect(&s.relativeNumber, &FvBoolAspect::changed, + this, [this, &s] { setShowRelativeLineNumbers(s.relativeNumber()); }); + connect(&s.blinkingCursor, &FvBoolAspect::changed, + this, [this, &s] { setCursorBlinking(s.blinkingCursor()); }); // Delayed operations. connect(this, &FakeVimPluginPrivate::delayedQuitRequested, diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index c5f30fa036f..9ada18c1194 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -1466,9 +1466,8 @@ void GitPluginPrivate::setupInstantBlame() forceInstantBlame(); }; - connect(&settings().instantBlame, &BoolAspect::valueChanged, this, - [this, setupBlameForEditor](bool enabled) { - if (enabled) + connect(&settings().instantBlame, &BaseAspect::changed, this, [this, setupBlameForEditor] { + if (settings().instantBlame()) setupBlameForEditor(EditorManager::currentEditor()); else stopInstantBlame(); diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 4ebf7debeed..4ef786c5354 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -146,8 +146,8 @@ GitSettings::GitSettings() st }; }); - connect(&binaryPath, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); - connect(&path, &StringAspect::valueChanged, this, [this] { tryResolve = true; }); + connect(&binaryPath, &BaseAspect::changed, this, [this] { tryResolve = true; }); + connect(&path, &BaseAspect::changed, this, [this] { tryResolve = true; }); } FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const diff --git a/src/plugins/nim/nimplugin.cpp b/src/plugins/nim/nimplugin.cpp index b3ef6fc49f0..cdad3981ca9 100644 --- a/src/plugins/nim/nimplugin.cpp +++ b/src/plugins/nim/nimplugin.cpp @@ -42,9 +42,10 @@ public: NimPluginPrivate() { Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.value()); - QObject::connect(&settings.nimSuggestPath, &StringAspect::valueChanged, - &Suggest::NimSuggestCache::instance(), - &Suggest::NimSuggestCache::setExecutablePath); + QObject::connect(&settings.nimSuggestPath, &StringAspect::changed, + &Suggest::NimSuggestCache::instance(), [this] { + Suggest::NimSuggestCache::instance().setExecutablePath(settings.nimSuggestPath.value()); + }); } NimSettings settings; diff --git a/src/plugins/perforce/perforcesettings.cpp b/src/plugins/perforce/perforcesettings.cpp index 6dff959d5f6..42201b208a0 100644 --- a/src/plugins/perforce/perforcesettings.cpp +++ b/src/plugins/perforce/perforcesettings.cpp @@ -109,8 +109,7 @@ PerforceSettings::PerforceSettings() errorLabel->setType(InfoLabel::Information); errorLabel->setText(Tr::tr("Testing...")); - const FilePath p4Bin = FilePath::fromUserInput( - p4BinaryPath.volatileValue().toString()); + const FilePath p4Bin = FilePath::fromUserInput(p4BinaryPath.volatileValue()); checker->start(p4Bin, {}, commonP4Arguments_volatile(), 10000); }); @@ -166,14 +165,14 @@ QStringList PerforceSettings::commonP4Arguments() const QStringList PerforceSettings::commonP4Arguments_volatile() const { QStringList lst; - if (customEnv.volatileValue().toBool()) { - auto p4C = p4Client.volatileValue().toString(); + if (customEnv.volatileValue()) { + const QString p4C = p4Client.volatileValue(); if (!p4C.isEmpty()) lst << "-c" << p4C; - auto p4P = p4Port.volatileValue().toString(); + const QString p4P = p4Port.volatileValue(); if (!p4P.isEmpty()) lst << "-p" << p4P; - auto p4U = p4User.volatileValue().toString(); + const QString p4U = p4User.volatileValue(); if (!p4U.isEmpty()) lst << "-u" << p4U; } diff --git a/src/plugins/perfprofiler/perfsettings.cpp b/src/plugins/perfprofiler/perfsettings.cpp index 59a753e5dde..8851b19d777 100644 --- a/src/plugins/perfprofiler/perfsettings.cpp +++ b/src/plugins/perfprofiler/perfsettings.cpp @@ -58,8 +58,8 @@ PerfSettings::PerfSettings(ProjectExplorer::Target *target) extraArguments.setLabelText(Tr::tr("Additional arguments:")); extraArguments.setSpan(4); - connect(&callgraphMode, &SelectionAspect::volatileValueChanged, this, [this](int index) { - stackSize.setEnabled(index == 0); + connect(&callgraphMode, &SelectionAspect::volatileValueChanged, this, [this] { + stackSize.setEnabled(callgraphMode.volatileValue() == 0); }); readGlobalSettings(); diff --git a/src/plugins/projectexplorer/buildpropertiessettings.cpp b/src/plugins/projectexplorer/buildpropertiessettings.cpp index 6df8fdd328e..aed8c5a8ba2 100644 --- a/src/plugins/projectexplorer/buildpropertiessettings.cpp +++ b/src/plugins/projectexplorer/buildpropertiessettings.cpp @@ -59,10 +59,12 @@ BuildPropertiesSettings::BuildPropertiesSettings() qtQuickCompiler.setSettingsKey("ProjectExplorer/Settings/QtQuickCompiler"); qtQuickCompiler.setLabelText(Tr::tr("Use qmlcachegen:")); - QObject::connect(&showQtSettings, &BoolAspect::valueChanged, - &qmlDebugging, &BaseAspect::setVisible); - QObject::connect(&showQtSettings, &BoolAspect::valueChanged, - &qtQuickCompiler, &BaseAspect::setVisible); + QObject::connect(&showQtSettings, &BaseAspect::changed, &qmlDebugging, [this] { + qmlDebugging.setVisible(showQtSettings()); + }); + QObject::connect(&showQtSettings, &BaseAspect::changed, &qtQuickCompiler, [this] { + qtQuickCompiler.setVisible(showQtSettings()); + }); } QString BuildPropertiesSettings::defaultBuildDirectoryTemplate() diff --git a/src/plugins/python/pythonwizardpage.cpp b/src/plugins/python/pythonwizardpage.cpp index 2216dbfa574..59ecebf688a 100644 --- a/src/plugins/python/pythonwizardpage.cpp +++ b/src/plugins/python/pythonwizardpage.cpp @@ -109,8 +109,8 @@ PythonWizardPage::PythonWizardPage(const QList<QPair<QString, QVariant>> &pySide m_stateLabel->setWordWrap(true); m_stateLabel->setFilled(true); m_stateLabel->setType(InfoLabel::Error); - connect(&m_venvPath, &StringAspect::valueChanged, this, &PythonWizardPage::updateStateLabel); - connect(&m_createVenv, &BoolAspect::valueChanged, this, &PythonWizardPage::updateStateLabel); + connect(&m_venvPath, &BaseAspect::changed, this, &PythonWizardPage::updateStateLabel); + connect(&m_createVenv, &BaseAspect::changed, this, &PythonWizardPage::updateStateLabel); Grid { m_pySideVersion, br, diff --git a/src/plugins/squish/squishsettings.cpp b/src/plugins/squish/squishsettings.cpp index f7758a844d3..5b069f35fcb 100644 --- a/src/plugins/squish/squishsettings.cpp +++ b/src/plugins/squish/squishsettings.cpp @@ -87,7 +87,8 @@ SquishSettings::SquishSettings() minimizeIDE.setToolTip(Tr::tr("Minimize IDE automatically while running or recording test cases.")); minimizeIDE.setDefaultValue(true); - connect(&local, &BoolAspect::volatileValueChanged, this, [this](bool checked) { + connect(&local, &BoolAspect::volatileValueChanged, this, [this] { + const bool checked = local.volatileValue(); serverHost.setEnabled(!checked); serverPort.setEnabled(!checked); }); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index e2921603e98..5224b3c78c8 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -923,13 +923,12 @@ void MemcheckToolPrivate::updateFromSettings() m_filterProjectAction->setChecked(!m_settings->filterExternalIssues()); m_errorView->settingsChanged(m_settings); - connect(&m_settings->visibleErrorKinds, &IntegersAspect::valueChanged, - &m_errorProxyModel, &MemcheckErrorFilterProxyModel::setAcceptedKinds); - m_errorProxyModel.setAcceptedKinds(m_settings->visibleErrorKinds()); - - connect(&m_settings->filterExternalIssues, &BoolAspect::valueChanged, - &m_errorProxyModel, &MemcheckErrorFilterProxyModel::setFilterExternalIssues); - m_errorProxyModel.setFilterExternalIssues(m_settings->filterExternalIssues()); + connect(&m_settings->visibleErrorKinds, &BaseAspect::changed, &m_errorProxyModel, [this] { + m_errorProxyModel.setAcceptedKinds(m_settings->visibleErrorKinds()); + }); + connect(&m_settings->filterExternalIssues, &BaseAspect::changed, &m_errorProxyModel, [this] { + m_errorProxyModel.setFilterExternalIssues(m_settings->filterExternalIssues()); + }); } void MemcheckToolPrivate::maybeActiveRunConfigurationChanged() diff --git a/src/plugins/valgrind/valgrindsettings.cpp b/src/plugins/valgrind/valgrindsettings.cpp index 4db2e39c3a5..55c6a3543ce 100644 --- a/src/plugins/valgrind/valgrindsettings.cpp +++ b/src/plugins/valgrind/valgrindsettings.cpp @@ -108,7 +108,7 @@ void SuppressionAspectPrivate::slotSuppressionSelectionChanged() // SuppressionAspect::SuppressionAspect(AspectContainer *container, bool global) - : BaseAspect(container) + : TypedAspect(container) { d = new SuppressionAspectPrivate(this, global); setSettingsKey("Analyzer.Valgrind.SuppressionFiles"); @@ -119,16 +119,6 @@ SuppressionAspect::~SuppressionAspect() delete d; } -FilePaths SuppressionAspect::value() const -{ - return FileUtils::toFilePathList(BaseAspect::value().toStringList()); -} - -void SuppressionAspect::setValue(const FilePaths &val) -{ - BaseAspect::setValue(Utils::transform<QStringList>(val, &FilePath::toString)); -} - void SuppressionAspect::addToLayout(Layouting::LayoutItem &parent) { QTC_CHECK(!d->addEntry); @@ -157,8 +147,6 @@ void SuppressionAspect::addToLayout(Layouting::LayoutItem &parent) Column { d->addEntry.data(), d->removeEntry.data(), st } }; parent.addItem(Span { 2, group }); - - setVolatileValue(BaseAspect::value()); } void SuppressionAspect::fromMap(const QVariantMap &map) @@ -171,22 +159,18 @@ void SuppressionAspect::toMap(QVariantMap &map) const BaseAspect::toMap(map); } -QVariant SuppressionAspect::volatileValue() const +void SuppressionAspect::guiToInternal() { - QStringList ret; - + m_internal.clear(); for (int i = 0; i < d->m_model.rowCount(); ++i) - ret << d->m_model.item(i)->text(); - - return ret; + m_internal.append(FilePath::fromUserInput(d->m_model.item(i)->text())); } -void SuppressionAspect::setVolatileValue(const QVariant &val) +void SuppressionAspect::internalToGui() { - const QStringList files = val.toStringList(); d->m_model.clear(); - for (const QString &file : files) - d->m_model.appendRow(new QStandardItem(file)); + for (const FilePath &file : m_internal) + d->m_model.appendRow(new QStandardItem(file.toUserOutput())); } ////////////////////////////////////////////////////////////////// @@ -388,7 +372,7 @@ QVariantMap ValgrindBaseSettings::defaultSettings() const { QVariantMap defaults; forEachAspect([&defaults](BaseAspect *aspect) { - defaults.insert(aspect->settingsKey(), aspect->defaultValue()); + defaults.insert(aspect->settingsKey(), aspect->defaultVariantValue()); }); return defaults; } diff --git a/src/plugins/valgrind/valgrindsettings.h b/src/plugins/valgrind/valgrindsettings.h index 29506b848f5..def8b793da7 100644 --- a/src/plugins/valgrind/valgrindsettings.h +++ b/src/plugins/valgrind/valgrindsettings.h @@ -12,7 +12,7 @@ const char ANALYZER_VALGRIND_SETTINGS[] = "Analyzer.Valgrind.Settings"; class SuppressionAspectPrivate; -class SuppressionAspect final : public Utils::BaseAspect +class SuppressionAspect final : public Utils::TypedAspect<Utils::FilePaths> { Q_OBJECT @@ -20,21 +20,17 @@ public: SuppressionAspect(Utils::AspectContainer *container, bool global); ~SuppressionAspect() final; - Utils::FilePaths operator()() const { return value(); } - Utils::FilePaths value() const; - void setValue(const Utils::FilePaths &val); - void addToLayout(Layouting::LayoutItem &parent) final; void fromMap(const QVariantMap &map) final; void toMap(QVariantMap &map) const final; - QVariant volatileValue() const final; - void setVolatileValue(const QVariant &val) final; - void addSuppressionFile(const Utils::FilePath &suppressionFile); private: + void internalToGui() override; + void guiToInternal() override; + friend class ValgrindBaseSettings; SuppressionAspectPrivate *d = nullptr; }; |