Handle theme change in QApplication/QGuiApplication.
[profile/ivi/qtbase.git] / src / gui / kernel / qguiapplication_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QGUIAPPLICATION_QPA_P_H
43 #define QGUIAPPLICATION_QPA_P_H
44
45 #include <QtGui/qguiapplication.h>
46
47 #include <QtCore/QPointF>
48 #include <QtCore/private/qcoreapplication_p.h>
49
50 #include <QtCore/private/qthread_p.h>
51
52 #include <QWindowSystemInterface>
53 #include "private/qwindowsysteminterface_qpa_p.h"
54 #include "private/qshortcutmap_p.h"
55
56 QT_BEGIN_HEADER
57
58 QT_BEGIN_NAMESPACE
59
60 class QPlatformIntegration;
61 class QPlatformTheme;
62
63 class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
64 {
65     Q_DECLARE_PUBLIC(QGuiApplication)
66 public:
67     QGuiApplicationPrivate(int &argc, char **argv, int flags);
68     ~QGuiApplicationPrivate();
69
70     void createPlatformIntegration();
71     void createEventDispatcher();
72     void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
73
74     virtual void notifyLayoutDirectionChange();
75     virtual void notifyActiveWindowChange(QWindow *previous);
76
77     virtual bool shouldQuit();
78
79     static Qt::KeyboardModifiers modifier_buttons;
80     static Qt::MouseButtons mouse_buttons;
81
82     static QPlatformIntegration *platform_integration;
83
84     static QPlatformIntegration *platformIntegration()
85     { return platform_integration; }
86
87     static QPlatformTheme *platform_theme;
88
89     static QPlatformTheme *platformTheme()
90     { return platform_theme; }
91
92     static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
93     { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
94
95     static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
96     static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
97     static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
98     static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
99
100     static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
101
102     static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
103
104     static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
105     static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
106
107     static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
108     static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
109
110     static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
111
112     static void reportScreenOrientationChange(QScreen *screen);
113     static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
114     static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
115     static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
116     static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
117     static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
118
119     static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
120     static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
121
122     static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
123
124     static Qt::DropAction processDrag(QWindow *w, QMimeData *dropData, const QPoint &p);
125     static Qt::DropAction processDrop(QWindow *w, QMimeData *dropData, const QPoint &p);
126
127     static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
128
129     static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
130     {
131         if (!(alignment & Qt::AlignHorizontal_Mask))
132             alignment |= Qt::AlignLeft;
133         if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
134             if (direction == Qt::RightToLeft)
135                 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
136             alignment |= Qt::AlignAbsolute;
137         }
138         return alignment;
139     }
140
141     static void emitLastWindowClosed();
142
143     QPixmap getPixmapCursor(Qt::CursorShape cshape);
144
145     static QGuiApplicationPrivate *instance() { return self; }
146
147     static bool app_do_modal;
148
149     static Qt::MouseButtons buttons;
150     static ulong mousePressTime;
151     static Qt::MouseButton mousePressButton;
152     static int mousePressX;
153     static int mousePressY;
154     static int mouse_double_click_distance;
155     static QPointF lastCursorPosition;
156
157 #ifndef QT_NO_CLIPBOARD
158     static QClipboard *qt_clipboard;
159 #endif
160
161     static QPalette *app_pal;
162
163     static QWindowList window_list;
164     static QWindow *focus_window;
165
166 #ifndef QT_NO_CURSOR
167     QList<QCursor> cursor_list;
168 #endif
169     static QList<QScreen *> screen_list;
170
171     static QFont *app_font;
172
173     QStyleHints *styleHints;
174     static bool obey_desktop_settings;
175     QInputMethod *inputMethod;
176
177     static QList<QObject *> generic_plugin_list;
178 #ifndef QT_NO_SHORTCUT
179     QShortcutMap shortcutMap;
180 #endif
181
182     struct ActiveTouchPointsKey {
183         ActiveTouchPointsKey(QTouchDevice *dev, int id) : device(dev), touchPointId(id) { }
184         QTouchDevice *device;
185         int touchPointId;
186     };
187     struct ActiveTouchPointsValue {
188         QWeakPointer<QWindow> window;
189         QWeakPointer<QObject> target;
190         QTouchEvent::TouchPoint touchPoint;
191     };
192     QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
193     QEvent::Type lastTouchType;
194     struct SynthesizedMouseData {
195         SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
196             : pos(p), screenPos(sp), window(w) { }
197         QPointF pos;
198         QPointF screenPos;
199         QWeakPointer<QWindow> window;
200     };
201     QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
202
203 protected:
204     virtual void notifyThemeChanged();
205
206 private:
207     void init();
208
209     static QGuiApplicationPrivate *self;
210     static QTouchDevice *m_fakeTouchDevice;
211     static int m_fakeMouseSourcePointId;
212 };
213
214 Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
215
216 Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,
217                              const QGuiApplicationPrivate::ActiveTouchPointsKey &b);
218
219 QT_END_NAMESPACE
220
221 QT_END_HEADER
222
223 #endif // QGUIAPPLICATION_QPA_P_H