VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/QIApplication.h@ 5999

Last change on this file since 5999 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
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 (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __QIApplication_h__
20#define __QIApplication_h__
21
22#include <qapplication.h>
23
24typedef bool (*QIFilterCallback)(EventRef inEvent, void *inUserArg);
25
26
27/** Sligtly modified QApplication class.
28 *
29 * The sole purpose of this class (ATM) is to hook the macEventFilter
30 * in order to intercept Command-Q, Command-H and similar menu hot-keys
31 * before the HI Manager translate them into (menu) command events and
32 * start blinking menus in the menu bar.
33 *
34 * @remark
35 * A special hack in qeventloop_mac.cpp is required for this
36 * to work. Overloading QEventLoop::processEvents isn't feasable
37 * unfortunately, thus the horrible hacks. Qt 4 does seem to provide
38 * an interface similar to the one we create here.
39 *
40 * Btw. is QI* the right right way to do this? Or should it perhapse
41 * be called VBoxQApplication or something?
42 */
43class QIApplication : public QApplication
44{
45public:
46 QIApplication (int &argc, char **argv)
47 : QApplication (argc, argv)
48#ifdef Q_WS_MAC
49 , m_callback (NULL)
50 , m_callbackUserArg (NULL)
51#endif
52 {
53 }
54
55#ifdef Q_WS_MAC
56 bool macEventFilter (EventHandlerCallRef, EventRef inEvent)
57 {
58 if ( m_callback
59 && m_callback (inEvent, m_callbackUserArg))
60 return true;
61 return false;
62 }
63
64 void setEventFilter (QIFilterCallback callback, void *inUserArg)
65 {
66 m_callback = callback;
67 m_callbackUserArg = inUserArg;
68 }
69
70protected:
71 QIFilterCallback m_callback;
72 void *m_callbackUserArg;
73
74public:
75#endif
76};
77
78
79#endif // __QIApplication_h__
80
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette