QIApplication.h revision 5680be749f1466c83b6739a10bff1db2909b786c
2N/A/** @file
2N/A *
2N/A * VBox frontends: Qt GUI ("VirtualBox"):
2N/A * VirtualBox Qt extensions: QIApplication class declaration
2N/A */
2N/A
2N/A/*
2N/A * Copyright (C) 2006-2007 Sun Microsystems, Inc.
2N/A *
2N/A * This file is part of VirtualBox Open Source Edition (OSE), as
2N/A * available from http://www.virtualbox.org. This file is free software;
2N/A * you can redistribute it and/or modify it under the terms of the GNU
2N/A * General Public License (GPL) as published by the Free Software
2N/A * Foundation, in version 2 as it comes in the "COPYING" file of the
2N/A * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2N/A * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2N/A *
2N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
2N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
2N/A * additional information or have any questions.
2N/A */
2N/A
2N/A#ifndef __QIApplication_h__
2N/A#define __QIApplication_h__
2N/A
2N/A/* Qt includes */
2N/A#include <QApplication>
2N/A
2N/Atypedef bool (*QIFilterCallback)(EventRef inEvent, void *inUserArg);
2N/A
2N/A
2N/A/** Sligtly modified QApplication class.
2N/A *
2N/A * The sole purpose of this class (ATM) is to hook the macEventFilter
2N/A * in order to intercept Command-Q, Command-H and similar menu hot-keys
2N/A * before the HI Manager translate them into (menu) command events and
2N/A * start blinking menus in the menu bar.
2N/A *
2N/A * @remark
2N/A * A special hack in qeventloop_mac.cpp is required for this
2N/A * to work. Overloading QEventLoop::processEvents isn't feasable
2N/A * unfortunately, thus the horrible hacks. Qt 4 does seem to provide
2N/A * an interface similar to the one we create here.
2N/A *
2N/A * Btw. is QI* the right right way to do this? Or should it perhapse
2N/A * be called VBoxQApplication or something?
2N/A */
2N/Aclass QIApplication : public QApplication
2N/A{
2N/Apublic:
2N/A QIApplication (int &argc, char **argv)
2N/A : QApplication (argc, argv)
2N/A#ifdef Q_WS_MAC
2N/A , m_callback (NULL)
2N/A , m_callbackUserArg (NULL)
2N/A#endif
2N/A {
2N/A }
2N/A
2N/A#ifdef Q_WS_MAC
2N/A bool macEventFilter (EventHandlerCallRef, EventRef inEvent)
2N/A {
2N/A if ( m_callback
2N/A && m_callback (inEvent, m_callbackUserArg))
2N/A return true;
2N/A return false;
2N/A }
2N/A
2N/A void setEventFilter (QIFilterCallback callback, void *inUserArg)
2N/A {
m_callback = callback;
m_callbackUserArg = inUserArg;
}
protected:
QIFilterCallback m_callback;
void *m_callbackUserArg;
public:
#endif
};
#endif // __QIApplication_h__