KGlobalAccel

kglobalacceld.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 2007 Andreas Hartmetz <[email protected]>
5  SPDX-FileCopyrightText: 2008 Michael Jansen <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 #ifndef KGLOBALACCELD_H
10 #define KGLOBALACCELD_H
11 
12 #include "kf5globalaccelprivate_export.h"
13 
14 #include <kglobalshortcutinfo.h>
15 
16 #include <QList>
17 #include <QStringList>
18 #include <QtDBus>
19 
20 struct KGlobalAccelDPrivate;
21 
22 /**
23  * @todo get rid of all of those QStringList parameters.
24  */
25 class KGLOBALACCELPRIVATE_EXPORT KGlobalAccelD : public QObject, protected QDBusContext
26 {
27  Q_OBJECT
28  Q_CLASSINFO("D-Bus Interface", "org.kde.KGlobalAccel")
29 
30 public:
31  enum SetShortcutFlag {
32  SetPresent = 2,
33  NoAutoloading = 4,
34  IsDefault = 8,
35  };
36  Q_ENUM(SetShortcutFlag)
37  Q_DECLARE_FLAGS(SetShortcutFlags, SetShortcutFlag)
39 
40  explicit KGlobalAccelD(QObject *parent = nullptr);
41  ~KGlobalAccelD();
42 
43  bool init();
44 
45 public Q_SLOTS:
46 
47  /**
48  * Get the dbus path for all known components.
49  *
50  * The returned path is absolute. No need to prepend anything.
51  */
52  Q_SCRIPTABLE QList<QDBusObjectPath> allComponents() const;
53 
54  Q_SCRIPTABLE QList<QStringList> allMainComponents() const;
55 
56  Q_SCRIPTABLE QList<QStringList> allActionsForComponent(const QStringList &actionId) const;
57 
58  Q_SCRIPTABLE QStringList action(int key) const;
59 
60  // to be called by main components not owning the action
61  Q_SCRIPTABLE QList<int> shortcut(const QStringList &actionId) const;
62 
63  // to be called by main components not owning the action
64  Q_SCRIPTABLE QList<int> defaultShortcut(const QStringList &actionId) const;
65 
66  /**
67  * Get the dbus path for @ componentUnique
68  *
69  * @param componentUnique the components unique identifier
70  *
71  * @return the absolute dbus path
72  */
73  Q_SCRIPTABLE QDBusObjectPath getComponent(const QString &componentUnique) const;
74 
75  // to be called by main components owning the action
76  Q_SCRIPTABLE QList<int> setShortcut(const QStringList &actionId, const QList<int> &keys, uint flags);
77 
78  // this is used if application A wants to change shortcuts of application B
79  Q_SCRIPTABLE void setForeignShortcut(const QStringList &actionId, const QList<int> &keys);
80 
81  // to be called when a KAction is destroyed. The shortcut stays in the data structures for
82  // conflict resolution but won't trigger.
83  Q_SCRIPTABLE void setInactive(const QStringList &actionId);
84 
85  Q_SCRIPTABLE void doRegister(const QStringList &actionId);
86 
87 #if KGLOBALACCELPRIVATE_ENABLE_DEPRECATED_SINCE(4, 3)
88  //! @deprecated Since 4.3, use KGlobalAccelD::unregister
89  KGLOBALACCELPRIVATE_DEPRECATED_VERSION(4, 3, "Use KGlobalAccelD::unregister(const QString&, const QString&")
90  Q_SCRIPTABLE void unRegister(const QStringList &actionId);
91 #endif
92 
93  Q_SCRIPTABLE void activateGlobalShortcutContext(const QString &component, const QString &context);
94 
95  /**
96  * Returns the shortcuts registered for @p key.
97  *
98  * If there is more than one shortcut they are guaranteed to be from the
99  * same component but different contexts. All shortcuts are searched.
100  */
101  Q_SCRIPTABLE QList<KGlobalShortcutInfo> getGlobalShortcutsByKey(int key) const;
102 
103  /**
104  * Return true if the @p shortcut is available for @p component.
105  */
106  Q_SCRIPTABLE bool isGlobalShortcutAvailable(int key, const QString &component) const;
107 
108  /**
109  * Delete the shortcut with @a component and @name.
110  *
111  * The shortcut is removed from the registry even if it is currently
112  * present. It is removed from all contexts.
113  *
114  * @param componentUnique the components unique identifier
115  * @param shortcutUnique the shortcut id
116  *
117  * @return @c true if the shortcuts was deleted, @c false if it didn't * exist.
118  */
119  Q_SCRIPTABLE bool unregister(const QString &componentUnique, const QString &shortcutUnique);
120 
121  Q_SCRIPTABLE void blockGlobalShortcuts(bool);
122 
123 Q_SIGNALS:
124 
125  Q_SCRIPTABLE void yourShortcutGotChanged(const QStringList &actionId, const QList<int> &newKeys);
126 
127 private:
128  void scheduleWriteSettings() const;
129 
130  KGlobalAccelDPrivate *const d;
131 };
132 
133 #endif // KGLOBALACCELD_H
Q_ENUM(...)
Q_CLASSINFO(Name, Value)
Q_FLAG(...)
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun May 16 2021 22:53:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.