delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kdedglobalaccel / component.h
blobe2bb68f12fa3453ae851fcf84f460941d6a4d110
1 #ifndef COMPONENT_H
2 #define COMPONENT_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 "globalshortcut.h"
22 #include "kglobalshortcutinfo.h"
24 #include "kconfiggroup.h"
26 #include <QtCore/QObject>
27 #include <QtCore/QHash>
29 class GlobalShortcut;
30 class GlobalShortcutContext;
31 class GlobalShortcutsRegistry;
34 namespace KdeDGlobalAccel {
36 /**
37 * @author Michael Jansen <kde@michael-jansen.biz>
39 class Component : public QObject
41 Q_OBJECT
43 Q_CLASSINFO("D-Bus Interface", "org.kde.kdedglobalaccel.Component")
45 Q_SCRIPTABLE Q_PROPERTY( QString friendlyName READ friendlyName )
46 Q_SCRIPTABLE Q_PROPERTY( QString uniqueName READ uniqueName )
48 public:
50 //! Creates a new component. The component will be registered with @p
51 //! registry if specified and registered with dbus.
52 Component(
53 const QString &uniqueName,
54 const QString &friendlyName,
55 GlobalShortcutsRegistry *registry = NULL);
57 ~Component();
59 bool activateGlobalShortcutContext(const QString &uniqueName);
61 void activateShortcuts();
63 //! Returns all shortcuts in context @context
64 QList<GlobalShortcut *> allShortcuts(const QString &context = "default") const;
66 //! Creates the new global shortcut context @p context
67 bool createGlobalShortcutContext(const QString &context, const QString &friendlyName="");
69 //! Return the current context
70 GlobalShortcutContext* currentContext();
72 //! Return uniqueName converted to a valid dbus path
73 QDBusObjectPath dbusPath() const;
75 //! Deactivate all currently active shortcuts
76 void deactivateShortcuts(bool temporarily=false);
78 //! Returns the friendly name
79 QString friendlyName() const;
81 //! Returns the currently active shortcut for key
82 GlobalShortcut *getShortcutByKey(int key) const;
84 //! Returns the shortcut context @p name or NULL
85 GlobalShortcutContext *shortcutContext(const QString &name);
86 GlobalShortcutContext const *shortcutContext(const QString &name) const;
88 /**
89 * Returns the list of shortcuts (different context) registered with @p
90 * key.
92 QList<GlobalShortcut *> getShortcutsByKey(int key) const;
94 //! Returns the shortcut by unique name. Only the active context is
95 //! searched.
96 GlobalShortcut *getShortcutByName(
97 const QString &uniqueName,
98 const QString &context = "default") const;
101 * Check if @a key is available for component @p component
103 bool isShortcutAvailable(
104 int key,
105 const QString &component,
106 const QString &context) const;
108 //! Load the settings from config group @p config
109 void loadSettings(KConfigGroup &config);
111 //! Sets the human readable name for this component.
112 void setFriendlyName(const QString &);
114 QString uniqueName() const;
116 void writeSettings(KConfigGroup &config) const;
118 public Q_SLOTS:
119 // For dbus Q_SCRIPTABLE has to be on slots. Scriptable methods are not
120 // exported.
122 Q_SCRIPTABLE QStringList shortcutNames(const QString &context = "default") const;
124 //! Returns all shortcut in context @context
125 Q_SCRIPTABLE QList<KGlobalShortcutInfo> allShortcutInfos(const QString &context = "default") const;
127 //! Returns the shortcut contexts available for the component.
128 Q_SCRIPTABLE QStringList getShortcutContexts() const;
130 private:
132 QString _uniqueName;
133 //the name as it would be found in a magazine article about the application,
134 //possibly localized if a localized name exists.
135 QString _friendlyName;
137 GlobalShortcutsRegistry *_registry;
139 GlobalShortcutContext *_current;
140 QHash<QString, GlobalShortcutContext *> _contexts;
146 #endif /* #ifndef COMPONENT_H */