source: trunk/src/gui/kernel/qapplication.h@ 564

Last change on this file since 564 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 14.3 KB
Line 
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** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** 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 have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
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
62QT_BEGIN_HEADER
63
64#if defined(Q_WS_S60)
65class CApaApplication;
66#endif
67
68QT_BEGIN_NAMESPACE
69
70QT_MODULE(Gui)
71
72class QSessionManager;
73class QDesktopWidget;
74class QStyle;
75class QEventLoop;
76class QIcon;
77class QInputContext;
78template <typename T> class QList;
79class QLocale;
80#if defined(Q_WS_QWS)
81class QDecoration;
82#endif
83#if defined(Q_OS_SYMBIAN)
84class QSymbianEvent;
85#endif
86
87class QApplication;
88class QApplicationPrivate;
89#if defined(qApp)
90#undef qApp
91#endif
92#define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
93
94
95class Q_GUI_EXPORT QApplication : public QCoreApplication
96{
97 Q_OBJECT
98 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
99 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
100 Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
101 Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
102 Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
103#ifndef QT_NO_WHEELEVENT
104 Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
105#endif
106 Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
107 Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
108 Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
109 Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
110#ifndef QT_NO_STYLE_STYLESHEET
111 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
112#endif
113#ifdef Q_WS_WINCE
114 Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
115#endif
116 Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
117
118public:
119 enum Type { Tty, GuiClient, GuiServer };
120
121#ifdef Q_WS_S60
122 typedef CApaApplication * (*QS60MainApplicationFactory)();
123#endif
124
125#ifndef qdoc
126 QApplication(int &argc, char **argv, int = QT_VERSION);
127 QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION);
128 QApplication(int &argc, char **argv, Type, int = QT_VERSION);
129#if defined(Q_WS_X11)
130 QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION);
131 QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION);
132#endif
133#if defined(Q_WS_S60)
134 QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION);
135#endif
136#endif
137 virtual ~QApplication();
138
139 static Type type();
140
141 static QStyle *style();
142 static void setStyle(QStyle*);
143 static QStyle *setStyle(const QString&);
144 enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
145 static int colorSpec();
146 static void setColorSpec(int);
147 static void setGraphicsSystem(const QString &);
148
149#ifndef QT_NO_CURSOR
150 static QCursor *overrideCursor();
151 static void setOverrideCursor(const QCursor &);
152 static void changeOverrideCursor(const QCursor &);
153 static void restoreOverrideCursor();
154#endif
155 static QPalette palette();
156 static QPalette palette(const QWidget *);
157 static QPalette palette(const char *className);
158 static void setPalette(const QPalette &, const char* className = 0);
159 static QFont font();
160 static QFont font(const QWidget*);
161 static QFont font(const char *className);
162 static void setFont(const QFont &, const char* className = 0);
163 static QFontMetrics fontMetrics();
164
165 static void setWindowIcon(const QIcon &icon);
166 static QIcon windowIcon();
167
168
169#ifdef QT3_SUPPORT
170 static QT3_SUPPORT QWidget *mainWidget();
171 static QT3_SUPPORT void setMainWidget(QWidget *);
172#endif
173
174 static QWidgetList allWidgets();
175 static QWidgetList topLevelWidgets();
176
177 static QDesktopWidget *desktop();
178
179 static QWidget *activePopupWidget();
180 static QWidget *activeModalWidget();
181#ifndef QT_NO_CLIPBOARD
182 static QClipboard *clipboard();
183#endif
184 static QWidget *focusWidget();
185
186 static QWidget *activeWindow();
187 static void setActiveWindow(QWidget* act);
188
189 static QWidget *widgetAt(const QPoint &p);
190 static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
191 static QWidget *topLevelAt(const QPoint &p);
192 static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
193
194 static void syncX();
195 static void beep();
196 static void alert(QWidget *widget, int duration = 0);
197
198 static Qt::KeyboardModifiers keyboardModifiers();
199 static Qt::MouseButtons mouseButtons();
200
201 static void setDesktopSettingsAware(bool);
202 static bool desktopSettingsAware();
203
204 static void setCursorFlashTime(int);
205 static int cursorFlashTime();
206
207 static void setDoubleClickInterval(int);
208 static int doubleClickInterval();
209
210 static void setKeyboardInputInterval(int);
211 static int keyboardInputInterval();
212
213#ifndef QT_NO_WHEELEVENT
214 static void setWheelScrollLines(int);
215 static int wheelScrollLines();
216#endif
217 static void setGlobalStrut(const QSize &);
218 static QSize globalStrut();
219
220 static void setStartDragTime(int ms);
221 static int startDragTime();
222 static void setStartDragDistance(int l);
223 static int startDragDistance();
224
225 static void setLayoutDirection(Qt::LayoutDirection direction);
226 static Qt::LayoutDirection layoutDirection();
227
228 static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
229 static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
230
231 static bool isEffectEnabled(Qt::UIEffect);
232 static void setEffectEnabled(Qt::UIEffect, bool enable = true);
233
234#if defined(Q_WS_MAC)
235 virtual bool macEventFilter(EventHandlerCallRef, EventRef);
236#endif
237#if defined(Q_WS_X11)
238 virtual bool x11EventFilter(XEvent *);
239 virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only);
240 int x11ProcessEvent(XEvent*);
241#endif
242#if defined(Q_OS_SYMBIAN)
243 int symbianProcessEvent(const QSymbianEvent *event);
244 virtual bool symbianEventFilter(const QSymbianEvent *event);
245#endif
246#if defined(Q_WS_QWS)
247 virtual bool qwsEventFilter(QWSEvent *);
248 int qwsProcessEvent(QWSEvent*);
249 void qwsSetCustomColors(QRgb *colortable, int start, int numColors);
250#ifndef QT_NO_QWS_MANAGER
251 static QDecoration &qwsDecoration();
252 static void qwsSetDecoration(QDecoration *);
253 static QDecoration *qwsSetDecoration(const QString &decoration);
254#endif
255#endif
256
257
258#if defined(Q_WS_WIN)
259 void winFocus(QWidget *, bool);
260 static void winMouseButtonUp();
261#endif
262#if defined(Q_WS_PM)
263 void pmFocus(QWidget *, bool);
264#endif
265
266#ifndef QT_NO_SESSIONMANAGER
267 // session management
268 bool isSessionRestored() const;
269 QString sessionId() const;
270 QString sessionKey() const;
271 virtual void commitData(QSessionManager& sm);
272 virtual void saveState(QSessionManager& sm);
273#endif
274 void setInputContext(QInputContext *);
275 QInputContext *inputContext() const;
276
277 static QLocale keyboardInputLocale();
278 static Qt::LayoutDirection keyboardInputDirection();
279
280 static int exec();
281 bool notify(QObject *, QEvent *);
282
283
284 static void setQuitOnLastWindowClosed(bool quit);
285 static bool quitOnLastWindowClosed();
286
287#ifdef QT_KEYPAD_NAVIGATION
288 static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
289 static bool keypadNavigationEnabled();
290 static void setNavigationMode(Qt::NavigationMode mode);
291 static Qt::NavigationMode navigationMode();
292#endif
293
294Q_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
303public:
304 QString styleSheet() const;
305public 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
318protected:
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
326public:
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
378private:
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
415QT_END_NAMESPACE
416
417QT_END_HEADER
418
419#endif // QAPPLICATION_H
Note: See TracBrowser for help on using the repository browser.