1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QGUIAPPLICATION_H
41#define QGUIAPPLICATION_H
42
43#include <QtGui/qtguiglobal.h>
44#include <QtCore/qcoreapplication.h>
45#include <QtGui/qwindowdefs.h>
46#include <QtGui/qinputmethod.h>
47#include <QtCore/qlocale.h>
48#include <QtCore/qpoint.h>
49#include <QtCore/qsize.h>
50
51QT_BEGIN_NAMESPACE
52
53
54class QSessionManager;
55class QGuiApplicationPrivate;
56class QPlatformNativeInterface;
57class QPlatformIntegration;
58class QPalette;
59class QScreen;
60class QStyleHints;
61
62#if defined(qApp)
63#undef qApp
64#endif
65#define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
66
67#if defined(qGuiApp)
68#undef qGuiApp
69#endif
70#define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
71
72class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
73{
74 Q_OBJECT
75 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
76 Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName
77 WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged)
78 Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
79 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection
80 NOTIFY layoutDirectionChanged)
81 Q_PROPERTY(QString platformName READ platformName STORED false)
82 Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed
83 WRITE setQuitOnLastWindowClosed)
84 Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false)
85
86public:
87#ifdef Q_QDOC
88 QGuiApplication(int &argc, char **argv);
89#else
90 QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
91#endif
92 ~QGuiApplication();
93
94 static void setApplicationDisplayName(const QString &name);
95 static QString applicationDisplayName();
96
97 static void setDesktopFileName(const QString &name);
98 static QString desktopFileName();
99
100 static QWindowList allWindows();
101 static QWindowList topLevelWindows();
102 static QWindow *topLevelAt(const QPoint &pos);
103
104 static void setWindowIcon(const QIcon &icon);
105 static QIcon windowIcon();
106
107 static QString platformName();
108
109 static QWindow *modalWindow();
110
111 static QWindow *focusWindow();
112 static QObject *focusObject();
113
114 static QScreen *primaryScreen();
115 static QList<QScreen *> screens();
116 static QScreen *screenAt(const QPoint &point);
117
118 qreal devicePixelRatio() const;
119
120#ifndef QT_NO_CURSOR
121 static QCursor *overrideCursor();
122 static void setOverrideCursor(const QCursor &);
123 static void changeOverrideCursor(const QCursor &);
124 static void restoreOverrideCursor();
125#endif
126
127 static QFont font();
128 static void setFont(const QFont &);
129
130#ifndef QT_NO_CLIPBOARD
131 static QClipboard *clipboard();
132#endif
133
134 static QPalette palette();
135 static void setPalette(const QPalette &pal);
136
137 static Qt::KeyboardModifiers keyboardModifiers();
138 static Qt::KeyboardModifiers queryKeyboardModifiers();
139 static Qt::MouseButtons mouseButtons();
140
141 static void setLayoutDirection(Qt::LayoutDirection direction);
142 static Qt::LayoutDirection layoutDirection();
143
144 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
145 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
146
147 static QStyleHints *styleHints();
148 static void setDesktopSettingsAware(bool on);
149 static bool desktopSettingsAware();
150
151 static QInputMethod *inputMethod();
152
153 static QPlatformNativeInterface *platformNativeInterface();
154
155 static QFunctionPointer platformFunction(const QByteArray &function);
156
157 static void setQuitOnLastWindowClosed(bool quit);
158 static bool quitOnLastWindowClosed();
159
160 static Qt::ApplicationState applicationState();
161
162 static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy);
163 static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy();
164
165 static int exec();
166 bool notify(QObject *, QEvent *) override;
167
168#ifndef QT_NO_SESSIONMANAGER
169 // session management
170 bool isSessionRestored() const;
171 QString sessionId() const;
172 QString sessionKey() const;
173 bool isSavingSession() const;
174#endif
175
176 QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication)
177
178 static void sync();
179Q_SIGNALS:
180 void fontDatabaseChanged();
181 void screenAdded(QScreen *screen);
182 void screenRemoved(QScreen *screen);
183 void primaryScreenChanged(QScreen *screen);
184 void lastWindowClosed();
185 void focusObjectChanged(QObject *focusObject);
186 void focusWindowChanged(QWindow *focusWindow);
187 void applicationStateChanged(Qt::ApplicationState state);
188 void layoutDirectionChanged(Qt::LayoutDirection direction);
189#ifndef QT_NO_SESSIONMANAGER
190 void commitDataRequest(QSessionManager &sessionManager);
191 void saveStateRequest(QSessionManager &sessionManager);
192#endif
193 void applicationDisplayNameChanged();
194#if QT_DEPRECATED_SINCE(6, 0)
195 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationPaletteChange instead") void paletteChanged(const QPalette &pal);
196 QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationFontChange instead") void fontChanged(const QFont &font);
197#endif
198protected:
199 bool event(QEvent *) override;
200 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
201
202 QGuiApplication(QGuiApplicationPrivate &p);
203
204private:
205 Q_DISABLE_COPY(QGuiApplication)
206 Q_DECLARE_PRIVATE(QGuiApplication)
207
208 Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object))
209
210#ifndef QT_NO_GESTURES
211 friend class QGestureManager;
212#endif
213 friend class QFontDatabasePrivate;
214 friend class QPlatformIntegration;
215#ifndef QT_NO_SESSIONMANAGER
216 friend class QPlatformSessionManager;
217#endif
218};
219
220QT_END_NAMESPACE
221
222#include <QtGui/qguiapplication_platform.h>
223
224#endif // QGUIAPPLICATION_H
225

source code of qtbase/src/gui/kernel/qguiapplication.h