Merge remote-tracking branch 'gerrit/master' into newdocs
[profile/ivi/qtbase.git] / src / gui / kernel / qguiapplication.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 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 QGUIAPPLICATION_H
43 #define QGUIAPPLICATION_H
44
45 #include <QtCore/qcoreapplication.h>
46 #include <QtGui/qwindowdefs.h>
47 #include <QtGui/qinputmethod.h>
48 #include <QtCore/qlocale.h>
49 #include <QtCore/qpoint.h>
50 #include <QtCore/qsize.h>
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56
57 class QGuiApplicationPrivate;
58 class QPlatformNativeInterface;
59 class QPlatformIntegration;
60 class QPalette;
61 class QScreen;
62 class QStyleHints;
63
64 #if defined(qApp)
65 #undef qApp
66 #endif
67 #define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
68
69 #if defined(qGuiApp)
70 #undef qGuiApp
71 #endif
72 #define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
73
74 class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
75 {
76     Q_OBJECT
77     Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
78     Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
79     Q_PROPERTY(QString platformName READ platformName STORED false)
80     Q_PROPERTY(bool quitOnLastWindowClosed  READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
81
82 public:
83 #ifdef Q_QDOC
84     QGuiApplication(int &argc, char **argv);
85 #else
86     QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
87 #endif
88     virtual ~QGuiApplication();
89
90     static void setApplicationDisplayName(const QString &name);
91     static QString applicationDisplayName();
92
93     static QWindowList allWindows();
94     static QWindowList topLevelWindows();
95     static QWindow *topLevelAt(const QPoint &pos);
96
97     static QString platformName();
98
99     static QWindow *modalWindow();
100
101     static QWindow *focusWindow();
102     static QObject *focusObject();
103
104     static QScreen *primaryScreen();
105     static QList<QScreen *> screens();
106
107 #ifndef QT_NO_CURSOR
108     static QCursor *overrideCursor();
109     static void setOverrideCursor(const QCursor &);
110     static void changeOverrideCursor(const QCursor &);
111     static void restoreOverrideCursor();
112 #endif
113
114     static QFont font();
115     static void setFont(const QFont &);
116
117 #ifndef QT_NO_CLIPBOARD
118     static QClipboard *clipboard();
119 #endif
120
121     static QPalette palette();
122     static void setPalette(const QPalette &pal);
123
124     static Qt::KeyboardModifiers keyboardModifiers();
125     static Qt::KeyboardModifiers queryKeyboardModifiers();
126     static Qt::MouseButtons mouseButtons();
127
128     static void setLayoutDirection(Qt::LayoutDirection direction);
129     static Qt::LayoutDirection layoutDirection();
130
131     static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
132     static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
133
134     static QStyleHints *styleHints();
135     static void setDesktopSettingsAware(bool on);
136     static bool desktopSettingsAware();
137
138     static QInputMethod *inputMethod();
139
140     static QPlatformNativeInterface *platformNativeInterface();
141
142     static void setQuitOnLastWindowClosed(bool quit);
143     static bool quitOnLastWindowClosed();
144
145     static int exec();
146     bool notify(QObject *, QEvent *);
147
148 Q_SIGNALS:
149     void fontDatabaseChanged();
150     void screenAdded(QScreen *screen);
151     void lastWindowClosed();
152     void focusObjectChanged(QObject *focusObject);
153     void focusWindowChanged(QWindow *focusWindow);
154
155 protected:
156     bool event(QEvent *);
157     bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
158
159     QGuiApplication(QGuiApplicationPrivate &p);
160
161 private:
162     Q_DISABLE_COPY(QGuiApplication)
163     Q_DECLARE_PRIVATE(QGuiApplication)
164
165     Q_PRIVATE_SLOT(d_func(), void _q_updateFocusObject(QObject *object))
166
167 #ifndef QT_NO_GESTURES
168     friend class QGestureManager;
169 #endif
170     friend class QFontDatabasePrivate;
171     friend class QPlatformIntegration;
172 };
173
174 QT_END_NAMESPACE
175
176 QT_END_HEADER
177
178 #endif // QGUIAPPLICATION_H