KGlobalAccel

globalshortcut.h
1 /*
2  SPDX-FileCopyrightText: 2008 Michael Jansen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef GLOBALSHORTCUT_H
8 #define GLOBALSHORTCUT_H
9 
10 #include <KGlobalShortcutInfo>
11 
13 
14 /**
15  * Represents a global shortcut.
16  *
17  * @internal
18  *
19  * \note This class can handle multiple keys (default and active). This
20  * feature isn't used currently. kde4 only allows setting one key per global
21  * shortcut.
22  *
23  * @author Michael Jansen <[email protected]>
24  */
26 {
27 public:
30 
31  ~GlobalShortcut();
32 
33  //! Returns the context the shortcuts belongs to
35  GlobalShortcutContext const *context() const;
36 
37  //! Returns the default keys for this shortcut.
38  QList<int> defaultKeys() const;
39 
40  //! Return the friendly display name for this shortcut.
41  QString friendlyName() const;
42 
43  //! Check if the shortcut is active. It's keys are grabbed
44  bool isActive() const;
45 
46  //! Check if the shortcut is fresh/new. Is an internal state
47  bool isFresh() const;
48 
49  //! Check if the shortcut is present. It application is running.
50  bool isPresent() const;
51 
52  //! Returns true if the shortcut is a session shortcut
53  bool isSessionShortcut() const;
54 
55  //! Returns a list of keys associated with this shortcut.
56  QList<int> keys() const;
57 
58  //! Activates the shortcut. The keys are grabbed.
59  void setActive();
60 
61  //! Sets the default keys for this shortcut.
62  void setDefaultKeys(const QList<int>);
63 
64  //! Sets the friendly name for the shortcut. For display.
65  void setFriendlyName(const QString &);
66 
67  //! Sets the shortcut inactive. No longer grabs the keys.
68  void setInactive();
69 
70  void setIsPresent(bool);
71  void setIsFresh(bool);
72 
73  //! Sets the keys activated with this shortcut. The old keys are freed.
74  void setKeys(const QList<int>);
75 
76  //! Returns the unique name aka id for the shortcuts.
77  QString uniqueName() const;
78 
79  operator KGlobalShortcutInfo() const;
80 
81  //! Remove this shortcut and it's siblings
82  void unRegister();
83 
84 private:
85  //! means the associated application is present.
86  bool _isPresent : 1;
87 
88  //! means the shortcut is registered with GlobalShortcutsRegistry
89  bool _isRegistered : 1;
90 
91  //! means the shortcut is new
92  bool _isFresh : 1;
93 
94  //! The context the shortcut belongs too
95  GlobalShortcutContext *_context;
96 
97  QString _uniqueName;
98  QString _friendlyName; // usually localized
99 
100  QList<int> _keys;
101  QList<int> _defaultKeys;
102 };
103 
104 #endif /* #ifndef GLOBALSHORTCUT_H */
bool isFresh() const
Check if the shortcut is fresh/new. Is an internal state.
bool isPresent() const
Check if the shortcut is present. It application is running.
GlobalShortcutContext * context()
Returns the context the shortcuts belongs to.
void setInactive()
Sets the shortcut inactive. No longer grabs the keys.
QString uniqueName() const
Returns the unique name aka id for the shortcuts.
void setFriendlyName(const QString &)
Sets the friendly name for the shortcut. For display.
void unRegister()
Remove this shortcut and it&#39;s siblings.
Represents a global shortcut.
QList< int > keys() const
Returns a list of keys associated with this shortcut.
bool isActive() const
Check if the shortcut is active. It&#39;s keys are grabbed.
QList< int > defaultKeys() const
Returns the default keys for this shortcut.
void setKeys(const QList< int >)
Sets the keys activated with this shortcut. The old keys are freed.
void setActive()
Activates the shortcut. The keys are grabbed.
void setDefaultKeys(const QList< int >)
Sets the default keys for this shortcut.
bool isSessionShortcut() const
Returns true if the shortcut is a session shortcut.
QString friendlyName() const
Return the friendly display name for this shortcut.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon May 17 2021 22:53:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.