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"), {});
extraAppArgs.setMacroExpander(macroExpander());
connect(&extraAppArgs, &BaseAspect::changed, this, [this, target] {
extraAppArgs.addOnChanged(this, [this, target] {
if (target->buildConfigurations().first()->buildType() == BuildConfiguration::BuildType::Release) {
const QString buildKey = target->activeBuildKey();
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.setDisplayStyle(StringAspect::LineEditDisplay);
m_arguments.setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs");
connect(&m_arguments, &BaseAspect::changed, this, [this] { m_runAutogen = true; });
m_arguments.addOnChanged(this, [this] { m_runAutogen = true; });
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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