[frameworks/kcmutils/kcmutils-kwin-scripts-nodefaults] src/core: kpluginmodel: Only write enabled state when not default

Nicolas Fella <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 3699adf6856c64489a90b0006583fe70e288aa81 by Nicolas Fella, on behalf of David W..
Committed on 20/07/2026 at 15:33.
Pushed by nicolasfella into branch 'kcmutils-kwin-scripts-nodefaults'.

kpluginmodel: Only write enabled state when not default

This matches how other config files work

M  +23   -1    src/core/kpluginmodel.cpp

https://invent.kde.org/frameworks/kcmutils/-/commit/3699adf6856c64489a90b0006583fe70e288aa81

diff --git a/src/core/kpluginmodel.cpp b/src/core/kpluginmodel.cpp
index 4f5e597c..f008a1ff 100644
--- a/src/core/kpluginmodel.cpp
+++ b/src/core/kpluginmodel.cpp
@@ -11,6 +11,7 @@
 #include <QPluginLoader>
 
 #include <KCategorizedSortFilterProxyModel>
+#include <KConfig>
 #include <KConfigGroup>
 
 #include <utility>
@@ -239,7 +240,28 @@ void KPluginModel::save()
 {
     if (d->m_config.isValid()) {
         for (auto it = d->m_pendingStates.cbegin(); it != d->m_pendingStates.cend(); ++it) {
-            d->m_config.writeEntry(it.key() + QLatin1String("Enabled"), it.value());
+            const QString key = it.key() + QStringLiteral("Enabled");
+            bool isDefault;
+
+            if (d->m_config.hasDefault(key)) {
+                d->m_config.config()->setReadDefaults(true);
+                isDefault = (it.value() == d->m_config.readEntry(key, false));
+                d->m_config.config()->setReadDefaults(false);
+            } else {
+                // Find the plugin to get its default state
+                const QString pluginId = it.key();
+                const auto pluginIt = std::find_if(d->m_plugins.cbegin(), d->m_plugins.cend(), [&pluginId](const KPluginMetaData &p) {
+                    return p.pluginId() == pluginId;
+                });
+
+                isDefault = (pluginIt != d->m_plugins.cend()) && (it.value() == pluginIt->isEnabledByDefault());
+            }
+
+            if (isDefault) {
+                d->m_config.revertToDefault(key);
+            } else {
+                d->m_config.writeEntry(key, it.value());
+            }
         }
 
         d->m_config.sync();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.