From 820dc0a553e50cc4560733d43fca2674a61d43b3 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Thu, 13 Jan 2022 10:04:13 +0100 Subject: Introduce StandardShortcutWatcher to watch for runtime changes Currently an application needs to be restarted before it can see any changes made to the standard shortcut configuration. To notify about changes a new class is introduced that looks for those changes using KConfigWatcher and also updates the global map. CCBUG:426656 --- src/gui/kstandardshortcut.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/gui/kstandardshortcut.cpp') diff --git a/src/gui/kstandardshortcut.cpp b/src/gui/kstandardshortcut.cpp index 1f67901f..e7639219 100644 --- a/src/gui/kstandardshortcut.cpp +++ b/src/gui/kstandardshortcut.cpp @@ -8,8 +8,10 @@ */ #include "kstandardshortcut.h" +#include "kstandardshortcutwatcher.h" #include "kconfig.h" +#include "kconfigwatcher.h" #include "ksharedconfig.h" #include @@ -437,7 +439,7 @@ static void sanitizeShortcutList(QList *list) On X11, if QApplication was initialized with GUI disabled, the default will always be used. */ -static void initialize(StandardShortcut id) +void initialize(StandardShortcut id) { KStandardShortcutInfo *info = guardedStandardShortcutInfo(id); @@ -483,7 +485,8 @@ void saveShortcut(StandardShortcut id, const QList &newShortcut) // If the shortcut is the equal to the hardcoded one we remove it from // kdeglobal if necessary and return. if (cg.hasKey(info->name)) { - cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent); + cg.deleteEntry(info->name, KConfig::Global | KConfig::Persistent | KConfig::Notify); + cg.sync(); } return; @@ -491,7 +494,8 @@ void saveShortcut(StandardShortcut id, const QList &newShortcut) // Write the changed shortcut to kdeglobals sanitizeShortcutList(&info->cut); - cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent); + cg.writeEntry(info->name, QKeySequence::listToString(info->cut), KConfig::Global | KConfig::Persistent | KConfig::Notify); + cg.sync(); } QString name(StandardShortcut id) -- cgit v1.2.1