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