1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
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 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. |
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 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. |
24 | ** |
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. |
28 | ** |
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. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QAPPLICATION_H |
43 | #define QAPPLICATION_H |
44 | |
45 | #include <QtCore/qcoreapplication.h> |
46 | #include <QtGui/qwindowdefs.h> |
47 | #include <QtCore/qpoint.h> |
48 | #include <QtCore/qsize.h> |
49 | #include <QtGui/qcursor.h> |
50 | #ifdef QT_INCLUDE_COMPAT |
51 | # include <QtGui/qdesktopwidget.h> |
52 | #endif |
53 | #ifdef QT3_SUPPORT |
54 | # include <QtGui/qwidget.h> |
55 | # include <QtGui/qpalette.h> |
56 | #endif |
57 | #ifdef Q_WS_QWS |
58 | # include <QtGui/qrgb.h> |
59 | # include <QtGui/qtransportauth_qws.h> |
60 | #endif |
61 | |
62 | QT_BEGIN_HEADER |
63 | |
64 | #if defined(Q_OS_SYMBIAN) |
65 | class CApaApplication; |
66 | #endif |
67 | |
68 | QT_BEGIN_NAMESPACE |
69 | |
70 | QT_MODULE(Gui) |
71 | |
72 | class QSessionManager; |
73 | class QDesktopWidget; |
74 | class QStyle; |
75 | class QEventLoop; |
76 | class QIcon; |
77 | #ifndef QT_NO_IM |
78 | class QInputContext; |
79 | #endif |
80 | template <typename T> class QList; |
81 | class QLocale; |
82 | #if defined(Q_WS_QWS) |
83 | class QDecoration; |
84 | #elif defined(Q_WS_QPA) |
85 | class QPlatformNativeInterface; |
86 | #endif |
87 | #if defined(Q_OS_SYMBIAN) |
88 | class QSymbianEvent; |
89 | #endif |
90 | |
91 | class QApplication; |
92 | class QApplicationPrivate; |
93 | #if defined(qApp) |
94 | #undef qApp |
95 | #endif |
96 | #define qApp (static_cast<QApplication *>(QCoreApplication::instance())) |
97 | |
98 | |
99 | class Q_GUI_EXPORT QApplication : public QCoreApplication |
100 | { |
101 | Q_OBJECT |
102 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection) |
103 | Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) |
104 | Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime) |
105 | Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval) |
106 | Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval) |
107 | #ifndef QT_NO_WHEELEVENT |
108 | Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines) |
109 | #endif |
110 | Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut) |
111 | Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime) |
112 | Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) |
113 | Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) |
114 | #ifndef QT_NO_STYLE_STYLESHEET |
115 | Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) |
116 | #endif |
117 | #ifdef Q_WS_WINCE |
118 | Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold) |
119 | #endif |
120 | Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) |
121 | |
122 | public: |
123 | enum Type { Tty, GuiClient, GuiServer }; |
124 | |
125 | #ifdef Q_OS_SYMBIAN |
126 | typedef CApaApplication * (*QS60MainApplicationFactory)(); |
127 | #endif |
128 | |
129 | #ifndef qdoc |
130 | QApplication(int &argc, char **argv, int = ApplicationFlags); |
131 | QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); |
132 | QApplication(int &argc, char **argv, Type, int = ApplicationFlags); |
133 | #if defined(Q_WS_X11) |
134 | QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); |
135 | QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags); |
136 | #endif |
137 | #if defined(Q_OS_SYMBIAN) |
138 | QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags); |
139 | #endif |
140 | #endif |
141 | virtual ~QApplication(); |
142 | |
143 | static Type type(); |
144 | |
145 | static QStyle *style(); |
146 | static void setStyle(QStyle*); |
147 | static QStyle *setStyle(const QString&); |
148 | enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; |
149 | static int colorSpec(); |
150 | static void setColorSpec(int); |
151 | static void setGraphicsSystem(const QString &); |
152 | |
153 | #ifndef QT_NO_CURSOR |
154 | static QCursor *overrideCursor(); |
155 | static void setOverrideCursor(const QCursor &); |
156 | static void changeOverrideCursor(const QCursor &); |
157 | static void restoreOverrideCursor(); |
158 | #endif |
159 | static QPalette palette(); |
160 | static QPalette palette(const QWidget *); |
161 | static QPalette palette(const char *className); |
162 | static void setPalette(const QPalette &, const char* className = 0); |
163 | static QFont font(); |
164 | static QFont font(const QWidget*); |
165 | static QFont font(const char *className); |
166 | static void setFont(const QFont &, const char* className = 0); |
167 | static QFontMetrics fontMetrics(); |
168 | |
169 | static void setWindowIcon(const QIcon &icon); |
170 | static QIcon windowIcon(); |
171 | |
172 | |
173 | #ifdef QT3_SUPPORT |
174 | static QT3_SUPPORT QWidget *mainWidget(); |
175 | static QT3_SUPPORT void setMainWidget(QWidget *); |
176 | #endif |
177 | |
178 | static QWidgetList allWidgets(); |
179 | static QWidgetList topLevelWidgets(); |
180 | |
181 | static QDesktopWidget *desktop(); |
182 | |
183 | static QWidget *(); |
184 | static QWidget *activeModalWidget(); |
185 | #ifndef QT_NO_CLIPBOARD |
186 | static QClipboard *clipboard(); |
187 | #endif |
188 | static QWidget *focusWidget(); |
189 | |
190 | static QWidget *activeWindow(); |
191 | static void setActiveWindow(QWidget* act); |
192 | |
193 | static QWidget *widgetAt(const QPoint &p); |
194 | static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); } |
195 | static QWidget *topLevelAt(const QPoint &p); |
196 | static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } |
197 | |
198 | static void syncX(); |
199 | static void beep(); |
200 | static void alert(QWidget *widget, int duration = 0); |
201 | |
202 | static Qt::KeyboardModifiers keyboardModifiers(); |
203 | static Qt::KeyboardModifiers queryKeyboardModifiers(); |
204 | static Qt::MouseButtons mouseButtons(); |
205 | |
206 | static void setDesktopSettingsAware(bool); |
207 | static bool desktopSettingsAware(); |
208 | |
209 | static void setCursorFlashTime(int); |
210 | static int cursorFlashTime(); |
211 | |
212 | static void setDoubleClickInterval(int); |
213 | static int doubleClickInterval(); |
214 | |
215 | static void setKeyboardInputInterval(int); |
216 | static int keyboardInputInterval(); |
217 | |
218 | #ifndef QT_NO_WHEELEVENT |
219 | static void setWheelScrollLines(int); |
220 | static int wheelScrollLines(); |
221 | #endif |
222 | static void setGlobalStrut(const QSize &); |
223 | static QSize globalStrut(); |
224 | |
225 | static void setStartDragTime(int ms); |
226 | static int startDragTime(); |
227 | static void setStartDragDistance(int l); |
228 | static int startDragDistance(); |
229 | |
230 | static void setLayoutDirection(Qt::LayoutDirection direction); |
231 | static Qt::LayoutDirection layoutDirection(); |
232 | |
233 | static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; } |
234 | static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; } |
235 | |
236 | static bool isEffectEnabled(Qt::UIEffect); |
237 | static void setEffectEnabled(Qt::UIEffect, bool enable = true); |
238 | |
239 | #if defined(Q_WS_MAC) |
240 | virtual bool macEventFilter(EventHandlerCallRef, EventRef); |
241 | #endif |
242 | #if defined(Q_WS_X11) |
243 | virtual bool x11EventFilter(XEvent *); |
244 | virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); |
245 | int x11ProcessEvent(XEvent*); |
246 | #endif |
247 | #if defined(Q_OS_SYMBIAN) |
248 | int symbianProcessEvent(const QSymbianEvent *event); |
249 | virtual bool symbianEventFilter(const QSymbianEvent *event); |
250 | #endif |
251 | #if defined(Q_WS_QWS) |
252 | virtual bool qwsEventFilter(QWSEvent *); |
253 | int qwsProcessEvent(QWSEvent*); |
254 | void qwsSetCustomColors(QRgb *colortable, int start, int numColors); |
255 | #ifndef QT_NO_QWS_MANAGER |
256 | static QDecoration &qwsDecoration(); |
257 | static void qwsSetDecoration(QDecoration *); |
258 | static QDecoration *qwsSetDecoration(const QString &decoration); |
259 | #endif |
260 | #endif |
261 | |
262 | #if defined(Q_WS_QPA) |
263 | static QPlatformNativeInterface *platformNativeInterface(); |
264 | #endif |
265 | |
266 | |
267 | #if defined(Q_WS_WIN) |
268 | void winFocus(QWidget *, bool); |
269 | static void winMouseButtonUp(); |
270 | #endif |
271 | #ifndef QT_NO_SESSIONMANAGER |
272 | // session management |
273 | bool isSessionRestored() const; |
274 | QString sessionId() const; |
275 | QString sessionKey() const; |
276 | virtual void commitData(QSessionManager& sm); |
277 | virtual void saveState(QSessionManager& sm); |
278 | #endif |
279 | |
280 | #ifndef QT_NO_IM |
281 | void setInputContext(QInputContext *); |
282 | QInputContext *inputContext() const; |
283 | #endif |
284 | |
285 | static QLocale keyboardInputLocale(); |
286 | static Qt::LayoutDirection keyboardInputDirection(); |
287 | |
288 | static int exec(); |
289 | bool notify(QObject *, QEvent *); |
290 | |
291 | |
292 | static void setQuitOnLastWindowClosed(bool quit); |
293 | static bool quitOnLastWindowClosed(); |
294 | |
295 | #ifdef QT_KEYPAD_NAVIGATION |
296 | static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool); |
297 | static bool keypadNavigationEnabled(); |
298 | static void setNavigationMode(Qt::NavigationMode mode); |
299 | static Qt::NavigationMode navigationMode(); |
300 | #endif |
301 | |
302 | Q_SIGNALS: |
303 | void lastWindowClosed(); |
304 | void focusChanged(QWidget *old, QWidget *now); |
305 | void fontDatabaseChanged(); |
306 | #ifndef QT_NO_SESSIONMANAGER |
307 | void commitDataRequest(QSessionManager &sessionManager); |
308 | void saveStateRequest(QSessionManager &sessionManager); |
309 | #endif |
310 | #ifdef Q_OS_SYMBIAN |
311 | void aboutToReleaseGpuResources(); |
312 | void aboutToUseGpuResources(); |
313 | #endif |
314 | |
315 | public: |
316 | QString styleSheet() const; |
317 | public Q_SLOTS: |
318 | #ifndef QT_NO_STYLE_STYLESHEET |
319 | void setStyleSheet(const QString& sheet); |
320 | #endif |
321 | #ifdef Q_WS_WINCE |
322 | void setAutoMaximizeThreshold(const int threshold); |
323 | int autoMaximizeThreshold() const; |
324 | #endif |
325 | void setAutoSipEnabled(const bool enabled); |
326 | bool autoSipEnabled() const; |
327 | static void closeAllWindows(); |
328 | static void aboutQt(); |
329 | |
330 | protected: |
331 | #if defined(Q_WS_QWS) |
332 | void setArgs(int, char **); |
333 | #endif |
334 | bool event(QEvent *); |
335 | bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); |
336 | |
337 | #ifdef QT3_SUPPORT |
338 | public: |
339 | static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); } |
340 | static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; } |
341 | static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align); |
342 | typedef int ColorMode; |
343 | enum { NormalColors = NormalColor, CustomColors = CustomColor }; |
344 | static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); } |
345 | static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); } |
346 | #if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) |
347 | static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; } |
348 | #endif |
349 | #if defined(Q_OS_MAC) |
350 | static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; } |
351 | #endif |
352 | # ifndef QT_NO_CURSOR |
353 | inline static QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace) |
354 | { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); } |
355 | # endif |
356 | inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;} |
357 | inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {} |
358 | inline static QT3_SUPPORT void flushX() { flush(); } |
359 | static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) { |
360 | QPalette p(palette()); |
361 | p.setColor(QPalette::Highlight, c); |
362 | setPalette(p); |
363 | } |
364 | static inline QT3_SUPPORT const QColor &winStyleHighlightColor() |
365 | { return palette().color(QPalette::Active, QPalette::Highlight); } |
366 | static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0) |
367 | { setPalette(pal, className); } |
368 | static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0) |
369 | { setFont(font, className); } |
370 | |
371 | static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child) |
372 | { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); } |
373 | static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child) |
374 | { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); } |
375 | #endif // QT3_SUPPORT |
376 | |
377 | #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) |
378 | QApplication(int &argc, char **argv); |
379 | QApplication(int &argc, char **argv, bool GUIenabled); |
380 | QApplication(int &argc, char **argv, Type); |
381 | #if defined(Q_WS_X11) |
382 | QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); |
383 | QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); |
384 | #endif |
385 | #if defined(Q_OS_SYMBIAN) || defined(qdoc) |
386 | QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv); |
387 | #endif |
388 | #endif |
389 | |
390 | private: |
391 | Q_DISABLE_COPY(QApplication) |
392 | Q_DECLARE_PRIVATE(QApplication) |
393 | |
394 | friend class QGraphicsWidget; |
395 | friend class QGraphicsItem; |
396 | friend class QGraphicsScene; |
397 | friend class QGraphicsScenePrivate; |
398 | friend class QWidget; |
399 | friend class QWidgetPrivate; |
400 | friend class QETWidget; |
401 | friend class Q3AccelManager; |
402 | friend class QTranslator; |
403 | friend class QWidgetAnimator; |
404 | #ifndef QT_NO_SHORTCUT |
405 | friend class QShortcut; |
406 | friend class QLineEdit; |
407 | friend class QTextControl; |
408 | #endif |
409 | friend class QAction; |
410 | friend class QFontDatabasePrivate; |
411 | |
412 | #if defined(Q_WS_QWS) |
413 | friend class QInputContext; |
414 | friend class QWSDirectPainterSurface; |
415 | friend class QDirectPainter; |
416 | friend class QDirectPainterPrivate; |
417 | #endif |
418 | #ifndef QT_NO_GESTURES |
419 | friend class QGestureManager; |
420 | #endif |
421 | |
422 | #if defined(Q_WS_MAC) || defined(Q_WS_X11) |
423 | Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) |
424 | #endif |
425 | #if defined(QT_RX71_MULTITOUCH) |
426 | Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) |
427 | #endif |
428 | #if defined(Q_OS_SYMBIAN) |
429 | Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit()) |
430 | #endif |
431 | }; |
432 | |
433 | QT_END_NAMESPACE |
434 | |
435 | QT_END_HEADER |
436 | |
437 | #endif // QAPPLICATION_H |
438 | |