KConfig

kstandardshortcutwatcher.cpp
1 /*
2  SPDX-FileCopyrightText: 2022 David Redondo <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "kstandardshortcutwatcher.h"
8 
9 #include "kconfigwatcher.h"
10 #include "kstandardshortcut_p.h"
11 
12 namespace KStandardShortcut
13 {
14 class StandardShortcutWatcherPrivate
15 {
16 public:
18 };
19 
20 StandardShortcutWatcher::StandardShortcutWatcher(QObject *parent)
21  : QObject(parent)
22  , d(std::make_unique<StandardShortcutWatcherPrivate>())
23 {
24  connect(d->watcher.get(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &keys) {
25  if (group.name() != QStringLiteral("Shortcuts")) {
26  return;
27  }
28  for (const auto &key : keys) {
30  if (shortcut != KStandardShortcut::AccelNone) {
32  Q_EMIT shortcutChanged(shortcut, KStandardShortcut::shortcut(shortcut));
33  }
34  }
35  });
36 }
37 
38 StandardShortcutWatcher::~StandardShortcutWatcher() = default;
39 
41 {
42  static StandardShortcutWatcher watcher;
43  return &watcher;
44 }
45 
46 }
47 
48 #include "moc_kstandardshortcutwatcher.cpp"
const QList< QKeySequence > & shortcut(StandardShortcut id)
Returns the keybinding for accel.
QString fromUtf8(const char *str, int size)
void configChanged(const KConfigGroup &group, const QByteArrayList &names)
Emitted when a config group has changed The config will be reloaded before this signal is emitted.
StandardShortcut findByName(const QString &name)
Return the StandardShortcut id of the standard accelerator action which has name as its name,...
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
Creates a KSharedConfig object to manipulate a configuration file.
void initialize(StandardShortcut id)
Initialize the accelerator id by checking if it is overridden in the configuration file (and if it is...
StandardShortcut
Defines the identifier of all standard accelerators.
static Ptr create(const KSharedConfig::Ptr &config)
Instantiate a ConfigWatcher for a given config.
StandardShortcutWatcher * shortcutWatcher()
Returns the global KStandardShortcutWatcher instance of this program.
Watches for changes made to standard shortcuts and notifies about those changes.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:11:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.