You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
plasma-desktop/0003-Cleanup-and-fixup-KCon...

159 lines
7.3 KiB

From 27ebf75bd44101976d8392eec4ff4d20f495fb69 Mon Sep 17 00:00:00 2001
From: Hrvoje Senjan <hrvoje.senjan@gmail.com>
Date: Tue, 17 May 2016 22:16:53 +0200
Subject: [PATCH 3/6] Cleanup and fixup KConfig handling for componentchooser
Fixup for reviews 123288 and 123281.
REVIEW: 127918
---
kcms/componentchooser/componentchooserbrowser.cpp | 4 ++--
.../componentchooserfilemanager.cpp | 2 +-
kcms/componentchooser/componentchooserterminal.cpp | 4 ++--
kcms/input/mouse.cpp | 25 +++++++++++-----------
kcms/migrationlib/kdelibs4config.h | 15 ++++++-------
5 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/kcms/componentchooser/componentchooserbrowser.cpp b/kcms/componentchooser/componentchooserbrowser.cpp
index 5795c2b..d2be681 100644
--- a/kcms/componentchooser/componentchooserbrowser.cpp
+++ b/kcms/componentchooser/componentchooserbrowser.cpp
@@ -83,7 +83,7 @@ void CfgBrowser::load(KConfig *)
void CfgBrowser::save(KConfig *)
{
- KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig);
+ KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
KConfigGroup config(profile, QStringLiteral("General"));
QString exec;
if (radioExec->isChecked())
@@ -97,7 +97,7 @@ void CfgBrowser::save(KConfig *)
config.writePathEntry( QStringLiteral("BrowserApplication"), exec); // KConfig::Normal|KConfig::Global
config.sync();
- Kdelibs4SharedConfig::syncConfigGroup(&config, QStringLiteral("kdeglobals"));
+ Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("General"), "kdeglobals");
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
diff --git a/kcms/componentchooser/componentchooserfilemanager.cpp b/kcms/componentchooser/componentchooserfilemanager.cpp
index a04cced..f1b8071 100644
--- a/kcms/componentchooser/componentchooserfilemanager.cpp
+++ b/kcms/componentchooser/componentchooserfilemanager.cpp
@@ -106,7 +106,7 @@ void CfgFileManager::save(KConfig *)
KConfigGroup defaultApp(profile, s_DefaultApplications);
defaultApp.writeXdgListEntry(mime, QStringList(storageId));
- Kdelibs4SharedConfig::syncConfigGroup(&addedApps, QStringLiteral("mimeapps.list"));
+ Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("Added Associations"), QStringLiteral("mimeapps.list"));
profile->sync();
diff --git a/kcms/componentchooser/componentchooserterminal.cpp b/kcms/componentchooser/componentchooserterminal.cpp
index 36f1296..9df3365 100644
--- a/kcms/componentchooser/componentchooserterminal.cpp
+++ b/kcms/componentchooser/componentchooserterminal.cpp
@@ -79,13 +79,13 @@ void CfgTerminalEmulator::load(KConfig *) {
void CfgTerminalEmulator::save(KConfig *)
{
- KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig);
+ KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
KConfigGroup config(profile, QStringLiteral("General"));
const QString terminal = terminalCB->isChecked() ? QStringLiteral("konsole") : terminalLE->text();
config.writePathEntry("TerminalApplication", terminal); // KConfig::Normal|KConfig::Global);
config.sync();
- Kdelibs4SharedConfig::syncConfigGroup(&config, QStringLiteral("kdeglobals"));
+ Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("General"), "kdeglobals");
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
diff --git a/kcms/input/mouse.cpp b/kcms/input/mouse.cpp
index f7d030f..3b1f4dd 100644
--- a/kcms/input/mouse.cpp
+++ b/kcms/input/mouse.cpp
@@ -441,10 +441,10 @@ void MouseConfig::save()
settings->reverseScrollPolarity = generalTab->cbScrollPolarity->isChecked();
settings->apply();
- KConfig config( "kcminputrc", KConfig::SimpleConfig );
+ KConfig config( "kcminputrc" );
settings->save(&config);
- KConfig ac("kaccessrc", KConfig::SimpleConfig);
+ KConfig ac("kaccessrc");
KConfigGroup group = ac.group("Mouse");
@@ -728,26 +728,27 @@ void MouseSettings::apply(bool force)
void MouseSettings::save(KConfig *config)
{
- KConfigGroup group = config->group("Mouse");
- group.writeEntry("Acceleration",accelRate);
- group.writeEntry("Threshold",thresholdMove);
+ KSharedConfig::Ptr kcminputProfile = KSharedConfig::openConfig("kcminputrc");
+ KConfigGroup kcminputGroup(kcminputProfile, "Mouse");
+ kcminputGroup.writeEntry("Acceleration",accelRate);
+ kcminputGroup.writeEntry("Threshold",thresholdMove);
if (handed == RIGHT_HANDED)
- group.writeEntry("MouseButtonMapping",QString("RightHanded"));
+ kcminputGroup.writeEntry("MouseButtonMapping",QString("RightHanded"));
else
- group.writeEntry("MouseButtonMapping",QString("LeftHanded"));
- group.writeEntry( "ReverseScrollPolarity", reverseScrollPolarity );
+ kcminputGroup.writeEntry("MouseButtonMapping",QString("LeftHanded"));
+ kcminputGroup.writeEntry( "ReverseScrollPolarity", reverseScrollPolarity );
- Kdelibs4SharedConfig::syncConfigGroup(&group, "kinputrc");
+ Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("Mouse"), "kcminputrc");
- KSharedConfig::Ptr profile = KSharedConfig::openConfig("kdeglobals", KConfig::SimpleConfig);
- group = KConfigGroup(profile, "KDE");
+ KSharedConfig::Ptr profile = KSharedConfig::openConfig("kdeglobals");
+ KConfigGroup group(profile, "KDE");
group.writeEntry("DoubleClickInterval", doubleClickInterval, KConfig::Persistent);
group.writeEntry("StartDragTime", dragStartTime, KConfig::Persistent);
group.writeEntry("StartDragDist", dragStartDist, KConfig::Persistent);
group.writeEntry("WheelScrollLines", wheelScrollLines, KConfig::Persistent);
group.writeEntry("SingleClick", singleClick, KConfig::Persistent);
- Kdelibs4SharedConfig::syncConfigGroup(&group, "kdeglobals");
+ Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("KDE"), "kdeglobals");
group.sync();
config->sync();
diff --git a/kcms/migrationlib/kdelibs4config.h b/kcms/migrationlib/kdelibs4config.h
index bb2dca2..a2f4139 100644
--- a/kcms/migrationlib/kdelibs4config.h
+++ b/kcms/migrationlib/kdelibs4config.h
@@ -25,18 +25,15 @@
class Kdelibs4SharedConfig
{
public:
- static KSharedConfig::Ptr openConfig(const QString &fileName, KConfig::OpenFlags mode=KConfig::SimpleConfig)
+ static void syncConfigGroup(const QLatin1String &sourceGroup, const QString &fileName)
{
Kdelibs4Migration migration;
QString configDirPath = migration.saveLocation("config");
- return KSharedConfig::openConfig(configDirPath + '/' + fileName);
- }
-
- static void syncConfigGroup(KConfigGroup *sourceGroup, const QString &fileName)
- {
- KSharedConfigPtr kde4Config = openConfig(fileName);
- KConfigGroup kde4ConfigGroup = kde4Config->group(sourceGroup->name());
- sourceGroup->copyTo(&kde4ConfigGroup);
+ KSharedConfigPtr kde4Config = KSharedConfig::openConfig(configDirPath + '/' + fileName);
+ KSharedConfigPtr simpleConfig = KSharedConfig::openConfig("kdeglobals", KConfig::SimpleConfig);
+ KConfigGroup simpleConfigGroup(simpleConfig, sourceGroup);
+ KConfigGroup kde4ConfigGroup = kde4Config->group(sourceGroup);
+ simpleConfigGroup.copyTo(&kde4ConfigGroup);
kde4ConfigGroup.sync();
}
--
2.7.4