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/kstandardshortcutwatcher.h | |
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/kstandardshortcutwatcher.h')
-rw-r--r-- | src/gui/kstandardshortcutwatcher.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/gui/kstandardshortcutwatcher.h b/src/gui/kstandardshortcutwatcher.h new file mode 100644 index 00000000..64c6d3d4 --- /dev/null +++ b/src/gui/kstandardshortcutwatcher.h @@ -0,0 +1,54 @@ +/* + SPDX-FileCopyrightText: 2022 David Redondo <kde@david-redondo.de> + + SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#ifndef KSTANDARDSHORTCUTWATCHER_H +#define KSTANDARDSHORTCUTWATCHER_H + +#include "kstandardshortcut.h" + +#include <QObject> + +#include <memory> + +#include <kconfiggui_export.h> + +namespace KStandardShortcut +{ +class StandardShortcutWatcherPrivate; + +/** + * Watches for changes made to standard shortcuts and notifies about those changes. + * @see KStandardShortcut::shortcutWatcher + * @since 5.91 + */ +class KCONFIGGUI_EXPORT StandardShortcutWatcher : public QObject +{ + Q_OBJECT +public: + ~StandardShortcutWatcher(); +Q_SIGNALS: + /** + * The standardshortcut @p id was changed to @p shortcut + */ + void shortcutChanged(KStandardShortcut::StandardShortcut id, const QList<QKeySequence> &shortcut); + +private: + explicit StandardShortcutWatcher(QObject *parent = nullptr); + friend StandardShortcutWatcher *shortcutWatcher(); + std::unique_ptr<StandardShortcutWatcherPrivate> d; +}; + +/** + * Returns the global KStandardShortcutWatcher instance of this program. + * In addition to the notifying about changes it also keeps the information returned by the + * functions in @p KStandardShortcut up to date. + * The object is created by the first call to this function. + * @since 5.91 + */ +KCONFIGGUI_EXPORT StandardShortcutWatcher *shortcutWatcher(); +} + +#endif |