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 | |
51 | QT_BEGIN_NAMESPACE |
52 | |
53 | |
54 | class QSessionManager; |
55 | class QGuiApplicationPrivate; |
56 | class QPlatformNativeInterface; |
57 | class QPlatformIntegration; |
58 | class QPalette; |
59 | class QScreen; |
60 | class 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 | |
72 | class 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 WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged) |
77 | Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName) |
78 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) |
79 | Q_PROPERTY(QString platformName READ platformName STORED false) |
80 | Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) |
81 | Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false) |
82 | |
83 | public: |
84 | #ifdef Q_QDOC |
85 | QGuiApplication(int &argc, char **argv); |
86 | #else |
87 | QGuiApplication(int &argc, char **argv, int = ApplicationFlags); |
88 | #endif |
89 | ~QGuiApplication(); |
90 | |
91 | static void setApplicationDisplayName(const QString &name); |
92 | static QString applicationDisplayName(); |
93 | |
94 | static void setDesktopFileName(const QString &name); |
95 | static QString desktopFileName(); |
96 | |
97 | static QWindowList allWindows(); |
98 | static QWindowList topLevelWindows(); |
99 | static QWindow *topLevelAt(const QPoint &pos); |
100 | |
101 | static void setWindowIcon(const QIcon &icon); |
102 | static QIcon windowIcon(); |
103 | |
104 | static QString platformName(); |
105 | |
106 | static QWindow *modalWindow(); |
107 | |
108 | static QWindow *focusWindow(); |
109 | static QObject *focusObject(); |
110 | |
111 | static QScreen *primaryScreen(); |
112 | static QList<QScreen *> screens(); |
113 | static QScreen *screenAt(const QPoint &point); |
114 | |
115 | qreal devicePixelRatio() const; |
116 | |
117 | #ifndef QT_NO_CURSOR |
118 | static QCursor *overrideCursor(); |
119 | static void setOverrideCursor(const QCursor &); |
120 | static void changeOverrideCursor(const QCursor &); |
121 | static void restoreOverrideCursor(); |
122 | #endif |
123 | |
124 | static QFont font(); |
125 | static void setFont(const QFont &); |
126 | |
127 | #ifndef QT_NO_CLIPBOARD |
128 | static QClipboard *clipboard(); |
129 | #endif |
130 | |
131 | static QPalette palette(); |
132 | static void setPalette(const QPalette &pal); |
133 | |
134 | static Qt::KeyboardModifiers keyboardModifiers(); |
135 | static Qt::KeyboardModifiers queryKeyboardModifiers(); |
136 | static Qt::MouseButtons mouseButtons(); |
137 | |
138 | static void setLayoutDirection(Qt::LayoutDirection direction); |
139 | static Qt::LayoutDirection layoutDirection(); |
140 | |
141 | static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; } |
142 | static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; } |
143 | |
144 | static QStyleHints *styleHints(); |
145 | static void setDesktopSettingsAware(bool on); |
146 | static bool desktopSettingsAware(); |
147 | |
148 | static QInputMethod *inputMethod(); |
149 | |
150 | static QPlatformNativeInterface *platformNativeInterface(); |
151 | |
152 | static QFunctionPointer platformFunction(const QByteArray &function); |
153 | |
154 | static void setQuitOnLastWindowClosed(bool quit); |
155 | static bool quitOnLastWindowClosed(); |
156 | |
157 | static Qt::ApplicationState applicationState(); |
158 | |
159 | static void setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy); |
160 | static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy(); |
161 | |
162 | static int exec(); |
163 | bool notify(QObject *, QEvent *) override; |
164 | |
165 | #ifndef QT_NO_SESSIONMANAGER |
166 | // session management |
167 | bool isSessionRestored() const; |
168 | QString sessionId() const; |
169 | QString sessionKey() const; |
170 | bool isSavingSession() const; |
171 | #endif |
172 | |
173 | static void sync(); |
174 | Q_SIGNALS: |
175 | void fontDatabaseChanged(); |
176 | void screenAdded(QScreen *screen); |
177 | void screenRemoved(QScreen *screen); |
178 | void primaryScreenChanged(QScreen *screen); |
179 | void lastWindowClosed(); |
180 | void focusObjectChanged(QObject *focusObject); |
181 | void focusWindowChanged(QWindow *focusWindow); |
182 | void applicationStateChanged(Qt::ApplicationState state); |
183 | void layoutDirectionChanged(Qt::LayoutDirection direction); |
184 | #ifndef QT_NO_SESSIONMANAGER |
185 | void commitDataRequest(QSessionManager &sessionManager); |
186 | void saveStateRequest(QSessionManager &sessionManager); |
187 | #endif |
188 | void applicationDisplayNameChanged(); |
189 | #if QT_DEPRECATED_SINCE(6, 0) |
190 | QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationPaletteChange instead" ) void paletteChanged(const QPalette &pal); |
191 | QT_DEPRECATED_VERSION_X_6_0("Handle QEvent::ApplicationFontChange instead" ) void fontChanged(const QFont &font); |
192 | #endif |
193 | protected: |
194 | bool event(QEvent *) override; |
195 | bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override; |
196 | |
197 | QGuiApplication(QGuiApplicationPrivate &p); |
198 | |
199 | private: |
200 | Q_DISABLE_COPY(QGuiApplication) |
201 | Q_DECLARE_PRIVATE(QGuiApplication) |
202 | |
203 | Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object)) |
204 | |
205 | #ifndef QT_NO_GESTURES |
206 | friend class QGestureManager; |
207 | #endif |
208 | friend class QFontDatabasePrivate; |
209 | friend class QPlatformIntegration; |
210 | #ifndef QT_NO_SESSIONMANAGER |
211 | friend class QPlatformSessionManager; |
212 | #endif |
213 | }; |
214 | |
215 | QT_END_NAMESPACE |
216 | |
217 | #endif // QGUIAPPLICATION_H |
218 | |