aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <[email protected]>2025-06-19 10:14:30 +0200
committerhjk <[email protected]>2025-07-04 13:09:13 +0000
commitbd13f4cc7f0d813355e3b0b2471b308e1c7278c0 (patch)
tree70bbebb95e468da553dadb4d35a9a7225d2cf29d /src/plugins
parentabf7d7d0c1795cc07a1e69c59ca3fb63f7cb41d1 (diff)
Centralize Settings storage a bitHEADmaster
Until now, the plugin manager effectively owned the settings, with forwarded access from ICore and three places in Utils getting settings injected. This here moves the storage to Utils, removing the need for injection, as all users depend on Utils. Syntax-wise this changes access to use references instead of pointers. Change-Id: If63258fbe37da2ad3dcf78f8c2eedb61753e7cc8 Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/autotest/testsettings.cpp26
-rw-r--r--src/plugins/coreplugin/icore.cpp4
-rw-r--r--src/plugins/coreplugin/secretaspect.cpp16
-rw-r--r--src/plugins/debugger/debuggersourcepathmappingwidget.cpp24
-rw-r--r--src/plugins/qmljseditor/qmllsclientsettings.cpp2
5 files changed, 37 insertions, 35 deletions
diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp
index 84edff3102d..c5443186fb9 100644
--- a/src/plugins/autotest/testsettings.cpp
+++ b/src/plugins/autotest/testsettings.cpp
@@ -121,27 +121,27 @@ void TestSettings::toSettings() const
{
AspectContainer::writeSettings();
- QtcSettings *s = BaseAspect::qtcSettings();
- s->beginGroup(Constants::SETTINGSGROUP);
+ QtcSettings &s = Utils::userSettings();
+ s.beginGroup(Constants::SETTINGSGROUP);
// store frameworks and their current active and grouping state
for (auto it = frameworks.cbegin(); it != frameworks.cend(); ++it) {
const Utils::Id &id = it.key();
- s->setValue(id.toKey(), it.value());
- s->setValue(id.toKey() + groupSuffix, frameworksGrouping.value(id));
+ s.setValue(id.toKey(), it.value());
+ s.setValue(id.toKey() + groupSuffix, frameworksGrouping.value(id));
}
// ..and the testtools as well
for (auto it = tools.cbegin(); it != tools.cend(); ++it)
- s->setValue(it.key().toKey(), it.value());
- s->endGroup();
+ s.setValue(it.key().toKey(), it.value());
+ s.endGroup();
}
void TestSettings::fromSettings()
{
AspectContainer::readSettings();
- QtcSettings *s = BaseAspect::qtcSettings();
- s->beginGroup(Constants::SETTINGSGROUP);
+ QtcSettings &s = Utils::userSettings();
+ s.beginGroup(Constants::SETTINGSGROUP);
// try to get settings for registered frameworks
const TestFrameworks &registered = TestFrameworkManager::registeredFrameworks();
@@ -151,18 +151,18 @@ void TestSettings::fromSettings()
// get their active state
const Id id = framework->id();
const Key key = id.toKey();
- frameworks.insert(id, s->value(key, framework->active()).toBool());
+ frameworks.insert(id, s.value(key, framework->active()).toBool());
// and whether grouping is enabled
- frameworksGrouping.insert(id, s->value(key + groupSuffix, framework->grouping()).toBool());
+ frameworksGrouping.insert(id, s.value(key + groupSuffix, framework->grouping()).toBool());
}
// ..and for test tools as well
const TestTools &registeredTools = TestFrameworkManager::registeredTestTools();
tools.clear();
for (const ITestTool *testTool : registeredTools) {
- const Utils::Id id = testTool->id();
- tools.insert(id, s->value(id.toKey(), testTool->active()).toBool());
+ const Id id = testTool->id();
+ tools.insert(id, s.value(id.toKey(), testTool->active()).toBool());
}
- s->endGroup();
+ s.endGroup();
}
RunAfterBuildMode TestSettings::runAfterBuildMode() const
diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp
index b16d881dbc3..e83cc29ce1a 100644
--- a/src/plugins/coreplugin/icore.cpp
+++ b/src/plugins/coreplugin/icore.cpp
@@ -565,9 +565,9 @@ bool ICore::showWarningWithOptions(const QString &title, const QString &text,
QtcSettings *ICore::settings(QSettings::Scope scope)
{
if (scope == QSettings::UserScope)
- return PluginManager::settings();
+ return &Utils::userSettings();
else
- return PluginManager::globalSettings();
+ return &Utils::installSettings();
}
/*!
diff --git a/src/plugins/coreplugin/secretaspect.cpp b/src/plugins/coreplugin/secretaspect.cpp
index 5ae0d68c350..9c30d8801b5 100644
--- a/src/plugins/coreplugin/secretaspect.cpp
+++ b/src/plugins/coreplugin/secretaspect.cpp
@@ -65,7 +65,7 @@ static bool applyKey(const SecretAspect &aspect, CredentialQuery &op)
return true;
}
-void SecretAspect::readSecret(const std::function<void(Utils::Result<QString>)> &cb) const
+void SecretAspect::readSecret(const std::function<void(Result<QString>)> &cb) const
{
d->readCallbacks.push_back(cb);
@@ -74,9 +74,10 @@ void SecretAspect::readSecret(const std::function<void(Utils::Result<QString>)>
if (!QKeychain::isAvailable()) {
qWarning() << "No Keychain available, reading from plaintext";
- qtcSettings()->beginGroup("Secrets");
- auto value = qtcSettings()->value(settingsKey());
- qtcSettings()->endGroup();
+ QtcSettings &settings = Utils::userSettings();
+ settings.beginGroup("Secrets");
+ QVariant value = settings.value(settingsKey());
+ settings.endGroup();
d->callReadCallbacks(fromSettingsValue(value).toString());
return;
@@ -126,9 +127,10 @@ void SecretAspect::writeSettings() const
return;
if (!QKeychain::isAvailable()) {
- qtcSettings()->beginGroup("Secrets");
- qtcSettings()->setValue(settingsKey(), toSettingsValue(d->value));
- qtcSettings()->endGroup();
+ QtcSettings &settings = Utils::userSettings();
+ settings.beginGroup("Secrets");
+ settings.setValue(settingsKey(), toSettingsValue(d->value));
+ settings.endGroup();
d->wasEdited = false;
return;
}
diff --git a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
index 1d52a674240..e254fb0311f 100644
--- a/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
+++ b/src/plugins/debugger/debuggersourcepathmappingwidget.cpp
@@ -497,8 +497,8 @@ const char sourcePathMappingTargetKeyC[] = "Target";
void SourcePathMapAspect::writeSettings() const
{
const SourcePathMap sourcePathMap = value();
- QtcSettings *s = qtcSettings();
- s->beginWriteArray(sourcePathMappingArrayNameC);
+ QtcSettings &s = userSettings();
+ s.beginWriteArray(sourcePathMappingArrayNameC);
if (!sourcePathMap.isEmpty()) {
const Key sourcePathMappingSourceKey(sourcePathMappingSourceKeyC);
const Key sourcePathMappingTargetKey(sourcePathMappingTargetKeyC);
@@ -506,29 +506,29 @@ void SourcePathMapAspect::writeSettings() const
for (auto it = sourcePathMap.constBegin(), cend = sourcePathMap.constEnd();
it != cend;
++it, ++i) {
- s->setArrayIndex(i);
- s->setValue(sourcePathMappingSourceKey, it.key());
- s->setValue(sourcePathMappingTargetKey, it.value());
+ s.setArrayIndex(i);
+ s.setValue(sourcePathMappingSourceKey, it.key());
+ s.setValue(sourcePathMappingTargetKey, it.value());
}
}
- s->endArray();
+ s.endArray();
}
void SourcePathMapAspect::readSettings()
{
- QtcSettings *s = qtcSettings();
+ QtcSettings &s = userSettings();
SourcePathMap sourcePathMap;
- if (const int count = s->beginReadArray(sourcePathMappingArrayNameC)) {
+ if (const int count = s.beginReadArray(sourcePathMappingArrayNameC)) {
const Key sourcePathMappingSourceKey(sourcePathMappingSourceKeyC);
const Key sourcePathMappingTargetKey(sourcePathMappingTargetKeyC);
for (int i = 0; i < count; ++i) {
- s->setArrayIndex(i);
- const QString key = s->value(sourcePathMappingSourceKey).toString();
- const QString value = s->value(sourcePathMappingTargetKey).toString();
+ s.setArrayIndex(i);
+ const QString key = s.value(sourcePathMappingSourceKey).toString();
+ const QString value = s.value(sourcePathMappingTargetKey).toString();
sourcePathMap.insert(key, value);
}
}
- s->endArray();
+ s.endArray();
setValue(sourcePathMap);
}
diff --git a/src/plugins/qmljseditor/qmllsclientsettings.cpp b/src/plugins/qmljseditor/qmllsclientsettings.cpp
index c1357eadb64..ba786543011 100644
--- a/src/plugins/qmljseditor/qmllsclientsettings.cpp
+++ b/src/plugins/qmljseditor/qmllsclientsettings.cpp
@@ -301,7 +301,7 @@ bool QmllsClientSettings::useQmllsWithBuiltinCodemodelOnProject(Project *project
// first time initialization: port old settings from the QmlJsEditingSettings AspectContainer
static void portFromOldSettings(QmllsClientSettings* qmllsClientSettings)
{
- QtcSettings *settings = BaseAspect::qtcSettings();
+ QtcSettings *settings = &Utils::userSettings();
const Key baseKey = Key{QmlJSEditor::Constants::SETTINGS_CATEGORY_QML} + "/";