1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
4 | * innotek Qt extensions: QIApplication class declaration
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License as published by the Free Software Foundation,
|
---|
14 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
15 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
16 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | *
|
---|
18 | * If you received this file as part of a commercial VirtualBox
|
---|
19 | * distribution, then only the terms of your commercial VirtualBox
|
---|
20 | * license agreement apply instead of the previous paragraph.
|
---|
21 | */
|
---|
22 |
|
---|
23 | #ifndef __QIApplication_h__
|
---|
24 | #define __QIApplication_h__
|
---|
25 |
|
---|
26 | #include <qapplication.h>
|
---|
27 |
|
---|
28 | typedef bool (*QIFilterCallback)(EventRef inEvent, void *inUserArg);
|
---|
29 |
|
---|
30 |
|
---|
31 | /** Sligtly modified QApplication class.
|
---|
32 | *
|
---|
33 | * The sole purpose of this class (ATM) is to hook the macEventFilter
|
---|
34 | * in order to intercept Command-Q, Command-H and similar menu hot-keys
|
---|
35 | * before the HI Manager translate them into (menu) command events and
|
---|
36 | * start blinking menus in the menu bar.
|
---|
37 | *
|
---|
38 | * @remark
|
---|
39 | * A special hack in qeventloop_mac.cpp is required for this
|
---|
40 | * to work. Overloading QEventLoop::processEvents isn't feasable
|
---|
41 | * unfortunately, thus the horrible hacks. Qt 4 does seem to provide
|
---|
42 | * an interface similar to the one we create here.
|
---|
43 | *
|
---|
44 | * Btw. is QI* the right right way to do this? Or should it perhapse
|
---|
45 | * be called VBoxQApplication or something?
|
---|
46 | */
|
---|
47 | class QIApplication : public QApplication
|
---|
48 | {
|
---|
49 | public:
|
---|
50 | QIApplication (int &argc, char **argv)
|
---|
51 | : QApplication (argc, argv)
|
---|
52 | #ifdef Q_WS_MAC
|
---|
53 | , m_callback (NULL)
|
---|
54 | , m_callbackUserArg (NULL)
|
---|
55 | #endif
|
---|
56 | {
|
---|
57 | }
|
---|
58 |
|
---|
59 | #ifdef Q_WS_MAC
|
---|
60 | bool macEventFilter (EventHandlerCallRef, EventRef inEvent)
|
---|
61 | {
|
---|
62 | if ( m_callback
|
---|
63 | && m_callback (inEvent, m_callbackUserArg))
|
---|
64 | return true;
|
---|
65 | return false;
|
---|
66 | }
|
---|
67 |
|
---|
68 | void setEventFilter (QIFilterCallback callback, void *inUserArg)
|
---|
69 | {
|
---|
70 | m_callback = callback;
|
---|
71 | m_callbackUserArg = inUserArg;
|
---|
72 | }
|
---|
73 |
|
---|
74 | protected:
|
---|
75 | QIFilterCallback m_callback;
|
---|
76 | void *m_callbackUserArg;
|
---|
77 |
|
---|
78 | public:
|
---|
79 | #endif
|
---|
80 | };
|
---|
81 |
|
---|
82 |
|
---|
83 | #endif // __QIApplication_h__
|
---|
84 |
|
---|