1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #ifndef QGUIAPPLICATION_H
43 #define QGUIAPPLICATION_H
45 #include <QtCore/qcoreapplication.h>
46 #include <QtGui/qwindowdefs.h>
47 #include <QtGui/qinputmethod.h>
48 #include <QtCore/qlocale.h>
49 #include <QtCore/qpoint.h>
50 #include <QtCore/qsize.h>
57 class QGuiApplicationPrivate;
58 class QPlatformNativeInterface;
59 class QPlatformIntegration;
67 #define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
72 #define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
74 class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
77 Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
78 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
79 Q_PROPERTY(QString platformName READ platformName STORED false)
80 Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
84 QGuiApplication(int &argc, char **argv);
86 QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
88 virtual ~QGuiApplication();
90 static void setApplicationDisplayName(const QString &name);
91 static QString applicationDisplayName();
93 static QWindowList allWindows();
94 static QWindowList topLevelWindows();
95 static QWindow *topLevelAt(const QPoint &pos);
97 static QString platformName();
99 static QWindow *modalWindow();
101 static QWindow *focusWindow();
102 static QObject *focusObject();
104 static QScreen *primaryScreen();
105 static QList<QScreen *> screens();
108 static QCursor *overrideCursor();
109 static void setOverrideCursor(const QCursor &);
110 static void changeOverrideCursor(const QCursor &);
111 static void restoreOverrideCursor();
115 static void setFont(const QFont &);
117 #ifndef QT_NO_CLIPBOARD
118 static QClipboard *clipboard();
121 static QPalette palette();
122 static void setPalette(const QPalette &pal);
124 static Qt::KeyboardModifiers keyboardModifiers();
125 static Qt::KeyboardModifiers queryKeyboardModifiers();
126 static Qt::MouseButtons mouseButtons();
128 static void setLayoutDirection(Qt::LayoutDirection direction);
129 static Qt::LayoutDirection layoutDirection();
131 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
132 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
134 static QStyleHints *styleHints();
135 static void setDesktopSettingsAware(bool on);
136 static bool desktopSettingsAware();
138 static QInputMethod *inputMethod();
140 static QPlatformNativeInterface *platformNativeInterface();
142 static void setQuitOnLastWindowClosed(bool quit);
143 static bool quitOnLastWindowClosed();
146 bool notify(QObject *, QEvent *);
149 void fontDatabaseChanged();
150 void screenAdded(QScreen *screen);
151 void lastWindowClosed();
152 void focusObjectChanged(QObject *focusObject);
153 void focusWindowChanged(QWindow *focusWindow);
156 bool event(QEvent *);
157 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
159 QGuiApplication(QGuiApplicationPrivate &p);
162 Q_DISABLE_COPY(QGuiApplication)
163 Q_DECLARE_PRIVATE(QGuiApplication)
165 Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object))
167 #ifndef QT_NO_GESTURES
168 friend class QGestureManager;
170 friend class QFontDatabasePrivate;
171 friend class QPlatformIntegration;
178 #endif // QGUIAPPLICATION_H