diff options
author | David Redondo <kde@david-redondo.de> | 2022-01-13 10:04:13 +0100 |
---|---|---|
committer | David Redondo <kde@david-redondo.de> | 2022-01-24 13:23:55 +0000 |
commit | 820dc0a553e50cc4560733d43fca2674a61d43b3 (patch) | |
tree | 6a89465d257b5b238b6bcd6a7f2f339ac167b9b6 /src/gui/kstandardshortcut.cpp | |
parent | 41d37407e80f5ccd110cf303c20a181f95fa7e73 (diff) | |
download | kconfig-820dc0a553e50cc4560733d43fca2674a61d43b3.tar.gz kconfig-820dc0a553e50cc4560733d43fca2674a61d43b3.tar.bz2 |
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
Diffstat (limited to 'src/gui/kstandardshortcut.cpp')
-rw-r--r-- | src/gui/kstandardshortcut.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
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 <kconfiggroup.h> @@ -437,7 +439,7 @@ static void sanitizeShortcutList(QList<QKeySequence> *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<QKeySequence> &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<QKeySequence> &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) |