Use the new BaseAspect::addOnChanged in a few places

... and in some cases move it closer to the aspect setup. I kept
the original location in cases where the order possibly matters.

Change-Id: I4774ea355d0d1e3cf890676a84121195fca6d406
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-07-03 12:16:38 +02:00
parent bbb6053374
commit cba64c460b
20 changed files with 41 additions and 53 deletions

View File

@@ -54,8 +54,7 @@ public:
environment.addSupportedBaseEnvironment(Tr::tr("Clean Environment"), {}); environment.addSupportedBaseEnvironment(Tr::tr("Clean Environment"), {});
extraAppArgs.setMacroExpander(macroExpander()); extraAppArgs.setMacroExpander(macroExpander());
extraAppArgs.addOnChanged(this, [this, target] {
connect(&extraAppArgs, &BaseAspect::changed, this, [this, target] {
if (target->buildConfigurations().first()->buildType() == BuildConfiguration::BuildType::Release) { if (target->buildConfigurations().first()->buildType() == BuildConfiguration::BuildType::Release) {
const QString buildKey = target->activeBuildKey(); const QString buildKey = target->activeBuildKey();
target->buildSystem()->setExtraData(buildKey, target->buildSystem()->setExtraData(buildKey,

View File

@@ -52,8 +52,7 @@ AutogenStep::AutogenStep(BuildStepList *bsl, Id id) : AbstractProcessStep(bsl, i
m_arguments.setLabelText(Tr::tr("Arguments:")); m_arguments.setLabelText(Tr::tr("Arguments:"));
m_arguments.setDisplayStyle(StringAspect::LineEditDisplay); m_arguments.setDisplayStyle(StringAspect::LineEditDisplay);
m_arguments.setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs"); m_arguments.setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs");
m_arguments.addOnChanged(this, [this] { m_runAutogen = true; });
connect(&m_arguments, &BaseAspect::changed, this, [this] { m_runAutogen = true; });
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); }); setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });

View File

@@ -42,8 +42,7 @@ public:
arguments.setValue("--force --install"); arguments.setValue("--force --install");
arguments.setDisplayStyle(StringAspect::LineEditDisplay); arguments.setDisplayStyle(StringAspect::LineEditDisplay);
arguments.setHistoryCompleter("AutotoolsPM.History.AutoreconfStepArgs"); arguments.setHistoryCompleter("AutotoolsPM.History.AutoreconfStepArgs");
arguments.addOnChanged(this, [this] { m_runAutoreconf = true; });
connect(&arguments, &BaseAspect::changed, this, [this] { m_runAutoreconf = true; });
setCommandLineProvider([this] { setCommandLineProvider([this] {
return CommandLine("autoreconf", arguments(), CommandLine::Raw); return CommandLine("autoreconf", arguments(), CommandLine::Raw);

View File

@@ -45,10 +45,7 @@ public:
arguments.setSettingsKey("AutotoolsProjectManager.ConfigureStep.AdditionalArguments"); arguments.setSettingsKey("AutotoolsProjectManager.ConfigureStep.AdditionalArguments");
arguments.setLabelText(Tr::tr("Arguments:")); arguments.setLabelText(Tr::tr("Arguments:"));
arguments.setHistoryCompleter("AutotoolsPM.History.ConfigureArgs"); arguments.setHistoryCompleter("AutotoolsPM.History.ConfigureArgs");
arguments.addOnChanged(this, [this] { m_runConfigure = true; });
connect(&arguments, &BaseAspect::changed, this, [this] {
m_runConfigure = true;
});
setCommandLineProvider([this] { setCommandLineProvider([this] {
return getCommandLine(arguments()); return getCommandLine(arguments());

View File

@@ -251,8 +251,8 @@ DashboardSettingsWidget::DashboardSettingsWidget(QWidget *parent, QPushButton *o
m_valid.setValue(isValid()); m_valid.setValue(isValid());
ok->setEnabled(m_valid()); ok->setEnabled(m_valid());
}; };
connect(&m_dashboardUrl, &BaseAspect::changed, this, checkValidity); m_dashboardUrl.addOnChanged(this, checkValidity);
connect(&m_username, &BaseAspect::changed, this, checkValidity); m_username.addOnChanged(this, checkValidity);
} }
AxivionServer DashboardSettingsWidget::dashboardServer() const AxivionServer DashboardSettingsWidget::dashboardServer() const

View File

@@ -251,8 +251,9 @@ public:
.addToContainer(menuId) .addToContainer(menuId)
.addOnTriggered(this, &ArtisticStyle::formatFile); .addOnTriggered(this, &ArtisticStyle::formatFile);
connect(&settings().supportedMimeTypes, &Utils::BaseAspect::changed, settings().supportedMimeTypes.addOnChanged(this, [this] {
this, [this] { updateActions(Core::EditorManager::currentEditor()); }); updateActions(Core::EditorManager::currentEditor());
});
} }
QString id() const final QString id() const final

View File

@@ -152,6 +152,7 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
command.setCommandVersionArguments({"--version"}); command.setCommandVersionArguments({"--version"});
command.setPromptDialogTitle(BeautifierTool::msgCommandPromptDialogTitle("Clang Format")); command.setPromptDialogTitle(BeautifierTool::msgCommandPromptDialogTitle("Clang Format"));
command.setValidatePlaceHolder(true); command.setValidatePlaceHolder(true);
command.addOnChanged(this, [this] { m_version = {}; version(); });
supportedMimeTypes.setDisplayStyle(StringAspect::LineEditDisplay); supportedMimeTypes.setDisplayStyle(StringAspect::LineEditDisplay);
supportedMimeTypes.setSettingsKey("supportedMime"); supportedMimeTypes.setSettingsKey("supportedMime");
@@ -172,8 +173,6 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
} }
return types.join("; "); return types.join("; ");
}); });
connect(&command, &BaseAspect::changed, this, [this] { m_version = {}; version(); });
} }
AbstractSettings::~AbstractSettings() = default; AbstractSettings::~AbstractSettings() = default;

View File

@@ -346,8 +346,9 @@ public:
.addToContainer(menuId) .addToContainer(menuId)
.addOnTriggered(this, &ClangFormat::disableFormattingSelectedText); .addOnTriggered(this, &ClangFormat::disableFormattingSelectedText);
connect(&settings().supportedMimeTypes, &BaseAspect::changed, settings().supportedMimeTypes.addOnChanged(this, [this] {
this, [this] { updateActions(Core::EditorManager::currentEditor()); }); updateActions(Core::EditorManager::currentEditor());
});
} }
QString id() const final QString id() const final

View File

@@ -254,8 +254,9 @@ public:
.addToContainer(menuId) .addToContainer(menuId)
.addOnTriggered(this, &Uncrustify::formatSelectedText); .addOnTriggered(this, &Uncrustify::formatSelectedText);
connect(&settings().supportedMimeTypes, &Utils::BaseAspect::changed, settings().supportedMimeTypes.addOnChanged(this, [this] {
this, [this] { updateActions(Core::EditorManager::currentEditor()); }); updateActions(Core::EditorManager::currentEditor());
});
} }
QString id() const final QString id() const final

View File

@@ -76,8 +76,8 @@ public:
fullCommand.setValue(cmd.toUserOutput()); fullCommand.setValue(cmd.toUserOutput());
}; };
connect(&arguments, &BaseAspect::changed, this, updateFullCommand); arguments.addOnChanged(this, updateFullCommand);
connect(&executable, &BaseAspect::changed, this, updateFullCommand); executable.addOnChanged(this, updateFullCommand);
updateFullCommand(); updateFullCommand();
} }

View File

@@ -201,11 +201,9 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
auto buildDirAspect = bc->buildDirectoryAspect(); auto buildDirAspect = bc->buildDirectoryAspect();
buildDirAspect->setAutoApplyOnEditingFinished(true); buildDirAspect->setAutoApplyOnEditingFinished(true);
connect(buildDirAspect, &BaseAspect::changed, this, [this] { buildDirAspect->addOnChanged(this, [this] { m_configModel->flush(); }); // clear config cache
m_configModel->flush(); // clear out config cache...;
});
connect(&m_buildConfig->buildTypeAspect, &BaseAspect::changed, this, [this] { m_buildConfig->buildTypeAspect.addOnChanged(this, [this] {
if (!m_buildConfig->cmakeBuildSystem()->isMultiConfig()) { if (!m_buildConfig->cmakeBuildSystem()->isMultiConfig()) {
CMakeConfig config; CMakeConfig config;
config << CMakeConfigItem("CMAKE_BUILD_TYPE", config << CMakeConfigItem("CMAKE_BUILD_TYPE",
@@ -216,9 +214,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
}); });
auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>(); auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
connect(qmlDebugAspect, &QtSupport::QmlDebuggingAspect::changed, this, [this] { qmlDebugAspect->addOnChanged(this, [this] { updateButtonState(); });
updateButtonState();
});
m_warningMessageLabel = new InfoLabel({}, InfoLabel::Warning); m_warningMessageLabel = new InfoLabel({}, InfoLabel::Warning);
m_warningMessageLabel->setVisible(false); m_warningMessageLabel->setVisible(false);

View File

@@ -610,11 +610,11 @@ QWidget *CMakeBuildStep::createConfigWidget()
updateDetails(); updateDetails();
connect(&cmakeArguments, &BaseAspect::changed, this, updateDetails); cmakeArguments.addOnChanged(this, updateDetails);
connect(&toolArguments, &BaseAspect::changed, this, updateDetails); toolArguments.addOnChanged(this, updateDetails);
connect(&useStaging, &BaseAspect::changed, this, updateDetails); useStaging.addOnChanged(this, updateDetails);
connect(&stagingDir, &BaseAspect::changed, this, updateDetails); stagingDir.addOnChanged(this, updateDetails);
connect(&useiOSAutomaticProvisioningUpdates, &BaseAspect::changed, this, updateDetails); useiOSAutomaticProvisioningUpdates.addOnChanged(this, updateDetails);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged, connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
this, updateDetails); this, updateDetails);

View File

@@ -116,8 +116,7 @@ public:
&& isApplicable(editor->document())); && isApplicable(editor->document()));
}; };
connect(&autoFormatMime, &Utils::StringAspect::changed, autoFormatMime.addOnChanged(this, updateActions);
this, updateActions);
connect(EditorManager::instance(), &EditorManager::currentEditorChanged, connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
this, updateActions); this, updateActions);
connect(EditorManager::instance(), &EditorManager::aboutToSave, connect(EditorManager::instance(), &EditorManager::aboutToSave,

View File

@@ -99,7 +99,7 @@ QWidget *CMakeInstallStep::createConfigWidget()
updateDetails(); updateDetails();
connect(&cmakeArguments, &StringAspect::changed, this, updateDetails); cmakeArguments.addOnChanged(this, updateDetails);
connect(ProjectExplorerPlugin::instance(), connect(ProjectExplorerPlugin::instance(),
&ProjectExplorerPlugin::settingsChanged, &ProjectExplorerPlugin::settingsChanged,

View File

@@ -104,7 +104,7 @@ public:
settings->source.setVolatileValue(plainText()); settings->source.setVolatileValue(plainText());
}); });
connect(&settings->source, &Utils::StringAspect::changed, this, [settings, this] { settings->source.addOnChanged(this, [settings, this] {
if (settings->source.volatileValue() != plainText()) if (settings->source.volatileValue() != plainText())
setPlainText(settings->source.volatileValue()); setPlainText(settings->source.volatileValue());
}); });

View File

@@ -77,10 +77,9 @@ SourceSettings::SourceSettings(const ApiConfigFunction &apiConfigFunction)
compilers.setCreateItemFunction([this, apiConfigFunction] { compilers.setCreateItemFunction([this, apiConfigFunction] {
auto result = std::make_shared<CompilerSettings>(apiConfigFunction); auto result = std::make_shared<CompilerSettings>(apiConfigFunction);
connect(this, &SourceSettings::languagesChanged, result.get(), &CompilerSettings::refresh); connect(this, &SourceSettings::languagesChanged, result.get(), &CompilerSettings::refresh);
connect(&languageId, languageId.addOnChanged( result.get(), [this, result = result.get()] {
&Utils::StringSelectionAspect::changed, result->setLanguageId(languageId());
result.get(), });
[this, result = result.get()] { result->setLanguageId(languageId()); });
connect(result.get(), &Utils::AspectContainer::changed, this, &SourceSettings::changed); connect(result.get(), &Utils::AspectContainer::changed, this, &SourceSettings::changed);

View File

@@ -125,7 +125,7 @@ public:
requestAct->setEnabled(enabled); requestAct->setEnabled(enabled);
}; };
connect(&settings().enableCopilot, &BaseAspect::changed, this, updateActions); settings().enableCopilot.addOnChanged(this, updateActions);
updateActions(); updateActions();

View File

@@ -252,8 +252,8 @@ CopilotProjectSettings::CopilotProjectSettings(ProjectExplorer::Project *project
Store map = storeFromVariant(project->namedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID)); Store map = storeFromVariant(project->namedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID));
fromMap(map); fromMap(map);
connect(&enableCopilot, &BaseAspect::changed, this, [this, project] { save(project); }); enableCopilot.addOnChanged(this, [this, project] { save(project); });
connect(&useGlobalSettings, &BaseAspect::changed, this, [this, project] { save(project); }); useGlobalSettings.addOnChanged(this, [this, project] { save(project); });
} }
void CopilotProjectSettings::setUseGlobalSettings(bool useGlobal) void CopilotProjectSettings::setUseGlobalSettings(bool useGlobal)

View File

@@ -60,6 +60,10 @@ GeneralSettings::GeneralSettings()
showShortcutsInContextMenus.setLabelText( showShortcutsInContextMenus.setLabelText(
Tr::tr("Show keyboard shortcuts in context menus (default: %1)") Tr::tr("Show keyboard shortcuts in context menus (default: %1)")
.arg(defaultShowShortcutsInContextMenu() ? Tr::tr("on") : Tr::tr("off"))); .arg(defaultShowShortcutsInContextMenu() ? Tr::tr("on") : Tr::tr("off")));
showShortcutsInContextMenus.addOnChanged(this, [this] {
QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
!showShortcutsInContextMenus());
});
provideSplitterCursors.setSettingsKey("General/OverrideSplitterCursors"); provideSplitterCursors.setSettingsKey("General/OverrideSplitterCursors");
provideSplitterCursors.setDefaultValue(false); provideSplitterCursors.setDefaultValue(false);
@@ -69,11 +73,6 @@ GeneralSettings::GeneralSettings()
"not displayed properly, you can use the cursors provided by %1.") "not displayed properly, you can use the cursors provided by %1.")
.arg(QGuiApplication::applicationDisplayName())); .arg(QGuiApplication::applicationDisplayName()));
connect(&showShortcutsInContextMenus, &BaseAspect::changed, this, [this] {
QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
!showShortcutsInContextMenus());
});
readSettings(); readSettings();
} }

View File

@@ -152,9 +152,8 @@ SystemSettings::SystemSettings()
autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled); autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled);
bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles); bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles);
connect(&autoSaveModifiedFiles, &BaseAspect::changed, autoSaveModifiedFiles.addOnChanged(this, &EditorManagerPrivate::updateAutoSave);
this, &EditorManagerPrivate::updateAutoSave); autoSaveInterval.addOnChanged(this, &EditorManagerPrivate::updateAutoSave);
connect(&autoSaveInterval, &BaseAspect::changed, this, &EditorManagerPrivate::updateAutoSave);
} }
class SystemSettingsWidget : public IOptionsPageWidget class SystemSettingsWidget : public IOptionsPageWidget