delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kdedglobalaccel / kglobalaccel_mac.h
blob7ad0bf40473dc308c7fd9d79dab00d75b347949d
1 /* This file is part of the KDE libraries
2 Copyright (C) 2006 Marijn Kruisselbrink <m.kruisselbrink@student.tue.nl>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef _KGLOBALACCEL_MAC_H
21 #define _KGLOBALACCEL_MAC_H
23 #include <QtGui/QWidget>
25 #include "kshortcut.h"
26 /* including kglobalaccel.h here because Carbon.h includes AssertMacros.h which
27 defines check(assertion) as nothing and breaks compilation */
28 #include "kglobalaccel.h"
30 #include <Carbon/Carbon.h>
32 template <class Key, class T> class QMap;
33 template <class T> class QList;
35 class GlobalShortcutsRegistry;
36 class KGlobalAccelImpl: public QWidget
38 Q_OBJECT
39 public:
40 KGlobalAccelImpl(GlobalShortcutsRegistry* owner);
41 ~KGlobalAccelImpl();
43 public:
44 /**
45 * This function registers or unregisters a certain key for global capture,
46 * depending on \b grab.
48 * Before destruction, every grabbed key will be released, so this
49 * object does not need to do any tracking.
51 * \param key the Qt keycode to grab or release.
52 * \param grab true to grab they key, false to release the key.
54 * \return true if successful, otherwise false.
56 bool grabKey(int key, bool grab);
58 /// Enable/disable all shortcuts. There will not be any grabbed shortcuts at this point.
59 void setEnabled(bool);
61 void keyboardLayoutChanged();
62 private:
63 friend OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void * inUserData);
64 /// Called by the carbon event handler when a key is pressed.
65 bool keyPressed(int key);
67 GlobalShortcutsRegistry* m_owner;
68 EventTargetRef m_eventTarget;
69 EventHandlerUPP m_eventHandler;
70 EventTypeSpec m_eventType[2];
71 EventHandlerRef m_curHandler;
72 QMap<int, QList<EventHotKeyRef> >* refs;
75 #endif // _KGLOBALACCEL_MAC_H