1 #ifndef GLOBALSHORTCUT_H
2 #define GLOBALSHORTCUT_H
3 /* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #include "kglobalshortcutinfo_p.h"
23 #include <QtCore/QObject>
26 class GlobalShortcutContext
;
29 * Represents a global shortcut.
33 * \note This class can handle multiple keys (default and active). This
34 * feature isn't used currently. kde4 only allows setting one key per global
37 * @author Michael Jansen <kde@michael-jansen.biz>
43 GlobalShortcut(const QString
&uniqueName
, const QString
&friendlyName
, GlobalShortcutContext
*context
);
48 //! Returns the context the shortcuts belongs to
49 GlobalShortcutContext
*context();
50 GlobalShortcutContext
const *context() const;
52 //! Returns the default keys for this shortcut.
53 QList
<int> defaultKeys() const;
55 //! Return the friendly display name for this shortcut.
56 QString
friendlyName() const;
58 //! Check if the shortcut is active. It's keys are grabbed
59 bool isActive() const;
61 //! Check if the shortcut is fresh/new. Is an internal state
64 //! Check if the shortcut is present. It application is running.
65 bool isPresent() const;
67 //! Returns true if the shortcut is a session shortcut
68 bool isSessionShortcut() const;
70 //! Returns a list of keys associated with this shortcut.
71 QList
<int> keys() const;
73 //! Activates the shortcut. The keys are grabbed.
76 //! Sets the default keys for this shortcut.
77 void setDefaultKeys(QList
<int>);
79 //! Sets the friendly name for the shortcut. For display.
80 void setFriendlyName(const QString
&);
82 //! Sets the shortcut inactive. No longer grabs the keys.
85 void setIsPresent(bool);
86 void setIsFresh(bool);
88 //! Sets the keys activated with this shortcut. The old keys are freed.
89 void setKeys(QList
<int>);
91 //! Returns the unique name aka id for the shortcuts.
92 QString
uniqueName() const;
94 operator KGlobalShortcutInfo () const;
98 //! means the associated application is present.
101 //! means the shortcut is registered with GlobalShortcutsRegistry
102 bool _isRegistered
:1;
104 //! means the shortcut is new
107 //! The context the shortcut belongs too
108 GlobalShortcutContext
*_context
;
111 QString _friendlyName
; //usually localized
114 QList
<int> _defaultKeys
;
118 #endif /* #ifndef GLOBALSHORTCUT_H */