1#ifndef GLOBALSHORTCUTCONTEXT_H
2#define GLOBALSHORTCUTCONTEXT_H
3/* Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
4
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.
9
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.
14
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.
19*/
20
21#include "kglobalshortcutinfo.h"
22
23#include <QtCore/QString>
24#include <QtCore/QHash>
25
26namespace KdeDGlobalAccel {
27 class Component;
28}
29
30class GlobalShortcut;
31
32/**
33 * @author Michael Jansen <kde@michael-jansen.biz>
34 */
35class GlobalShortcutContext
36 {
37public:
38
39 /**
40 * Default constructor
41 */
42 GlobalShortcutContext(
43 const QString &uniqueName,
44 const QString &friendlyName,
45 KdeDGlobalAccel::Component *component );
46
47 /**
48 * Destructor
49 */
50 virtual ~GlobalShortcutContext();
51
52 //! Adds @p shortcut to the context
53 void addShortcut(GlobalShortcut *shortcut);
54
55 //! Return KGlobalShortcutInfos for all shortcuts
56 QList<KGlobalShortcutInfo> allShortcutInfos() const;
57
58 /**
59 * Get the name for the context
60 */
61 QString uniqueName() const;
62 QString friendlyName() const;
63
64 KdeDGlobalAccel::Component *component();
65 KdeDGlobalAccel::Component const *component() const;
66
67 //! Get shortcut for @p key or NULL
68 GlobalShortcut *getShortcutByKey(int key) const;
69
70 //! Remove @p shortcut from the context. The shortcut is not deleted.
71 GlobalShortcut *takeShortcut(GlobalShortcut *shortcut);
72
73private:
74
75 friend class KdeDGlobalAccel::Component;
76
77 //! The unique name for this context
78 QString _uniqueName;
79
80 //! The unique name for this context
81 QString _friendlyName;
82
83 //! The component the context belongs too
84 KdeDGlobalAccel::Component *_component;
85
86 //! The actions associated with this context
87 QHash<QString, GlobalShortcut*> _actions;
88};
89
90
91#endif /* #ifndef GLOBALSHORTCUTCONTEXT_H */
92