Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
| ** | |
| ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | |
| ** Contact: http://www.qt-project.org/legal | |
| ** | |
| ** This file is part of the QtGui module of the Qt Toolkit. | |
| ** | |
| ** $QT_BEGIN_LICENSE:LGPL$ | |
| ** Commercial License Usage | |
| ** Licensees holding valid commercial Qt licenses may use this file in | |
| ** accordance with the commercial license agreement provided with the | |
| ** Software or, alternatively, in accordance with the terms contained in | |
| ** a written agreement between you and Digia. For licensing terms and | |
| ** conditions see http://qt.digia.com/licensing. For further information | |
| ** use the contact form at http://qt.digia.com/contact-us. | |
| ** | |
| ** GNU Lesser General Public License Usage | |
| ** Alternatively, this file may be used under the terms of the GNU Lesser | |
| ** General Public License version 2.1 as published by the Free Software | |
| ** Foundation and appearing in the file LICENSE.LGPL included in the | |
| ** packaging of this file. Please review the following information to | |
| ** ensure the GNU Lesser General Public License version 2.1 requirements | |
| ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | |
| ** | |
| ** In addition, as a special exception, Digia gives you certain additional | |
| ** rights. These rights are described in the Digia Qt LGPL Exception | |
| ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | |
| ** | |
| ** GNU General Public License Usage | |
| ** Alternatively, this file may be used under the terms of the GNU | |
| ** General Public License version 3.0 as published by the Free Software | |
| ** Foundation and appearing in the file LICENSE.GPL included in the | |
| ** packaging of this file. Please review the following information to | |
| ** ensure the GNU General Public License version 3.0 requirements will be | |
| ** met: http://www.gnu.org/copyleft/gpl.html. | |
| ** | |
| ** | |
| ** $QT_END_LICENSE$ | |
| ** | |
| ****************************************************************************/**************************************************************************** | |
2 | ** | - |
3 | ** Copyright (C) 2013 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 | #include "qguiapplication.h" | - |
43 | | - |
44 | #include "private/qguiapplication_p.h" | - |
45 | #include <qpa/qplatformintegrationfactory_p.h> | - |
46 | #include "private/qevent_p.h" | - |
47 | #include "qfont.h" | - |
48 | #include <qpa/qplatformfontdatabase.h> | - |
49 | #include <qpa/qplatformwindow.h> | - |
50 | #include <qpa/qplatformnativeinterface.h> | - |
51 | #include <qpa/qplatformtheme.h> | - |
52 | #include <qpa/qplatformintegration.h> | - |
53 | #include <qpa/qplatformdrag.h> | - |
54 | | - |
55 | #include <QtCore/QAbstractEventDispatcher> | - |
56 | #include <QtCore/QVariant> | - |
57 | #include <QtCore/private/qcoreapplication_p.h> | - |
58 | #include <QtCore/private/qabstracteventdispatcher_p.h> | - |
59 | #include <QtCore/qmutex.h> | - |
60 | #include <QtCore/private/qthread_p.h> | - |
61 | #include <QtCore/qdir.h> | - |
62 | #include <QtDebug> | - |
63 | #ifndef QT_NO_ACCESSIBILITY | - |
64 | #include "qaccessible.h" | - |
65 | #endif | - |
66 | #include <qpalette.h> | - |
67 | #include <qscreen.h> | - |
68 | #include "qsessionmanager.h" | - |
69 | #include <private/qscreen_p.h> | - |
70 | #include <private/qdrawhelper_p.h> | - |
71 | | - |
72 | #include <QtGui/qgenericpluginfactory.h> | - |
73 | #include <QtGui/qstylehints.h> | - |
74 | #include <QtGui/qinputmethod.h> | - |
75 | #include <QtGui/qpixmapcache.h> | - |
76 | #include <qpa/qplatforminputcontext.h> | - |
77 | #include <qpa/qplatforminputcontext_p.h> | - |
78 | | - |
79 | #include <qpa/qwindowsysteminterface.h> | - |
80 | #include <qpa/qwindowsysteminterface_p.h> | - |
81 | #include "private/qwindow_p.h" | - |
82 | #include "private/qcursor_p.h" | - |
83 | | - |
84 | #include "private/qdnd_p.h" | - |
85 | #include <qpa/qplatformthemefactory_p.h> | - |
86 | | - |
87 | #ifndef QT_NO_CURSOR | - |
88 | #include <qpa/qplatformcursor.h> | - |
89 | #endif | - |
90 | | - |
91 | #include <QtGui/QPixmap> | - |
92 | | - |
93 | #ifndef QT_NO_CLIPBOARD | - |
94 | #include <QtGui/QClipboard> | - |
95 | #endif | - |
96 | | - |
97 | #ifdef Q_OS_MAC | - |
98 | # include "private/qcore_mac_p.h" | - |
99 | #endif | - |
100 | | - |
101 | QT_BEGIN_NAMESPACE | - |
102 | | - |
103 | Q_GUI_EXPORT bool qt_is_gui_used = true; | - |
104 | | - |
105 | Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; | - |
106 | Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; | - |
107 | | - |
108 | QPointF QGuiApplicationPrivate::lastCursorPosition(0.0, 0.0); | - |
109 | | - |
110 | bool QGuiApplicationPrivate::tabletState = false; | - |
111 | QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; | - |
112 | QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; | - |
113 | | - |
114 | QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; | - |
115 | QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; | - |
116 | | - |
117 | QList<QObject *> QGuiApplicationPrivate::generic_plugin_list; | - |
118 | | - |
119 | enum ApplicationResourceFlags | - |
120 | { | - |
121 | ApplicationPaletteExplicitlySet = 0x1, | - |
122 | ApplicationFontExplicitlySet = 0x2 | - |
123 | }; | - |
124 | | - |
125 | static unsigned applicationResourceFlags = 0; | - |
126 | | - |
127 | QString *QGuiApplicationPrivate::platform_name = 0; | - |
128 | QString *QGuiApplicationPrivate::displayName = 0; | - |
129 | | - |
130 | QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette | - |
131 | | - |
132 | Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; | - |
133 | ulong QGuiApplicationPrivate::mousePressTime = 0; | - |
134 | Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; | - |
135 | int QGuiApplicationPrivate::mousePressX = 0; | - |
136 | int QGuiApplicationPrivate::mousePressY = 0; | - |
137 | int QGuiApplicationPrivate::mouse_double_click_distance = 5; | - |
138 | | - |
139 | static Qt::LayoutDirection layout_direction = Qt::LeftToRight; | - |
140 | static bool force_reverse = false; | - |
141 | | - |
142 | QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; | - |
143 | QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; | - |
144 | int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; | - |
145 | | - |
146 | #ifndef QT_NO_CLIPBOARD | - |
147 | QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; | - |
148 | #endif | - |
149 | | - |
150 | QList<QScreen *> QGuiApplicationPrivate::screen_list; | - |
151 | | - |
152 | QWindowList QGuiApplicationPrivate::window_list; | - |
153 | QWindow *QGuiApplicationPrivate::focus_window = 0; | - |
154 | | - |
155 | static QBasicMutex applicationFontMutex; | - |
156 | QFont *QGuiApplicationPrivate::app_font = 0; | - |
157 | bool QGuiApplicationPrivate::obey_desktop_settings = true; | - |
158 | bool QGuiApplicationPrivate::noGrab = false; | - |
159 | | - |
160 | static qreal fontSmoothingGamma = 1.7; | - |
161 | | - |
162 | extern void qRegisterGuiVariant(); | - |
163 | extern void qInitDrawhelperAsm(); | - |
164 | extern void qInitImageConversions(); | - |
165 | | - |
166 | static bool qt_detectRTLLanguage() | - |
167 | { | - |
168 | return force_reverse ^ | - |
169 | (QCoreApplication::tr("QT_LAYOUT_DIRECTION", | - |
170 | "Translate this string to the string 'LTR' in left-to-right" | - |
171 | " languages or to 'RTL' in right-to-left languages (such as Hebrew" | - |
172 | " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | - |
173 | } | - |
174 | | - |
175 | static void initPalette() | - |
176 | { | - |
177 | if (!QGuiApplicationPrivate::app_pal) | - |
178 | if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) | - |
179 | QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); | - |
180 | if (!QGuiApplicationPrivate::app_pal) | - |
181 | QGuiApplicationPrivate::app_pal = new QPalette(Qt::black); | - |
182 | } | - |
183 | | - |
184 | static inline void clearPalette() | - |
185 | { | - |
186 | delete QGuiApplicationPrivate::app_pal; | - |
187 | QGuiApplicationPrivate::app_pal = 0; | - |
188 | } | - |
189 | | - |
190 | static void initFontUnlocked() | - |
191 | { | - |
192 | if (!QGuiApplicationPrivate::app_font) { | - |
193 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) | - |
194 | if (const QFont *font = theme->font(QPlatformTheme::SystemFont)) | - |
195 | QGuiApplicationPrivate::app_font = new QFont(*font); | - |
196 | } | - |
197 | if (!QGuiApplicationPrivate::app_font) | - |
198 | QGuiApplicationPrivate::app_font = | - |
199 | new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); | - |
200 | } | - |
201 | | - |
202 | static inline void clearFontUnlocked() | - |
203 | { | - |
204 | delete QGuiApplicationPrivate::app_font; | - |
205 | QGuiApplicationPrivate::app_font = 0; | - |
206 | } | - |
207 | | - |
208 | /*! | - |
| \class QGuiApplication | |
| \brief The QGuiApplication class manages the GUI application's control | |
| flow and main settings. | |
| | |
| \inmodule QtGui | |
| \since 5.0 | |
| | |
| QGuiApplication contains the main event loop, where all events from the window | |
| system and other sources are processed and dispatched. It also handles the | |
| application's initialization and finalization, and provides session management. | |
| In addition, QGuiApplication handles most of the system-wide and application-wide | |
| settings. | |
| | |
| For any GUI application using Qt, there is precisely \b one QGuiApplication | |
| object no matter whether the application has 0, 1, 2 or more windows at | |
| any given time. For non-GUI Qt applications, use QCoreApplication instead, | |
| as it does not depend on the \l QtGui library. For QWidget based Qt applications, | |
| use QApplication instead, as it provides some functionality needed for creating | |
| QWidget instances. | |
| | |
| The QGuiApplication object is accessible through the instance() function, which | |
| returns a pointer equivalent to the global \l qApp pointer. | |
| | |
| QGuiApplication's main areas of responsibility are: | |
| \list | |
| \li It initializes the application with the user's desktop settings, | |
| such as palette(), font() and styleHints(). It keeps | |
| track of these properties in case the user changes the desktop | |
| globally, for example, through some kind of control panel. | |
| | |
| \li It performs event handling, meaning that it receives events | |
| from the underlying window system and dispatches them to the | |
| relevant widgets. You can send your own events to windows by | |
| using sendEvent() and postEvent(). | |
| | |
| \li It parses common command line arguments and sets its internal | |
| state accordingly. See the \l{QGuiApplication::QGuiApplication()} | |
| {constructor documentation} below for more details. | |
| | |
| \li It provides localization of strings that are visible to the | |
| user via translate(). | |
| | |
| \li It provides some magical objects like the clipboard(). | |
| | |
| \li It knows about the application's windows. You can ask which | |
| window is at a certain position using topLevelAt(), get a list of | |
| topLevelWindows(), etc. | |
| | |
| \li It manages the application's mouse cursor handling, see | |
| setOverrideCursor() | |
| | |
| \li It provides support for sophisticated \l{Session Management} | |
| {session management}. This makes it possible for applications | |
| to terminate gracefully when the user logs out, to cancel a | |
| shutdown process if termination isn't possible and even to | |
| preserve the entire application's state for a future session. | |
| See isSessionRestored(), sessionId() and commitDataRequest() and | |
| saveStateRequest() for details. | |
| \endlist | |
| | |
| Since the QGuiApplication object does so much initialization, it \e{must} be | |
| created before any other objects related to the user interface are created. | |
| QGuiApplication also deals with common command line arguments. Hence, it is | |
| usually a good idea to create it \e before any interpretation or | |
| modification of \c argv is done in the application itself. | |
| | |
| \table | |
| \header | |
| \li{2,1} Groups of functions | |
| | |
| \row | |
| \li System settings | |
| \li desktopSettingsAware(), | |
| setDesktopSettingsAware(), | |
| styleHints(), | |
| palette(), | |
| setPalette(), | |
| font(), | |
| setFont(). | |
| | |
| \row | |
| \li Event handling | |
| \li exec(), | |
| processEvents(), | |
| exit(), | |
| quit(). | |
| sendEvent(), | |
| postEvent(), | |
| sendPostedEvents(), | |
| removePostedEvents(), | |
| hasPendingEvents(), | |
| notify(). | |
| | |
| \row | |
| \li Windows | |
| \li allWindows(), | |
| topLevelWindows(), | |
| focusWindow(), | |
| clipboard(), | |
| topLevelAt(). | |
| | |
| \row | |
| \li Advanced cursor handling | |
| \li overrideCursor(), | |
| setOverrideCursor(), | |
| restoreOverrideCursor(). | |
| | |
| \row | |
| \li Session management | |
| \li isSessionRestored(), | |
| sessionId(), | |
| commitDataRequest(), | |
| saveStateRequest(). | |
| | |
| \row | |
| \li Miscellaneous | |
| \li startingUp(), | |
| closingDown(), | |
| type(). | |
| \endtable | |
| | |
| \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop | |
| */*! | |
209 | \class QGuiApplication | - |
210 | \brief The QGuiApplication class manages the GUI application's control | - |
211 | flow and main settings. | - |
212 | | - |
213 | \inmodule QtGui | - |
214 | \since 5.0 | - |
215 | | - |
216 | QGuiApplication contains the main event loop, where all events from the window | - |
217 | system and other sources are processed and dispatched. It also handles the | - |
218 | application's initialization and finalization, and provides session management. | - |
219 | In addition, QGuiApplication handles most of the system-wide and application-wide | - |
220 | settings. | - |
221 | | - |
222 | For any GUI application using Qt, there is precisely \b one QGuiApplication | - |
223 | object no matter whether the application has 0, 1, 2 or more windows at | - |
224 | any given time. For non-GUI Qt applications, use QCoreApplication instead, | - |
225 | as it does not depend on the Qt GUI module. For QWidget based Qt applications, | - |
226 | use QApplication instead, as it provides some functionality needed for creating | - |
227 | QWidget instances. | - |
228 | | - |
229 | The QGuiApplication object is accessible through the instance() function, which | - |
230 | returns a pointer equivalent to the global \l qApp pointer. | - |
231 | | - |
232 | QGuiApplication's main areas of responsibility are: | - |
233 | \list | - |
234 | \li It initializes the application with the user's desktop settings, | - |
235 | such as palette(), font() and styleHints(). It keeps | - |
236 | track of these properties in case the user changes the desktop | - |
237 | globally, for example, through some kind of control panel. | - |
238 | | - |
239 | \li It performs event handling, meaning that it receives events | - |
240 | from the underlying window system and dispatches them to the | - |
241 | relevant widgets. You can send your own events to windows by | - |
242 | using sendEvent() and postEvent(). | - |
243 | | - |
244 | \li It parses common command line arguments and sets its internal | - |
245 | state accordingly. See the \l{QGuiApplication::QGuiApplication()} | - |
246 | {constructor documentation} below for more details. | - |
247 | | - |
248 | \li It provides localization of strings that are visible to the | - |
249 | user via translate(). | - |
250 | | - |
251 | \li It provides some magical objects like the clipboard(). | - |
252 | | - |
253 | \li It knows about the application's windows. You can ask which | - |
254 | window is at a certain position using topLevelAt(), get a list of | - |
255 | topLevelWindows(), etc. | - |
256 | | - |
257 | \li It manages the application's mouse cursor handling, see | - |
258 | setOverrideCursor() | - |
259 | | - |
260 | \li It provides support for sophisticated \l{Session Management} | - |
261 | {session management}. This makes it possible for applications | - |
262 | to terminate gracefully when the user logs out, to cancel a | - |
263 | shutdown process if termination isn't possible and even to | - |
264 | preserve the entire application's state for a future session. | - |
265 | See isSessionRestored(), sessionId() and commitDataRequest() and | - |
266 | saveStateRequest() for details. | - |
267 | \endlist | - |
268 | | - |
269 | Since the QGuiApplication object does so much initialization, it \e{must} be | - |
270 | created before any other objects related to the user interface are created. | - |
271 | QGuiApplication also deals with common command line arguments. Hence, it is | - |
272 | usually a good idea to create it \e before any interpretation or | - |
273 | modification of \c argv is done in the application itself. | - |
274 | | - |
275 | \table | - |
276 | \header | - |
277 | \li{2,1} Groups of functions | - |
278 | | - |
279 | \row | - |
280 | \li System settings | - |
281 | \li desktopSettingsAware(), | - |
282 | setDesktopSettingsAware(), | - |
283 | styleHints(), | - |
284 | palette(), | - |
285 | setPalette(), | - |
286 | font(), | - |
287 | setFont(). | - |
288 | | - |
289 | \row | - |
290 | \li Event handling | - |
291 | \li exec(), | - |
292 | processEvents(), | - |
293 | exit(), | - |
294 | quit(). | - |
295 | sendEvent(), | - |
296 | postEvent(), | - |
297 | sendPostedEvents(), | - |
298 | removePostedEvents(), | - |
299 | hasPendingEvents(), | - |
300 | notify(). | - |
301 | | - |
302 | \row | - |
303 | \li Windows | - |
304 | \li allWindows(), | - |
305 | topLevelWindows(), | - |
306 | focusWindow(), | - |
307 | clipboard(), | - |
308 | topLevelAt(). | - |
309 | | - |
310 | \row | - |
311 | \li Advanced cursor handling | - |
312 | \li overrideCursor(), | - |
313 | setOverrideCursor(), | - |
314 | restoreOverrideCursor(). | - |
315 | | - |
316 | \row | - |
317 | \li Session management | - |
318 | \li isSessionRestored(), | - |
319 | sessionId(), | - |
320 | commitDataRequest(), | - |
321 | saveStateRequest(). | - |
322 | | - |
323 | \row | - |
324 | \li Miscellaneous | - |
325 | \li startingUp(), | - |
326 | closingDown(), | - |
327 | type(). | - |
328 | \endtable | - |
329 | | - |
330 | \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop | - |
331 | */ | - |
332 | | - |
333 | /*! | - |
334 | Initializes the window system and constructs an application object with | - |
335 | \a argc command line arguments in \a argv. | - |
336 | | - |
337 | \warning The data referred to by \a argc and \a argv must stay valid for | - |
338 | the entire lifetime of the QGuiApplication object. In addition, \a argc must | - |
339 | be greater than zero and \a argv must contain at least one valid character | - |
340 | string. | - |
341 | | - |
342 | The global \c qApp pointer refers to this application object. Only one | - |
343 | application object should be created. | - |
344 | | - |
345 | This application object must be constructed before any \l{QPaintDevice} | - |
346 | {paint devices} (including pixmaps, bitmaps etc.). | - |
347 | | - |
348 | \note \a argc and \a argv might be changed as Qt removes command line | - |
349 | arguments that it recognizes. | - |
350 | | - |
351 | All Qt programs automatically support the following command line options: | - |
352 | \list | - |
353 | \li -reverse, sets the application's layout direction to | - |
354 | Qt::RightToLeft | - |
355 | \li -qmljsdebugger=, activates the QML/JS debugger with a specified port. | - |
356 | The value must be of format port:1234[,block], where block is optional | - |
357 | and will make the application wait until a debugger connects to it. | - |
358 | \li -session \e session, restores the application from an earlier | - |
359 | \l{Session Management}{session}. | - |
360 | \endlist | - |
361 | | - |
362 | \sa arguments() | - |
363 | */ | - |
364 | #ifdef Q_QDOC | - |
365 | QGuiApplication::QGuiApplication(int &argc, char **argv) | - |
366 | #else | - |
367 | QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) | - |
368 | #endif | - |
369 | : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) | - |
370 | { | - |
371 | d_func()->init(); | - |
372 | | - |
373 | QCoreApplicationPrivate::eventDispatcher->startingUp(); | - |
374 | } | - |
375 | | - |
376 | /*! | - |
377 | \internal | - |
378 | */ | - |
379 | QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) | - |
380 | : QCoreApplication(p) | - |
381 | { | - |
382 | d_func()->init(); } | - |
383 | | - |
384 | /*! | - |
385 | Destructs the application. | - |
386 | */ | - |
387 | QGuiApplication::~QGuiApplication() | - |
388 | { | - |
389 | Q_D(QGuiApplication); | - |
390 | | - |
391 | d->eventDispatcher->closingDown(); | - |
392 | d->eventDispatcher = 0; | - |
393 | | - |
394 | #ifndef QT_NO_CLIPBOARD | - |
395 | delete QGuiApplicationPrivate::qt_clipboard; | - |
396 | QGuiApplicationPrivate::qt_clipboard = 0; | - |
397 | #endif | - |
398 | | - |
399 | #ifndef QT_NO_SESSIONMANAGER | - |
400 | delete d->session_manager; | - |
401 | d->session_manager = 0; | - |
402 | #endif //QT_NO_SESSIONMANAGER | - |
403 | | - |
404 | clearPalette(); | - |
405 | | - |
406 | #ifndef QT_NO_CURSOR | - |
407 | d->cursor_list.clear(); | - |
408 | #endif | - |
409 | | - |
410 | delete QGuiApplicationPrivate::platform_name; | - |
411 | QGuiApplicationPrivate::platform_name = 0; | - |
412 | delete QGuiApplicationPrivate::displayName; | - |
413 | QGuiApplicationPrivate::displayName = 0; | - |
414 | } | - |
415 | | - |
416 | QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) | - |
417 | : QCoreApplicationPrivate(argc, argv, flags), | - |
418 | styleHints(0), | - |
419 | inputMethod(0), | - |
420 | lastTouchType(QEvent::TouchEnd) | - |
421 | { | - |
422 | self = this; | - |
423 | application_type = QCoreApplicationPrivate::Gui; | - |
424 | #ifndef QT_NO_SESSIONMANAGER | - |
425 | is_session_restored = false; | - |
426 | is_saving_session = false; | - |
427 | #endif | - |
428 | } | - |
429 | | - |
430 | /*! | - |
431 | \property QGuiApplication::applicationDisplayName | - |
432 | \brief the user-visible name of this application | - |
433 | \since 5.0 | - |
434 | | - |
435 | This name is shown to the user, for instance in window titles. | - |
436 | It can be translated, if necessary. | - |
437 | | - |
438 | If not set, the application display name defaults to the application name. | - |
439 | | - |
440 | \sa applicationName | - |
441 | */ | - |
442 | void QGuiApplication::setApplicationDisplayName(const QString &name) | - |
443 | { | - |
444 | if (!QGuiApplicationPrivate::displayName) | - |
445 | QGuiApplicationPrivate::displayName = new QString; | - |
446 | *QGuiApplicationPrivate::displayName = name; | - |
447 | } | - |
448 | | - |
449 | QString QGuiApplication::applicationDisplayName() | - |
450 | { | - |
451 | return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName(); | - |
452 | } | - |
453 | | - |
454 | /*! | - |
455 | Returns the most recently shown modal window. If no modal windows are | - |
456 | visible, this function returns zero. | - |
457 | | - |
458 | A modal window is a window which has its | - |
459 | \l{QWindow::modality}{modality} property set to Qt::WindowModal | - |
460 | or Qt::ApplicationModal. A modal window must be closed before the user can | - |
461 | continue with other parts of the program. | - |
462 | | - |
463 | Modal window are organized in a stack. This function returns the modal | - |
464 | window at the top of the stack. | - |
465 | | - |
466 | \sa Qt::WindowModality, QWindow::setModality() | - |
467 | */ | - |
468 | QWindow *QGuiApplication::modalWindow() | - |
469 | { | - |
470 | if (QGuiApplicationPrivate::self->modalWindowList.isEmpty()) | - |
471 | return 0; | - |
472 | return QGuiApplicationPrivate::self->modalWindowList.first(); | - |
473 | } | - |
474 | | - |
475 | void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) | - |
476 | { | - |
477 | bool shouldBeBlocked = false; | - |
478 | if ((window->type() & Qt::Popup) != Qt::Popup && !self->modalWindowList.isEmpty()) | - |
479 | shouldBeBlocked = self->isWindowBlocked(window); | - |
480 | | - |
481 | if (shouldBeBlocked != window->d_func()->blockedByModalWindow) { | - |
482 | QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked); | - |
483 | | - |
484 | window->d_func()->blockedByModalWindow = shouldBeBlocked; | - |
485 | QGuiApplication::sendEvent(window, &e); | - |
486 | } | - |
487 | } | - |
488 | | - |
489 | void QGuiApplicationPrivate::showModalWindow(QWindow *modal) | - |
490 | { | - |
491 | self->modalWindowList.prepend(modal); | - |
492 | | - |
493 | // Send leave for currently entered window if it should be blocked | - |
494 | if (currentMouseWindow && (currentMouseWindow->type() & Qt::Popup) != Qt::Popup) { | - |
495 | bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); | - |
496 | if (shouldBeBlocked) { | - |
497 | // Remove the new window from modalWindowList temporarily so leave can go through | - |
498 | self->modalWindowList.removeFirst(); | - |
499 | QEvent e(QEvent::Leave); | - |
500 | QGuiApplication::sendEvent(currentMouseWindow, &e); | - |
501 | currentMouseWindow = 0; | - |
502 | self->modalWindowList.prepend(modal); | - |
503 | } | - |
504 | } | - |
505 | | - |
506 | QWindowList windows = QGuiApplication::topLevelWindows(); | - |
507 | for (int i = 0; i < windows.count(); ++i) { | - |
508 | QWindow *window = windows.at(i); | - |
509 | if (!window->d_func()->blockedByModalWindow) | - |
510 | updateBlockedStatus(window); | - |
511 | } | - |
512 | | - |
513 | updateBlockedStatus(modal); | - |
514 | } | - |
515 | | - |
516 | void QGuiApplicationPrivate::hideModalWindow(QWindow *window) | - |
517 | { | - |
518 | self->modalWindowList.removeAll(window); | - |
519 | | - |
520 | QWindowList windows = QGuiApplication::topLevelWindows(); | - |
521 | for (int i = 0; i < windows.count(); ++i) { | - |
522 | QWindow *window = windows.at(i); | - |
523 | if (window->d_func()->blockedByModalWindow) | - |
524 | updateBlockedStatus(window); | - |
525 | } | - |
526 | } | - |
527 | | - |
528 | /* | - |
529 | Returns true if \a window is blocked by a modal window. If \a | - |
530 | blockingWindow is non-zero, *blockingWindow will be set to the blocking | - |
531 | window (or to zero if \a window is not blocked). | - |
532 | */ | - |
533 | bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const | - |
534 | { | - |
535 | QWindow *unused = 0; | - |
536 | if (!blockingWindow) | - |
537 | blockingWindow = &unused; | - |
538 | | - |
539 | if (modalWindowList.isEmpty()) { | - |
540 | *blockingWindow = 0; | - |
541 | return false; | - |
542 | } | - |
543 | | - |
544 | for (int i = 0; i < modalWindowList.count(); ++i) { | - |
545 | QWindow *modalWindow = modalWindowList.at(i); | - |
546 | | - |
547 | { | - |
548 | // check if the modal window is our window or a (transient) parent of our window | - |
549 | QWindow *w = window; | - |
550 | while (w) { | - |
551 | if (w == modalWindow) { | - |
552 | *blockingWindow = 0; | - |
553 | return false; | - |
554 | } | - |
555 | QWindow *p = w->parent(); | - |
556 | if (!p) | - |
557 | p = w->transientParent(); | - |
558 | w = p; | - |
559 | } | - |
560 | } | - |
561 | | - |
562 | Qt::WindowModality windowModality = modalWindow->modality(); | - |
563 | switch (windowModality) { | - |
564 | case Qt::ApplicationModal: | - |
565 | { | - |
566 | if (modalWindow != window) { | - |
567 | *blockingWindow = modalWindow; | - |
568 | return true; | - |
569 | } | - |
570 | break; | - |
571 | } | - |
572 | case Qt::WindowModal: | - |
573 | { | - |
574 | QWindow *w = window; | - |
575 | do { | - |
576 | QWindow *m = modalWindow; | - |
577 | do { | - |
578 | if (m == w) { | - |
579 | *blockingWindow = m; | - |
580 | return true; | - |
581 | } | - |
582 | QWindow *p = m->parent(); | - |
583 | if (!p) | - |
584 | p = m->transientParent(); | - |
585 | m = p; | - |
586 | } while (m); | - |
587 | QWindow *p = w->parent(); | - |
588 | if (!p) | - |
589 | p = w->transientParent(); | - |
590 | w = p; | - |
591 | } while (w); | - |
592 | break; | - |
593 | } | - |
594 | default: | - |
595 | Q_ASSERT_X(false, "QGuiApplication", "internal error, a modal widget cannot be modeless"); | - |
596 | break; | - |
597 | } | - |
598 | } | - |
599 | *blockingWindow = 0; | - |
600 | return false; | - |
601 | } | - |
602 | | - |
603 | /*! | - |
604 | Returns the QWindow that receives events tied to focus, | - |
605 | such as key events. | - |
606 | */ | - |
607 | QWindow *QGuiApplication::focusWindow() | - |
608 | { | - |
609 | return QGuiApplicationPrivate::focus_window; | - |
610 | } | - |
611 | | - |
612 | /*! | - |
613 | \fn QGuiApplication::focusObjectChanged(QObject *focusObject) | - |
614 | | - |
615 | This signal is emitted when final receiver of events tied to focus is changed. | - |
616 | \a focusObject is the new receiver. | - |
617 | | - |
618 | \sa focusObject() | - |
619 | */ | - |
620 | | - |
621 | /*! | - |
622 | \fn QGuiApplication::focusWindowChanged(QWindow *focusWindow) | - |
623 | | - |
624 | This signal is emitted when the focused window changes. | - |
625 | \a focusWindow is the new focused window. | - |
626 | | - |
627 | \sa focusWindow() | - |
628 | */ | - |
629 | | - |
630 | /*! | - |
631 | Returns the QObject in currently active window that will be final receiver of events | - |
632 | tied to focus, such as key events. | - |
633 | */ | - |
634 | QObject *QGuiApplication::focusObject() | - |
635 | { | - |
636 | if (focusWindow()) | - |
637 | return focusWindow()->focusObject(); | - |
638 | return 0; | - |
639 | } | - |
640 | | - |
641 | /*! | - |
642 | \fn QGuiApplication::allWindows() | - |
643 | | - |
644 | Returns a list of all the windows in the application. | - |
645 | | - |
646 | The list is empty if there are no windows. | - |
647 | | - |
648 | \sa topLevelWindows() | - |
649 | */ | - |
650 | QWindowList QGuiApplication::allWindows() | - |
651 | { | - |
652 | return QGuiApplicationPrivate::window_list; | - |
653 | } | - |
654 | | - |
655 | /*! | - |
656 | \fn QGuiApplication::topLevelWindows() | - |
657 | | - |
658 | Returns a list of the top-level windows in the application. | - |
659 | | - |
660 | \sa allWindows() | - |
661 | */ | - |
662 | QWindowList QGuiApplication::topLevelWindows() | - |
663 | { | - |
664 | const QWindowList &list = QGuiApplicationPrivate::window_list; | - |
665 | QWindowList topLevelWindows; | - |
666 | for (int i = 0; i < list.size(); i++) { | - |
667 | if (!list.at(i)->parent()) { | - |
668 | // Top windows of embedded QAxServers do not have QWindow parents, | - |
669 | // but they are not true top level windows, so do not include them. | - |
670 | const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(0); | - |
671 | if (!embedded) | - |
672 | topLevelWindows.prepend(list.at(i)); | - |
673 | } | - |
674 | } | - |
675 | return topLevelWindows; | - |
676 | } | - |
677 | | - |
678 | /*! | - |
679 | Returns the primary (or default) screen of the application. | - |
680 | | - |
681 | This will be the screen where QWindows are shown, unless otherwise specified. | - |
682 | */ | - |
683 | QScreen *QGuiApplication::primaryScreen() | - |
684 | { | - |
685 | if (QGuiApplicationPrivate::screen_list.isEmpty()) | - |
686 | return 0; | - |
687 | return QGuiApplicationPrivate::screen_list.at(0); | - |
688 | } | - |
689 | | - |
690 | /*! | - |
691 | Returns a list of all the screens associated with the | - |
692 | windowing system the application is connected to. | - |
693 | */ | - |
694 | QList<QScreen *> QGuiApplication::screens() | - |
695 | { | - |
696 | return QGuiApplicationPrivate::screen_list; | - |
697 | } | - |
698 | | - |
699 | /*! | - |
700 | \fn void QGuiApplication::screenAdded(QScreen *screen) | - |
701 | | - |
702 | This signal is emitted whenever a new screen \a screen has been added to the system. | - |
703 | | - |
704 | \sa screens(), primaryScreen() | - |
705 | */ | - |
706 | | - |
707 | | - |
708 | /*! | - |
| Returns the highest screen device pixel ratio found on | |
| the system. This is the ratio between physical pixels and | |
| device-independent pixels. | |
| | |
| Use this function only when you don't know which window you are targeting. | |
| If you do know the target window use QWindow::devicePixelRatio() instead. | |
| | |
| \sa QWindow::devicePixelRatio(); | |
| \sa QGuiApplicaiton::devicePixelRatio(); | |
| */*! | |
709 | Returns the highest screen device pixel ratio found on | - |
710 | the system. This is the ratio between physical pixels and | - |
711 | device-independent pixels. | - |
712 | | - |
713 | Use this function only when you don't know which window you are targeting. | - |
714 | If you do know the target window, use QWindow::devicePixelRatio() instead. | - |
715 | | - |
716 | \sa QWindow::devicePixelRatio() | - |
717 | */ | - |
718 | qreal QGuiApplication::devicePixelRatio() const | - |
719 | { | - |
720 | // Cache topDevicePixelRatio, iterate through the screen list once only. | - |
721 | static qreal topDevicePixelRatio = 0.0; | - |
722 | if (!qFuzzyIsNull(topDevicePixelRatio)) { | - |
723 | return topDevicePixelRatio; | - |
724 | } | - |
725 | | - |
726 | topDevicePixelRatio = 1.0; // make sure we never return 0. | - |
727 | foreach (QScreen *screen, QGuiApplicationPrivate::screen_list) { | - |
728 | topDevicePixelRatio = qMax(topDevicePixelRatio, screen->devicePixelRatio()); | - |
729 | } | - |
730 | | - |
731 | return topDevicePixelRatio; | - |
732 | } | - |
733 | | - |
734 | /*! | - |
735 | Returns the top level window at the given position, if any. | - |
736 | */ | - |
737 | QWindow *QGuiApplication::topLevelAt(const QPoint &pos) | - |
738 | { | - |
739 | QList<QScreen *> screens = QGuiApplication::screens(); | - |
740 | QList<QScreen *>::const_iterator screen = screens.constBegin(); | - |
741 | QList<QScreen *>::const_iterator end = screens.constEnd(); | - |
742 | | - |
743 | while (screen != end) { | - |
744 | if ((*screen)->geometry().contains(pos)) | - |
745 | return (*screen)->handle()->topLevelAt(pos); | - |
746 | ++screen; | - |
747 | } | - |
748 | return 0; | - |
749 | } | - |
750 | | - |
751 | /*! | - |
752 | \property QGuiApplication::platformName | - |
753 | \brief The name of the underlying platform plugin. | - |
754 | | - |
755 | Examples: "xcb" (for X11), "Cocoa" (for Mac OS X), "windows", "qnx", | - |
756 | "directfb", "kms", "MinimalEgl", "LinuxFb", "EglFS", "OpenWFD"... | - |
757 | */ | - |
758 | | - |
759 | QString QGuiApplication::platformName() | - |
760 | { | - |
761 | return QGuiApplicationPrivate::platform_name ? | - |
762 | *QGuiApplicationPrivate::platform_name : QString(); | - |
763 | } | - |
764 | | - |
765 | static void init_platform(const QString &pluginArgument, const QString &platformPluginPath) | - |
766 | { | - |
767 | // Split into platform name and arguments | - |
768 | QStringList arguments = pluginArgument.split(QLatin1Char(':')); | - |
769 | const QString name = arguments.takeFirst().toLower(); | - |
770 | | - |
771 | // Create the platform integration. | - |
772 | QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath); | - |
773 | if (QGuiApplicationPrivate::platform_integration) { | - |
774 | QGuiApplicationPrivate::platform_name = new QString(name); | - |
775 | } else { | - |
776 | QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); | - |
777 | QString fatalMessage = | - |
778 | QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); | - |
779 | foreach(const QString &key, keys) { | - |
780 | fatalMessage.append(key + QLatin1Char('\n')); | - |
781 | } | - |
782 | qFatal("%s", fatalMessage.toLocal8Bit().constData()); | - |
783 | return; | - |
784 | } | - |
785 | | - |
786 | // Create the platform theme: | - |
787 | // 1) Ask the platform integration for a list of names. | - |
788 | const QStringList themeNames = QGuiApplicationPrivate::platform_integration->themeNames(); | - |
789 | foreach (const QString &themeName, themeNames) { | - |
790 | QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); | - |
791 | if (QGuiApplicationPrivate::platform_theme) | - |
792 | break; | - |
793 | } | - |
794 | | - |
795 | // 2) If none found, look for a theme plugin. Theme plugins are located in the | - |
796 | // same directory as platform plugins. | - |
797 | if (!QGuiApplicationPrivate::platform_theme) { | - |
798 | foreach (const QString &themeName, themeNames) { | - |
799 | QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); | - |
800 | if (QGuiApplicationPrivate::platform_theme) | - |
801 | break; | - |
802 | } | - |
803 | // No error message; not having a theme plugin is allowed. | - |
804 | } | - |
805 | | - |
806 | // 3) Fall back on the built-in "null" platform theme. | - |
807 | if (!QGuiApplicationPrivate::platform_theme) | - |
808 | QGuiApplicationPrivate::platform_theme = new QPlatformTheme; | - |
809 | | - |
810 | #ifndef QT_NO_PROPERTIES | - |
811 | // Set arguments as dynamic properties on the native interface as | - |
812 | // boolean 'foo' or strings: 'foo=bar' | - |
813 | if (!arguments.isEmpty()) { | - |
814 | if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) { | - |
815 | foreach (const QString &argument, arguments) { | - |
816 | const int equalsPos = argument.indexOf(QLatin1Char('=')); | - |
817 | const QByteArray name = | - |
818 | equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8(); | - |
819 | const QVariant value = | - |
820 | equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true); | - |
821 | nativeInterface->setProperty(name.constData(), value); | - |
822 | } | - |
823 | } | - |
824 | } | - |
825 | #endif | - |
826 | | - |
827 | fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); | - |
828 | } | - |
829 | | - |
830 | static void init_plugins(const QList<QByteArray> &pluginList) | - |
831 | { | - |
832 | for (int i = 0; i < pluginList.count(); ++i) { | - |
833 | QByteArray pluginSpec = pluginList.at(i); | - |
834 | int colonPos = pluginSpec.indexOf(':'); | - |
835 | QObject *plugin; | - |
836 | if (colonPos < 0) | - |
837 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); | - |
838 | else | - |
839 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), | - |
840 | QLatin1String(pluginSpec.mid(colonPos+1))); | - |
841 | if (plugin) | - |
842 | QGuiApplicationPrivate::generic_plugin_list.append(plugin); | - |
843 | } | - |
844 | } | - |
845 | | - |
846 | void QGuiApplicationPrivate::createPlatformIntegration() | - |
847 | { | - |
848 | // Use the Qt menus by default. Platform plugins that | - |
849 | // want to enable a native menu implementation can clear | - |
850 | // this flag. | - |
851 | QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); executed (the execution status of this line is deduced): QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); | - |
852 | | - |
853 | // Load the platform integration | - |
854 | QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); executed (the execution status of this line is deduced): QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); | - |
855 | | - |
856 | | - |
857 | / On Mac, look inside the application bundle for the platform plugin. | - |
| // TODO (msorvig): Create proper cross-platform solution for loading | |
| // deployed platform plugins | |
| #ifdef Q_OS_MAC | |
| const QString bundlePluginPath = QCoreApplication::applicationDirPath() + QLatin1String("../Plugins/"); | |
| if (platformPluginPath.isEmpty() && QDir(bundlePluginPath).exists()) { | |
| platformPluginPath = bundlePluginPath; | |
| } | |
| #endifQByteArray platformName; executed (the execution status of this line is deduced): QByteArray platformName; | |
858 | #ifdef QT_QPA_DEFAULT_PLATFORM_NAME | - |
859 | platformName = QT_QPA_DEFAULT_PLATFORM_NAME; executed (the execution status of this line is deduced): platformName = "xcb"; | - |
860 | #endif | - |
861 | QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); executed (the execution status of this line is deduced): QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); | - |
862 | if (!platformNameEnv.isEmpty()) { partially evaluated: !platformNameEnv.isEmpty() no Evaluation Count:0 | yes Evaluation Count:289 |
| 0-289 |
863 | platformName = platformNameEnv; never executed (the execution status of this line is deduced): platformName = platformNameEnv; | - |
864 | } | 0 |
865 | | - |
866 | // Get command line params | - |
867 | | - |
868 | int j = argc ? 1 : 0; evaluated: argc yes Evaluation Count:221 | yes Evaluation Count:68 |
| 68-221 |
869 | for (int i=1; i<argc; i++) { evaluated: i<argc yes Evaluation Count:8 | yes Evaluation Count:289 |
| 8-289 |
870 | if (argv[i] && *argv[i] != '-') { partially evaluated: argv[i] yes Evaluation Count:8 | no Evaluation Count:0 |
evaluated: *argv[i] != '-' yes Evaluation Count:3 | yes Evaluation Count:5 |
| 0-8 |
871 | argv[j++] = argv[i]; executed (the execution status of this line is deduced): argv[j++] = argv[i]; | - |
872 | continue; executed: continue; Execution Count:3 | 3 |
873 | } | - |
874 | QByteArray arg = argv[i]; executed (the execution status of this line is deduced): QByteArray arg = argv[i]; | - |
875 | if (arg == "-platformpluginpath") { partially evaluated: arg == "-platformpluginpath" no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
876 | if (++i < argc) never evaluated: ++i < argc | 0 |
877 | platformPluginPath = QLatin1String(argv[i]); never executed: platformPluginPath = QLatin1String(argv[i]); | 0 |
878 | } else if (arg == "-platform") { never executed: } partially evaluated: arg == "-platform" no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
879 | if (++i < argc) never evaluated: ++i < argc | 0 |
880 | platformName = argv[i]; never executed: platformName = argv[i]; | 0 |
881 | } else { | 0 |
882 | argv[j++] = argv[i]; executed (the execution status of this line is deduced): argv[j++] = argv[i]; | - |
883 | } executed: } Execution Count:5 | 5 |
884 | } | - |
885 | | - |
886 | if (j < argc) { partially evaluated: j < argc no Evaluation Count:0 | yes Evaluation Count:289 |
| 0-289 |
887 | argv[j] = 0; never executed (the execution status of this line is deduced): argv[j] = 0; | - |
888 | argc = j; never executed (the execution status of this line is deduced): argc = j; | - |
889 | } | 0 |
890 | | - |
891 | init_platform(QLatin1String(platformName), platformPluginPath); executed (the execution status of this line is deduced): init_platform(QLatin1String(platformName), platformPluginPath); | - |
892 | | - |
893 | } executed: } Execution Count:289 | 289 |
894 | | - |
895 | void QGuiApplicationPrivate::createEventDispatcher() | - |
896 | { | - |
897 | if (platform_integration == 0) | - |
898 | createPlatformIntegration(); | - |
899 | | - |
900 | if (!eventDispatcher) { | - |
901 | QAbstractEventDispatcher *eventDispatcher = platform_integration->guiThreadEventDispatcher(); | - |
902 | setEventDispatcher(eventDispatcher); | - |
903 | } | - |
904 | } | - |
905 | | - |
906 | void QGuiApplicationPrivate::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) | - |
907 | { | - |
908 | Q_Q(QGuiApplication); | - |
909 | | - |
910 | if (!QCoreApplicationPrivate::eventDispatcher) { | - |
911 | QCoreApplicationPrivate::eventDispatcher = eventDispatcher; | - |
912 | QCoreApplicationPrivate::eventDispatcher->setParent(q); | - |
913 | threadData->eventDispatcher = eventDispatcher; | - |
914 | } | - |
915 | | - |
916 | } | - |
917 | | - |
918 | #if defined(QT_DEBUG) && defined(Q_OS_LINUX) | - |
919 | // Find out if our parent process is gdb by looking at the 'exe' symlink under /proc. | - |
920 | static bool runningUnderDebugger() | - |
921 | { | - |
922 | const QFileInfo parentProcExe(QStringLiteral("/proc/") + QString::number(getppid()) + QStringLiteral("/exe")); | - |
923 | return parentProcExe.isSymLink() && parentProcExe.symLinkTarget().endsWith(QStringLiteral("/gdb")); | - |
924 | } | - |
925 | #endif | - |
926 | | - |
927 | void QGuiApplicationPrivate::init() | - |
928 | { | - |
929 | bool doGrabUnderDebugger = false; | - |
930 | QList<QByteArray> pluginList; | - |
931 | // Get command line params | - |
932 | | - |
933 | int j = argc ? 1 : 0; | - |
934 | for (int i=1; i<argc; i++) { | - |
935 | if (argv[i] && *argv[i] != '-') { | - |
936 | argv[j++] = argv[i]; | - |
937 | continue; | - |
938 | } | - |
939 | QByteArray arg = argv[i]; | - |
940 | if (arg == "-plugin") { | - |
941 | if (++i < argc) | - |
942 | pluginList << argv[i]; | - |
943 | } else if (arg == "-reverse") { | - |
944 | force_reverse = true; | - |
945 | QGuiApplication::setLayoutDirection(Qt::RightToLeft); | - |
946 | #ifdef Q_OS_MAC | - |
947 | } else if (arg.startsWith("-psn_")) { | - |
948 | // eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder. | - |
949 | // special hack to change working directory (for an app bundle) when running from finder | - |
950 | if (QDir::currentPath() == QLatin1String("/")) { | - |
951 | QCFType<CFURLRef> bundleURL(CFBundleCopyBundleURL(CFBundleGetMainBundle())); | - |
952 | QString qbundlePath = QCFString(CFURLCopyFileSystemPath(bundleURL, | - |
953 | kCFURLPOSIXPathStyle)); | - |
954 | if (qbundlePath.endsWith(QLatin1String(".app"))) | - |
955 | QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2)); | - |
956 | } | - |
957 | #endif | - |
958 | } else if (arg == "-nograb") { | - |
959 | QGuiApplicationPrivate::noGrab = true; | - |
960 | } else if (arg == "-dograb") { | - |
961 | doGrabUnderDebugger = true; | - |
962 | #ifndef QT_NO_SESSIONMANAGER | - |
963 | } else if (arg == "-session" && i < argc-1) { | - |
964 | ++i; | - |
965 | if (argv[i] && *argv[i]) { | - |
966 | session_id = QString::fromLatin1(argv[i]); | - |
967 | int p = session_id.indexOf(QLatin1Char('_')); | - |
968 | if (p >= 0) { | - |
969 | session_key = session_id.mid(p +1); | - |
970 | session_id = session_id.left(p); | - |
971 | } | - |
972 | is_session_restored = true; | - |
973 | } | - |
974 | #endif | - |
975 | } else { | - |
976 | argv[j++] = argv[i]; | - |
977 | } | - |
978 | } | - |
979 | | - |
980 | if (j < argc) { | - |
981 | argv[j] = 0; | - |
982 | argc = j; | - |
983 | } | - |
984 | | - |
985 | #if defined(QT_DEBUG) && defined(Q_OS_LINUX) | - |
986 | if (!doGrabUnderDebugger && !QGuiApplicationPrivate::noGrab && runningUnderDebugger()) { | - |
987 | QGuiApplicationPrivate::noGrab = true; | - |
988 | qDebug("Qt: gdb: -nograb added to command-line options.\n" | - |
989 | "\t Use the -dograb option to enforce grabbing."); | - |
990 | } | - |
991 | #else | - |
992 | Q_UNUSED(doGrabUnderDebugger) | - |
993 | #endif | - |
994 | | - |
995 | // Load environment exported generic plugins | - |
996 | foreach (const QByteArray &plugin, qgetenv("QT_QPA_GENERIC_PLUGINS").split(',')) | - |
997 | pluginList << plugin; | - |
998 | | - |
999 | if (platform_integration == 0) | - |
1000 | createPlatformIntegration(); | - |
1001 | | - |
1002 | // Set up which span functions should be used in raster engine... | - |
1003 | qInitDrawhelperAsm(); | - |
1004 | // and QImage conversion functions | - |
1005 | qInitImageConversions(); | - |
1006 | | - |
1007 | QFont::initialize(); | - |
1008 | | - |
1009 | #ifndef QT_NO_CURSOR | - |
1010 | QCursorData::initialize(); | - |
1011 | #endif | - |
1012 | | - |
1013 | // trigger registering of QVariant's GUI types | - |
1014 | qRegisterGuiVariant(); | - |
1015 | | - |
1016 | QWindowSystemInterfacePrivate::eventTime.start(); | - |
1017 | | - |
1018 | is_app_running = true; | - |
1019 | init_plugins(pluginList); | - |
1020 | QWindowSystemInterface::flushWindowSystemEvents(); | - |
1021 | | - |
1022 | Q_Q(QGuiApplication); | - |
1023 | | - |
1024 | #ifndef QT_NO_SESSIONMANAGER | - |
1025 | // connect to the session manager | - |
1026 | session_manager = new QSessionManager(q, session_id, session_key); | - |
1027 | #endif | - |
1028 | | - |
1029 | } | - |
1030 | | - |
1031 | extern void qt_cleanupFontDatabase(); | - |
1032 | | - |
1033 | QGuiApplicationPrivate::~QGuiApplicationPrivate() | - |
1034 | { | - |
1035 | is_app_closing = true; | - |
1036 | is_app_running = false; | - |
1037 | | - |
1038 | for (int i = 0; i < generic_plugin_list.count(); ++i) | - |
1039 | delete generic_plugin_list.at(i); | - |
1040 | generic_plugin_list.clear(); | - |
1041 | | - |
1042 | clearFontUnlocked(); | - |
1043 | | - |
1044 | QFont::cleanup(); | - |
1045 | | - |
1046 | #ifndef QT_NO_CURSOR | - |
1047 | QCursorData::cleanup(); | - |
1048 | #endif | - |
1049 | | - |
1050 | layout_direction = Qt::LeftToRight; | - |
1051 | | - |
1052 | cleanupThreadData(); | - |
1053 | | - |
1054 | delete styleHints; | - |
1055 | delete inputMethod; | - |
1056 | | - |
1057 | qt_cleanupFontDatabase(); | - |
1058 | | - |
1059 | QPixmapCache::clear(); | - |
1060 | | - |
1061 | delete platform_theme; | - |
1062 | platform_theme = 0; | - |
1063 | delete platform_integration; | - |
1064 | platform_integration = 0; | - |
1065 | delete m_gammaTables.load(); | - |
1066 | } | - |
1067 | | - |
1068 | #if 0 | - |
1069 | #ifndef QT_NO_CURSOR | - |
1070 | QCursor *overrideCursor(); | - |
1071 | void setOverrideCursor(const QCursor &); | - |
1072 | void changeOverrideCursor(const QCursor &); | - |
1073 | void restoreOverrideCursor(); | - |
1074 | #endif | - |
1075 | | - |
1076 | static QFont font(); | - |
1077 | static QFont font(const QWidget*); | - |
1078 | static QFont font(const char *className); | - |
1079 | static void setFont(const QFont &, const char* className = 0); | - |
1080 | static QFontMetrics fontMetrics(); | - |
1081 | | - |
1082 | #ifndef QT_NO_CLIPBOARD | - |
1083 | static QClipboard *clipboard(); | - |
1084 | #endif | - |
1085 | #endif | - |
1086 | | - |
1087 | /*! | - |
1088 | Returns the current state of the modifier keys on the keyboard. The current | - |
1089 | state is updated sychronously as the event queue is emptied of events that | - |
1090 | will spontaneously change the keyboard state (QEvent::KeyPress and | - |
1091 | QEvent::KeyRelease events). | - |
1092 | | - |
1093 | It should be noted this may not reflect the actual keys held on the input | - |
1094 | device at the time of calling but rather the modifiers as last reported in | - |
1095 | one of the above events. If no keys are being held Qt::NoModifier is | - |
1096 | returned. | - |
1097 | | - |
1098 | \sa mouseButtons(), queryKeyboardModifiers() | - |
1099 | */ | - |
1100 | Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() | - |
1101 | { | - |
1102 | return QGuiApplicationPrivate::modifier_buttons; | - |
1103 | } | - |
1104 | | - |
1105 | /*! | - |
1106 | \fn Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - |
1107 | | - |
1108 | Queries and returns the state of the modifier keys on the keyboard. | - |
1109 | Unlike keyboardModifiers, this method returns the actual keys held | - |
1110 | on the input device at the time of calling the method. | - |
1111 | | - |
1112 | It does not rely on the keypress events having been received by this | - |
1113 | process, which makes it possible to check the modifiers while moving | - |
1114 | a window, for instance. Note that in most cases, you should use | - |
1115 | keyboardModifiers(), which is faster and more accurate since it contains | - |
1116 | the state of the modifiers as they were when the currently processed | - |
1117 | event was received. | - |
1118 | | - |
1119 | \sa keyboardModifiers() | - |
1120 | */ | - |
1121 | Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - |
1122 | { | - |
1123 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - |
1124 | return pi->queryKeyboardModifiers(); | - |
1125 | } | - |
1126 | | - |
1127 | /*! | - |
1128 | Returns the current state of the buttons on the mouse. The current state is | - |
1129 | updated syncronously as the event queue is emptied of events that will | - |
1130 | spontaneously change the mouse state (QEvent::MouseButtonPress and | - |
1131 | QEvent::MouseButtonRelease events). | - |
1132 | | - |
1133 | It should be noted this may not reflect the actual buttons held on the | - |
1134 | input device at the time of calling but rather the mouse buttons as last | - |
1135 | reported in one of the above events. If no mouse buttons are being held | - |
1136 | Qt::NoButton is returned. | - |
1137 | | - |
1138 | \sa keyboardModifiers() | - |
1139 | */ | - |
1140 | Qt::MouseButtons QGuiApplication::mouseButtons() | - |
1141 | { | - |
1142 | return QGuiApplicationPrivate::mouse_buttons; | - |
1143 | } | - |
1144 | | - |
1145 | /*! | - |
1146 | Returns the platform's native interface, for platform specific | - |
1147 | functionality. | - |
1148 | */ | - |
1149 | QPlatformNativeInterface *QGuiApplication::platformNativeInterface() | - |
1150 | { | - |
1151 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - |
1152 | return pi ? pi->nativeInterface() : 0; | - |
1153 | } | - |
1154 | | - |
1155 | /*! | - |
1156 | Enters the main event loop and waits until exit() is called, and then | - |
1157 | returns the value that was set to exit() (which is 0 if exit() is called | - |
1158 | via quit()). | - |
1159 | | - |
1160 | It is necessary to call this function to start event handling. The main | - |
1161 | event loop receives events from the window system and dispatches these to | - |
1162 | the application widgets. | - |
1163 | | - |
1164 | Generally, no user interaction can take place before calling exec(). | - |
1165 | | - |
1166 | To make your application perform idle processing, e.g., executing a special | - |
1167 | function whenever there are no pending events, use a QTimer with 0 timeout. | - |
1168 | More advanced idle processing schemes can be achieved using processEvents(). | - |
1169 | | - |
1170 | We recommend that you connect clean-up code to the | - |
1171 | \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your | - |
1172 | application's \c{main()} function. This is because, on some platforms, the | - |
1173 | QApplication::exec() call may not return. | - |
1174 | | - |
1175 | \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), | - |
1176 | QCoreApplication::exec() | - |
1177 | */ | - |
1178 | int QGuiApplication::exec() | - |
1179 | { | - |
1180 | #ifndef QT_NO_ACCESSIBILITY | - |
1181 | QAccessible::setRootObject(qApp); | - |
1182 | #endif | - |
1183 | return QCoreApplication::exec(); | - |
1184 | } | - |
1185 | | - |
1186 | /*! \reimp | - |
1187 | */ | - |
1188 | bool QGuiApplication::notify(QObject *object, QEvent *event) | - |
1189 | { | - |
1190 | #ifndef QT_NO_SHORTCUT | - |
1191 | if (event->type() == QEvent::KeyPress) { | - |
1192 | // Try looking for a Shortcut before sending key events | - |
1193 | QWindow *w = qobject_cast<QWindow *>(object); | - |
1194 | QObject *focus = w ? w->focusObject() : 0; | - |
1195 | if (!focus) | - |
1196 | focus = object; | - |
1197 | if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, static_cast<QKeyEvent *>(event))) | - |
1198 | return true; | - |
1199 | } | - |
1200 | #endif | - |
1201 | | - |
1202 | if (object->isWindowType()) | - |
1203 | QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event); | - |
1204 | return QCoreApplication::notify(object, event); | - |
1205 | } | - |
1206 | | - |
1207 | /*! \reimp | - |
1208 | */ | - |
1209 | bool QGuiApplication::event(QEvent *e) | - |
1210 | { | - |
1211 | if(e->type() == QEvent::LanguageChange) { | - |
1212 | setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); | - |
1213 | } | - |
1214 | return QCoreApplication::event(e); | - |
1215 | } | - |
1216 | | - |
1217 | /*! | - |
1218 | \internal | - |
1219 | */ | - |
1220 | bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) | - |
1221 | { | - |
1222 | return QCoreApplication::compressEvent(event, receiver, postedEvents); | - |
1223 | } | - |
1224 | | - |
1225 | void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event) | - |
1226 | { | - |
1227 | if (!window) | - |
1228 | return; | - |
1229 | QPlatformWindow *platformWindow = window->handle(); | - |
1230 | if (!platformWindow) | - |
1231 | return; | - |
1232 | // spontaneous events come from the platform integration already, we don't need to send the events back | - |
1233 | if (event->spontaneous()) | - |
1234 | return; | - |
1235 | // let the platform window do any handling it needs to as well | - |
1236 | platformWindow->windowEvent(event); | - |
1237 | } | - |
1238 | | - |
1239 | bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) | - |
1240 | { | - |
1241 | return window->nativeEvent(eventType, message, result); | - |
1242 | } | - |
1243 | | - |
1244 | void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) | - |
1245 | { | - |
1246 | switch(e->type) { | - |
1247 | case QWindowSystemInterfacePrivate::FrameStrutMouse: | - |
1248 | case QWindowSystemInterfacePrivate::Mouse: | - |
1249 | QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); | - |
1250 | break; | - |
1251 | case QWindowSystemInterfacePrivate::Wheel: | - |
1252 | QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e)); | - |
1253 | break; | - |
1254 | case QWindowSystemInterfacePrivate::Key: | - |
1255 | QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e)); | - |
1256 | break; | - |
1257 | case QWindowSystemInterfacePrivate::Touch: | - |
1258 | QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e)); | - |
1259 | break; | - |
1260 | case QWindowSystemInterfacePrivate::GeometryChange: | - |
1261 | QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e)); | - |
1262 | break; | - |
1263 | case QWindowSystemInterfacePrivate::Enter: | - |
1264 | QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e)); | - |
1265 | break; | - |
1266 | case QWindowSystemInterfacePrivate::Leave: | - |
1267 | QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e)); | - |
1268 | break; | - |
1269 | case QWindowSystemInterfacePrivate::ActivatedWindow: | - |
1270 | QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e)); | - |
1271 | break; | - |
1272 | case QWindowSystemInterfacePrivate::WindowStateChanged: | - |
1273 | QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); | - |
1274 | break; | - |
1275 | case QWindowSystemInterfacePrivate::Close: | - |
1276 | QGuiApplicationPrivate::processCloseEvent( | - |
1277 | static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); | - |
1278 | break; | - |
1279 | case QWindowSystemInterfacePrivate::ScreenOrientation: | - |
1280 | QGuiApplicationPrivate::reportScreenOrientationChange( | - |
1281 | static_cast<QWindowSystemInterfacePrivate::ScreenOrientationEvent *>(e)); | - |
1282 | break; | - |
1283 | case QWindowSystemInterfacePrivate::ScreenGeometry: | - |
1284 | QGuiApplicationPrivate::reportGeometryChange( | - |
1285 | static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e)); | - |
1286 | break; | - |
1287 | case QWindowSystemInterfacePrivate::ScreenAvailableGeometry: | - |
1288 | QGuiApplicationPrivate::reportAvailableGeometryChange( | - |
1289 | static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e)); | - |
1290 | break; | - |
1291 | case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: | - |
1292 | QGuiApplicationPrivate::reportLogicalDotsPerInchChange( | - |
1293 | static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e)); | - |
1294 | break; | - |
1295 | case QWindowSystemInterfacePrivate::ScreenRefreshRate: | - |
1296 | QGuiApplicationPrivate::reportRefreshRateChange( | - |
1297 | static_cast<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *>(e)); | - |
1298 | break; | - |
1299 | case QWindowSystemInterfacePrivate::ThemeChange: | - |
1300 | QGuiApplicationPrivate::processThemeChanged( | - |
1301 | static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e)); | - |
1302 | break; | - |
1303 | case QWindowSystemInterfacePrivate::Expose: | - |
1304 | QGuiApplicationPrivate::processExposeEvent(static_cast<QWindowSystemInterfacePrivate::ExposeEvent *>(e)); | - |
1305 | break; | - |
1306 | case QWindowSystemInterfacePrivate::Tablet: | - |
1307 | QGuiApplicationPrivate::processTabletEvent( | - |
1308 | static_cast<QWindowSystemInterfacePrivate::TabletEvent *>(e)); | - |
1309 | break; | - |
1310 | case QWindowSystemInterfacePrivate::TabletEnterProximity: | - |
1311 | QGuiApplicationPrivate::processTabletEnterProximityEvent( | - |
1312 | static_cast<QWindowSystemInterfacePrivate::TabletEnterProximityEvent *>(e)); | - |
1313 | break; | - |
1314 | case QWindowSystemInterfacePrivate::TabletLeaveProximity: | - |
1315 | QGuiApplicationPrivate::processTabletLeaveProximityEvent( | - |
1316 | static_cast<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *>(e)); | - |
1317 | break; | - |
1318 | case QWindowSystemInterfacePrivate::PlatformPanel: | - |
1319 | QGuiApplicationPrivate::processPlatformPanelEvent( | - |
1320 | static_cast<QWindowSystemInterfacePrivate::PlatformPanelEvent *>(e)); | - |
1321 | break; | - |
1322 | case QWindowSystemInterfacePrivate::FileOpen: | - |
1323 | QGuiApplicationPrivate::processFileOpenEvent( | - |
1324 | static_cast<QWindowSystemInterfacePrivate::FileOpenEvent *>(e)); | - |
1325 | break; | - |
1326 | #ifndef QT_NO_CONTEXTMENU | - |
1327 | case QWindowSystemInterfacePrivate::ContextMenu: | - |
1328 | QGuiApplicationPrivate::processContextMenuEvent( | - |
1329 | static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e)); | - |
1330 | break; | - |
1331 | #endif | - |
1332 | default: | - |
1333 | qWarning() << "Unknown user input event type:" << e->type; | - |
1334 | break; | - |
1335 | } | - |
1336 | } | - |
1337 | | - |
1338 | void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) | - |
1339 | { | - |
1340 | QEvent::Type type; | - |
1341 | // move first | - |
1342 | Qt::MouseButtons stateChange = e->buttons ^ buttons; | - |
1343 | const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse; | - |
1344 | if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { | - |
1345 | QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent = | - |
1346 | new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers); | - |
1347 | QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop | - |
1348 | stateChange = Qt::NoButton; | - |
1349 | } | - |
1350 | | - |
1351 | QWindow *window = e->window.data(); | - |
1352 | modifier_buttons = e->modifiers; | - |
1353 | | - |
1354 | QPointF localPoint = e->localPos; | - |
1355 | QPointF globalPoint = e->globalPos; | - |
1356 | | - |
1357 | if (e->nullWindow) { | - |
1358 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - |
1359 | if (window) { | - |
1360 | QPointF delta = globalPoint - globalPoint.toPoint(); | - |
1361 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - |
1362 | } | - |
1363 | } | - |
1364 | | - |
1365 | Qt::MouseButton button = Qt::NoButton; | - |
1366 | bool doubleClick = false; | - |
1367 | | - |
1368 | if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) { | - |
1369 | type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove; | - |
1370 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - |
1371 | if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance|| | - |
1372 | qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance) | - |
1373 | mousePressButton = Qt::NoButton; | - |
1374 | } else { // Check to see if a new button has been pressed/released. | - |
1375 | for (int check = Qt::LeftButton; | - |
1376 | check <= int(Qt::MaxMouseButton); | - |
1377 | check = check << 1) { | - |
1378 | if (check & stateChange) { | - |
1379 | button = Qt::MouseButton(check); | - |
1380 | break; | - |
1381 | } | - |
1382 | } | - |
1383 | if (button == Qt::NoButton) { | - |
1384 | // Ignore mouse events that don't change the current state. | - |
1385 | return; | - |
1386 | } | - |
1387 | mouse_buttons = buttons = e->buttons; | - |
1388 | if (button & e->buttons) { | - |
1389 | ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval()); | - |
1390 | doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton; | - |
1391 | type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress; | - |
1392 | mousePressTime = e->timestamp; | - |
1393 | mousePressButton = button; | - |
1394 | const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint(); | - |
1395 | mousePressX = point.x(); | - |
1396 | mousePressY = point.y(); | - |
1397 | } else { | - |
1398 | type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease; | - |
1399 | } | - |
1400 | } | - |
1401 | | - |
1402 | if (!window) | - |
1403 | return; | - |
1404 | | - |
1405 | if (window->d_func()->blockedByModalWindow) { | - |
1406 | // a modal window is blocking this window, don't allow mouse events through | - |
1407 | return; | - |
1408 | } | - |
1409 | | - |
1410 | QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers); | - |
1411 | ev.setTimestamp(e->timestamp); | - |
1412 | #ifndef QT_NO_CURSOR | - |
1413 | if (const QScreen *screen = window->screen()) | - |
1414 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - |
1415 | cursor->pointerEvent(ev); | - |
1416 | #endif | - |
1417 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1418 | if (!e->synthetic && !ev.isAccepted() | - |
1419 | && !frameStrut | - |
1420 | && qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) { | - |
1421 | if (!m_fakeTouchDevice) { | - |
1422 | m_fakeTouchDevice = new QTouchDevice; | - |
1423 | QWindowSystemInterface::registerTouchDevice(m_fakeTouchDevice); | - |
1424 | } | - |
1425 | QList<QWindowSystemInterface::TouchPoint> points; | - |
1426 | QWindowSystemInterface::TouchPoint point; | - |
1427 | point.id = 1; | - |
1428 | point.area = QRectF(globalPoint.x() - 2, globalPoint.y() - 2, 4, 4); | - |
1429 | | - |
1430 | // only translate left button related events to | - |
1431 | // avoid strange touch event sequences when several | - |
1432 | // buttons are pressed | - |
1433 | if (type == QEvent::MouseButtonPress && button == Qt::LeftButton) { | - |
1434 | point.state = Qt::TouchPointPressed; | - |
1435 | } else if (type == QEvent::MouseButtonRelease && button == Qt::LeftButton) { | - |
1436 | point.state = Qt::TouchPointReleased; | - |
1437 | } else if (type == QEvent::MouseMove && (buttons & Qt::LeftButton)) { | - |
1438 | point.state = Qt::TouchPointMoved; | - |
1439 | } else { | - |
1440 | return; | - |
1441 | } | - |
1442 | | - |
1443 | points << point; | - |
1444 | | - |
1445 | QEvent::Type type; | - |
1446 | QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::convertTouchPoints(points, &type); | - |
1447 | | - |
1448 | QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); | - |
1449 | fake.synthetic = true; | - |
1450 | processTouchEvent(&fake); | - |
1451 | } | - |
1452 | if (doubleClick) { | - |
1453 | mousePressButton = Qt::NoButton; | - |
1454 | const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick; | - |
1455 | QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, | - |
1456 | button, buttons, e->modifiers); | - |
1457 | dblClickEvent.setTimestamp(e->timestamp); | - |
1458 | QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent); | - |
1459 | } | - |
1460 | } | - |
1461 | | - |
1462 | void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) | - |
1463 | { | - |
1464 | #ifndef QT_NO_WHEELEVENT | - |
1465 | QWindow *window = e->window.data(); | - |
1466 | QPointF globalPoint = e->globalPos; | - |
1467 | QPointF localPoint = e->localPos; | - |
1468 | | - |
1469 | if (e->nullWindow) { | - |
1470 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - |
1471 | if (window) { | - |
1472 | QPointF delta = globalPoint - globalPoint.toPoint(); | - |
1473 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - |
1474 | } | - |
1475 | } | - |
1476 | | - |
1477 | if (!window) | - |
1478 | return; | - |
1479 | | - |
1480 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - |
1481 | modifier_buttons = e->modifiers; | - |
1482 | | - |
1483 | if (window->d_func()->blockedByModalWindow) { | - |
1484 | // a modal window is blocking this window, don't allow wheel events through | - |
1485 | return; | - |
1486 | } | - |
1487 | | - |
1488 | QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers); | - |
1489 | ev.setTimestamp(e->timestamp); | - |
1490 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1491 | #endif /* ifndef QT_NO_WHEELEVENT */ | - |
1492 | } | - |
1493 | | - |
1494 | // Remember, Qt convention is: keyboard state is state *before* | - |
1495 | | - |
1496 | void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) | - |
1497 | { | - |
1498 | QWindow *window = e->window.data(); | - |
1499 | modifier_buttons = e->modifiers; | - |
1500 | if (e->nullWindow) | - |
1501 | window = QGuiApplication::focusWindow(); | - |
1502 | if (!window) | - |
1503 | return; | - |
1504 | if (window->d_func()->blockedByModalWindow) { | - |
1505 | // a modal window is blocking this window, don't allow key events through | - |
1506 | return; | - |
1507 | } | - |
1508 | | - |
1509 | QKeyEvent ev(e->keyType, e->key, e->modifiers, | - |
1510 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, | - |
1511 | e->unicode, e->repeat, e->repeatCount); | - |
1512 | ev.setTimestamp(e->timestamp); | - |
1513 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1514 | } | - |
1515 | | - |
1516 | void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) | - |
1517 | { | - |
1518 | if (!e->enter) | - |
1519 | return; | - |
1520 | if (e->enter.data()->d_func()->blockedByModalWindow) { | - |
1521 | // a modal window is blocking this window, don't allow enter events through | - |
1522 | return; | - |
1523 | } | - |
1524 | | - |
1525 | currentMouseWindow = e->enter; | - |
1526 | | - |
1527 | QEnterEvent event(e->localPos, e->localPos, e->globalPos); | - |
1528 | QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); | - |
1529 | } | - |
1530 | | - |
1531 | void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) | - |
1532 | { | - |
1533 | if (!e->leave) | - |
1534 | return; | - |
1535 | if (e->leave.data()->d_func()->blockedByModalWindow) { | - |
1536 | // a modal window is blocking this window, don't allow leave events through | - |
1537 | return; | - |
1538 | } | - |
1539 | | - |
1540 | currentMouseWindow = 0; | - |
1541 | | - |
1542 | QEvent event(QEvent::Leave); | - |
1543 | QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); | - |
1544 | } | - |
1545 | | - |
1546 | void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) | - |
1547 | { | - |
1548 | QWindow *previous = QGuiApplicationPrivate::focus_window; | - |
1549 | QWindow *newFocus = e->activated.data(); | - |
1550 | | - |
1551 | if (previous == newFocus) | - |
1552 | return; | - |
1553 | | - |
1554 | QObject *previousFocusObject = previous ? previous->focusObject() : 0; | - |
1555 | | - |
1556 | if (previous) { | - |
1557 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - |
1558 | QCoreApplication::sendSpontaneousEvent(previous, &focusAboutToChange); | - |
1559 | } | - |
1560 | | - |
1561 | QGuiApplicationPrivate::focus_window = newFocus; | - |
1562 | | - |
1563 | if (previous) { | - |
1564 | QFocusEvent focusOut(QEvent::FocusOut); | - |
1565 | QCoreApplication::sendSpontaneousEvent(previous, &focusOut); | - |
1566 | QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)), | - |
1567 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - |
1568 | } else { | - |
1569 | QEvent appActivate(QEvent::ApplicationActivate); | - |
1570 | qApp->sendSpontaneousEvent(qApp, &appActivate); | - |
1571 | } | - |
1572 | | - |
1573 | if (QGuiApplicationPrivate::focus_window) { | - |
1574 | QFocusEvent focusIn(QEvent::FocusIn); | - |
1575 | QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); | - |
1576 | QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)), | - |
1577 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - |
1578 | } else { | - |
1579 | QEvent appActivate(QEvent::ApplicationDeactivate); | - |
1580 | qApp->sendSpontaneousEvent(qApp, &appActivate); | - |
1581 | } | - |
1582 | | - |
1583 | if (self) { | - |
1584 | self->notifyActiveWindowChange(previous); | - |
1585 | | - |
1586 | if (previousFocusObject != qApp->focusObject()) | - |
1587 | self->_q_updateFocusObject(qApp->focusObject()); | - |
1588 | } | - |
1589 | | - |
1590 | emit qApp->focusWindowChanged(newFocus); | - |
1591 | } | - |
1592 | | - |
1593 | void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) | - |
1594 | { | - |
1595 | if (QWindow *window = wse->window.data()) { | - |
1596 | QWindowStateChangeEvent e(window->windowState()); | - |
1597 | window->d_func()->windowState = wse->newState; | - |
1598 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1599 | } | - |
1600 | } | - |
1601 | | - |
1602 | void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) | - |
1603 | { | - |
1604 | if (self) | - |
1605 | self->notifyThemeChanged(); | - |
1606 | if (QWindow *window = tce->window.data()) { | - |
1607 | QEvent e(QEvent::ThemeChange); | - |
1608 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1609 | } | - |
1610 | } | - |
1611 | | - |
1612 | void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) | - |
1613 | { | - |
1614 | if (e->tlw.isNull()) | - |
1615 | return; | - |
1616 | | - |
1617 | QWindow *window = e->tlw.data(); | - |
1618 | if (!window) | - |
1619 | return; | - |
1620 | | - |
1621 | QRect newRect = e->newGeometry; | - |
1622 | QRect cr = window->d_func()->geometry; | - |
1623 | | - |
1624 | bool isResize = cr.size() != newRect.size(); | - |
1625 | bool isMove = cr.topLeft() != newRect.topLeft(); | - |
1626 | | - |
1627 | window->d_func()->geometry = newRect; | - |
1628 | | - |
1629 | if (isResize || window->d_func()->resizeEventPending) { | - |
1630 | QResizeEvent e(newRect.size(), cr.size()); | - |
1631 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1632 | | - |
1633 | window->d_func()->resizeEventPending = false; | - |
1634 | | - |
1635 | if (cr.width() != newRect.width()) | - |
1636 | window->widthChanged(newRect.width()); | - |
1637 | if (cr.height() != newRect.height()) | - |
1638 | window->heightChanged(newRect.height()); | - |
1639 | } | - |
1640 | | - |
1641 | if (isMove) { | - |
1642 | //### frame geometry | - |
1643 | QMoveEvent e(newRect.topLeft(), cr.topLeft()); | - |
1644 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
1645 | | - |
1646 | if (cr.x() != newRect.x()) | - |
1647 | window->xChanged(newRect.x()); | - |
1648 | if (cr.y() != newRect.y()) | - |
1649 | window->yChanged(newRect.y()); | - |
1650 | } | - |
1651 | } | - |
1652 | | - |
1653 | void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) | - |
1654 | { | - |
1655 | if (e->window.isNull()) | - |
1656 | return; | - |
1657 | if (e->window.data()->d_func()->blockedByModalWindow) { | - |
1658 | // a modal window is blocking this window, don't allow close events through | - |
1659 | return; | - |
1660 | } | - |
1661 | | - |
1662 | QCloseEvent event; | - |
1663 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); | - |
1664 | } | - |
1665 | | - |
1666 | void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) | - |
1667 | { | - |
1668 | if (e->fileName.isEmpty()) | - |
1669 | return; | - |
1670 | | - |
1671 | QFileOpenEvent event(e->fileName); | - |
1672 | QGuiApplication::sendSpontaneousEvent(qApp, &event); | - |
1673 | } | - |
1674 | | - |
1675 | void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) | - |
1676 | { | - |
1677 | #ifndef QT_NO_TABLETEVENT | - |
1678 | QEvent::Type type = QEvent::TabletMove; | - |
1679 | if (e->down != tabletState) { | - |
1680 | type = e->down ? QEvent::TabletPress : QEvent::TabletRelease; | - |
1681 | tabletState = e->down; | - |
1682 | } | - |
1683 | | - |
1684 | QWindow *window = e->window.data(); | - |
1685 | modifier_buttons = e->modifiers; | - |
1686 | | - |
1687 | bool localValid = true; | - |
1688 | // If window is null, pick one based on the global position and make sure all | - |
1689 | // subsequent events up to the release are delivered to that same window. | - |
1690 | // If window is given, just send to that. | - |
1691 | if (type == QEvent::TabletPress) { | - |
1692 | if (e->nullWindow) { | - |
1693 | window = QGuiApplication::topLevelAt(e->global.toPoint()); | - |
1694 | localValid = false; | - |
1695 | } | - |
1696 | if (!window) | - |
1697 | return; | - |
1698 | tabletPressTarget = window; | - |
1699 | } else { | - |
1700 | if (e->nullWindow) { | - |
1701 | window = tabletPressTarget; | - |
1702 | localValid = false; | - |
1703 | } | - |
1704 | if (type == QEvent::TabletRelease) | - |
1705 | tabletPressTarget = 0; | - |
1706 | if (!window) | - |
1707 | return; | - |
1708 | } | - |
1709 | QPointF local = e->local; | - |
1710 | if (!localValid) { | - |
1711 | QPointF delta = e->global - e->global.toPoint(); | - |
1712 | local = window->mapFromGlobal(e->global.toPoint()) + delta; | - |
1713 | } | - |
1714 | QTabletEvent ev(type, local, e->global, | - |
1715 | e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt, | - |
1716 | e->tangentialPressure, e->rotation, e->z, | - |
1717 | e->modifiers, e->uid); | - |
1718 | ev.setTimestamp(e->timestamp); | - |
1719 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - |
1720 | #else | - |
1721 | Q_UNUSED(e) | - |
1722 | #endif | - |
1723 | } | - |
1724 | | - |
1725 | void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e) | - |
1726 | { | - |
1727 | #ifndef QT_NO_TABLETEVENT | - |
1728 | QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), | - |
1729 | e->device, e->pointerType, 0, 0, 0, | - |
1730 | 0, 0, 0, | - |
1731 | Qt::NoModifier, e->uid); | - |
1732 | ev.setTimestamp(e->timestamp); | - |
1733 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - |
1734 | #else | - |
1735 | Q_UNUSED(e) | - |
1736 | #endif | - |
1737 | } | - |
1738 | | - |
1739 | void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e) | - |
1740 | { | - |
1741 | #ifndef QT_NO_TABLETEVENT | - |
1742 | QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), | - |
1743 | e->device, e->pointerType, 0, 0, 0, | - |
1744 | 0, 0, 0, | - |
1745 | Qt::NoModifier, e->uid); | - |
1746 | ev.setTimestamp(e->timestamp); | - |
1747 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - |
1748 | #else | - |
1749 | Q_UNUSED(e) | - |
1750 | #endif | - |
1751 | } | - |
1752 | | - |
1753 | void QGuiApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e) | - |
1754 | { | - |
1755 | if (!e->window) | - |
1756 | return; | - |
1757 | | - |
1758 | if (e->window->d_func()->blockedByModalWindow) { | - |
1759 | // a modal window is blocking this window, don't allow events through | - |
1760 | return; | - |
1761 | } | - |
1762 | | - |
1763 | QEvent ev(QEvent::PlatformPanel); | - |
1764 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - |
1765 | } | - |
1766 | | - |
1767 | #ifndef QT_NO_CONTEXTMENU | - |
1768 | void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e) | - |
1769 | { | - |
1770 | // Widgets do not care about mouse triggered context menu events. Also, do not forward event | - |
1771 | // to a window blocked by a modal window. | - |
1772 | if (!e->window || e->mouseTriggered || e->window->d_func()->blockedByModalWindow) | - |
1773 | return; | - |
1774 | | - |
1775 | QContextMenuEvent ev(QContextMenuEvent::Keyboard, e->pos, e->globalPos, e->modifiers); | - |
1776 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - |
1777 | } | - |
1778 | #endif | - |
1779 | | - |
1780 | Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) | - |
1781 | { | - |
1782 | return qHash(k.device) + k.touchPointId; | - |
1783 | } | - |
1784 | | - |
1785 | Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, | - |
1786 | const QGuiApplicationPrivate::ActiveTouchPointsKey &b) | - |
1787 | { | - |
1788 | return a.device == b.device | - |
1789 | && a.touchPointId == b.touchPointId; | - |
1790 | } | - |
1791 | | - |
1792 | void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) | - |
1793 | { | - |
1794 | QGuiApplicationPrivate *d = self; | - |
1795 | modifier_buttons = e->modifiers; | - |
1796 | | - |
1797 | if (e->touchType == QEvent::TouchCancel) { | - |
1798 | // The touch sequence has been canceled (e.g. by the compositor). | - |
1799 | // Send the TouchCancel to all windows with active touches and clean up. | - |
1800 | QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers); | - |
1801 | touchEvent.setTimestamp(e->timestamp); | - |
1802 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it | - |
1803 | = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); | - |
1804 | QSet<QWindow *> windowsNeedingCancel; | - |
1805 | while (it != ite) { | - |
1806 | QWindow *w = it->window.data(); | - |
1807 | if (w) | - |
1808 | windowsNeedingCancel.insert(w); | - |
1809 | ++it; | - |
1810 | } | - |
1811 | for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(), | - |
1812 | winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) { | - |
1813 | touchEvent.setWindow(*winIt); | - |
1814 | QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); | - |
1815 | } | - |
1816 | if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) { | - |
1817 | for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), | - |
1818 | synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) { | - |
1819 | if (!synthIt->window) | - |
1820 | continue; | - |
1821 | QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), | - |
1822 | e->timestamp, | - |
1823 | synthIt->pos, | - |
1824 | synthIt->screenPos, | - |
1825 | Qt::NoButton, | - |
1826 | e->modifiers); | - |
1827 | fake.synthetic = true; | - |
1828 | processMouseEvent(&fake); | - |
1829 | } | - |
1830 | self->synthesizedMousePoints.clear(); | - |
1831 | } | - |
1832 | self->activeTouchPoints.clear(); | - |
1833 | self->lastTouchType = e->touchType; | - |
1834 | return; | - |
1835 | } | - |
1836 | | - |
1837 | // Prevent sending ill-formed event sequences: Cancel can only be followed by a Begin. | - |
1838 | if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin) | - |
1839 | return; | - |
1840 | | - |
1841 | self->lastTouchType = e->touchType; | - |
1842 | | - |
1843 | QWindow *window = e->window.data(); | - |
1844 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - |
1845 | QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; | - |
1846 | | - |
1847 | for (int i = 0; i < e->points.count(); ++i) { | - |
1848 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - |
1849 | // explicitly detach from the original touch point that we got, so even | - |
1850 | // if the touchpoint structs are reused, we will make a copy that we'll | - |
1851 | // deliver to the user (which might want to store the struct for later use). | - |
1852 | touchPoint.d = touchPoint.d->detach(); | - |
1853 | | - |
1854 | // update state | - |
1855 | QPointer<QWindow> w; | - |
1856 | QTouchEvent::TouchPoint previousTouchPoint; | - |
1857 | ActiveTouchPointsKey touchInfoKey(e->device, touchPoint.id()); | - |
1858 | ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; | - |
1859 | switch (touchPoint.state()) { | - |
1860 | case Qt::TouchPointPressed: | - |
1861 | if (e->device->type() == QTouchDevice::TouchPad) { | - |
1862 | // on touch-pads, send all touch points to the same widget | - |
1863 | w = d->activeTouchPoints.isEmpty() | - |
1864 | ? QPointer<QWindow>() | - |
1865 | : d->activeTouchPoints.constBegin().value().window; | - |
1866 | } | - |
1867 | | - |
1868 | if (!w) { | - |
1869 | // determine which window this event will go to | - |
1870 | if (!window) | - |
1871 | window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); | - |
1872 | if (!window) | - |
1873 | continue; | - |
1874 | w = window; | - |
1875 | } | - |
1876 | | - |
1877 | touchInfo.window = w; | - |
1878 | touchPoint.d->startScreenPos = touchPoint.screenPos(); | - |
1879 | touchPoint.d->lastScreenPos = touchPoint.screenPos(); | - |
1880 | touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); | - |
1881 | touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); | - |
1882 | if (touchPoint.pressure() < qreal(0.)) | - |
1883 | touchPoint.d->pressure = qreal(1.); | - |
1884 | | - |
1885 | touchInfo.touchPoint = touchPoint; | - |
1886 | break; | - |
1887 | | - |
1888 | case Qt::TouchPointReleased: | - |
1889 | w = touchInfo.window; | - |
1890 | if (!w) | - |
1891 | continue; | - |
1892 | | - |
1893 | previousTouchPoint = touchInfo.touchPoint; | - |
1894 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - |
1895 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - |
1896 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - |
1897 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - |
1898 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - |
1899 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - |
1900 | if (touchPoint.pressure() < qreal(0.)) | - |
1901 | touchPoint.d->pressure = qreal(0.); | - |
1902 | | - |
1903 | break; | - |
1904 | | - |
1905 | default: | - |
1906 | w = touchInfo.window; | - |
1907 | if (!w) | - |
1908 | continue; | - |
1909 | | - |
1910 | previousTouchPoint = touchInfo.touchPoint; | - |
1911 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - |
1912 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - |
1913 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - |
1914 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - |
1915 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - |
1916 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - |
1917 | if (touchPoint.pressure() < qreal(0.)) | - |
1918 | touchPoint.d->pressure = qreal(1.); | - |
1919 | | - |
1920 | // Stationary points might not be delivered down to the receiving item | - |
1921 | // and get their position transformed, keep the old values instead. | - |
1922 | if (touchPoint.state() != Qt::TouchPointStationary) | - |
1923 | touchInfo.touchPoint = touchPoint; | - |
1924 | break; | - |
1925 | } | - |
1926 | | - |
1927 | Q_ASSERT(w.data() != 0); | - |
1928 | | - |
1929 | // make the *scene* functions return the same as the *screen* functions | - |
1930 | touchPoint.d->sceneRect = touchPoint.screenRect(); | - |
1931 | touchPoint.d->startScenePos = touchPoint.startScreenPos(); | - |
1932 | touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); | - |
1933 | | - |
1934 | StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()]; | - |
1935 | maskAndPoints.first |= touchPoint.state(); | - |
1936 | maskAndPoints.second.append(touchPoint); | - |
1937 | } | - |
1938 | | - |
1939 | if (windowsNeedingEvents.isEmpty()) | - |
1940 | return; | - |
1941 | | - |
1942 | QHash<QWindow *, StatesAndTouchPoints>::ConstIterator it = windowsNeedingEvents.constBegin(); | - |
1943 | const QHash<QWindow *, StatesAndTouchPoints>::ConstIterator end = windowsNeedingEvents.constEnd(); | - |
1944 | for (; it != end; ++it) { | - |
1945 | QWindow *w = it.key(); | - |
1946 | | - |
1947 | QEvent::Type eventType; | - |
1948 | switch (it.value().first) { | - |
1949 | case Qt::TouchPointPressed: | - |
1950 | eventType = QEvent::TouchBegin; | - |
1951 | break; | - |
1952 | case Qt::TouchPointReleased: | - |
1953 | eventType = QEvent::TouchEnd; | - |
1954 | break; | - |
1955 | case Qt::TouchPointStationary: | - |
1956 | // don't send the event if nothing changed | - |
1957 | continue; | - |
1958 | default: | - |
1959 | eventType = QEvent::TouchUpdate; | - |
1960 | break; | - |
1961 | } | - |
1962 | | - |
1963 | if (w->d_func()->blockedByModalWindow) { | - |
1964 | // a modal window is blocking this window, don't allow touch events through | - |
1965 | continue; | - |
1966 | } | - |
1967 | | - |
1968 | QTouchEvent touchEvent(eventType, | - |
1969 | e->device, | - |
1970 | e->modifiers, | - |
1971 | it.value().first, | - |
1972 | it.value().second); | - |
1973 | touchEvent.setTimestamp(e->timestamp); | - |
1974 | touchEvent.setWindow(w); | - |
1975 | | - |
1976 | const int pointCount = touchEvent.touchPoints().count(); | - |
1977 | for (int i = 0; i < pointCount; ++i) { | - |
1978 | QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; | - |
1979 | | - |
1980 | // preserve the sub-pixel resolution | - |
1981 | QRectF rect = touchPoint.screenRect(); | - |
1982 | const QPointF screenPos = rect.center(); | - |
1983 | const QPointF delta = screenPos - screenPos.toPoint(); | - |
1984 | | - |
1985 | rect.moveCenter(w->mapFromGlobal(screenPos.toPoint()) + delta); | - |
1986 | touchPoint.d->rect = rect; | - |
1987 | if (touchPoint.state() == Qt::TouchPointPressed) { | - |
1988 | touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; | - |
1989 | touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; | - |
1990 | } | - |
1991 | } | - |
1992 | | - |
1993 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - |
1994 | if (!e->synthetic && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) { | - |
1995 | // exclude touchpads as those generate their own mouse events | - |
1996 | if (touchEvent.device()->type() != QTouchDevice::TouchPad) { | - |
1997 | Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton; | - |
1998 | if (b == Qt::NoButton) | - |
1999 | self->synthesizedMousePoints.clear(); | - |
2000 | | - |
2001 | QList<QTouchEvent::TouchPoint> touchPoints = touchEvent.touchPoints(); | - |
2002 | if (eventType == QEvent::TouchBegin) | - |
2003 | m_fakeMouseSourcePointId = touchPoints.first().id(); | - |
2004 | | - |
2005 | for (int i = 0; i < touchPoints.count(); ++i) { | - |
2006 | const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); | - |
2007 | if (touchPoint.id() == m_fakeMouseSourcePointId) { | - |
2008 | if (b != Qt::NoButton) | - |
2009 | self->synthesizedMousePoints.insert(w, SynthesizedMouseData( | - |
2010 | touchPoint.pos(), touchPoint.screenPos(), w)); | - |
2011 | QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, | - |
2012 | touchPoint.pos(), | - |
2013 | touchPoint.screenPos(), | - |
2014 | b, e->modifiers); | - |
2015 | fake.synthetic = true; | - |
2016 | processMouseEvent(&fake); | - |
2017 | break; | - |
2018 | } | - |
2019 | } | - |
2020 | } | - |
2021 | } | - |
2022 | } | - |
2023 | | - |
2024 | // Remove released points from the hash table only after the event is | - |
2025 | // delivered. When the receiver is a widget, QApplication will access | - |
2026 | // activeTouchPoints during delivery and therefore nothing can be removed | - |
2027 | // before sending the event. | - |
2028 | for (int i = 0; i < e->points.count(); ++i) { | - |
2029 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - |
2030 | if (touchPoint.state() == Qt::TouchPointReleased) | - |
2031 | d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); | - |
2032 | } | - |
2033 | } | - |
2034 | | - |
2035 | void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) | - |
2036 | { | - |
2037 | // This operation only makes sense after the QGuiApplication constructor runs | - |
2038 | if (QCoreApplication::startingUp()) | - |
2039 | return; | - |
2040 | | - |
2041 | if (!e->screen) | - |
2042 | return; | - |
2043 | | - |
2044 | QScreen *s = e->screen.data(); | - |
2045 | s->d_func()->orientation = e->orientation; | - |
2046 | | - |
2047 | updateFilteredScreenOrientation(s); | - |
2048 | } | - |
2049 | | - |
2050 | void QGuiApplicationPrivate::updateFilteredScreenOrientation(QScreen *s) | - |
2051 | { | - |
2052 | Qt::ScreenOrientation o = s->d_func()->orientation; | - |
2053 | if (o == Qt::PrimaryOrientation) | - |
2054 | o = s->primaryOrientation(); | - |
2055 | o = Qt::ScreenOrientation(o & s->orientationUpdateMask()); | - |
2056 | if (o == Qt::PrimaryOrientation) | - |
2057 | return; | - |
2058 | if (o == s->d_func()->filteredOrientation) | - |
2059 | return; | - |
2060 | s->d_func()->filteredOrientation = o; | - |
2061 | reportScreenOrientationChange(s); | - |
2062 | } | - |
2063 | | - |
2064 | void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) | - |
2065 | { | - |
2066 | emit s->orientationChanged(s->orientation()); | - |
2067 | | - |
2068 | QScreenOrientationChangeEvent event(s, s->orientation()); | - |
2069 | QCoreApplication::sendEvent(QCoreApplication::instance(), &event); | - |
2070 | } | - |
2071 | | - |
2072 | void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) | - |
2073 | { | - |
2074 | // This operation only makes sense after the QGuiApplication constructor runs | - |
2075 | if (QCoreApplication::startingUp()) | - |
2076 | return; | - |
2077 | | - |
2078 | if (!e->screen) | - |
2079 | return; | - |
2080 | | - |
2081 | QScreen *s = e->screen.data(); | - |
2082 | s->d_func()->geometry = e->geometry; | - |
2083 | | - |
2084 | Qt::ScreenOrientation primaryOrientation = s->primaryOrientation(); | - |
2085 | s->d_func()->updatePrimaryOrientation(); | - |
2086 | | - |
2087 | emit s->geometryChanged(s->geometry()); | - |
2088 | emit s->physicalSizeChanged(s->physicalSize()); | - |
2089 | emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch()); | - |
2090 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - |
2091 | foreach (QScreen* sibling, s->virtualSiblings()) | - |
2092 | emit sibling->virtualGeometryChanged(sibling->virtualGeometry()); | - |
2093 | | - |
2094 | if (s->primaryOrientation() != primaryOrientation) | - |
2095 | emit s->primaryOrientationChanged(s->primaryOrientation()); | - |
2096 | | - |
2097 | if (s->d_func()->orientation == Qt::PrimaryOrientation) | - |
2098 | updateFilteredScreenOrientation(s); | - |
2099 | } | - |
2100 | | - |
2101 | void QGuiApplicationPrivate::reportAvailableGeometryChange( | - |
2102 | QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e) | - |
2103 | { | - |
2104 | // This operation only makes sense after the QGuiApplication constructor runs | - |
2105 | if (QCoreApplication::startingUp()) | - |
2106 | return; | - |
2107 | | - |
2108 | if (!e->screen) | - |
2109 | return; | - |
2110 | | - |
2111 | QScreen *s = e->screen.data(); | - |
2112 | s->d_func()->availableGeometry = e->availableGeometry; | - |
2113 | | - |
2114 | foreach (QScreen* sibling, s->virtualSiblings()) | - |
2115 | emit sibling->virtualGeometryChanged(sibling->virtualGeometry()); | - |
2116 | } | - |
2117 | | - |
2118 | void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) | - |
2119 | { | - |
2120 | // This operation only makes sense after the QGuiApplication constructor runs | - |
2121 | if (QCoreApplication::startingUp()) | - |
2122 | return; | - |
2123 | | - |
2124 | if (!e->screen) | - |
2125 | return; | - |
2126 | | - |
2127 | QScreen *s = e->screen.data(); | - |
2128 | s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); | - |
2129 | | - |
2130 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - |
2131 | } | - |
2132 | | - |
2133 | void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) | - |
2134 | { | - |
2135 | // This operation only makes sense after the QGuiApplication constructor runs | - |
2136 | if (QCoreApplication::startingUp()) | - |
2137 | return; | - |
2138 | | - |
2139 | if (!e->screen) | - |
2140 | return; | - |
2141 | | - |
2142 | QScreen *s = e->screen.data(); | - |
2143 | s->d_func()->refreshRate = e->rate; | - |
2144 | | - |
2145 | emit s->refreshRateChanged(s->refreshRate()); | - |
2146 | } | - |
2147 | | - |
2148 | void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e) | - |
2149 | { | - |
2150 | if (!e->exposed) | - |
2151 | return; | - |
2152 | | - |
2153 | QWindow *window = e->exposed.data(); | - |
2154 | QWindowPrivate *p = qt_window_private(window); | - |
2155 | | - |
2156 | if (!p->receivedExpose) { | - |
2157 | if (p->resizeEventPending) { | - |
2158 | // as a convenience for plugins, send a resize event before the first expose event if they haven't done so | - |
2159 | QSize size = p->geometry.size(); | - |
2160 | QResizeEvent e(size, size); | - |
2161 | QGuiApplication::sendSpontaneousEvent(window, &e); | - |
2162 | | - |
2163 | p->resizeEventPending = false; | - |
2164 | } | - |
2165 | | - |
2166 | p->receivedExpose = true; | - |
2167 | } | - |
2168 | | - |
2169 | p->exposed = e->isExposed; | - |
2170 | | - |
2171 | QExposeEvent exposeEvent(e->region); | - |
2172 | QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); | - |
2173 | } | - |
2174 | | - |
2175 | #ifndef QT_NO_DRAGANDDROP | - |
2176 | | - |
2177 | QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - |
2178 | { | - |
2179 | static QPointer<QWindow> currentDragWindow; | - |
2180 | static Qt::DropAction lastAcceptedDropAction = Qt::IgnoreAction; | - |
2181 | QPlatformDrag *platformDrag = platformIntegration()->drag(); | - |
2182 | if (!platformDrag) { | - |
2183 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
2184 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - |
2185 | } | - |
2186 | | - |
2187 | if (!dropData) { | - |
2188 | if (currentDragWindow.data() == w) | - |
2189 | currentDragWindow = 0; | - |
2190 | QDragLeaveEvent e; | - |
2191 | QGuiApplication::sendEvent(w, &e); | - |
2192 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
2193 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - |
2194 | } | - |
2195 | QDragMoveEvent me(p, supportedActions, dropData, | - |
2196 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
2197 | | - |
2198 | if (w != currentDragWindow) { | - |
2199 | lastAcceptedDropAction = Qt::IgnoreAction; | - |
2200 | if (currentDragWindow) { | - |
2201 | QDragLeaveEvent e; | - |
2202 | QGuiApplication::sendEvent(currentDragWindow, &e); | - |
2203 | } | - |
2204 | currentDragWindow = w; | - |
2205 | QDragEnterEvent e(p, supportedActions, dropData, | - |
2206 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
2207 | QGuiApplication::sendEvent(w, &e); | - |
2208 | if (e.isAccepted() && e.dropAction() != Qt::IgnoreAction) | - |
2209 | lastAcceptedDropAction = e.dropAction(); | - |
2210 | } | - |
2211 | | - |
2212 | // Handling 'DragEnter' should suffice for the application. | - |
2213 | if (lastAcceptedDropAction != Qt::IgnoreAction | - |
2214 | && (supportedActions & lastAcceptedDropAction)) { | - |
2215 | me.setDropAction(lastAcceptedDropAction); | - |
2216 | me.accept(); | - |
2217 | } | - |
2218 | QGuiApplication::sendEvent(w, &me); | - |
2219 | lastAcceptedDropAction = me.isAccepted() ? | - |
2220 | me.dropAction() : Qt::IgnoreAction; | - |
2221 | return QPlatformDragQtResponse(me.isAccepted(), lastAcceptedDropAction, me.answerRect()); | - |
2222 | } | - |
2223 | | - |
2224 | QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - |
2225 | { | - |
2226 | QDropEvent de(p, supportedActions, dropData, | - |
2227 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - |
2228 | QGuiApplication::sendEvent(w, &de); | - |
2229 | | - |
2230 | Qt::DropAction acceptedAction = de.isAccepted() ? de.dropAction() : Qt::IgnoreAction; | - |
2231 | QPlatformDropQtResponse response(de.isAccepted(),acceptedAction); | - |
2232 | return response; | - |
2233 | } | - |
2234 | | - |
2235 | #endif // QT_NO_DRAGANDDROP | - |
2236 | | - |
2237 | #ifndef QT_NO_CLIPBOARD | - |
2238 | /*! | - |
2239 | Returns the object for interacting with the clipboard. | - |
2240 | */ | - |
2241 | QClipboard * QGuiApplication::clipboard() | - |
2242 | { | - |
2243 | if (QGuiApplicationPrivate::qt_clipboard == 0) { | - |
2244 | if (!qApp) { | - |
2245 | qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); | - |
2246 | return 0; | - |
2247 | } | - |
2248 | QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); | - |
2249 | } | - |
2250 | return QGuiApplicationPrivate::qt_clipboard; | - |
2251 | } | - |
2252 | #endif | - |
2253 | | - |
2254 | /*! | - |
2255 | Returns the default application palette. | - |
2256 | | - |
2257 | \sa setPalette() | - |
2258 | */ | - |
2259 | | - |
2260 | QPalette QGuiApplication::palette() | - |
2261 | { | - |
2262 | initPalette(); | - |
2263 | return *QGuiApplicationPrivate::app_pal; | - |
2264 | } | - |
2265 | | - |
2266 | /*! | - |
2267 | Changes the default application palette to \a pal. | - |
2268 | | - |
2269 | \sa palette() | - |
2270 | */ | - |
2271 | void QGuiApplication::setPalette(const QPalette &pal) | - |
2272 | { | - |
2273 | if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) | - |
2274 | return; | - |
2275 | if (!QGuiApplicationPrivate::app_pal) | - |
2276 | QGuiApplicationPrivate::app_pal = new QPalette(pal); | - |
2277 | else | - |
2278 | *QGuiApplicationPrivate::app_pal = pal; | - |
2279 | applicationResourceFlags |= ApplicationPaletteExplicitlySet; | - |
2280 | } | - |
2281 | | - |
2282 | /*! | - |
2283 | Returns the default application font. | - |
2284 | | - |
2285 | \sa setFont() | - |
2286 | */ | - |
2287 | QFont QGuiApplication::font() | - |
2288 | { | - |
2289 | Q_ASSERT_X(QGuiApplicationPrivate::self, "QGuiApplication::font()", "no QGuiApplication instance"); executed (the execution status of this line is deduced): qt_noop(); | - |
2290 | QMutexLocker locker(&applicationFontMutex); executed (the execution status of this line is deduced): QMutexLocker locker(&applicationFontMutex); | - |
2291 | initFontUnlocked(); executed (the execution status of this line is deduced): initFontUnlocked(); | - |
2292 | return *QGuiApplicationPrivate::app_font; executed: return *QGuiApplicationPrivate::app_font; Execution Count:1200852 | 1200852 |
2293 | } | - |
2294 | | - |
2295 | /*! | - |
2296 | Changes the default application font to \a font. | - |
2297 | | - |
2298 | \sa font() | - |
2299 | */ | - |
2300 | void QGuiApplication::setFont(const QFont &font) | - |
2301 | { | - |
2302 | QMutexLocker locker(&applicationFontMutex); | - |
2303 | if (!QGuiApplicationPrivate::app_font) | - |
2304 | QGuiApplicationPrivate::app_font = new QFont(font); | - |
2305 | else | - |
2306 | *QGuiApplicationPrivate::app_font = font; | - |
2307 | applicationResourceFlags |= ApplicationFontExplicitlySet; | - |
2308 | } | - |
2309 | | - |
2310 | /*! | - |
2311 | \fn bool QGuiApplication::isRightToLeft() | - |
2312 | | - |
2313 | Returns true if the application's layout direction is | - |
2314 | Qt::RightToLeft; otherwise returns false. | - |
2315 | | - |
2316 | \sa layoutDirection(), isLeftToRight() | - |
2317 | */ | - |
2318 | | - |
2319 | /*! | - |
2320 | \fn bool QGuiApplication::isLeftToRight() | - |
2321 | | - |
2322 | Returns true if the application's layout direction is | - |
2323 | Qt::LeftToRight; otherwise returns false. | - |
2324 | | - |
2325 | \sa layoutDirection(), isRightToLeft() | - |
2326 | */ | - |
2327 | | - |
2328 | void QGuiApplicationPrivate::notifyLayoutDirectionChange() | - |
2329 | { | - |
2330 | } | - |
2331 | | - |
2332 | void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) | - |
2333 | { | - |
2334 | } | - |
2335 | | - |
2336 | | - |
2337 | /*! | - |
2338 | \property QGuiApplication::quitOnLastWindowClosed | - |
2339 | | - |
2340 | \brief whether the application implicitly quits when the last window is | - |
2341 | closed. | - |
2342 | | - |
2343 | The default is true. | - |
2344 | | - |
2345 | If this property is true, the applications quits when the last visible | - |
2346 | primary window (i.e. window with no parent) is closed. | - |
2347 | | - |
2348 | \sa quit(), QWindow::close() | - |
2349 | */ | - |
2350 | | - |
2351 | void QGuiApplication::setQuitOnLastWindowClosed(bool quit) | - |
2352 | { | - |
2353 | QCoreApplication::setQuitLockEnabled(quit); | - |
2354 | } | - |
2355 | | - |
2356 | | - |
2357 | | - |
2358 | bool QGuiApplication::quitOnLastWindowClosed() | - |
2359 | { | - |
2360 | return QCoreApplication::isQuitLockEnabled(); | - |
2361 | } | - |
2362 | | - |
2363 | | - |
2364 | /*! | - |
2365 | \fn void QGuiApplication::lastWindowClosed() | - |
2366 | | - |
2367 | This signal is emitted from exec() when the last visible | - |
2368 | primary window (i.e. window with no parent) is closed. | - |
2369 | | - |
2370 | By default, QGuiApplication quits after this signal is emitted. This feature | - |
2371 | can be turned off by setting \l quitOnLastWindowClosed to false. | - |
2372 | | - |
2373 | \sa QWindow::close(), QWindow::isTopLevel() | - |
2374 | */ | - |
2375 | | - |
2376 | void QGuiApplicationPrivate::emitLastWindowClosed() | - |
2377 | { | - |
2378 | if (qGuiApp && qGuiApp->d_func()->in_exec) { | - |
2379 | emit qGuiApp->lastWindowClosed(); | - |
2380 | } | - |
2381 | } | - |
2382 | | - |
2383 | bool QGuiApplicationPrivate::shouldQuit() | - |
2384 | { | - |
2385 | /* if there is no visible top-level window left, we allow the quit */ | - |
2386 | QWindowList list = QGuiApplication::topLevelWindows(); | - |
2387 | for (int i = 0; i < list.size(); ++i) { | - |
2388 | QWindow *w = list.at(i); | - |
2389 | if (w->isVisible() && !w->transientParent()) | - |
2390 | return false; | - |
2391 | } | - |
2392 | return true; | - |
2393 | } | - |
2394 | | - |
2395 | /*! | - |
2396 | \since 4.2 | - |
2397 | \fn void QGuiApplication::commitDataRequest(QSessionManager &manager) | - |
2398 | | - |
2399 | This signal deals with \l{Session Management}{session management}. It is | - |
2400 | emitted when the QSessionManager wants the application to commit all its | - |
2401 | data. | - |
2402 | | - |
2403 | Usually this means saving all open files, after getting permission from | - |
2404 | the user. Furthermore you may want to provide a means by which the user | - |
2405 | can cancel the shutdown. | - |
2406 | | - |
2407 | You should not exit the application within this signal. Instead, | - |
2408 | the session manager may or may not do this afterwards, depending on the | - |
2409 | context. | - |
2410 | | - |
2411 | \warning Within this signal, no user interaction is possible, \e | - |
2412 | unless you ask the \a manager for explicit permission. See | - |
2413 | QSessionManager::allowsInteraction() and | - |
2414 | QSessionManager::allowsErrorInteraction() for details and example | - |
2415 | usage. | - |
2416 | | - |
2417 | \note You should use Qt::DirectConnection when connecting to this signal. | - |
2418 | | - |
2419 | \sa isSessionRestored(), sessionId(), saveStateRequest(), {Session Management} | - |
2420 | */ | - |
2421 | | - |
2422 | /*! | - |
2423 | \since 4.2 | - |
2424 | \fn void QGuiApplication::saveStateRequest(QSessionManager &manager) | - |
2425 | | - |
2426 | This signal deals with \l{Session Management}{session management}. It is | - |
2427 | invoked when the \l{QSessionManager}{session manager} wants the application | - |
2428 | to preserve its state for a future session. | - |
2429 | | - |
2430 | For example, a text editor would create a temporary file that includes the | - |
2431 | current contents of its edit buffers, the location of the cursor and other | - |
2432 | aspects of the current editing session. | - |
2433 | | - |
2434 | You should never exit the application within this signal. Instead, the | - |
2435 | session manager may or may not do this afterwards, depending on the | - |
2436 | context. Futhermore, most session managers will very likely request a saved | - |
2437 | state immediately after the application has been started. This permits the | - |
2438 | session manager to learn about the application's restart policy. | - |
2439 | | - |
2440 | \warning Within this signal, no user interaction is possible, \e | - |
2441 | unless you ask the \a manager for explicit permission. See | - |
2442 | QSessionManager::allowsInteraction() and | - |
2443 | QSessionManager::allowsErrorInteraction() for details. | - |
2444 | | - |
2445 | \note You should use Qt::DirectConnection when connecting to this signal. | - |
2446 | | - |
2447 | \sa isSessionRestored(), sessionId(), commitDataRequest(), {Session Management} | - |
2448 | */ | - |
2449 | | - |
2450 | /*! | - |
2451 | \fn bool QGuiApplication::isSessionRestored() const | - |
2452 | | - |
2453 | Returns true if the application has been restored from an earlier | - |
2454 | \l{Session Management}{session}; otherwise returns false. | - |
2455 | | - |
2456 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - |
2457 | */ | - |
2458 | | - |
2459 | /*! | - |
2460 | \since 5.0 | - |
2461 | \fn bool QGuiApplication::isSavingSession() const | - |
2462 | | - |
2463 | Returns true if the application is currently saving the | - |
2464 | \l{Session Management}{session}; otherwise returns false. | - |
2465 | | - |
2466 | This is true when commitDataRequest() and saveStateRequest() are emitted, | - |
2467 | but also when the windows are closed afterwards by session management. | - |
2468 | | - |
2469 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - |
2470 | */ | - |
2471 | | - |
2472 | /*! | - |
2473 | \fn QString QGuiApplication::sessionId() const | - |
2474 | | - |
2475 | Returns the current \l{Session Management}{session's} identifier. | - |
2476 | | - |
2477 | If the application has been restored from an earlier session, this | - |
2478 | identifier is the same as it was in that previous session. The session | - |
2479 | identifier is guaranteed to be unique both for different applications | - |
2480 | and for different instances of the same application. | - |
2481 | | - |
2482 | \sa isSessionRestored(), sessionKey(), commitDataRequest(), saveStateRequest() | - |
2483 | */ | - |
2484 | | - |
2485 | /*! | - |
2486 | \fn QString QGuiApplication::sessionKey() const | - |
2487 | | - |
2488 | Returns the session key in the current \l{Session Management}{session}. | - |
2489 | | - |
2490 | If the application has been restored from an earlier session, this key is | - |
2491 | the same as it was when the previous session ended. | - |
2492 | | - |
2493 | The session key changes every time the session is saved. If the shutdown process | - |
2494 | is cancelled, another session key will be used when shutting down again. | - |
2495 | | - |
2496 | \sa isSessionRestored(), sessionId(), commitDataRequest(), saveStateRequest() | - |
2497 | */ | - |
2498 | #ifndef QT_NO_SESSIONMANAGER | - |
2499 | bool QGuiApplication::isSessionRestored() const | - |
2500 | { | - |
2501 | Q_D(const QGuiApplication); | - |
2502 | return d->is_session_restored; | - |
2503 | } | - |
2504 | | - |
2505 | QString QGuiApplication::sessionId() const | - |
2506 | { | - |
2507 | Q_D(const QGuiApplication); | - |
2508 | return d->session_id; | - |
2509 | } | - |
2510 | | - |
2511 | QString QGuiApplication::sessionKey() const | - |
2512 | { | - |
2513 | Q_D(const QGuiApplication); | - |
2514 | return d->session_key; | - |
2515 | } | - |
2516 | | - |
2517 | bool QGuiApplication::isSavingSession() const | - |
2518 | { | - |
2519 | Q_D(const QGuiApplication); | - |
2520 | return d->is_saving_session; | - |
2521 | } | - |
2522 | | - |
2523 | void QGuiApplicationPrivate::commitData(QSessionManager& manager) | - |
2524 | { | - |
2525 | Q_Q(QGuiApplication); | - |
2526 | is_saving_session = true; | - |
2527 | emit q->commitDataRequest(manager); | - |
2528 | if (manager.allowsInteraction()) { | - |
2529 | QWindowList done; | - |
2530 | QWindowList list = QGuiApplication::topLevelWindows(); | - |
2531 | bool cancelled = false; | - |
2532 | for (int i = 0; !cancelled && i < list.size(); ++i) { | - |
2533 | QWindow* w = list.at(i); | - |
2534 | if (w->isVisible() && !done.contains(w)) { | - |
2535 | cancelled = !w->close(); | - |
2536 | if (!cancelled) | - |
2537 | done.append(w); | - |
2538 | list = QGuiApplication::topLevelWindows(); | - |
2539 | i = -1; | - |
2540 | } | - |
2541 | } | - |
2542 | if (cancelled) | - |
2543 | manager.cancel(); | - |
2544 | } | - |
2545 | is_saving_session = false; | - |
2546 | } | - |
2547 | | - |
2548 | | - |
2549 | void QGuiApplicationPrivate::saveState(QSessionManager &manager) | - |
2550 | { | - |
2551 | Q_Q(QGuiApplication); | - |
2552 | is_saving_session = true; | - |
2553 | emit q->saveStateRequest(manager); | - |
2554 | is_saving_session = false; | - |
2555 | } | - |
2556 | #endif //QT_NO_SESSIONMANAGER | - |
2557 | | - |
2558 | /*! | - |
2559 | \property QGuiApplication::layoutDirection | - |
2560 | \brief the default layout direction for this application | - |
2561 | | - |
2562 | On system start-up, the default layout direction depends on the | - |
2563 | application's language. | - |
2564 | | - |
2565 | \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() | - |
2566 | */ | - |
2567 | | - |
2568 | void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction) | - |
2569 | { | - |
2570 | if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) | - |
2571 | return; | - |
2572 | | - |
2573 | layout_direction = direction; | - |
2574 | | - |
2575 | QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); | - |
2576 | } | - |
2577 | | - |
2578 | Qt::LayoutDirection QGuiApplication::layoutDirection() | - |
2579 | { | - |
2580 | return layout_direction; | - |
2581 | } | - |
2582 | | - |
2583 | /*! | - |
2584 | \fn QCursor *QGuiApplication::overrideCursor() | - |
2585 | | - |
2586 | Returns the active application override cursor. | - |
2587 | | - |
2588 | This function returns 0 if no application cursor has been defined (i.e. the | - |
2589 | internal cursor stack is empty). | - |
2590 | | - |
2591 | \sa setOverrideCursor(), restoreOverrideCursor() | - |
2592 | */ | - |
2593 | #ifndef QT_NO_CURSOR | - |
2594 | QCursor *QGuiApplication::overrideCursor() | - |
2595 | { | - |
2596 | return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first(); | - |
2597 | } | - |
2598 | | - |
2599 | /*! | - |
2600 | Changes the currently active application override cursor to \a cursor. | - |
2601 | | - |
2602 | This function has no effect if setOverrideCursor() was not called. | - |
2603 | | - |
2604 | \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), | - |
2605 | QWidget::setCursor() | - |
2606 | */ | - |
2607 | void QGuiApplication::changeOverrideCursor(const QCursor &cursor) | - |
2608 | { | - |
2609 | if (qGuiApp->d_func()->cursor_list.isEmpty()) | - |
2610 | return; | - |
2611 | qGuiApp->d_func()->cursor_list.removeFirst(); | - |
2612 | setOverrideCursor(cursor); | - |
2613 | } | - |
2614 | #endif | - |
2615 | | - |
2616 | | - |
2617 | #ifndef QT_NO_CURSOR | - |
2618 | static inline void applyCursor(QWindow *w, QCursor c) | - |
2619 | { | - |
2620 | if (const QScreen *screen = w->screen()) | - |
2621 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - |
2622 | cursor->changeCursor(&c, w); | - |
2623 | } | - |
2624 | | - |
2625 | static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) | - |
2626 | { | - |
2627 | for (int i = 0; i < l.size(); ++i) { | - |
2628 | QWindow *w = l.at(i); | - |
2629 | if (w->handle() && w->type() != Qt::Desktop) | - |
2630 | applyCursor(w, c); | - |
2631 | } | - |
2632 | } | - |
2633 | | - |
2634 | static inline void applyWindowCursor(const QList<QWindow *> &l) | - |
2635 | { | - |
2636 | for (int i = 0; i < l.size(); ++i) { | - |
2637 | QWindow *w = l.at(i); | - |
2638 | if (w->handle() && w->type() != Qt::Desktop) | - |
2639 | applyCursor(w, w->cursor()); | - |
2640 | } | - |
2641 | } | - |
2642 | | - |
2643 | /*! | - |
2644 | \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - |
2645 | | - |
2646 | Sets the application override cursor to \a cursor. | - |
2647 | | - |
2648 | Application override cursors are intended for showing the user that the | - |
2649 | application is in a special state, for example during an operation that | - |
2650 | might take some time. | - |
2651 | | - |
2652 | This cursor will be displayed in all the application's widgets until | - |
2653 | restoreOverrideCursor() or another setOverrideCursor() is called. | - |
2654 | | - |
2655 | Application cursors are stored on an internal stack. setOverrideCursor() | - |
2656 | pushes the cursor onto the stack, and restoreOverrideCursor() pops the | - |
2657 | active cursor off the stack. changeOverrideCursor() changes the curently | - |
2658 | active application override cursor. | - |
2659 | | - |
2660 | Every setOverrideCursor() must eventually be followed by a corresponding | - |
2661 | restoreOverrideCursor(), otherwise the stack will never be emptied. | - |
2662 | | - |
2663 | Example: | - |
2664 | \snippet code/src_gui_kernel_qapplication_x11.cpp 0 | - |
2665 | | - |
2666 | \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), | - |
2667 | QWidget::setCursor() | - |
2668 | */ | - |
2669 | void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - |
2670 | { | - |
2671 | qGuiApp->d_func()->cursor_list.prepend(cursor); | - |
2672 | applyCursor(QGuiApplicationPrivate::window_list, cursor); | - |
2673 | } | - |
2674 | | - |
2675 | /*! | - |
2676 | \fn void QGuiApplication::restoreOverrideCursor() | - |
2677 | | - |
2678 | Undoes the last setOverrideCursor(). | - |
2679 | | - |
2680 | If setOverrideCursor() has been called twice, calling | - |
2681 | restoreOverrideCursor() will activate the first cursor set. Calling this | - |
2682 | function a second time restores the original widgets' cursors. | - |
2683 | | - |
2684 | \sa setOverrideCursor(), overrideCursor() | - |
2685 | */ | - |
2686 | void QGuiApplication::restoreOverrideCursor() | - |
2687 | { | - |
2688 | if (qGuiApp->d_func()->cursor_list.isEmpty()) | - |
2689 | return; | - |
2690 | qGuiApp->d_func()->cursor_list.removeFirst(); | - |
2691 | if (qGuiApp->d_func()->cursor_list.size() > 0) { | - |
2692 | QCursor c(qGuiApp->d_func()->cursor_list.value(0)); | - |
2693 | applyCursor(QGuiApplicationPrivate::window_list, c); | - |
2694 | } else { | - |
2695 | applyWindowCursor(QGuiApplicationPrivate::window_list); | - |
2696 | } | - |
2697 | } | - |
2698 | #endif// QT_NO_CURSOR | - |
2699 | | - |
2700 | /*! | - |
2701 | Returns the application's style hints. | - |
2702 | | - |
2703 | The style hints encapsulate a set of platform dependent properties | - |
2704 | such as double click intervals, full width selection and others. | - |
2705 | | - |
2706 | The hints can be used to integrate tighter with the underlying platform. | - |
2707 | | - |
2708 | \sa QStyleHints | - |
2709 | */ | - |
2710 | QStyleHints *QGuiApplication::styleHints() | - |
2711 | { | - |
2712 | if (!qGuiApp->d_func()->styleHints) | - |
2713 | qGuiApp->d_func()->styleHints = new QStyleHints(); | - |
2714 | return qGuiApp->d_func()->styleHints; | - |
2715 | } | - |
2716 | | - |
2717 | /*! | - |
2718 | Sets whether Qt should use the system's standard colors, fonts, etc., to | - |
2719 | \a on. By default, this is true. | - |
2720 | | - |
2721 | This function must be called before creating the QGuiApplication object, like | - |
2722 | this: | - |
2723 | | - |
2724 | \snippet code/src_gui_kernel_qapplication.cpp 6 | - |
2725 | | - |
2726 | \sa desktopSettingsAware() | - |
2727 | */ | - |
2728 | void QGuiApplication::setDesktopSettingsAware(bool on) | - |
2729 | { | - |
2730 | QGuiApplicationPrivate::obey_desktop_settings = on; | - |
2731 | } | - |
2732 | | - |
2733 | /*! | - |
2734 | Returns true if Qt is set to use the system's standard colors, fonts, etc.; | - |
2735 | otherwise returns false. The default is true. | - |
2736 | | - |
2737 | \sa setDesktopSettingsAware() | - |
2738 | */ | - |
2739 | bool QGuiApplication::desktopSettingsAware() | - |
2740 | { | - |
2741 | return QGuiApplicationPrivate::obey_desktop_settings; | - |
2742 | } | - |
2743 | | - |
2744 | /*! | - |
2745 | returns the input method. | - |
2746 | | - |
2747 | The input method returns properties about the state and position of | - |
2748 | the virtual keyboard. It also provides information about the position of the | - |
2749 | current focused input element. | - |
2750 | | - |
2751 | \sa QInputMethod | - |
2752 | */ | - |
2753 | QInputMethod *QGuiApplication::inputMethod() | - |
2754 | { | - |
2755 | if (!qGuiApp->d_func()->inputMethod) | - |
2756 | qGuiApp->d_func()->inputMethod = new QInputMethod(); | - |
2757 | return qGuiApp->d_func()->inputMethod; | - |
2758 | } | - |
2759 | | - |
2760 | /*! | - |
2761 | \fn void QGuiApplication::fontDatabaseChanged() | - |
2762 | | - |
2763 | This signal is emitted when application fonts are loaded or removed. | - |
2764 | | - |
2765 | \sa QFontDatabase::addApplicationFont(), | - |
2766 | QFontDatabase::addApplicationFontFromData(), | - |
2767 | QFontDatabase::removeAllApplicationFonts(), | - |
2768 | QFontDatabase::removeApplicationFont() | - |
2769 | */ | - |
2770 | | - |
2771 | // These pixmaps approximate the images in the Windows User Interface Guidelines. | - |
2772 | | - |
2773 | // XPM | - |
2774 | | - |
2775 | static const char * const move_xpm[] = { | - |
2776 | "11 20 3 1", | - |
2777 | ". c None", | - |
2778 | "a c #FFFFFF", | - |
2779 | "X c #000000", // X11 cursor is traditionally black | - |
2780 | "aa.........", | - |
2781 | "aXa........", | - |
2782 | "aXXa.......", | - |
2783 | "aXXXa......", | - |
2784 | "aXXXXa.....", | - |
2785 | "aXXXXXa....", | - |
2786 | "aXXXXXXa...", | - |
2787 | "aXXXXXXXa..", | - |
2788 | "aXXXXXXXXa.", | - |
2789 | "aXXXXXXXXXa", | - |
2790 | "aXXXXXXaaaa", | - |
2791 | "aXXXaXXa...", | - |
2792 | "aXXaaXXa...", | - |
2793 | "aXa..aXXa..", | - |
2794 | "aa...aXXa..", | - |
2795 | "a.....aXXa.", | - |
2796 | "......aXXa.", | - |
2797 | ".......aXXa", | - |
2798 | ".......aXXa", | - |
2799 | "........aa."}; | - |
2800 | | - |
2801 | | - |
2802 | /* XPM */ | - |
2803 | static const char * const copy_xpm[] = { | - |
2804 | "24 30 3 1", | - |
2805 | ". c None", | - |
2806 | "a c #000000", | - |
2807 | "X c #FFFFFF", | - |
2808 | "XX......................", | - |
2809 | "XaX.....................", | - |
2810 | "XaaX....................", | - |
2811 | "XaaaX...................", | - |
2812 | "XaaaaX..................", | - |
2813 | "XaaaaaX.................", | - |
2814 | "XaaaaaaX................", | - |
2815 | "XaaaaaaaX...............", | - |
2816 | "XaaaaaaaaX..............", | - |
2817 | "XaaaaaaaaaX.............", | - |
2818 | "XaaaaaaXXXX.............", | - |
2819 | "XaaaXaaX................", | - |
2820 | "XaaXXaaX................", | - |
2821 | "XaX..XaaX...............", | - |
2822 | "XX...XaaX...............", | - |
2823 | "X.....XaaX..............", | - |
2824 | "......XaaX..............", | - |
2825 | ".......XaaX.............", | - |
2826 | ".......XaaX.............", | - |
2827 | "........XX...aaaaaaaaaaa", | - |
2828 | ".............aXXXXXXXXXa", | - |
2829 | ".............aXXXXXXXXXa", | - |
2830 | ".............aXXXXaXXXXa", | - |
2831 | ".............aXXXXaXXXXa", | - |
2832 | ".............aXXaaaaaXXa", | - |
2833 | ".............aXXXXaXXXXa", | - |
2834 | ".............aXXXXaXXXXa", | - |
2835 | ".............aXXXXXXXXXa", | - |
2836 | ".............aXXXXXXXXXa", | - |
2837 | ".............aaaaaaaaaaa"}; | - |
2838 | | - |
2839 | /* XPM */ | - |
2840 | static const char * const link_xpm[] = { | - |
2841 | "24 30 3 1", | - |
2842 | ". c None", | - |
2843 | "a c #000000", | - |
2844 | "X c #FFFFFF", | - |
2845 | "XX......................", | - |
2846 | "XaX.....................", | - |
2847 | "XaaX....................", | - |
2848 | "XaaaX...................", | - |
2849 | "XaaaaX..................", | - |
2850 | "XaaaaaX.................", | - |
2851 | "XaaaaaaX................", | - |
2852 | "XaaaaaaaX...............", | - |
2853 | "XaaaaaaaaX..............", | - |
2854 | "XaaaaaaaaaX.............", | - |
2855 | "XaaaaaaXXXX.............", | - |
2856 | "XaaaXaaX................", | - |
2857 | "XaaXXaaX................", | - |
2858 | "XaX..XaaX...............", | - |
2859 | "XX...XaaX...............", | - |
2860 | "X.....XaaX..............", | - |
2861 | "......XaaX..............", | - |
2862 | ".......XaaX.............", | - |
2863 | ".......XaaX.............", | - |
2864 | "........XX...aaaaaaaaaaa", | - |
2865 | ".............aXXXXXXXXXa", | - |
2866 | ".............aXXXaaaaXXa", | - |
2867 | ".............aXXXXaaaXXa", | - |
2868 | ".............aXXXaaaaXXa", | - |
2869 | ".............aXXaaaXaXXa", | - |
2870 | ".............aXXaaXXXXXa", | - |
2871 | ".............aXXaXXXXXXa", | - |
2872 | ".............aXXXaXXXXXa", | - |
2873 | ".............aXXXXXXXXXa", | - |
2874 | ".............aaaaaaaaaaa"}; | - |
2875 | | - |
2876 | QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) | - |
2877 | { | - |
2878 | Q_UNUSED(cshape); | - |
2879 | return QPixmap(); | - |
2880 | } | - |
2881 | | - |
2882 | void QGuiApplicationPrivate::notifyThemeChanged() | - |
2883 | { | - |
2884 | if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) { | - |
2885 | clearPalette(); | - |
2886 | initPalette(); | - |
2887 | } | - |
2888 | if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { | - |
2889 | QMutexLocker locker(&applicationFontMutex); | - |
2890 | clearFontUnlocked(); | - |
2891 | initFontUnlocked(); | - |
2892 | } | - |
2893 | } | - |
2894 | | - |
2895 | #ifndef QT_NO_DRAGANDDROP | - |
2896 | void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) | - |
2897 | { | - |
2898 | Q_UNUSED(drag) | - |
2899 | | - |
2900 | } | - |
2901 | #endif | - |
2902 | | - |
2903 | const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() | - |
2904 | { | - |
2905 | QDrawHelperGammaTables *result = m_gammaTables.load(); | - |
2906 | if (!result){ | - |
2907 | QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(fontSmoothingGamma); | - |
2908 | if (!m_gammaTables.testAndSetRelease(0, tables)) | - |
2909 | delete tables; | - |
2910 | result = m_gammaTables.load(); | - |
2911 | } | - |
2912 | return result; | - |
2913 | } | - |
2914 | | - |
2915 | void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) | - |
2916 | { | - |
2917 | Q_Q(QGuiApplication); | - |
2918 | | - |
2919 | bool enabled = false; | - |
2920 | if (object) { | - |
2921 | QInputMethodQueryEvent query(Qt::ImEnabled); | - |
2922 | QGuiApplication::sendEvent(object, &query); | - |
2923 | enabled = query.value(Qt::ImEnabled).toBool(); | - |
2924 | } | - |
2925 | | - |
2926 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - |
2927 | QPlatformInputContext *inputContext = platformIntegration()->inputContext(); | - |
2928 | if (inputContext) | - |
2929 | inputContext->setFocusObject(object); | - |
2930 | emit q->focusObjectChanged(object); | - |
2931 | } | - |
2932 | | - |
2933 | int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event) | - |
2934 | { | - |
2935 | return event->caps; | - |
2936 | } | - |
2937 | | - |
2938 | QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event) | - |
2939 | { | - |
2940 | return event->velocity; | - |
2941 | } | - |
2942 | | - |
2943 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity) | - |
2944 | { | - |
2945 | event->caps = caps; | - |
2946 | event->velocity = velocity; | - |
2947 | } | - |
2948 | | - |
2949 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other) | - |
2950 | { | - |
2951 | event->caps = other->caps; | - |
2952 | event->velocity = other->velocity; | - |
2953 | } | - |
2954 | | - |
2955 | | - |
2956 | #include "moc_qguiapplication.cpp" | - |
2957 | | - |
2958 | QT_END_NAMESPACE | - |
2959 | | - |
| | |