|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
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_WS_S60) |
|
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 class QInputContext; |
|
78 template <typename T> class QList; |
|
79 class QLocale; |
|
80 #if defined(Q_WS_QWS) |
|
81 class QDecoration; |
|
82 #endif |
|
83 #if defined(Q_OS_SYMBIAN) |
|
84 class QSymbianEvent; |
|
85 #endif |
|
86 |
|
87 class QApplication; |
|
88 class QApplicationPrivate; |
|
89 class QGestureRecognizer; |
|
90 #if defined(qApp) |
|
91 #undef qApp |
|
92 #endif |
|
93 #define qApp (static_cast<QApplication *>(QCoreApplication::instance())) |
|
94 |
|
95 |
|
96 class Q_GUI_EXPORT QApplication : public QCoreApplication |
|
97 { |
|
98 Q_OBJECT |
|
99 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection) |
|
100 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) |
|
101 Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime) |
|
102 Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval) |
|
103 Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval) |
|
104 #ifndef QT_NO_WHEELEVENT |
|
105 Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines) |
|
106 #endif |
|
107 Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut) |
|
108 Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime) |
|
109 Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) |
|
110 Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) |
|
111 #ifndef QT_NO_STYLE_STYLESHEET |
|
112 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) |
|
113 #endif |
|
114 #ifdef Q_WS_WINCE |
|
115 Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold) |
|
116 #endif |
|
117 Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) |
|
118 |
|
119 public: |
|
120 enum Type { Tty, GuiClient, GuiServer }; |
|
121 |
|
122 #ifdef Q_WS_S60 |
|
123 typedef CApaApplication * (*QS60MainApplicationFactory)(); |
|
124 #endif |
|
125 |
|
126 #ifndef qdoc |
|
127 QApplication(int &argc, char **argv, int = QT_VERSION); |
|
128 QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION); |
|
129 QApplication(int &argc, char **argv, Type, int = QT_VERSION); |
|
130 #if defined(Q_WS_X11) |
|
131 QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION); |
|
132 QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION); |
|
133 #endif |
|
134 #if defined(Q_WS_S60) |
|
135 QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION); |
|
136 #endif |
|
137 #endif |
|
138 virtual ~QApplication(); |
|
139 |
|
140 static Type type(); |
|
141 |
|
142 static QStyle *style(); |
|
143 static void setStyle(QStyle*); |
|
144 static QStyle *setStyle(const QString&); |
|
145 enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }; |
|
146 static int colorSpec(); |
|
147 static void setColorSpec(int); |
|
148 static void setGraphicsSystem(const QString &); |
|
149 |
|
150 #ifndef QT_NO_CURSOR |
|
151 static QCursor *overrideCursor(); |
|
152 static void setOverrideCursor(const QCursor &); |
|
153 static void changeOverrideCursor(const QCursor &); |
|
154 static void restoreOverrideCursor(); |
|
155 #endif |
|
156 static QPalette palette(); |
|
157 static QPalette palette(const QWidget *); |
|
158 static QPalette palette(const char *className); |
|
159 static void setPalette(const QPalette &, const char* className = 0); |
|
160 static QFont font(); |
|
161 static QFont font(const QWidget*); |
|
162 static QFont font(const char *className); |
|
163 static void setFont(const QFont &, const char* className = 0); |
|
164 static QFontMetrics fontMetrics(); |
|
165 |
|
166 static void setWindowIcon(const QIcon &icon); |
|
167 static QIcon windowIcon(); |
|
168 |
|
169 |
|
170 #ifdef QT3_SUPPORT |
|
171 static QT3_SUPPORT QWidget *mainWidget(); |
|
172 static QT3_SUPPORT void setMainWidget(QWidget *); |
|
173 #endif |
|
174 |
|
175 static QWidgetList allWidgets(); |
|
176 static QWidgetList topLevelWidgets(); |
|
177 |
|
178 static QDesktopWidget *desktop(); |
|
179 |
|
180 static QWidget *activePopupWidget(); |
|
181 static QWidget *activeModalWidget(); |
|
182 #ifndef QT_NO_CLIPBOARD |
|
183 static QClipboard *clipboard(); |
|
184 #endif |
|
185 static QWidget *focusWidget(); |
|
186 |
|
187 static QWidget *activeWindow(); |
|
188 static void setActiveWindow(QWidget* act); |
|
189 |
|
190 static QWidget *widgetAt(const QPoint &p); |
|
191 static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); } |
|
192 static QWidget *topLevelAt(const QPoint &p); |
|
193 static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } |
|
194 |
|
195 static void syncX(); |
|
196 static void beep(); |
|
197 static void alert(QWidget *widget, int duration = 0); |
|
198 |
|
199 static Qt::KeyboardModifiers keyboardModifiers(); |
|
200 static Qt::MouseButtons mouseButtons(); |
|
201 |
|
202 static void setDesktopSettingsAware(bool); |
|
203 static bool desktopSettingsAware(); |
|
204 |
|
205 static void setCursorFlashTime(int); |
|
206 static int cursorFlashTime(); |
|
207 |
|
208 static void setDoubleClickInterval(int); |
|
209 static int doubleClickInterval(); |
|
210 |
|
211 static void setKeyboardInputInterval(int); |
|
212 static int keyboardInputInterval(); |
|
213 |
|
214 #ifndef QT_NO_WHEELEVENT |
|
215 static void setWheelScrollLines(int); |
|
216 static int wheelScrollLines(); |
|
217 #endif |
|
218 static void setGlobalStrut(const QSize &); |
|
219 static QSize globalStrut(); |
|
220 |
|
221 static void setStartDragTime(int ms); |
|
222 static int startDragTime(); |
|
223 static void setStartDragDistance(int l); |
|
224 static int startDragDistance(); |
|
225 |
|
226 static void setLayoutDirection(Qt::LayoutDirection direction); |
|
227 static Qt::LayoutDirection layoutDirection(); |
|
228 |
|
229 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; } |
|
230 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; } |
|
231 |
|
232 static bool isEffectEnabled(Qt::UIEffect); |
|
233 static void setEffectEnabled(Qt::UIEffect, bool enable = true); |
|
234 |
|
235 #if defined(Q_WS_MAC) |
|
236 virtual bool macEventFilter(EventHandlerCallRef, EventRef); |
|
237 #endif |
|
238 #if defined(Q_WS_X11) |
|
239 virtual bool x11EventFilter(XEvent *); |
|
240 virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); |
|
241 int x11ProcessEvent(XEvent*); |
|
242 #endif |
|
243 #if defined(Q_OS_SYMBIAN) |
|
244 int symbianProcessEvent(const QSymbianEvent *event); |
|
245 virtual bool symbianEventFilter(const QSymbianEvent *event); |
|
246 #endif |
|
247 #if defined(Q_WS_QWS) |
|
248 virtual bool qwsEventFilter(QWSEvent *); |
|
249 int qwsProcessEvent(QWSEvent*); |
|
250 void qwsSetCustomColors(QRgb *colortable, int start, int numColors); |
|
251 #ifndef QT_NO_QWS_MANAGER |
|
252 static QDecoration &qwsDecoration(); |
|
253 static void qwsSetDecoration(QDecoration *); |
|
254 static QDecoration *qwsSetDecoration(const QString &decoration); |
|
255 #endif |
|
256 #endif |
|
257 |
|
258 |
|
259 #if defined(Q_WS_WIN) |
|
260 void winFocus(QWidget *, bool); |
|
261 static void winMouseButtonUp(); |
|
262 #endif |
|
263 #ifndef QT_NO_SESSIONMANAGER |
|
264 // session management |
|
265 bool isSessionRestored() const; |
|
266 QString sessionId() const; |
|
267 QString sessionKey() const; |
|
268 virtual void commitData(QSessionManager& sm); |
|
269 virtual void saveState(QSessionManager& sm); |
|
270 #endif |
|
271 void setInputContext(QInputContext *); |
|
272 QInputContext *inputContext() const; |
|
273 |
|
274 static QLocale keyboardInputLocale(); |
|
275 static Qt::LayoutDirection keyboardInputDirection(); |
|
276 |
|
277 static int exec(); |
|
278 bool notify(QObject *, QEvent *); |
|
279 |
|
280 |
|
281 static void setQuitOnLastWindowClosed(bool quit); |
|
282 static bool quitOnLastWindowClosed(); |
|
283 |
|
284 #ifdef QT_KEYPAD_NAVIGATION |
|
285 static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool); |
|
286 static bool keypadNavigationEnabled(); |
|
287 static void setNavigationMode(Qt::NavigationMode mode); |
|
288 static Qt::NavigationMode navigationMode(); |
|
289 #endif |
|
290 |
|
291 Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); |
|
292 void unregisterGestureRecognizer(Qt::GestureType type); |
|
293 |
|
294 Q_SIGNALS: |
|
295 void lastWindowClosed(); |
|
296 void focusChanged(QWidget *old, QWidget *now); |
|
297 void fontDatabaseChanged(); |
|
298 #ifndef QT_NO_SESSIONMANAGER |
|
299 void commitDataRequest(QSessionManager &sessionManager); |
|
300 void saveStateRequest(QSessionManager &sessionManager); |
|
301 #endif |
|
302 |
|
303 public: |
|
304 QString styleSheet() const; |
|
305 public Q_SLOTS: |
|
306 #ifndef QT_NO_STYLE_STYLESHEET |
|
307 void setStyleSheet(const QString& sheet); |
|
308 #endif |
|
309 #ifdef Q_WS_WINCE |
|
310 void setAutoMaximizeThreshold(const int threshold); |
|
311 int autoMaximizeThreshold() const; |
|
312 #endif |
|
313 void setAutoSipEnabled(const bool enabled); |
|
314 bool autoSipEnabled() const; |
|
315 static void closeAllWindows(); |
|
316 static void aboutQt(); |
|
317 |
|
318 protected: |
|
319 #if defined(Q_WS_QWS) |
|
320 void setArgs(int, char **); |
|
321 #endif |
|
322 bool event(QEvent *); |
|
323 bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); |
|
324 |
|
325 #ifdef QT3_SUPPORT |
|
326 public: |
|
327 static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); } |
|
328 static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; } |
|
329 static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align); |
|
330 typedef int ColorMode; |
|
331 enum { NormalColors = NormalColor, CustomColors = CustomColor }; |
|
332 static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); } |
|
333 static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); } |
|
334 #if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN) |
|
335 static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; } |
|
336 #endif |
|
337 #if defined(Q_OS_MAC) |
|
338 static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; } |
|
339 #endif |
|
340 # ifndef QT_NO_CURSOR |
|
341 inline static QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace) |
|
342 { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); } |
|
343 # endif |
|
344 inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;} |
|
345 inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {} |
|
346 inline static QT3_SUPPORT void flushX() { flush(); } |
|
347 static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) { |
|
348 QPalette p(palette()); |
|
349 p.setColor(QPalette::Highlight, c); |
|
350 setPalette(p); |
|
351 } |
|
352 static inline QT3_SUPPORT const QColor &winStyleHighlightColor() |
|
353 { return palette().color(QPalette::Active, QPalette::Highlight); } |
|
354 static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0) |
|
355 { setPalette(pal, className); } |
|
356 static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0) |
|
357 { setFont(font, className); } |
|
358 |
|
359 static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child) |
|
360 { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); } |
|
361 static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child) |
|
362 { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); } |
|
363 #endif // QT3_SUPPORT |
|
364 |
|
365 #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) |
|
366 QApplication(int &argc, char **argv); |
|
367 QApplication(int &argc, char **argv, bool GUIenabled); |
|
368 QApplication(int &argc, char **argv, Type); |
|
369 #if defined(Q_WS_X11) |
|
370 QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); |
|
371 QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); |
|
372 #endif |
|
373 #if defined(Q_WS_S60) || defined(qdoc) |
|
374 QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv); |
|
375 #endif |
|
376 #endif |
|
377 |
|
378 private: |
|
379 Q_DISABLE_COPY(QApplication) |
|
380 Q_DECLARE_PRIVATE(QApplication) |
|
381 |
|
382 friend class QGraphicsWidget; |
|
383 friend class QGraphicsScene; |
|
384 friend class QGraphicsScenePrivate; |
|
385 friend class QWidget; |
|
386 friend class QWidgetPrivate; |
|
387 friend class QETWidget; |
|
388 friend class Q3AccelManager; |
|
389 friend class QTranslator; |
|
390 friend class QWidgetAnimator; |
|
391 #ifndef QT_NO_SHORTCUT |
|
392 friend class QShortcut; |
|
393 friend class QLineEdit; |
|
394 friend class QTextControl; |
|
395 #endif |
|
396 friend class QAction; |
|
397 friend class QFontDatabasePrivate; |
|
398 |
|
399 #if defined(Q_WS_QWS) |
|
400 friend class QInputContext; |
|
401 friend class QWSDirectPainterSurface; |
|
402 friend class QDirectPainter; |
|
403 friend class QDirectPainterPrivate; |
|
404 #endif |
|
405 friend class QGestureManager; |
|
406 |
|
407 #if defined(Q_WS_MAC) || defined(Q_WS_X11) |
|
408 Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) |
|
409 #endif |
|
410 #if defined(QT_RX71_MULTITOUCH) |
|
411 Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) |
|
412 #endif |
|
413 }; |
|
414 |
|
415 QT_END_NAMESPACE |
|
416 |
|
417 QT_END_HEADER |
|
418 |
|
419 #endif // QAPPLICATION_H |