author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 10:37:55 +0300 | |
changeset 33 | 3e2da88830cd |
parent 30 | 5dc02b23752f |
child 37 | 758a864f9613 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qplatformdefs.h" |
|
43 |
#include "qabstracteventdispatcher.h" |
|
44 |
#include "qaccessible.h" |
|
45 |
#include "qapplication.h" |
|
46 |
#include "qclipboard.h" |
|
47 |
#include "qcursor.h" |
|
48 |
#include "qdesktopwidget.h" |
|
49 |
#include "qdir.h" |
|
50 |
#include "qevent.h" |
|
51 |
#include "qfile.h" |
|
52 |
#include "qfileinfo.h" |
|
53 |
#include "qgraphicsscene.h" |
|
54 |
#include "qhash.h" |
|
55 |
#include "qset.h" |
|
56 |
#include "qlayout.h" |
|
57 |
#include "qsessionmanager.h" |
|
58 |
#include "qstyle.h" |
|
59 |
#include "qstylefactory.h" |
|
60 |
#include "qtextcodec.h" |
|
61 |
#include "qtranslator.h" |
|
62 |
#include "qvariant.h" |
|
63 |
#include "qwidget.h" |
|
64 |
#include "qdnd_p.h" |
|
65 |
#include "qcolormap.h" |
|
66 |
#include "qdebug.h" |
|
67 |
#include "private/qgraphicssystemfactory_p.h" |
|
68 |
#include "private/qstylesheetstyle_p.h" |
|
69 |
#include "private/qstyle_p.h" |
|
70 |
#include "qmessagebox.h" |
|
71 |
#include <QtGui/qgraphicsproxywidget.h> |
|
72 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
73 |
#ifdef QT_GRAPHICSSYSTEM_RUNTIME |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
74 |
#include "private/qgraphicssystem_runtime_p.h" |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
75 |
#endif |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
76 |
|
0 | 77 |
#include "qinputcontext.h" |
78 |
#include "qkeymapper_p.h" |
|
79 |
||
80 |
#ifdef Q_WS_X11 |
|
81 |
#include <private/qt_x11_p.h> |
|
82 |
#endif |
|
83 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
84 |
#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN) |
0 | 85 |
#include "qinputcontextfactory.h" |
86 |
#endif |
|
87 |
||
88 |
#include "qguiplatformplugin_p.h" |
|
89 |
||
90 |
#include <qthread.h> |
|
91 |
#include <private/qthread_p.h> |
|
92 |
||
93 |
#include <private/qfont_p.h> |
|
94 |
||
95 |
#include <stdlib.h> |
|
96 |
||
97 |
#include "qapplication_p.h" |
|
98 |
#include "qevent_p.h" |
|
99 |
#include "qwidget_p.h" |
|
100 |
||
101 |
#include "qapplication.h" |
|
102 |
||
103 |
#include "qgesture.h" |
|
104 |
#include "private/qgesturemanager_p.h" |
|
105 |
||
106 |
#ifndef QT_NO_LIBRARY |
|
107 |
#include "qlibrary.h" |
|
108 |
#endif |
|
109 |
||
110 |
#ifdef Q_WS_WINCE |
|
111 |
#include "qdatetime.h" |
|
112 |
#include "qguifunctions_wince.h" |
|
113 |
extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp |
|
114 |
extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp |
|
115 |
extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp |
|
116 |
#endif |
|
117 |
||
118 |
#include "qdatetime.h" |
|
119 |
||
120 |
#ifdef QT_MAC_USE_COCOA |
|
121 |
#include <private/qt_cocoa_helpers_mac_p.h> |
|
122 |
#endif |
|
123 |
||
124 |
//#define ALIEN_DEBUG |
|
125 |
||
126 |
static void initResources() |
|
127 |
{ |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
128 |
#if defined(Q_WS_WINCE) |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
129 |
Q_INIT_RESOURCE_EXTERN(qstyle_wince) |
0 | 130 |
Q_INIT_RESOURCE(qstyle_wince); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
131 |
#elif defined(Q_OS_SYMBIAN) |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
132 |
Q_INIT_RESOURCE_EXTERN(qstyle_s60) |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
133 |
Q_INIT_RESOURCE(qstyle_s60); |
0 | 134 |
#else |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
135 |
Q_INIT_RESOURCE_EXTERN(qstyle) |
0 | 136 |
Q_INIT_RESOURCE(qstyle); |
137 |
#endif |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
138 |
Q_INIT_RESOURCE_EXTERN(qmessagebox) |
0 | 139 |
Q_INIT_RESOURCE(qmessagebox); |
140 |
#if !defined(QT_NO_PRINTDIALOG) |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
141 |
Q_INIT_RESOURCE_EXTERN(qprintdialog) |
0 | 142 |
Q_INIT_RESOURCE(qprintdialog); |
143 |
#endif |
|
144 |
||
145 |
} |
|
146 |
||
147 |
QT_BEGIN_NAMESPACE |
|
148 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
149 |
Q_CORE_EXPORT void qt_call_post_routines(); |
0 | 150 |
|
151 |
int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 |
|
152 |
||
153 |
QApplication::Type qt_appType=QApplication::Tty; |
|
154 |
QApplicationPrivate *QApplicationPrivate::self = 0; |
|
155 |
||
156 |
QInputContext *QApplicationPrivate::inputContext = 0; |
|
157 |
||
158 |
bool QApplicationPrivate::quitOnLastWindowClosed = true; |
|
159 |
||
160 |
#ifdef Q_WS_WINCE |
|
161 |
int QApplicationPrivate::autoMaximizeThreshold = -1; |
|
162 |
bool QApplicationPrivate::autoSipEnabled = false; |
|
163 |
#else |
|
164 |
bool QApplicationPrivate::autoSipEnabled = true; |
|
165 |
#endif |
|
166 |
||
167 |
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type) |
|
168 |
: QCoreApplicationPrivate(argc, argv) |
|
169 |
{ |
|
170 |
application_type = type; |
|
171 |
qt_appType = type; |
|
172 |
||
173 |
#ifndef QT_NO_SESSIONMANAGER |
|
174 |
is_session_restored = false; |
|
175 |
#endif |
|
176 |
||
177 |
quitOnLastWindowClosed = true; |
|
178 |
||
179 |
#ifdef QT3_SUPPORT |
|
180 |
qt_compat_used = 0; |
|
181 |
qt_compat_resolved = 0; |
|
182 |
qt_tryAccelEvent = 0; |
|
183 |
qt_tryComposeUnicode = 0; |
|
184 |
qt_dispatchAccelEvent = 0; |
|
185 |
#endif |
|
186 |
#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER) |
|
187 |
directPainters = 0; |
|
188 |
#endif |
|
189 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
190 |
#ifndef QT_NO_GESTURES |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
191 |
gestureManager = 0; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
gestureWidget = 0; |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
193 |
#endif // QT_NO_GESTURES |
0 | 194 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
195 |
#if defined(Q_WS_X11) || defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
196 |
move_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
197 |
copy_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
198 |
link_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
199 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
200 |
#if defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
201 |
ignore_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
202 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
203 |
|
0 | 204 |
if (!self) |
205 |
self = this; |
|
206 |
} |
|
207 |
||
208 |
QApplicationPrivate::~QApplicationPrivate() |
|
209 |
{ |
|
210 |
if (self == this) |
|
211 |
self = 0; |
|
212 |
} |
|
213 |
||
214 |
/*! |
|
215 |
\class QApplication |
|
216 |
\brief The QApplication class manages the GUI application's control |
|
217 |
flow and main settings. |
|
218 |
||
219 |
QApplication contains the main event loop, where all events from the window |
|
220 |
system and other sources are processed and dispatched. It also handles the |
|
221 |
application's initialization, finalization, and provides session |
|
222 |
management. In addition, QApplication handles most of the system-wide and |
|
223 |
application-wide settings. |
|
224 |
||
225 |
For any GUI application using Qt, there is precisely \bold one QApplication |
|
226 |
object, no matter whether the application has 0, 1, 2 or more windows at |
|
227 |
any given time. For non-GUI Qt applications, use QCoreApplication instead, |
|
228 |
as it does not depend on the \l QtGui library. |
|
229 |
||
230 |
The QApplication object is accessible through the instance() function that |
|
231 |
returns a pointer equivalent to the global qApp pointer. |
|
232 |
||
233 |
QApplication's main areas of responsibility are: |
|
234 |
\list |
|
235 |
\o It initializes the application with the user's desktop settings |
|
236 |
such as palette(), font() and doubleClickInterval(). It keeps |
|
237 |
track of these properties in case the user changes the desktop |
|
238 |
globally, for example through some kind of control panel. |
|
239 |
||
240 |
\o It performs event handling, meaning that it receives events |
|
241 |
from the underlying window system and dispatches them to the |
|
242 |
relevant widgets. By using sendEvent() and postEvent() you can |
|
243 |
send your own events to widgets. |
|
244 |
||
245 |
\o It parses common command line arguments and sets its internal |
|
246 |
state accordingly. See the \l{QApplication::QApplication()} |
|
247 |
{constructor documentation} below for more details. |
|
248 |
||
249 |
\o It defines the application's look and feel, which is |
|
250 |
encapsulated in a QStyle object. This can be changed at runtime |
|
251 |
with setStyle(). |
|
252 |
||
253 |
\o It specifies how the application is to allocate colors. See |
|
254 |
setColorSpec() for details. |
|
255 |
||
256 |
\o It provides localization of strings that are visible to the |
|
257 |
user via translate(). |
|
258 |
||
259 |
\o It provides some magical objects like the desktop() and the |
|
260 |
clipboard(). |
|
261 |
||
262 |
\o It knows about the application's windows. You can ask which |
|
263 |
widget is at a certain position using widgetAt(), get a list of |
|
264 |
topLevelWidgets() and closeAllWindows(), etc. |
|
265 |
||
266 |
\o It manages the application's mouse cursor handling, see |
|
267 |
setOverrideCursor() |
|
268 |
||
269 |
\o On the X window system, it provides functions to flush and sync |
|
270 |
the communication stream, see flushX() and syncX(). |
|
271 |
||
272 |
\o It provides support for sophisticated \l{Session Management} |
|
273 |
{session management}. This makes it possible for applications |
|
274 |
to terminate gracefully when the user logs out, to cancel a |
|
275 |
shutdown process if termination isn't possible and even to |
|
276 |
preserve the entire application's state for a future session. |
|
277 |
See isSessionRestored(), sessionId() and commitData() and |
|
278 |
saveState() for details. |
|
279 |
\endlist |
|
280 |
||
281 |
Since the QApplication object does so much initialization, it \e{must} be |
|
282 |
created before any other objects related to the user interface are created. |
|
283 |
QApplication also deals with common command line arguments. Hence, it is |
|
284 |
usually a good idea to create it \e before any interpretation or |
|
285 |
modification of \c argv is done in the application itself. |
|
286 |
||
287 |
\table |
|
288 |
\header |
|
289 |
\o{2,1} Groups of functions |
|
290 |
||
291 |
\row |
|
292 |
\o System settings |
|
293 |
\o desktopSettingsAware(), |
|
294 |
setDesktopSettingsAware(), |
|
295 |
cursorFlashTime(), |
|
296 |
setCursorFlashTime(), |
|
297 |
doubleClickInterval(), |
|
298 |
setDoubleClickInterval(), |
|
299 |
setKeyboardInputInterval(), |
|
300 |
wheelScrollLines(), |
|
301 |
setWheelScrollLines(), |
|
302 |
palette(), |
|
303 |
setPalette(), |
|
304 |
font(), |
|
305 |
setFont(), |
|
306 |
fontMetrics(). |
|
307 |
||
308 |
\row |
|
309 |
\o Event handling |
|
310 |
\o exec(), |
|
311 |
processEvents(), |
|
312 |
exit(), |
|
313 |
quit(). |
|
314 |
sendEvent(), |
|
315 |
postEvent(), |
|
316 |
sendPostedEvents(), |
|
317 |
removePostedEvents(), |
|
318 |
hasPendingEvents(), |
|
319 |
notify(), |
|
320 |
macEventFilter(), |
|
321 |
qwsEventFilter(), |
|
322 |
x11EventFilter(), |
|
323 |
x11ProcessEvent(), |
|
324 |
winEventFilter(). |
|
325 |
||
326 |
\row |
|
327 |
\o GUI Styles |
|
328 |
\o style(), |
|
329 |
setStyle(). |
|
330 |
||
331 |
\row |
|
332 |
\o Color usage |
|
333 |
\o colorSpec(), |
|
334 |
setColorSpec(), |
|
335 |
qwsSetCustomColors(). |
|
336 |
||
337 |
\row |
|
338 |
\o Text handling |
|
339 |
\o installTranslator(), |
|
340 |
removeTranslator() |
|
341 |
translate(). |
|
342 |
||
343 |
\row |
|
344 |
\o Widgets |
|
345 |
\o allWidgets(), |
|
346 |
topLevelWidgets(), |
|
347 |
desktop(), |
|
348 |
activePopupWidget(), |
|
349 |
activeModalWidget(), |
|
350 |
clipboard(), |
|
351 |
focusWidget(), |
|
352 |
activeWindow(), |
|
353 |
widgetAt(). |
|
354 |
||
355 |
\row |
|
356 |
\o Advanced cursor handling |
|
357 |
\o overrideCursor(), |
|
358 |
setOverrideCursor(), |
|
359 |
restoreOverrideCursor(). |
|
360 |
||
361 |
\row |
|
362 |
\o X Window System synchronization |
|
363 |
\o flushX(), |
|
364 |
syncX(). |
|
365 |
||
366 |
\row |
|
367 |
\o Session management |
|
368 |
\o isSessionRestored(), |
|
369 |
sessionId(), |
|
370 |
commitData(), |
|
371 |
saveState(). |
|
372 |
||
373 |
\row |
|
374 |
\o Miscellaneous |
|
375 |
\o closeAllWindows(), |
|
376 |
startingUp(), |
|
377 |
closingDown(), |
|
378 |
type(). |
|
379 |
\endtable |
|
380 |
||
381 |
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings |
|
382 |
*/ |
|
383 |
||
384 |
/*! |
|
385 |
\enum QApplication::Type |
|
386 |
||
387 |
\value Tty a console application |
|
388 |
\value GuiClient a GUI client application |
|
389 |
\value GuiServer a GUI server application (for Qt for Embedded Linux) |
|
390 |
*/ |
|
391 |
||
392 |
/*! |
|
393 |
\enum QApplication::ColorSpec |
|
394 |
||
395 |
\value NormalColor the default color allocation policy |
|
396 |
\value CustomColor the same as NormalColor for X11; allocates colors |
|
397 |
to a palette on demand under Windows |
|
398 |
\value ManyColor the right choice for applications that use thousands of |
|
399 |
colors |
|
400 |
||
401 |
See setColorSpec() for full details. |
|
402 |
*/ |
|
403 |
||
404 |
/*! |
|
405 |
\fn QWidget *QApplication::topLevelAt(const QPoint &point) |
|
406 |
||
407 |
Returns the top-level widget at the given \a point; returns 0 if |
|
408 |
there is no such widget. |
|
409 |
*/ |
|
410 |
||
411 |
/*! |
|
412 |
\fn QWidget *QApplication::topLevelAt(int x, int y) |
|
413 |
||
414 |
\overload |
|
415 |
||
416 |
Returns the top-level widget at the point (\a{x}, \a{y}); returns |
|
417 |
0 if there is no such widget. |
|
418 |
*/ |
|
419 |
||
420 |
||
421 |
/* |
|
422 |
The qt_init() and qt_cleanup() functions are implemented in the |
|
423 |
qapplication_xyz.cpp file. |
|
424 |
*/ |
|
425 |
||
426 |
void qt_init(QApplicationPrivate *priv, int type |
|
427 |
#ifdef Q_WS_X11 |
|
428 |
, Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 |
|
429 |
#endif |
|
430 |
); |
|
431 |
void qt_cleanup(); |
|
432 |
||
433 |
Qt::MouseButtons QApplicationPrivate::mouse_buttons = Qt::NoButton; |
|
434 |
Qt::KeyboardModifiers QApplicationPrivate::modifier_buttons = Qt::NoModifier; |
|
435 |
||
436 |
QStyle *QApplicationPrivate::app_style = 0; // default application style |
|
437 |
QString QApplicationPrivate::styleOverride; // style override |
|
438 |
||
439 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
440 |
QString QApplicationPrivate::styleSheet; // default application stylesheet |
|
441 |
#endif |
|
442 |
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; |
|
443 |
||
444 |
int QApplicationPrivate::app_cspec = QApplication::NormalColor; |
|
445 |
QPalette *QApplicationPrivate::app_pal = 0; // default application palette |
|
446 |
QPalette *QApplicationPrivate::sys_pal = 0; // default system palette |
|
447 |
QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer |
|
448 |
||
449 |
QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system |
|
450 |
QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
451 |
bool QApplicationPrivate::runtime_graphics_system = false; |
0 | 452 |
|
453 |
Q_GLOBAL_STATIC(QMutex, applicationFontMutex) |
|
454 |
QFont *QApplicationPrivate::app_font = 0; // default application font |
|
455 |
QFont *QApplicationPrivate::sys_font = 0; // default system font |
|
456 |
QFont *QApplicationPrivate::set_font = 0; // default font set by programmer |
|
457 |
||
458 |
QIcon *QApplicationPrivate::app_icon = 0; |
|
459 |
QWidget *QApplicationPrivate::main_widget = 0; // main application widget |
|
460 |
QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus |
|
461 |
QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show() |
|
462 |
QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus |
|
463 |
bool QApplicationPrivate::obey_desktop_settings = true; // use winsys resources |
|
464 |
int QApplicationPrivate::cursor_flash_time = 1000; // text caret flash time |
|
465 |
int QApplicationPrivate::mouse_double_click_time = 400; // mouse dbl click limit |
|
466 |
int QApplicationPrivate::keyboard_input_time = 400; // keyboard input interval |
|
467 |
#ifndef QT_NO_WHEELEVENT |
|
468 |
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll |
|
469 |
#endif |
|
470 |
bool qt_is_gui_used; |
|
471 |
bool Q_GUI_EXPORT qt_tab_all_widgets = true; |
|
472 |
bool qt_in_tab_key_event = false; |
|
473 |
int qt_antialiasing_threshold = -1; |
|
474 |
static int drag_time = 500; |
|
475 |
#ifdef Q_OS_SYMBIAN |
|
476 |
// The screens are a bit too small to for your thumb when using only 4 pixels drag distance. |
|
477 |
static int drag_distance = 8; |
|
478 |
#else |
|
479 |
static int drag_distance = 4; |
|
480 |
#endif |
|
481 |
static Qt::LayoutDirection layout_direction = Qt::LeftToRight; |
|
482 |
QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut |
|
483 |
bool QApplicationPrivate::animate_ui = true; |
|
484 |
bool QApplicationPrivate::animate_menu = false; |
|
485 |
bool QApplicationPrivate::fade_menu = false; |
|
486 |
bool QApplicationPrivate::animate_combo = false; |
|
487 |
bool QApplicationPrivate::animate_tooltip = false; |
|
488 |
bool QApplicationPrivate::fade_tooltip = false; |
|
489 |
bool QApplicationPrivate::animate_toolbox = false; |
|
490 |
bool QApplicationPrivate::widgetCount = false; |
|
491 |
bool QApplicationPrivate::load_testability = false; |
|
492 |
#ifdef QT_KEYPAD_NAVIGATION |
|
493 |
# ifdef Q_OS_SYMBIAN |
|
494 |
Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; |
|
495 |
# else |
|
496 |
Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder; |
|
497 |
# endif |
|
498 |
QWidget *QApplicationPrivate::oldEditFocus = 0; |
|
499 |
#endif |
|
500 |
||
501 |
bool qt_tabletChokeMouse = false; |
|
502 |
static bool force_reverse = false; |
|
503 |
||
504 |
inline bool QApplicationPrivate::isAlien(QWidget *widget) |
|
505 |
{ |
|
506 |
if (!widget) |
|
507 |
return false; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
508 |
#if defined(Q_WS_QWS) |
0 | 509 |
return !widget->isWindow() |
510 |
# ifdef Q_BACKINGSTORE_SUBSURFACES |
|
511 |
&& !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface) |
|
512 |
# endif |
|
513 |
; |
|
514 |
#else |
|
515 |
return !widget->internalWinId(); |
|
516 |
#endif |
|
517 |
} |
|
518 |
||
519 |
// ######## move to QApplicationPrivate |
|
520 |
// Default application palettes and fonts (per widget type) |
|
521 |
Q_GLOBAL_STATIC(PaletteHash, app_palettes) |
|
522 |
PaletteHash *qt_app_palettes_hash() |
|
523 |
{ |
|
524 |
return app_palettes(); |
|
525 |
} |
|
526 |
||
527 |
Q_GLOBAL_STATIC(FontHash, app_fonts) |
|
528 |
FontHash *qt_app_fonts_hash() |
|
529 |
{ |
|
530 |
return app_fonts(); |
|
531 |
} |
|
532 |
||
533 |
QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus |
|
534 |
||
535 |
QDesktopWidget *qt_desktopWidget = 0; // root window widgets |
|
536 |
#ifndef QT_NO_CLIPBOARD |
|
537 |
QClipboard *qt_clipboard = 0; // global clipboard object |
|
538 |
#endif |
|
539 |
QWidgetList * qt_modal_stack=0; // stack of modal widgets |
|
540 |
||
541 |
/*! |
|
542 |
\internal |
|
543 |
*/ |
|
544 |
void QApplicationPrivate::process_cmdline() |
|
545 |
{ |
|
546 |
// process platform-indep command line |
|
547 |
if (!qt_is_gui_used || !argc) |
|
548 |
return; |
|
549 |
||
550 |
int i, j; |
|
551 |
||
552 |
j = 1; |
|
553 |
for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments() |
|
554 |
if (argv[i] && *argv[i] != '-') { |
|
555 |
argv[j++] = argv[i]; |
|
556 |
continue; |
|
557 |
} |
|
558 |
QByteArray arg = argv[i]; |
|
559 |
arg = arg; |
|
560 |
QString s; |
|
561 |
if (arg == "-qdevel" || arg == "-qdebug") { |
|
562 |
// obsolete argument |
|
563 |
} else if (arg.indexOf("-style=", 0) != -1) { |
|
564 |
s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower()); |
|
565 |
} else if (arg == "-style" && i < argc-1) { |
|
566 |
s = QString::fromLocal8Bit(argv[++i]).toLower(); |
|
567 |
#ifndef QT_NO_SESSIONMANAGER |
|
568 |
} else if (arg == "-session" && i < argc-1) { |
|
569 |
++i; |
|
570 |
if (argv[i] && *argv[i]) { |
|
571 |
session_id = QString::fromLatin1(argv[i]); |
|
572 |
int p = session_id.indexOf(QLatin1Char('_')); |
|
573 |
if (p >= 0) { |
|
574 |
session_key = session_id.mid(p +1); |
|
575 |
session_id = session_id.left(p); |
|
576 |
} |
|
577 |
is_session_restored = true; |
|
578 |
} |
|
579 |
#endif |
|
580 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
581 |
} else if (arg == "-stylesheet" && i < argc -1) { |
|
582 |
styleSheet = QLatin1String("file:///"); |
|
583 |
styleSheet.append(QString::fromLocal8Bit(argv[++i])); |
|
584 |
} else if (arg.indexOf("-stylesheet=") != -1) { |
|
585 |
styleSheet = QLatin1String("file:///"); |
|
586 |
styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12))); |
|
587 |
#endif |
|
588 |
} else if (qstrcmp(arg, "-reverse") == 0) { |
|
589 |
force_reverse = true; |
|
590 |
QApplication::setLayoutDirection(Qt::RightToLeft); |
|
591 |
} else if (qstrcmp(arg, "-widgetcount") == 0) { |
|
592 |
widgetCount = true; |
|
593 |
} else if (qstrcmp(arg, "-testability") == 0) { |
|
594 |
load_testability = true; |
|
595 |
} else if (arg == "-graphicssystem" && i < argc-1) { |
|
596 |
graphics_system_name = QString::fromLocal8Bit(argv[++i]); |
|
597 |
} else { |
|
598 |
argv[j++] = argv[i]; |
|
599 |
} |
|
600 |
if (!s.isEmpty()) { |
|
601 |
if (app_style) { |
|
602 |
delete app_style; |
|
603 |
app_style = 0; |
|
604 |
} |
|
605 |
styleOverride = s; |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
if(j < argc) { |
|
610 |
argv[j] = 0; |
|
611 |
argc = j; |
|
612 |
} |
|
613 |
} |
|
614 |
||
615 |
/*! |
|
616 |
Initializes the window system and constructs an application object with |
|
617 |
\a argc command line arguments in \a argv. |
|
618 |
||
619 |
\warning The data referred to by \a argc and \a argv must stay valid for |
|
620 |
the entire lifetime of the QApplication object. In addition, \a argc must |
|
621 |
be greater than zero and \a argv must contain at least one valid character |
|
622 |
string. |
|
623 |
||
624 |
The global \c qApp pointer refers to this application object. Only one |
|
625 |
application object should be created. |
|
626 |
||
627 |
This application object must be constructed before any \l{QPaintDevice} |
|
628 |
{paint devices} (including widgets, pixmaps, bitmaps etc.). |
|
629 |
||
630 |
\note \a argc and \a argv might be changed as Qt removes command line |
|
631 |
arguments that it recognizes. |
|
632 |
||
633 |
Qt debugging options (not available if Qt was compiled without the QT_DEBUG |
|
634 |
flag defined): |
|
635 |
\list |
|
636 |
\o -nograb, tells Qt that it must never grab the mouse or the |
|
637 |
keyboard. |
|
638 |
\o -dograb (only under X11), running under a debugger can cause an |
|
639 |
implicit -nograb, use -dograb to override. |
|
640 |
\o -sync (only under X11), switches to synchronous mode for |
|
641 |
debugging. |
|
642 |
\endlist |
|
643 |
||
644 |
See \l{Debugging Techniques} for a more detailed explanation. |
|
645 |
||
646 |
All Qt programs automatically support the following command line options: |
|
647 |
\list |
|
648 |
\o -style= \e style, sets the application GUI style. Possible values |
|
649 |
are \c motif, \c windows, and \c platinum. If you compiled Qt with |
|
650 |
additional styles or have additional styles as plugins these will |
|
651 |
be available to the \c -style command line option. |
|
652 |
\o -style \e style, is the same as listed above. |
|
653 |
\o -stylesheet= \e stylesheet, sets the application \l styleSheet. The |
|
654 |
value must be a path to a file that contains the Style Sheet. |
|
655 |
\note Relative URLs in the Style Sheet file are relative to the |
|
656 |
Style Sheet file's path. |
|
657 |
\o -stylesheet \e stylesheet, is the same as listed above. |
|
658 |
\o -session= \e session, restores the application from an earlier |
|
659 |
\l{Session Management}{session}. |
|
660 |
\o -session \e session, is the same as listed above. |
|
661 |
\o -widgetcount, prints debug message at the end about number of |
|
662 |
widgets left undestroyed and maximum number of widgets existed at |
|
663 |
the same time |
|
664 |
\o -reverse, sets the application's layout direction to |
|
665 |
Qt::RightToLeft |
|
666 |
\o -graphicssystem, sets the backend to be used for on-screen widgets |
|
667 |
and QPixmaps. Available options are \c{raster} and \c{opengl}. |
|
668 |
\endlist |
|
669 |
||
670 |
The X11 version of Qt supports some traditional X11 command line options: |
|
671 |
\list |
|
672 |
\o -display \e display, sets the X display (default is $DISPLAY). |
|
673 |
\o -geometry \e geometry, sets the client geometry of the first window |
|
674 |
that is shown. |
|
675 |
\o -fn or \c -font \e font, defines the application font. The font |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
676 |
should be specified using an X logical font description. Note that |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
677 |
this option is ignored when Qt is built with fontconfig support enabled. |
0 | 678 |
\o -bg or \c -background \e color, sets the default background color |
679 |
and an application palette (light and dark shades are calculated). |
|
680 |
\o -fg or \c -foreground \e color, sets the default foreground color. |
|
681 |
\o -btn or \c -button \e color, sets the default button color. |
|
682 |
\o -name \e name, sets the application name. |
|
683 |
\o -title \e title, sets the application title. |
|
684 |
\o -visual \c TrueColor, forces the application to use a TrueColor |
|
685 |
visual on an 8-bit display. |
|
686 |
\o -ncols \e count, limits the number of colors allocated in the color |
|
687 |
cube on an 8-bit display, if the application is using the |
|
688 |
QApplication::ManyColor color specification. If \e count is 216 |
|
689 |
then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, |
|
690 |
and 6 of blue); for other values, a cube approximately proportional |
|
691 |
to a 2x3x1 cube is used. |
|
692 |
\o -cmap, causes the application to install a private color map on an |
|
693 |
8-bit display. |
|
694 |
\o -im, sets the input method server (equivalent to setting the |
|
695 |
XMODIFIERS environment variable) |
|
696 |
\o -inputstyle, defines how the input is inserted into the given |
|
697 |
widget, e.g., \c onTheSpot makes the input appear directly in the |
|
698 |
widget, while \c overTheSpot makes the input appear in a box |
|
699 |
floating over the widget and is not inserted until the editing is |
|
700 |
done. |
|
701 |
\endlist |
|
702 |
||
703 |
\sa arguments() |
|
704 |
*/ |
|
705 |
||
706 |
QApplication::QApplication(int &argc, char **argv) |
|
707 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
708 |
{ Q_D(QApplication); d->construct(); } |
|
709 |
||
710 |
QApplication::QApplication(int &argc, char **argv, int _internal) |
|
711 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
712 |
{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} |
|
713 |
||
714 |
||
715 |
/*! |
|
716 |
Constructs an application object with \a argc command line arguments in |
|
717 |
\a argv. If \a GUIenabled is true, a GUI application is constructed, |
|
718 |
otherwise a non-GUI (console) application is created. |
|
719 |
||
720 |
\warning The data referred to by \a argc and \a argv must stay valid for |
|
721 |
the entire lifetime of the QApplication object. In addition, \a argc must |
|
722 |
be greater than zero and \a argv must contain at least one valid character |
|
723 |
string. |
|
724 |
||
725 |
Set \a GUIenabled to false for programs without a graphical user interface |
|
726 |
that should be able to run without a window system. |
|
727 |
||
728 |
On X11, the window system is initialized if \a GUIenabled is true. If |
|
729 |
\a GUIenabled is false, the application does not connect to the X server. |
|
730 |
On Windows and Mac OS, currently the window system is always initialized, |
|
731 |
regardless of the value of GUIenabled. This may change in future versions |
|
732 |
of Qt. |
|
733 |
||
734 |
The following example shows how to create an application that uses a |
|
735 |
graphical interface when available. |
|
736 |
||
737 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 |
|
738 |
*/ |
|
739 |
||
740 |
QApplication::QApplication(int &argc, char **argv, bool GUIenabled ) |
|
741 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty)) |
|
742 |
{ Q_D(QApplication); d->construct(); } |
|
743 |
||
744 |
QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal) |
|
745 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty)) |
|
746 |
{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} |
|
747 |
||
748 |
||
749 |
||
750 |
/*! |
|
751 |
Constructs an application object with \a argc command line arguments in |
|
752 |
\a argv. |
|
753 |
||
754 |
\warning The data referred to by \a argc and \a argv must stay valid for |
|
755 |
the entire lifetime of the QApplication object. In addition, \a argc must |
|
756 |
be greater than zero and \a argv must contain at least one valid character |
|
757 |
string. |
|
758 |
||
759 |
With Qt for Embedded Linux, passing QApplication::GuiServer for \a type |
|
760 |
makes this application the server (equivalent to running with the |
|
761 |
\c -qws option). |
|
762 |
*/ |
|
763 |
QApplication::QApplication(int &argc, char **argv, Type type) |
|
764 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, type)) |
|
765 |
{ Q_D(QApplication); d->construct(); } |
|
766 |
||
767 |
QApplication::QApplication(int &argc, char **argv, Type type , int _internal) |
|
768 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, type)) |
|
769 |
{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} |
|
770 |
||
771 |
||
772 |
/*! |
|
773 |
\internal |
|
774 |
*/ |
|
775 |
void QApplicationPrivate::construct( |
|
776 |
#ifdef Q_WS_X11 |
|
777 |
Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap |
|
778 |
#endif |
|
779 |
) |
|
780 |
{ |
|
781 |
initResources(); |
|
782 |
||
783 |
qt_is_gui_used = (qt_appType != QApplication::Tty); |
|
784 |
process_cmdline(); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
785 |
// the environment variable has the lowest precedence of runtime graphicssystem switches |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
786 |
if (graphics_system_name.isEmpty()) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
787 |
graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); |
0 | 788 |
// Must be called before initialize() |
789 |
qt_init(this, qt_appType |
|
790 |
#ifdef Q_WS_X11 |
|
791 |
, dpy, visual, cmap |
|
792 |
#endif |
|
793 |
); |
|
794 |
initialize(); |
|
795 |
eventDispatcher->startingUp(); |
|
796 |
||
797 |
#ifdef QT_EVAL |
|
798 |
extern void qt_gui_eval_init(uint); |
|
799 |
qt_gui_eval_init(application_type); |
|
800 |
#endif |
|
801 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
802 |
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
803 |
symbianInit(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
804 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
805 |
|
0 | 806 |
#ifndef QT_NO_LIBRARY |
807 |
if(load_testability) { |
|
808 |
QLibrary testLib(QLatin1String("qttestability")); |
|
809 |
if (testLib.load()) { |
|
810 |
typedef void (*TasInitialize)(void); |
|
811 |
TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); |
|
812 |
if (initFunction) { |
|
813 |
initFunction(); |
|
814 |
} else { |
|
815 |
qCritical("Library qttestability resolve failed!"); |
|
816 |
} |
|
817 |
} else { |
|
818 |
qCritical("Library qttestability load failed!"); |
|
819 |
} |
|
820 |
} |
|
821 |
||
822 |
//make sure the plugin is loaded |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
823 |
if (qt_is_gui_used) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
qt_guiPlatformPlugin(); |
0 | 825 |
#endif |
826 |
} |
|
827 |
||
828 |
#if defined(Q_WS_X11) |
|
829 |
// ### a string literal is a cont char* |
|
830 |
// ### using it as a char* is wrong and could lead to segfaults |
|
831 |
// ### if aargv is modified someday |
|
832 |
// ########## make it work with argc == argv == 0 |
|
833 |
static int aargc = 1; |
|
834 |
static char *aargv[] = { (char*)"unknown", 0 }; |
|
835 |
||
836 |
/*! |
|
837 |
\fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) |
|
838 |
||
839 |
Creates an application, given an already open display \a display. If |
|
840 |
\a visual and \a colormap are non-zero, the application will use those |
|
841 |
values as the default Visual and Colormap contexts. |
|
842 |
||
843 |
\warning Qt only supports TrueColor visuals at depths higher than 8 |
|
844 |
bits-per-pixel. |
|
845 |
||
846 |
This function is only available on X11. |
|
847 |
*/ |
|
848 |
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) |
|
849 |
: QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)) |
|
850 |
{ |
|
851 |
if (! dpy) |
|
852 |
qWarning("QApplication: Invalid Display* argument"); |
|
853 |
Q_D(QApplication); |
|
854 |
d->construct(dpy, visual, colormap); |
|
855 |
} |
|
856 |
||
857 |
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) |
|
858 |
: QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)) |
|
859 |
{ |
|
860 |
if (! dpy) |
|
861 |
qWarning("QApplication: Invalid Display* argument"); |
|
862 |
Q_D(QApplication); |
|
863 |
d->construct(dpy, visual, colormap); |
|
864 |
QApplicationPrivate::app_compile_version = _internal; |
|
865 |
} |
|
866 |
||
867 |
/*! |
|
868 |
\fn QApplication::QApplication(Display *display, int &argc, char **argv, |
|
869 |
Qt::HANDLE visual, Qt::HANDLE colormap) |
|
870 |
||
871 |
Creates an application, given an already open \a display and using \a argc |
|
872 |
command line arguments in \a argv. If \a visual and \a colormap are |
|
873 |
non-zero, the application will use those values as the default Visual |
|
874 |
and Colormap contexts. |
|
875 |
||
876 |
\warning Qt only supports TrueColor visuals at depths higher than 8 |
|
877 |
bits-per-pixel. |
|
878 |
||
879 |
This function is only available on X11. |
|
880 |
*/ |
|
881 |
QApplication::QApplication(Display *dpy, int &argc, char **argv, |
|
882 |
Qt::HANDLE visual, Qt::HANDLE colormap) |
|
883 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
884 |
{ |
|
885 |
if (! dpy) |
|
886 |
qWarning("QApplication: Invalid Display* argument"); |
|
887 |
Q_D(QApplication); |
|
888 |
d->construct(dpy, visual, colormap); |
|
889 |
} |
|
890 |
||
891 |
QApplication::QApplication(Display *dpy, int &argc, char **argv, |
|
892 |
Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) |
|
893 |
: QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) |
|
894 |
{ |
|
895 |
if (! dpy) |
|
896 |
qWarning("QApplication: Invalid Display* argument"); |
|
897 |
Q_D(QApplication); |
|
898 |
d->construct(dpy, visual, colormap); |
|
899 |
QApplicationPrivate::app_compile_version = _internal; |
|
900 |
} |
|
901 |
||
902 |
#endif // Q_WS_X11 |
|
903 |
||
904 |
extern void qInitDrawhelperAsm(); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
905 |
extern void qInitImageConversions(); |
0 | 906 |
extern int qRegisterGuiVariant(); |
907 |
extern int qUnregisterGuiVariant(); |
|
908 |
#ifndef QT_NO_STATEMACHINE |
|
909 |
extern int qRegisterGuiStateMachine(); |
|
910 |
extern int qUnregisterGuiStateMachine(); |
|
911 |
#endif |
|
912 |
||
913 |
/*! |
|
914 |
\fn void QApplicationPrivate::initialize() |
|
915 |
||
916 |
Initializes the QApplication object, called from the constructors. |
|
917 |
*/ |
|
918 |
void QApplicationPrivate::initialize() |
|
919 |
{ |
|
920 |
QWidgetPrivate::mapper = new QWidgetMapper; |
|
921 |
QWidgetPrivate::allWidgets = new QWidgetSet; |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
922 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
923 |
#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) |
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
924 |
// initialize the graphics system - on X11 this is initialized inside |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
925 |
// qt_init() in qapplication_x11.cpp because of several reasons. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
926 |
// On QWS, the graphics system is set by the QScreen plugin. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
927 |
graphics_system = QGraphicsSystemFactory::create(graphics_system_name); |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
928 |
#endif |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
929 |
|
0 | 930 |
if (qt_appType != QApplication::Tty) |
931 |
(void) QApplication::style(); // trigger creation of application style |
|
932 |
// trigger registering of QVariant's GUI types |
|
933 |
qRegisterGuiVariant(); |
|
934 |
#ifndef QT_NO_STATEMACHINE |
|
935 |
// trigger registering of QStateMachine's GUI types |
|
936 |
qRegisterGuiStateMachine(); |
|
937 |
#endif |
|
938 |
||
939 |
is_app_running = true; // no longer starting up |
|
940 |
||
941 |
Q_Q(QApplication); |
|
942 |
#ifndef QT_NO_SESSIONMANAGER |
|
943 |
// connect to the session manager |
|
944 |
session_manager = new QSessionManager(q, session_id, session_key); |
|
945 |
#endif |
|
946 |
||
947 |
if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0) |
|
948 |
q->setAttribute(Qt::AA_NativeWindows); |
|
949 |
||
950 |
#ifdef Q_WS_WINCE |
|
951 |
#ifdef QT_AUTO_MAXIMIZE_THRESHOLD |
|
952 |
autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD; |
|
953 |
#else |
|
954 |
if (qt_wince_is_mobile()) |
|
955 |
autoMaximizeThreshold = 50; |
|
956 |
else |
|
957 |
autoMaximizeThreshold = -1; |
|
958 |
#endif //QT_AUTO_MAXIMIZE_THRESHOLD |
|
959 |
#endif //Q_WS_WINCE |
|
960 |
||
961 |
// Set up which span functions should be used in raster engine... |
|
962 |
qInitDrawhelperAsm(); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
963 |
// and QImage conversion functions |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
964 |
qInitImageConversions(); |
0 | 965 |
|
966 |
#ifndef QT_NO_WHEELEVENT |
|
967 |
QApplicationPrivate::wheel_scroll_lines = 3; |
|
968 |
#endif |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
969 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
970 |
if (qt_is_gui_used) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
971 |
initializeMultitouch(); |
0 | 972 |
} |
973 |
||
974 |
/*! |
|
975 |
Returns the type of application (\l Tty, GuiClient, or |
|
976 |
GuiServer). The type is set when constructing the QApplication |
|
977 |
object. |
|
978 |
*/ |
|
979 |
QApplication::Type QApplication::type() |
|
980 |
{ |
|
981 |
return qt_appType; |
|
982 |
} |
|
983 |
||
984 |
/***************************************************************************** |
|
985 |
Functions returning the active popup and modal widgets. |
|
986 |
*****************************************************************************/ |
|
987 |
||
988 |
/*! |
|
989 |
Returns the active popup widget. |
|
990 |
||
991 |
A popup widget is a special top-level widget that sets the \c |
|
992 |
Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application |
|
993 |
opens a popup widget, all events are sent to the popup. Normal widgets and |
|
994 |
modal widgets cannot be accessed before the popup widget is closed. |
|
995 |
||
996 |
Only other popup widgets may be opened when a popup widget is shown. The |
|
997 |
popup widgets are organized in a stack. This function returns the active |
|
998 |
popup widget at the top of the stack. |
|
999 |
||
1000 |
\sa activeModalWidget(), topLevelWidgets() |
|
1001 |
*/ |
|
1002 |
||
1003 |
QWidget *QApplication::activePopupWidget() |
|
1004 |
{ |
|
1005 |
return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ? |
|
1006 |
QApplicationPrivate::popupWidgets->last() : 0; |
|
1007 |
} |
|
1008 |
||
1009 |
||
1010 |
/*! |
|
1011 |
Returns the active modal widget. |
|
1012 |
||
1013 |
A modal widget is a special top-level widget which is a subclass of QDialog |
|
1014 |
that specifies the modal parameter of the constructor as true. A modal |
|
1015 |
widget must be closed before the user can continue with other parts of the |
|
1016 |
program. |
|
1017 |
||
1018 |
Modal widgets are organized in a stack. This function returns the active |
|
1019 |
modal widget at the top of the stack. |
|
1020 |
||
1021 |
\sa activePopupWidget(), topLevelWidgets() |
|
1022 |
*/ |
|
1023 |
||
1024 |
QWidget *QApplication::activeModalWidget() |
|
1025 |
{ |
|
1026 |
return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0; |
|
1027 |
} |
|
1028 |
||
1029 |
/*! |
|
1030 |
Cleans up any window system resources that were allocated by this |
|
1031 |
application. Sets the global variable \c qApp to 0. |
|
1032 |
*/ |
|
1033 |
||
1034 |
QApplication::~QApplication() |
|
1035 |
{ |
|
1036 |
Q_D(QApplication); |
|
1037 |
||
1038 |
#ifndef QT_NO_CLIPBOARD |
|
1039 |
// flush clipboard contents |
|
1040 |
if (qt_clipboard) { |
|
1041 |
QEvent event(QEvent::Clipboard); |
|
1042 |
QApplication::sendEvent(qt_clipboard, &event); |
|
1043 |
} |
|
1044 |
#endif |
|
1045 |
||
1046 |
//### this should probable be done even later |
|
1047 |
qt_call_post_routines(); |
|
1048 |
||
1049 |
// kill timers before closing down the dispatcher |
|
1050 |
d->toolTipWakeUp.stop(); |
|
1051 |
d->toolTipFallAsleep.stop(); |
|
1052 |
||
1053 |
d->eventDispatcher->closingDown(); |
|
1054 |
d->eventDispatcher = 0; |
|
1055 |
QApplicationPrivate::is_app_closing = true; |
|
1056 |
QApplicationPrivate::is_app_running = false; |
|
1057 |
||
1058 |
delete qt_desktopWidget; |
|
1059 |
qt_desktopWidget = 0; |
|
1060 |
||
1061 |
#ifndef QT_NO_CLIPBOARD |
|
1062 |
delete qt_clipboard; |
|
1063 |
qt_clipboard = 0; |
|
1064 |
#endif |
|
1065 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1066 |
#if defined(Q_WS_X11) || defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1067 |
delete d->move_cursor; d->move_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1068 |
delete d->copy_cursor; d->copy_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1069 |
delete d->link_cursor; d->link_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1070 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1071 |
#if defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1072 |
delete d->ignore_cursor; d->ignore_cursor = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1073 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
1074 |
|
0 | 1075 |
delete QWidgetPrivate::mapper; |
1076 |
QWidgetPrivate::mapper = 0; |
|
1077 |
||
1078 |
// delete all widgets |
|
1079 |
if (QWidgetPrivate::allWidgets) { |
|
1080 |
QWidgetSet *mySet = QWidgetPrivate::allWidgets; |
|
1081 |
QWidgetPrivate::allWidgets = 0; |
|
1082 |
for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) { |
|
1083 |
register QWidget *w = *it; |
|
1084 |
if (!w->parent()) // window |
|
1085 |
w->destroy(true, true); |
|
1086 |
} |
|
1087 |
delete mySet; |
|
1088 |
} |
|
1089 |
||
1090 |
delete QApplicationPrivate::app_pal; |
|
1091 |
QApplicationPrivate::app_pal = 0; |
|
1092 |
delete QApplicationPrivate::sys_pal; |
|
1093 |
QApplicationPrivate::sys_pal = 0; |
|
1094 |
delete QApplicationPrivate::set_pal; |
|
1095 |
QApplicationPrivate::set_pal = 0; |
|
1096 |
app_palettes()->clear(); |
|
1097 |
||
1098 |
{ |
|
1099 |
QMutexLocker locker(applicationFontMutex()); |
|
1100 |
delete QApplicationPrivate::app_font; |
|
1101 |
QApplicationPrivate::app_font = 0; |
|
1102 |
} |
|
1103 |
delete QApplicationPrivate::sys_font; |
|
1104 |
QApplicationPrivate::sys_font = 0; |
|
1105 |
delete QApplicationPrivate::set_font; |
|
1106 |
QApplicationPrivate::set_font = 0; |
|
1107 |
app_fonts()->clear(); |
|
1108 |
||
1109 |
delete QApplicationPrivate::app_style; |
|
1110 |
QApplicationPrivate::app_style = 0; |
|
1111 |
delete QApplicationPrivate::app_icon; |
|
1112 |
QApplicationPrivate::app_icon = 0; |
|
1113 |
#ifndef QT_NO_CURSOR |
|
1114 |
d->cursor_list.clear(); |
|
1115 |
#endif |
|
1116 |
||
1117 |
#ifndef QT_NO_DRAGANDDROP |
|
1118 |
if (qt_is_gui_used) |
|
1119 |
delete QDragManager::self(); |
|
1120 |
#endif |
|
1121 |
||
1122 |
d->cleanupMultitouch(); |
|
1123 |
||
1124 |
qt_cleanup(); |
|
1125 |
||
1126 |
if (QApplicationPrivate::widgetCount) |
|
1127 |
qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances); |
|
1128 |
#ifndef QT_NO_SESSIONMANAGER |
|
1129 |
delete d->session_manager; |
|
1130 |
d->session_manager = 0; |
|
1131 |
#endif //QT_NO_SESSIONMANAGER |
|
1132 |
||
1133 |
QApplicationPrivate::obey_desktop_settings = true; |
|
1134 |
QApplicationPrivate::cursor_flash_time = 1000; |
|
1135 |
QApplicationPrivate::mouse_double_click_time = 400; |
|
1136 |
QApplicationPrivate::keyboard_input_time = 400; |
|
1137 |
||
1138 |
drag_time = 500; |
|
1139 |
drag_distance = 4; |
|
1140 |
layout_direction = Qt::LeftToRight; |
|
1141 |
QApplicationPrivate::app_strut = QSize(0, 0); |
|
1142 |
QApplicationPrivate::animate_ui = true; |
|
1143 |
QApplicationPrivate::animate_menu = false; |
|
1144 |
QApplicationPrivate::fade_menu = false; |
|
1145 |
QApplicationPrivate::animate_combo = false; |
|
1146 |
QApplicationPrivate::animate_tooltip = false; |
|
1147 |
QApplicationPrivate::fade_tooltip = false; |
|
1148 |
QApplicationPrivate::widgetCount = false; |
|
1149 |
||
1150 |
#ifndef QT_NO_STATEMACHINE |
|
1151 |
// trigger unregistering of QStateMachine's GUI types |
|
1152 |
qUnregisterGuiStateMachine(); |
|
1153 |
#endif |
|
1154 |
// trigger unregistering of QVariant's GUI types |
|
1155 |
qUnregisterGuiVariant(); |
|
1156 |
} |
|
1157 |
||
1158 |
||
1159 |
/*! |
|
1160 |
\fn QWidget *QApplication::widgetAt(const QPoint &point) |
|
1161 |
||
1162 |
Returns the widget at global screen position \a point, or 0 if there is no |
|
1163 |
Qt widget there. |
|
1164 |
||
1165 |
This function can be slow. |
|
1166 |
||
1167 |
\sa QCursor::pos(), QWidget::grabMouse(), QWidget::grabKeyboard() |
|
1168 |
*/ |
|
1169 |
QWidget *QApplication::widgetAt(const QPoint &p) |
|
1170 |
{ |
|
1171 |
QWidget *window = QApplication::topLevelAt(p); |
|
1172 |
if (!window) |
|
1173 |
return 0; |
|
1174 |
||
1175 |
QWidget *child = 0; |
|
1176 |
||
1177 |
if (!window->testAttribute(Qt::WA_TransparentForMouseEvents)) |
|
1178 |
child = window->childAt(window->mapFromGlobal(p)); |
|
1179 |
||
1180 |
if (child) |
|
1181 |
return child; |
|
1182 |
||
1183 |
if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) { |
|
1184 |
//shoot a hole in the widget and try once again, |
|
1185 |
//suboptimal on Qt for Embedded Linux where we do |
|
1186 |
//know the stacking order of the toplevels. |
|
1187 |
int x = p.x(); |
|
1188 |
int y = p.y(); |
|
1189 |
QRegion oldmask = window->mask(); |
|
1190 |
QPoint wpoint = window->mapFromGlobal(QPoint(x, y)); |
|
1191 |
QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask) |
|
1192 |
- QRegion(wpoint.x(), wpoint.y(), 1, 1); |
|
1193 |
window->setMask(newmask); |
|
1194 |
QWidget *recurse = 0; |
|
1195 |
if (QApplication::topLevelAt(p) != window) // verify recursion will terminate |
|
1196 |
recurse = widgetAt(x, y); |
|
1197 |
if (oldmask.isEmpty()) |
|
1198 |
window->clearMask(); |
|
1199 |
else |
|
1200 |
window->setMask(oldmask); |
|
1201 |
return recurse; |
|
1202 |
} |
|
1203 |
return window; |
|
1204 |
} |
|
1205 |
||
1206 |
/*! |
|
1207 |
\fn QWidget *QApplication::widgetAt(int x, int y) |
|
1208 |
||
1209 |
\overload |
|
1210 |
||
1211 |
Returns the widget at global screen position (\a x, \a y), or 0 if there is |
|
1212 |
no Qt widget there. |
|
1213 |
*/ |
|
1214 |
||
1215 |
/*! |
|
1216 |
\fn void QApplication::setArgs(int argc, char **argv) |
|
1217 |
\internal |
|
1218 |
*/ |
|
1219 |
||
1220 |
||
1221 |
||
1222 |
/*! |
|
1223 |
\internal |
|
1224 |
*/ |
|
1225 |
bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) |
|
1226 |
{ |
|
1227 |
if ((event->type() == QEvent::UpdateRequest |
|
1228 |
#ifdef QT3_SUPPORT |
|
1229 |
|| event->type() == QEvent::LayoutHint |
|
1230 |
#endif |
|
1231 |
|| event->type() == QEvent::LayoutRequest |
|
1232 |
|| event->type() == QEvent::Resize |
|
1233 |
|| event->type() == QEvent::Move |
|
1234 |
|| event->type() == QEvent::LanguageChange |
|
1235 |
|| event->type() == QEvent::UpdateSoftKeys |
|
1236 |
|| event->type() == QEvent::InputMethod)) { |
|
1237 |
for (int i = 0; i < postedEvents->size(); ++i) { |
|
1238 |
const QPostEvent &cur = postedEvents->at(i); |
|
1239 |
if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type()) |
|
1240 |
continue; |
|
1241 |
if (cur.event->type() == QEvent::LayoutRequest |
|
1242 |
#ifdef QT3_SUPPORT |
|
1243 |
|| cur.event->type() == QEvent::LayoutHint |
|
1244 |
#endif |
|
1245 |
|| cur.event->type() == QEvent::UpdateRequest) { |
|
1246 |
; |
|
1247 |
} else if (cur.event->type() == QEvent::Resize) { |
|
1248 |
((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s; |
|
1249 |
} else if (cur.event->type() == QEvent::Move) { |
|
1250 |
((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p; |
|
1251 |
} else if (cur.event->type() == QEvent::LanguageChange) { |
|
1252 |
; |
|
1253 |
} else if (cur.event->type() == QEvent::UpdateSoftKeys) { |
|
1254 |
; |
|
1255 |
} else if ( cur.event->type() == QEvent::InputMethod ) { |
|
1256 |
*(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event; |
|
1257 |
} else { |
|
1258 |
continue; |
|
1259 |
} |
|
1260 |
delete event; |
|
1261 |
return true; |
|
1262 |
} |
|
1263 |
return false; |
|
1264 |
} |
|
1265 |
return QCoreApplication::compressEvent(event, receiver, postedEvents); |
|
1266 |
} |
|
1267 |
||
1268 |
/*! |
|
1269 |
\property QApplication::styleSheet |
|
1270 |
\brief the application style sheet |
|
1271 |
\since 4.2 |
|
1272 |
||
1273 |
By default, this property returns an empty string unless the user specifies |
|
1274 |
the \c{-stylesheet} option on the command line when running the application. |
|
1275 |
||
1276 |
\sa QWidget::setStyle(), {Qt Style Sheets} |
|
1277 |
*/ |
|
1278 |
||
1279 |
/*! |
|
1280 |
\property QApplication::autoMaximizeThreshold |
|
1281 |
\since 4.4 |
|
1282 |
\brief defines a threshold for auto maximizing widgets |
|
1283 |
||
1284 |
\bold{The auto maximize threshold is only available as part of Qt for |
|
1285 |
Windows CE.} |
|
1286 |
||
1287 |
This property defines a threshold for the size of a window as a percentage |
|
1288 |
of the screen size. If the minimum size hint of a window exceeds the |
|
1289 |
threshold, calling show() will cause the window to be maximized |
|
1290 |
automatically. |
|
1291 |
||
1292 |
Setting the threshold to 100 or greater means that the widget will always |
|
1293 |
be maximized. Alternatively, setting the threshold to 50 means that the |
|
1294 |
widget will be maximized only if the vertical minimum size hint is at least |
|
1295 |
50% of the vertical screen size. |
|
1296 |
||
1297 |
Setting the threshold to -1 disables the feature. |
|
1298 |
||
1299 |
On Windows CE the default is -1 (i.e., it is disabled). |
|
1300 |
On Windows Mobile the default is 40. |
|
1301 |
*/ |
|
1302 |
||
1303 |
/*! |
|
1304 |
\property QApplication::autoSipEnabled |
|
1305 |
\since 4.5 |
|
1306 |
\brief toggles automatic SIP (software input panel) visibility |
|
1307 |
||
1308 |
Set this property to \c true to automatically display the SIP when entering |
|
1309 |
widgets that accept keyboard input. This property only affects widgets with |
|
1310 |
the WA_InputMethodEnabled attribute set, and is typically used to launch |
|
1311 |
a virtual keyboard on devices which have very few or no keys. |
|
1312 |
||
1313 |
\bold{ The property only has an effect on platforms which use software input |
|
1314 |
panels, such as Windows CE and Symbian.} |
|
1315 |
||
1316 |
The default is platform dependent. |
|
1317 |
*/ |
|
1318 |
||
1319 |
#ifdef Q_WS_WINCE |
|
1320 |
void QApplication::setAutoMaximizeThreshold(const int threshold) |
|
1321 |
{ |
|
1322 |
QApplicationPrivate::autoMaximizeThreshold = threshold; |
|
1323 |
} |
|
1324 |
||
1325 |
int QApplication::autoMaximizeThreshold() const |
|
1326 |
{ |
|
1327 |
return QApplicationPrivate::autoMaximizeThreshold; |
|
1328 |
} |
|
1329 |
#endif |
|
1330 |
||
1331 |
void QApplication::setAutoSipEnabled(const bool enabled) |
|
1332 |
{ |
|
1333 |
QApplicationPrivate::autoSipEnabled = enabled; |
|
1334 |
} |
|
1335 |
||
1336 |
bool QApplication::autoSipEnabled() const |
|
1337 |
{ |
|
1338 |
return QApplicationPrivate::autoSipEnabled; |
|
1339 |
} |
|
1340 |
||
1341 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1342 |
||
1343 |
QString QApplication::styleSheet() const |
|
1344 |
{ |
|
1345 |
return QApplicationPrivate::styleSheet; |
|
1346 |
} |
|
1347 |
||
1348 |
void QApplication::setStyleSheet(const QString& styleSheet) |
|
1349 |
{ |
|
1350 |
QApplicationPrivate::styleSheet = styleSheet; |
|
1351 |
QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplicationPrivate::app_style); |
|
1352 |
if (styleSheet.isEmpty()) { // application style sheet removed |
|
1353 |
if (!proxy) |
|
1354 |
return; // there was no stylesheet before |
|
1355 |
setStyle(proxy->base); |
|
1356 |
} else if (proxy) { // style sheet update, just repolish |
|
1357 |
proxy->repolish(qApp); |
|
1358 |
} else { // stylesheet set the first time |
|
1359 |
QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style); |
|
1360 |
QApplicationPrivate::app_style->setParent(newProxy); |
|
1361 |
setStyle(newProxy); |
|
1362 |
} |
|
1363 |
} |
|
1364 |
||
1365 |
#endif // QT_NO_STYLE_STYLESHEET |
|
1366 |
||
1367 |
/*! |
|
1368 |
Returns the application's style object. |
|
1369 |
||
1370 |
\sa setStyle(), QStyle |
|
1371 |
*/ |
|
1372 |
QStyle *QApplication::style() |
|
1373 |
{ |
|
1374 |
if (QApplicationPrivate::app_style) |
|
1375 |
return QApplicationPrivate::app_style; |
|
1376 |
if (!qt_is_gui_used) { |
|
1377 |
Q_ASSERT(!"No style available in non-gui applications!"); |
|
1378 |
return 0; |
|
1379 |
} |
|
1380 |
||
1381 |
if (!QApplicationPrivate::app_style) { |
|
1382 |
// Compile-time search for default style |
|
1383 |
// |
|
1384 |
QString style; |
|
1385 |
if (!QApplicationPrivate::styleOverride.isEmpty()) |
|
1386 |
style = QApplicationPrivate::styleOverride; |
|
1387 |
else |
|
1388 |
style = QApplicationPrivate::desktopStyleKey(); |
|
1389 |
||
1390 |
QStyle *&app_style = QApplicationPrivate::app_style; |
|
1391 |
app_style = QStyleFactory::create(style); |
|
1392 |
if (!app_style) { |
|
1393 |
QStringList styles = QStyleFactory::keys(); |
|
1394 |
for (int i = 0; i < styles.size(); ++i) { |
|
1395 |
if ((app_style = QStyleFactory::create(styles.at(i)))) |
|
1396 |
break; |
|
1397 |
} |
|
1398 |
} |
|
1399 |
if (!app_style) { |
|
1400 |
Q_ASSERT(!"No styles available!"); |
|
1401 |
return 0; |
|
1402 |
} |
|
1403 |
} |
|
1404 |
// take ownership of the style |
|
1405 |
QApplicationPrivate::app_style->setParent(qApp); |
|
1406 |
||
1407 |
if (!QApplicationPrivate::sys_pal) |
|
1408 |
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); |
|
1409 |
if (QApplicationPrivate::set_pal) // repolish set palette with the new style |
|
1410 |
QApplication::setPalette(*QApplicationPrivate::set_pal); |
|
1411 |
||
1412 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1413 |
if (!QApplicationPrivate::styleSheet.isEmpty()) { |
|
1414 |
qApp->setStyleSheet(QApplicationPrivate::styleSheet); |
|
1415 |
} else |
|
1416 |
#endif |
|
1417 |
QApplicationPrivate::app_style->polish(qApp); |
|
1418 |
||
1419 |
return QApplicationPrivate::app_style; |
|
1420 |
} |
|
1421 |
||
1422 |
/*! |
|
1423 |
Sets the application's GUI style to \a style. Ownership of the style object |
|
1424 |
is transferred to QApplication, so QApplication will delete the style |
|
1425 |
object on application exit or when a new style is set and the old style is |
|
1426 |
still the parent of the application object. |
|
1427 |
||
1428 |
Example usage: |
|
1429 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1 |
|
1430 |
||
1431 |
When switching application styles, the color palette is set back to the |
|
1432 |
initial colors or the system defaults. This is necessary since certain |
|
1433 |
styles have to adapt the color palette to be fully style-guide compliant. |
|
1434 |
||
1435 |
Setting the style before a palette has been se, i.e., before creating |
|
1436 |
QApplication, will cause the application to use QStyle::standardPalette() |
|
1437 |
for the palette. |
|
1438 |
||
1439 |
\warning Qt style sheets are currently not supported for custom QStyle |
|
1440 |
subclasses. We plan to address this in some future release. |
|
1441 |
||
1442 |
\sa style(), QStyle, setPalette(), desktopSettingsAware() |
|
1443 |
*/ |
|
1444 |
void QApplication::setStyle(QStyle *style) |
|
1445 |
{ |
|
1446 |
if (!style || style == QApplicationPrivate::app_style) |
|
1447 |
return; |
|
1448 |
||
1449 |
QWidgetList all = allWidgets(); |
|
1450 |
||
1451 |
// clean up the old style |
|
1452 |
if (QApplicationPrivate::app_style) { |
|
1453 |
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { |
|
1454 |
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { |
|
1455 |
register QWidget *w = *it; |
|
1456 |
if (!(w->windowType() == Qt::Desktop) && // except desktop |
|
1457 |
w->testAttribute(Qt::WA_WState_Polished)) { // has been polished |
|
1458 |
QApplicationPrivate::app_style->unpolish(w); |
|
1459 |
} |
|
1460 |
} |
|
1461 |
} |
|
1462 |
QApplicationPrivate::app_style->unpolish(qApp); |
|
1463 |
} |
|
1464 |
||
1465 |
QStyle *old = QApplicationPrivate::app_style; // save |
|
1466 |
||
1467 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1468 |
if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) { |
|
1469 |
// we have a stylesheet already and a new style is being set |
|
1470 |
QStyleSheetStyle *newProxy = new QStyleSheetStyle(style); |
|
1471 |
style->setParent(newProxy); |
|
1472 |
QApplicationPrivate::app_style = newProxy; |
|
1473 |
} else |
|
1474 |
#endif // QT_NO_STYLE_STYLESHEET |
|
1475 |
QApplicationPrivate::app_style = style; |
|
1476 |
QApplicationPrivate::app_style->setParent(qApp); // take ownership |
|
1477 |
||
1478 |
// take care of possible palette requirements of certain gui |
|
1479 |
// styles. Do it before polishing the application since the style |
|
1480 |
// might call QApplication::setPalette() itself |
|
1481 |
if (QApplicationPrivate::set_pal) { |
|
1482 |
QApplication::setPalette(*QApplicationPrivate::set_pal); |
|
1483 |
} else if (QApplicationPrivate::sys_pal) { |
|
1484 |
QApplicationPrivate::initializeWidgetPaletteHash(); |
|
1485 |
QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false); |
|
1486 |
} else if (!QApplicationPrivate::sys_pal) { |
|
1487 |
// Initialize the sys_pal if it hasn't happened yet... |
|
1488 |
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); |
|
1489 |
} |
|
1490 |
||
1491 |
// initialize the application with the new style |
|
1492 |
QApplicationPrivate::app_style->polish(qApp); |
|
1493 |
||
1494 |
// re-polish existing widgets if necessary |
|
1495 |
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { |
|
1496 |
for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) { |
|
1497 |
register QWidget *w = *it1; |
|
1498 |
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) { |
|
1499 |
if (w->style() == QApplicationPrivate::app_style) |
|
1500 |
QApplicationPrivate::app_style->polish(w); // repolish |
|
1501 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1502 |
else |
|
1503 |
w->setStyleSheet(w->styleSheet()); // touch |
|
1504 |
#endif |
|
1505 |
} |
|
1506 |
} |
|
1507 |
||
1508 |
for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) { |
|
1509 |
register QWidget *w = *it2; |
|
1510 |
if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) { |
|
1511 |
QEvent e(QEvent::StyleChange); |
|
1512 |
QApplication::sendEvent(w, &e); |
|
1513 |
#ifdef QT3_SUPPORT |
|
1514 |
if (old) |
|
1515 |
w->styleChange(*old); |
|
1516 |
#endif |
|
1517 |
w->update(); |
|
1518 |
} |
|
1519 |
} |
|
1520 |
} |
|
1521 |
||
1522 |
#ifndef QT_NO_STYLE_STYLESHEET |
|
1523 |
if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) { |
|
1524 |
oldProxy->deref(); |
|
1525 |
} else |
|
1526 |
#endif |
|
1527 |
if (old && old->parent() == qApp) { |
|
1528 |
delete old; |
|
1529 |
} |
|
1530 |
||
1531 |
if (QApplicationPrivate::focus_widget) { |
|
1532 |
QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason); |
|
1533 |
QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); |
|
1534 |
QApplicationPrivate::focus_widget->update(); |
|
1535 |
} |
|
1536 |
} |
|
1537 |
||
1538 |
/*! |
|
1539 |
\overload |
|
1540 |
||
1541 |
Requests a QStyle object for \a style from the QStyleFactory. |
|
1542 |
||
1543 |
The string must be one of the QStyleFactory::keys(), typically one of |
|
1544 |
"windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style |
|
1545 |
names are case insensitive. |
|
1546 |
||
1547 |
Returns 0 if an unknown \a style is passed, otherwise the QStyle object |
|
1548 |
returned is set as the application's GUI style. |
|
1549 |
||
1550 |
\warning To ensure that the application's style is set correctly, it is |
|
1551 |
best to call this function before the QApplication constructor, if |
|
1552 |
possible. |
|
1553 |
*/ |
|
1554 |
QStyle* QApplication::setStyle(const QString& style) |
|
1555 |
{ |
|
1556 |
QStyle *s = QStyleFactory::create(style); |
|
1557 |
if (!s) |
|
1558 |
return 0; |
|
1559 |
||
1560 |
setStyle(s); |
|
1561 |
return s; |
|
1562 |
} |
|
1563 |
||
1564 |
/*! |
|
1565 |
\since 4.5 |
|
1566 |
||
1567 |
Sets the default graphics backend to \a system, which will be used for |
|
1568 |
on-screen widgets and QPixmaps. The available systems are \c{"native"}, |
|
1569 |
\c{"raster"} and \c{"opengl"}. |
|
1570 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1571 |
There are several ways to set the graphics backend, in order of decreasing |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1572 |
precedence: |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1573 |
\list |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1574 |
\o the application commandline \c{-graphicssystem} switch |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1575 |
\o QApplication::setGraphicsSystem() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1576 |
\o the QT_GRAPHICSSYSTEM environment variable |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1577 |
\o the Qt configure \c{-graphicssystem} switch |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1578 |
\endlist |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1579 |
If the highest precedence switch sets an invalid name, the error will be |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1580 |
ignored and the default backend will be used. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1581 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1582 |
\warning This function is only effective before the QApplication constructor |
0 | 1583 |
is called. |
1584 |
||
1585 |
\note The \c{"opengl"} option is currently experimental. |
|
1586 |
*/ |
|
1587 |
||
1588 |
void QApplication::setGraphicsSystem(const QString &system) |
|
1589 |
{ |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1590 |
#ifdef QT_GRAPHICSSYSTEM_RUNTIME |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1591 |
if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1592 |
QRuntimeGraphicsSystem *r = |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1593 |
static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1594 |
r->setGraphicsSystem(system); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1595 |
} else |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1596 |
#endif |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1597 |
QApplicationPrivate::graphics_system_name = system; |
0 | 1598 |
} |
1599 |
||
1600 |
/*! |
|
1601 |
Returns the color specification. |
|
1602 |
||
1603 |
\sa QApplication::setColorSpec() |
|
1604 |
*/ |
|
1605 |
||
1606 |
int QApplication::colorSpec() |
|
1607 |
{ |
|
1608 |
return QApplicationPrivate::app_cspec; |
|
1609 |
} |
|
1610 |
||
1611 |
/*! |
|
1612 |
Sets the color specification for the application to \a spec. |
|
1613 |
||
1614 |
The color specification controls how the application allocates colors when |
|
1615 |
run on a display with a limited amount of colors, e.g. 8 bit / 256 color |
|
1616 |
displays. |
|
1617 |
||
1618 |
The color specification must be set before you create the QApplication |
|
1619 |
object. |
|
1620 |
||
1621 |
The options are: |
|
1622 |
\list |
|
1623 |
\o QApplication::NormalColor. This is the default color allocation |
|
1624 |
strategy. Use this option if your application uses buttons, menus, |
|
1625 |
texts and pixmaps with few colors. With this option, the |
|
1626 |
application uses system global colors. This works fine for most |
|
1627 |
applications under X11, but on the Windows platform, it may cause |
|
1628 |
dithering of non-standard colors. |
|
1629 |
\o QApplication::CustomColor. Use this option if your application |
|
1630 |
needs a small number of custom colors. On X11, this option is the |
|
1631 |
same as NormalColor. On Windows, Qt creates a Windows palette, and |
|
1632 |
allocates colors to it on demand. |
|
1633 |
\o QApplication::ManyColor. Use this option if your application is |
|
1634 |
very color hungry, e.g., it requires thousands of colors. \br |
|
1635 |
Under X11 the effect is: |
|
1636 |
\list |
|
1637 |
\o For 256-color displays which have at best a 256 color true |
|
1638 |
color visual, the default visual is used, and colors are |
|
1639 |
allocated from a color cube. The color cube is the 6x6x6 |
|
1640 |
(216 color) "Web palette" (the red, green, and blue |
|
1641 |
components always have one of the following values: 0x00, |
|
1642 |
0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors |
|
1643 |
can be changed by the \e -ncols option. The user can force |
|
1644 |
the application to use the true color visual with the |
|
1645 |
\l{QApplication::QApplication()}{-visual} option. |
|
1646 |
\o For 256-color displays which have a true color visual with |
|
1647 |
more than 256 colors, use that visual. Silicon Graphics X |
|
1648 |
servers this feature, for example. They provide an 8 bit |
|
1649 |
visual by default but can deliver true color when asked. |
|
1650 |
\endlist |
|
1651 |
On Windows, Qt creates a Windows palette, and fills it with a color |
|
1652 |
cube. |
|
1653 |
\endlist |
|
1654 |
||
1655 |
Be aware that the CustomColor and ManyColor choices may lead to colormap |
|
1656 |
flashing: The foreground application gets (most) of the available colors, |
|
1657 |
while the background windows will look less attractive. |
|
1658 |
||
1659 |
Example: |
|
1660 |
||
1661 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2 |
|
1662 |
||
1663 |
\sa colorSpec() |
|
1664 |
*/ |
|
1665 |
||
1666 |
void QApplication::setColorSpec(int spec) |
|
1667 |
{ |
|
1668 |
if (qApp) |
|
1669 |
qWarning("QApplication::setColorSpec: This function must be " |
|
1670 |
"called before the QApplication object is created"); |
|
1671 |
QApplicationPrivate::app_cspec = spec; |
|
1672 |
} |
|
1673 |
||
1674 |
/*! |
|
1675 |
\property QApplication::globalStrut |
|
1676 |
\brief the minimum size that any GUI element that the user can interact |
|
1677 |
with should have |
|
1678 |
||
1679 |
For example, no button should be resized to be smaller than the global |
|
1680 |
strut size. The strut size should be considered when reimplementing GUI |
|
1681 |
controls that may be used on touch-screens or similar I/O devices. |
|
1682 |
||
1683 |
Example: |
|
1684 |
||
1685 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 3 |
|
1686 |
||
1687 |
By default, this property contains a QSize object with zero width and height. |
|
1688 |
*/ |
|
1689 |
QSize QApplication::globalStrut() |
|
1690 |
{ |
|
1691 |
return QApplicationPrivate::app_strut; |
|
1692 |
} |
|
1693 |
||
1694 |
void QApplication::setGlobalStrut(const QSize& strut) |
|
1695 |
{ |
|
1696 |
QApplicationPrivate::app_strut = strut; |
|
1697 |
} |
|
1698 |
||
1699 |
/*! |
|
1700 |
Returns the application palette. |
|
1701 |
||
1702 |
\sa setPalette(), QWidget::palette() |
|
1703 |
*/ |
|
1704 |
QPalette QApplication::palette() |
|
1705 |
{ |
|
1706 |
if (!QApplicationPrivate::app_pal) |
|
1707 |
QApplicationPrivate::app_pal = new QPalette(Qt::black); |
|
1708 |
return *QApplicationPrivate::app_pal; |
|
1709 |
} |
|
1710 |
||
1711 |
/*! |
|
1712 |
\fn QPalette QApplication::palette(const QWidget* widget) |
|
1713 |
\overload |
|
1714 |
||
1715 |
If a \a widget is passed, the default palette for the widget's class is |
|
1716 |
returned. This may or may not be the application palette. In most cases |
|
1717 |
there is no special palette for certain types of widgets, but one notable |
|
1718 |
exception is the popup menu under Windows, if the user has defined a |
|
1719 |
special background color for menus in the display settings. |
|
1720 |
||
1721 |
\sa setPalette(), QWidget::palette() |
|
1722 |
*/ |
|
1723 |
QPalette QApplication::palette(const QWidget* w) |
|
1724 |
{ |
|
1725 |
PaletteHash *hash = app_palettes(); |
|
1726 |
if (w && hash && hash->size()) { |
|
1727 |
QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className()); |
|
1728 |
if (it != hash->constEnd()) |
|
1729 |
return *it; |
|
1730 |
for (it = hash->constBegin(); it != hash->constEnd(); ++it) { |
|
1731 |
if (w->inherits(it.key())) |
|
1732 |
return it.value(); |
|
1733 |
} |
|
1734 |
} |
|
1735 |
return palette(); |
|
1736 |
} |
|
1737 |
||
1738 |
/*! |
|
1739 |
\overload |
|
1740 |
||
1741 |
Returns the palette for widgets of the given \a className. |
|
1742 |
||
1743 |
\sa setPalette(), QWidget::palette() |
|
1744 |
*/ |
|
1745 |
QPalette QApplication::palette(const char *className) |
|
1746 |
{ |
|
1747 |
if (!QApplicationPrivate::app_pal) |
|
1748 |
palette(); |
|
1749 |
PaletteHash *hash = app_palettes(); |
|
1750 |
if (className && hash && hash->size()) { |
|
1751 |
QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className); |
|
1752 |
if (it != hash->constEnd()) |
|
1753 |
return *it; |
|
1754 |
} |
|
1755 |
return *QApplicationPrivate::app_pal; |
|
1756 |
} |
|
1757 |
||
1758 |
void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash) |
|
1759 |
{ |
|
1760 |
QPalette pal = palette; |
|
1761 |
||
1762 |
if (QApplicationPrivate::app_style) |
|
1763 |
QApplicationPrivate::app_style->polish(pal); // NB: non-const reference |
|
1764 |
||
1765 |
bool all = false; |
|
1766 |
PaletteHash *hash = app_palettes(); |
|
1767 |
if (!className) { |
|
1768 |
if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal)) |
|
1769 |
return; |
|
1770 |
if (!QApplicationPrivate::app_pal) |
|
1771 |
QApplicationPrivate::app_pal = new QPalette(pal); |
|
1772 |
else |
|
1773 |
*QApplicationPrivate::app_pal = pal; |
|
1774 |
if (hash && hash->size()) { |
|
1775 |
all = true; |
|
1776 |
if (clearWidgetPaletteHash) |
|
1777 |
hash->clear(); |
|
1778 |
} |
|
1779 |
} else if (hash) { |
|
1780 |
hash->insert(className, pal); |
|
1781 |
} |
|
1782 |
||
1783 |
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { |
|
1784 |
// Send ApplicationPaletteChange to qApp itself, and to the widgets. |
|
1785 |
QEvent e(QEvent::ApplicationPaletteChange); |
|
1786 |
QApplication::sendEvent(QApplication::instance(), &e); |
|
1787 |
||
1788 |
QWidgetList wids = QApplication::allWidgets(); |
|
1789 |
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) { |
|
1790 |
register QWidget *w = *it; |
|
1791 |
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class |
|
1792 |
QApplication::sendEvent(w, &e); |
|
1793 |
} |
|
1794 |
||
1795 |
// Send to all scenes as well. |
|
1796 |
#ifndef QT_NO_GRAPHICSVIEW |
|
1797 |
QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list; |
|
1798 |
for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin(); |
|
1799 |
it != scenes.constEnd(); ++it) { |
|
1800 |
QApplication::sendEvent(*it, &e); |
|
1801 |
} |
|
1802 |
#endif //QT_NO_GRAPHICSVIEW |
|
1803 |
} |
|
1804 |
if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { |
|
1805 |
if (!QApplicationPrivate::set_pal) |
|
1806 |
QApplicationPrivate::set_pal = new QPalette(palette); |
|
1807 |
else |
|
1808 |
*QApplicationPrivate::set_pal = palette; |
|
1809 |
} |
|
1810 |
} |
|
1811 |
||
1812 |
/*! |
|
1813 |
Changes the default application palette to \a palette. |
|
1814 |
||
1815 |
If \a className is passed, the change applies only to widgets that inherit |
|
1816 |
\a className (as reported by QObject::inherits()). If \a className is left |
|
1817 |
0, the change affects all widgets, thus overriding any previously set class |
|
1818 |
specific palettes. |
|
1819 |
||
1820 |
The palette may be changed according to the current GUI style in |
|
1821 |
QStyle::polish(). |
|
1822 |
||
1823 |
\warning Do not use this function in conjunction with \l{Qt Style Sheets}. |
|
1824 |
When using style sheets, the palette of a widget can be customized using |
|
1825 |
the "color", "background-color", "selection-color", |
|
1826 |
"selection-background-color" and "alternate-background-color". |
|
1827 |
||
1828 |
\note Some styles do not use the palette for all drawing, for instance, if |
|
1829 |
they make use of native theme engines. This is the case for the Windows XP, |
|
1830 |
Windows Vista, and Mac OS X styles. |
|
1831 |
||
1832 |
\sa QWidget::setPalette(), palette(), QStyle::polish() |
|
1833 |
*/ |
|
1834 |
||
1835 |
void QApplication::setPalette(const QPalette &palette, const char* className) |
|
1836 |
{ |
|
1837 |
QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true); |
|
1838 |
} |
|
1839 |
||
1840 |
||
1841 |
||
1842 |
void QApplicationPrivate::setSystemPalette(const QPalette &pal) |
|
1843 |
{ |
|
1844 |
QPalette adjusted; |
|
1845 |
||
1846 |
#if 0 |
|
1847 |
// adjust the system palette to avoid dithering |
|
1848 |
QColormap cmap = QColormap::instance(); |
|
1849 |
if (cmap.depths() > 4 && cmap.depths() < 24) { |
|
1850 |
for (int g = 0; g < QPalette::NColorGroups; g++) |
|
1851 |
for (int i = 0; i < QPalette::NColorRoles; i++) { |
|
1852 |
QColor color = pal.color((QPalette::ColorGroup)g, (QPalette::ColorRole)i); |
|
1853 |
color = cmap.colorAt(cmap.pixel(color)); |
|
1854 |
adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color); |
|
1855 |
} |
|
1856 |
} |
|
1857 |
#else |
|
1858 |
adjusted = pal; |
|
1859 |
#endif |
|
1860 |
||
1861 |
if (!sys_pal) |
|
1862 |
sys_pal = new QPalette(adjusted); |
|
1863 |
else |
|
1864 |
*sys_pal = adjusted; |
|
1865 |
||
1866 |
||
1867 |
if (!QApplicationPrivate::set_pal) |
|
1868 |
QApplication::setPalette(*sys_pal); |
|
1869 |
} |
|
1870 |
||
1871 |
/*! |
|
1872 |
Returns the default application font. |
|
1873 |
||
1874 |
\sa fontMetrics(), QWidget::font() |
|
1875 |
*/ |
|
1876 |
QFont QApplication::font() |
|
1877 |
{ |
|
1878 |
QMutexLocker locker(applicationFontMutex()); |
|
1879 |
if (!QApplicationPrivate::app_font) |
|
1880 |
QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica")); |
|
1881 |
return *QApplicationPrivate::app_font; |
|
1882 |
} |
|
1883 |
||
1884 |
/*! |
|
1885 |
\overload |
|
1886 |
||
1887 |
Returns the default font for the \a widget. |
|
1888 |
||
1889 |
\sa fontMetrics(), QWidget::setFont() |
|
1890 |
*/ |
|
1891 |
||
1892 |
QFont QApplication::font(const QWidget *widget) |
|
1893 |
{ |
|
1894 |
FontHash *hash = app_fonts(); |
|
1895 |
||
1896 |
#ifdef Q_WS_MAC |
|
1897 |
// short circuit for small and mini controls |
|
1898 |
if (widget->testAttribute(Qt::WA_MacSmallSize)) { |
|
1899 |
return hash->value("QSmallFont"); |
|
1900 |
} else if (widget->testAttribute(Qt::WA_MacMiniSize)) { |
|
1901 |
return hash->value("QMiniFont"); |
|
1902 |
} |
|
1903 |
#endif |
|
1904 |
if (widget && hash && hash->size()) { |
|
1905 |
QHash<QByteArray, QFont>::ConstIterator it = |
|
1906 |
hash->constFind(widget->metaObject()->className()); |
|
1907 |
if (it != hash->constEnd()) |
|
1908 |
return it.value(); |
|
1909 |
for (it = hash->constBegin(); it != hash->constEnd(); ++it) { |
|
1910 |
if (widget->inherits(it.key())) |
|
1911 |
return it.value(); |
|
1912 |
} |
|
1913 |
} |
|
1914 |
return font(); |
|
1915 |
} |
|
1916 |
||
1917 |
/*! |
|
1918 |
\overload |
|
1919 |
||
1920 |
Returns the font for widgets of the given \a className. |
|
1921 |
||
1922 |
\sa setFont(), QWidget::font() |
|
1923 |
*/ |
|
1924 |
QFont QApplication::font(const char *className) |
|
1925 |
{ |
|
1926 |
FontHash *hash = app_fonts(); |
|
1927 |
if (className && hash && hash->size()) { |
|
1928 |
QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(className); |
|
1929 |
if (it != hash->constEnd()) |
|
1930 |
return *it; |
|
1931 |
} |
|
1932 |
return font(); |
|
1933 |
} |
|
1934 |
||
1935 |
||
1936 |
/*! |
|
1937 |
Changes the default application font to \a font. If \a className is passed, |
|
1938 |
the change applies only to classes that inherit \a className (as reported |
|
1939 |
by QObject::inherits()). |
|
1940 |
||
1941 |
On application start-up, the default font depends on the window system. It |
|
1942 |
can vary depending on both the window system version and the locale. This |
|
1943 |
function lets you override the default font; but overriding may be a bad |
|
1944 |
idea because, for example, some locales need extra large fonts to support |
|
1945 |
their special characters. |
|
1946 |
||
1947 |
\warning Do not use this function in conjunction with \l{Qt Style Sheets}. |
|
1948 |
The font of an application can be customized using the "font" style sheet |
|
1949 |
property. To set a bold font for all QPushButtons, set the application |
|
1950 |
styleSheet() as "QPushButton { font: bold }" |
|
1951 |
||
1952 |
\sa font(), fontMetrics(), QWidget::setFont() |
|
1953 |
*/ |
|
1954 |
||
1955 |
void QApplication::setFont(const QFont &font, const char *className) |
|
1956 |
{ |
|
1957 |
bool all = false; |
|
1958 |
FontHash *hash = app_fonts(); |
|
1959 |
if (!className) { |
|
1960 |
QMutexLocker locker(applicationFontMutex()); |
|
1961 |
if (!QApplicationPrivate::app_font) |
|
1962 |
QApplicationPrivate::app_font = new QFont(font); |
|
1963 |
else |
|
1964 |
*QApplicationPrivate::app_font = font; |
|
1965 |
if (hash && hash->size()) { |
|
1966 |
all = true; |
|
1967 |
hash->clear(); |
|
1968 |
} |
|
1969 |
} else if (hash) { |
|
1970 |
hash->insert(className, font); |
|
1971 |
} |
|
1972 |
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { |
|
1973 |
// Send ApplicationFontChange to qApp itself, and to the widgets. |
|
1974 |
QEvent e(QEvent::ApplicationFontChange); |
|
1975 |
QApplication::sendEvent(QApplication::instance(), &e); |
|
1976 |
||
1977 |
QWidgetList wids = QApplication::allWidgets(); |
|
1978 |
for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) { |
|
1979 |
register QWidget *w = *it; |
|
1980 |
if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class |
|
1981 |
sendEvent(w, &e); |
|
1982 |
} |
|
1983 |
||
1984 |
#ifndef QT_NO_GRAPHICSVIEW |
|
1985 |
// Send to all scenes as well. |
|
1986 |
QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list; |
|
1987 |
for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin(); |
|
1988 |
it != scenes.constEnd(); ++it) { |
|
1989 |
QApplication::sendEvent(*it, &e); |
|
1990 |
} |
|
1991 |
#endif //QT_NO_GRAPHICSVIEW |
|
1992 |
} |
|
1993 |
if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) { |
|
1994 |
if (!QApplicationPrivate::set_font) |
|
1995 |
QApplicationPrivate::set_font = new QFont(font); |
|
1996 |
else |
|
1997 |
*QApplicationPrivate::set_font = font; |
|
1998 |
} |
|
1999 |
} |
|
2000 |
||
2001 |
/*! \internal |
|
2002 |
*/ |
|
2003 |
void QApplicationPrivate::setSystemFont(const QFont &font) |
|
2004 |
{ |
|
2005 |
if (!sys_font) |
|
2006 |
sys_font = new QFont(font); |
|
2007 |
else |
|
2008 |
*sys_font = font; |
|
2009 |
||
2010 |
if (!QApplicationPrivate::set_font) |
|
2011 |
QApplication::setFont(*sys_font); |
|
2012 |
} |
|
2013 |
||
2014 |
/*! \internal |
|
2015 |
*/ |
|
2016 |
QString QApplicationPrivate::desktopStyleKey() |
|
2017 |
{ |
|
2018 |
return qt_guiPlatformPlugin()->styleName(); |
|
2019 |
} |
|
2020 |
||
2021 |
/*! |
|
2022 |
\property QApplication::windowIcon |
|
2023 |
\brief the default window icon |
|
2024 |
||
2025 |
\sa QWidget::setWindowIcon(), {Setting the Application Icon} |
|
2026 |
*/ |
|
2027 |
QIcon QApplication::windowIcon() |
|
2028 |
{ |
|
2029 |
return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon(); |
|
2030 |
} |
|
2031 |
||
2032 |
void QApplication::setWindowIcon(const QIcon &icon) |
|
2033 |
{ |
|
2034 |
if (!QApplicationPrivate::app_icon) |
|
2035 |
QApplicationPrivate::app_icon = new QIcon(); |
|
2036 |
*QApplicationPrivate::app_icon = icon; |
|
2037 |
if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { |
|
2038 |
#ifdef Q_WS_MAC |
|
2039 |
void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp |
|
2040 |
QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128)); |
|
2041 |
qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size)); |
|
2042 |
#endif |
|
2043 |
QEvent e(QEvent::ApplicationWindowIconChange); |
|
2044 |
QWidgetList all = QApplication::allWidgets(); |
|
2045 |
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { |
|
2046 |
register QWidget *w = *it; |
|
2047 |
if (w->isWindow()) |
|
2048 |
sendEvent(w, &e); |
|
2049 |
} |
|
2050 |
} |
|
2051 |
} |
|
2052 |
||
2053 |
/*! |
|
2054 |
Returns a list of the top-level widgets (windows) in the application. |
|
2055 |
||
2056 |
\note Some of the top-level widgets may be hidden, for example a tooltip if |
|
2057 |
no tooltip is currently shown. |
|
2058 |
||
2059 |
Example: |
|
2060 |
||
2061 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 4 |
|
2062 |
||
2063 |
\sa allWidgets(), QWidget::isWindow(), QWidget::isHidden() |
|
2064 |
*/ |
|
2065 |
QWidgetList QApplication::topLevelWidgets() |
|
2066 |
{ |
|
2067 |
QWidgetList list; |
|
2068 |
QWidgetList all = allWidgets(); |
|
2069 |
||
2070 |
for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { |
|
2071 |
QWidget *w = *it; |
|
2072 |
if (w->isWindow() && w->windowType() != Qt::Desktop) |
|
2073 |
list.append(w); |
|
2074 |
} |
|
2075 |
return list; |
|
2076 |
} |
|
2077 |
||
2078 |
/*! |
|
2079 |
Returns a list of all the widgets in the application. |
|
2080 |
||
2081 |
The list is empty (QList::isEmpty()) if there are no widgets. |
|
2082 |
||
2083 |
\note Some of the widgets may be hidden. |
|
2084 |
||
2085 |
Example: |
|
2086 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5 |
|
2087 |
||
2088 |
\sa topLevelWidgets(), QWidget::isVisible() |
|
2089 |
*/ |
|
2090 |
||
2091 |
QWidgetList QApplication::allWidgets() |
|
2092 |
{ |
|
2093 |
if (QWidgetPrivate::allWidgets) |
|
2094 |
return QWidgetPrivate::allWidgets->toList(); |
|
2095 |
return QWidgetList(); |
|
2096 |
} |
|
2097 |
||
2098 |
/*! |
|
2099 |
Returns the application widget that has the keyboard input focus, or 0 if |
|
2100 |
no widget in this application has the focus. |
|
2101 |
||
2102 |
\sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged() |
|
2103 |
*/ |
|
2104 |
||
2105 |
QWidget *QApplication::focusWidget() |
|
2106 |
{ |
|
2107 |
return QApplicationPrivate::focus_widget; |
|
2108 |
} |
|
2109 |
||
2110 |
void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) |
|
2111 |
{ |
|
2112 |
#ifndef QT_NO_GRAPHICSVIEW |
|
2113 |
if (focus && focus->window()->graphicsProxyWidget()) |
|
2114 |
return; |
|
2115 |
#endif |
|
2116 |
||
2117 |
hidden_focus_widget = 0; |
|
2118 |
||
2119 |
if (focus != focus_widget) { |
|
2120 |
if (focus && focus->isHidden()) { |
|
2121 |
hidden_focus_widget = focus; |
|
2122 |
return; |
|
2123 |
} |
|
2124 |
||
2125 |
if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason) |
|
2126 |
&& qt_in_tab_key_event) |
|
2127 |
focus->window()->setAttribute(Qt::WA_KeyboardFocusChange); |
|
2128 |
else if (focus && reason == Qt::ShortcutFocusReason) { |
|
2129 |
focus->window()->setAttribute(Qt::WA_KeyboardFocusChange); |
|
2130 |
} |
|
2131 |
QWidget *prev = focus_widget; |
|
2132 |
focus_widget = focus; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2133 |
#ifndef QT_NO_IM |
0 | 2134 |
if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason |
2135 |
&& prev->testAttribute(Qt::WA_InputMethodEnabled)) |
|
2136 |
// Do reset the input context, in case the new focus widget won't accept keyboard input |
|
2137 |
// or it is not created fully yet. |
|
2138 |
|| (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled) |
|
2139 |
|| !focus_widget->testAttribute(Qt::WA_WState_Created))))) { |
|
2140 |
QInputContext *qic = prev->inputContext(); |
|
2141 |
if(qic) { |
|
2142 |
qic->reset(); |
|
2143 |
qic->setFocusWidget(0); |
|
2144 |
} |
|
2145 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2146 |
#endif //QT_NO_IM |
0 | 2147 |
|
2148 |
if(focus_widget) |
|
2149 |
focus_widget->d_func()->setFocus_sys(); |
|
2150 |
||
2151 |
if (reason != Qt::NoFocusReason) { |
|
2152 |
||
2153 |
//send events |
|
2154 |
if (prev) { |
|
2155 |
#ifdef QT_KEYPAD_NAVIGATION |
|
2156 |
if (QApplication::keypadNavigationEnabled()) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2157 |
if (prev->hasEditFocus() && reason != Qt::PopupFocusReason |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2158 |
#ifdef Q_OS_SYMBIAN |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2159 |
&& reason != Qt::ActiveWindowFocusReason |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2160 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2161 |
) |
0 | 2162 |
prev->setEditFocus(false); |
2163 |
} |
|
2164 |
#endif |
|
2165 |
#ifndef QT_NO_IM |
|
2166 |
if (focus) { |
|
2167 |
QInputContext *prevIc; |
|
2168 |
prevIc = prev->inputContext(); |
|
2169 |
if (prevIc && prevIc != focus->inputContext()) { |
|
2170 |
QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel); |
|
2171 |
QApplication::sendEvent(prev, &closeSIPEvent); |
|
2172 |
} |
|
2173 |
} |
|
2174 |
#endif |
|
2175 |
QFocusEvent out(QEvent::FocusOut, reason); |
|
2176 |
QPointer<QWidget> that = prev; |
|
2177 |
QApplication::sendEvent(prev, &out); |
|
2178 |
if (that) |
|
2179 |
QApplication::sendEvent(that->style(), &out); |
|
2180 |
} |
|
2181 |
if(focus && QApplicationPrivate::focus_widget == focus) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2182 |
#ifndef QT_NO_IM |
0 | 2183 |
if (focus->testAttribute(Qt::WA_InputMethodEnabled)) { |
2184 |
QInputContext *qic = focus->inputContext(); |
|
2185 |
if (qic && focus->testAttribute(Qt::WA_WState_Created) |
|
2186 |
&& focus->isEnabled()) |
|
2187 |
qic->setFocusWidget(focus); |
|
2188 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2189 |
#endif //QT_NO_IM |
0 | 2190 |
QFocusEvent in(QEvent::FocusIn, reason); |
2191 |
QPointer<QWidget> that = focus; |
|
2192 |
QApplication::sendEvent(focus, &in); |
|
2193 |
if (that) |
|
2194 |
QApplication::sendEvent(that->style(), &in); |
|
2195 |
} |
|
2196 |
emit qApp->focusChanged(prev, focus_widget); |
|
2197 |
} |
|
2198 |
} |
|
2199 |
} |
|
2200 |
||
2201 |
||
2202 |
/*! |
|
2203 |
Returns the application top-level window that has the keyboard input focus, |
|
2204 |
or 0 if no application window has the focus. There might be an |
|
2205 |
activeWindow() even if there is no focusWidget(), for example if no widget |
|
2206 |
in that window accepts key events. |
|
2207 |
||
2208 |
\sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget() |
|
2209 |
*/ |
|
2210 |
||
2211 |
QWidget *QApplication::activeWindow() |
|
2212 |
{ |
|
2213 |
return QApplicationPrivate::active_window; |
|
2214 |
} |
|
2215 |
||
2216 |
/*! |
|
2217 |
Returns display (screen) font metrics for the application font. |
|
2218 |
||
2219 |
\sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics() |
|
2220 |
*/ |
|
2221 |
||
2222 |
QFontMetrics QApplication::fontMetrics() |
|
2223 |
{ |
|
2224 |
return desktop()->fontMetrics(); |
|
2225 |
} |
|
2226 |
||
2227 |
||
2228 |
/*! |
|
2229 |
Closes all top-level windows. |
|
2230 |
||
2231 |
This function is particularly useful for applications with many top-level |
|
2232 |
windows. It could, for example, be connected to a \gui{Exit} entry in the |
|
2233 |
\gui{File} menu: |
|
2234 |
||
2235 |
\snippet examples/mainwindows/mdi/mainwindow.cpp 0 |
|
2236 |
||
2237 |
The windows are closed in random order, until one window does not accept |
|
2238 |
the close event. The application quits when the last window was |
|
2239 |
successfully closed; this can be turned off by setting |
|
2240 |
\l quitOnLastWindowClosed to false. |
|
2241 |
||
2242 |
\sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(), |
|
2243 |
QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(), |
|
2244 |
QWidget::isWindow() |
|
2245 |
*/ |
|
2246 |
void QApplication::closeAllWindows() |
|
2247 |
{ |
|
2248 |
bool did_close = true; |
|
2249 |
QWidget *w; |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2250 |
while ((w = activeModalWidget()) && did_close) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2251 |
if (!w->isVisible() || w->data->is_closing) |
0 | 2252 |
break; |
2253 |
did_close = w->close(); |
|
2254 |
} |
|
2255 |
QWidgetList list = QApplication::topLevelWidgets(); |
|
2256 |
for (int i = 0; did_close && i < list.size(); ++i) { |
|
2257 |
w = list.at(i); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2258 |
if (w->isVisible() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2259 |
&& w->windowType() != Qt::Desktop |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2260 |
&& !w->data->is_closing) { |
0 | 2261 |
did_close = w->close(); |
2262 |
list = QApplication::topLevelWidgets(); |
|
2263 |
i = -1; |
|
2264 |
} |
|
2265 |
} |
|
2266 |
} |
|
2267 |
||
2268 |
/*! |
|
2269 |
Displays a simple message box about Qt. The message includes the version |
|
2270 |
number of Qt being used by the application. |
|
2271 |
||
2272 |
This is useful for inclusion in the \gui Help menu of an application, as |
|
2273 |
shown in the \l{mainwindows/menus}{Menus} example. |
|
2274 |
||
2275 |
This function is a convenience slot for QMessageBox::aboutQt(). |
|
2276 |
*/ |
|
2277 |
void QApplication::aboutQt() |
|
2278 |
{ |
|
2279 |
#ifndef QT_NO_MESSAGEBOX |
|
2280 |
QMessageBox::aboutQt( |
|
2281 |
#ifdef Q_WS_MAC |
|
2282 |
0 |
|
2283 |
#else |
|
2284 |
activeWindow() |
|
2285 |
#endif // Q_WS_MAC |
|
2286 |
); |
|
2287 |
#endif // QT_NO_MESSAGEBOX |
|
2288 |
} |
|
2289 |
||
2290 |
||
2291 |
/*! |
|
2292 |
\fn void QApplication::lastWindowClosed() |
|
2293 |
||
2294 |
This signal is emitted from QApplication::exec() when the last visible |
|
2295 |
primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose |
|
2296 |
attribute set is closed. |
|
2297 |
||
2298 |
By default, |
|
2299 |
||
2300 |
\list |
|
2301 |
\o this attribute is set for all widgets except transient windows such |
|
2302 |
as splash screens, tool windows, and popup menus |
|
2303 |
||
2304 |
\o QApplication implicitly quits when this signal is emitted. |
|
2305 |
\endlist |
|
2306 |
||
2307 |
This feature can be turned off by setting \l quitOnLastWindowClosed to |
|
2308 |
false. |
|
2309 |
||
2310 |
\sa QWidget::close() |
|
2311 |
*/ |
|
2312 |
||
2313 |
/*! |
|
2314 |
\since 4.1 |
|
2315 |
\fn void QApplication::focusChanged(QWidget *old, QWidget *now) |
|
2316 |
||
2317 |
This signal is emitted when the widget that has keyboard focus changed from |
|
2318 |
\a old to \a now, i.e., because the user pressed the tab-key, clicked into |
|
2319 |
a widget or changed the active window. Both \a old and \a now can be the |
|
2320 |
null-pointer. |
|
2321 |
||
2322 |
The signal is emitted after both widget have been notified about the change |
|
2323 |
through QFocusEvent. |
|
2324 |
||
2325 |
\sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason |
|
2326 |
*/ |
|
2327 |
||
2328 |
/*! |
|
2329 |
\since 4.5 |
|
2330 |
\fn void QApplication::fontDatabaseChanged() |
|
2331 |
||
2332 |
This signal is emitted when application fonts are loaded or removed. |
|
2333 |
||
2334 |
\sa QFontDatabase::addApplicationFont(), |
|
2335 |
QFontDatabase::addApplicationFontFromData(), |
|
2336 |
QFontDatabase::removeAllApplicationFonts(), |
|
2337 |
QFontDatabase::removeApplicationFont() |
|
2338 |
*/ |
|
2339 |
||
2340 |
#ifndef QT_NO_TRANSLATION |
|
2341 |
static bool qt_detectRTLLanguage() |
|
2342 |
{ |
|
2343 |
return force_reverse ^ |
|
2344 |
(QApplication::tr("QT_LAYOUT_DIRECTION", |
|
2345 |
"Translate this string to the string 'LTR' in left-to-right" |
|
2346 |
" languages or to 'RTL' in right-to-left languages (such as Hebrew" |
|
2347 |
" and Arabic) to get proper widget layout.") == QLatin1String("RTL")); |
|
2348 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2349 |
#if defined(Q_WS_MAC) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2350 |
static const char *application_menu_strings[] = { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2351 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2352 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2353 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2354 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2355 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2356 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2357 |
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1") |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2358 |
}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2359 |
QString qt_mac_applicationmenu_string(int type) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2360 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2361 |
return qApp->translate("MAC_APPLICATION_MENU", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2362 |
application_menu_strings[type]); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2363 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2364 |
#endif |
0 | 2365 |
#endif |
2366 |
||
2367 |
/*!\reimp |
|
2368 |
||
2369 |
*/ |
|
2370 |
bool QApplication::event(QEvent *e) |
|
2371 |
{ |
|
2372 |
Q_D(QApplication); |
|
2373 |
if(e->type() == QEvent::Close) { |
|
2374 |
QCloseEvent *ce = static_cast<QCloseEvent*>(e); |
|
2375 |
ce->accept(); |
|
2376 |
closeAllWindows(); |
|
2377 |
||
2378 |
QWidgetList list = topLevelWidgets(); |
|
2379 |
for (int i = 0; i < list.size(); ++i) { |
|
2380 |
QWidget *w = list.at(i); |
|
2381 |
if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) && |
|
2382 |
(!(w->windowType() == Qt::Dialog) || !w->parentWidget())) { |
|
2383 |
ce->ignore(); |
|
2384 |
break; |
|
2385 |
} |
|
2386 |
} |
|
2387 |
if(ce->isAccepted()) |
|
2388 |
return true; |
|
2389 |
} else if(e->type() == QEvent::LanguageChange) { |
|
2390 |
#ifndef QT_NO_TRANSLATION |
|
2391 |
setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); |
|
2392 |
#endif |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2393 |
#if defined(QT_MAC_USE_COCOA) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2394 |
qt_mac_post_retranslateAppMenu(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2395 |
#endif |
0 | 2396 |
QWidgetList list = topLevelWidgets(); |
2397 |
for (int i = 0; i < list.size(); ++i) { |
|
2398 |
QWidget *w = list.at(i); |
|
2399 |
if (!(w->windowType() == Qt::Desktop)) |
|
2400 |
postEvent(w, new QEvent(QEvent::LanguageChange)); |
|
2401 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2402 |
#ifndef Q_OS_WIN |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2403 |
} else if (e->type() == QEvent::LocaleChange) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2404 |
// on Windows the event propagation is taken care by the |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2405 |
// WM_SETTINGCHANGE event handler. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2406 |
QWidgetList list = topLevelWidgets(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2407 |
for (int i = 0; i < list.size(); ++i) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2408 |
QWidget *w = list.at(i); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2409 |
if (!(w->windowType() == Qt::Desktop)) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2410 |
if (!w->testAttribute(Qt::WA_SetLocale)) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2411 |
w->d_func()->setLocale_helper(QLocale(), true); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2412 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2413 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
2414 |
#endif |
0 | 2415 |
} else if (e->type() == QEvent::Timer) { |
2416 |
QTimerEvent *te = static_cast<QTimerEvent*>(e); |
|
2417 |
Q_ASSERT(te != 0); |
|
2418 |
if (te->timerId() == d->toolTipWakeUp.timerId()) { |
|
2419 |
d->toolTipWakeUp.stop(); |
|
2420 |
if (d->toolTipWidget) { |
|
2421 |
QWidget *w = d->toolTipWidget->window(); |
|
2422 |
// show tooltip if WA_AlwaysShowToolTips is set, or if |
|
2423 |
// any ancestor of d->toolTipWidget is the active |
|
2424 |
// window |
|
2425 |
bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips); |
|
2426 |
while (w && !showToolTip) { |
|
2427 |
showToolTip = w->isActiveWindow(); |
|
2428 |
w = w->parentWidget(); |
|
2429 |
w = w ? w->window() : 0; |
|
2430 |
} |
|
2431 |
if (showToolTip) { |
|
2432 |
QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos); |
|
2433 |
QApplication::sendEvent(d->toolTipWidget, &e); |
|
2434 |
if (e.isAccepted()) |
|
2435 |
d->toolTipFallAsleep.start(2000, this); |
|
2436 |
} |
|
2437 |
} |
|
2438 |
} else if (te->timerId() == d->toolTipFallAsleep.timerId()) { |
|
2439 |
d->toolTipFallAsleep.stop(); |
|
2440 |
} |
|
2441 |
} |
|
2442 |
return QCoreApplication::event(e); |
|
2443 |
} |
|
2444 |
#if !defined(Q_WS_X11) |
|
2445 |
||
2446 |
// The doc and X implementation of this function is in qapplication_x11.cpp |
|
2447 |
||
2448 |
void QApplication::syncX() {} // do nothing |
|
2449 |
||
2450 |
#endif |
|
2451 |
||
2452 |
/*! |
|
2453 |
\fn Qt::WindowsVersion QApplication::winVersion() |
|
2454 |
||
2455 |
Use \l QSysInfo::WindowsVersion instead. |
|
2456 |
*/ |
|
2457 |
||
2458 |
/*! |
|
2459 |
\fn void QApplication::setActiveWindow(QWidget* active) |
|
2460 |
||
2461 |
Sets the active window to the \a active widget in response to a system |
|
2462 |
event. The function is called from the platform specific event handlers. |
|
2463 |
||
2464 |
\warning This function does \e not set the keyboard focus to the active |
|
2465 |
widget. Call QWidget::activateWindow() instead. |
|
2466 |
||
2467 |
It sets the activeWindow() and focusWidget() attributes and sends proper |
|
2468 |
\l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate} |
|
2469 |
{WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut} |
|
2470 |
{FocusOut} events to all appropriate widgets. The window will then be |
|
2471 |
painted in active state (e.g. cursors in line edits will blink), and it |
|
2472 |
will have tool tips enabled. |
|
2473 |
||
2474 |
\sa activeWindow(), QWidget::activateWindow() |
|
2475 |
*/ |
|
2476 |
void QApplication::setActiveWindow(QWidget* act) |
|
2477 |
{ |
|
2478 |
QWidget* window = act?act->window():0; |
|
2479 |
||
2480 |
if (QApplicationPrivate::active_window == window) |
|
2481 |
return; |
|
2482 |
||
2483 |
#ifndef QT_NO_GRAPHICSVIEW |
|
2484 |
if (window && window->graphicsProxyWidget()) { |
|
2485 |
// Activate the proxy's view->viewport() ? |
|
2486 |
return; |
|
2487 |
} |
|
2488 |
#endif |
|
2489 |
||
2490 |
QWidgetList toBeActivated; |
|
2491 |
QWidgetList toBeDeactivated; |
|
2492 |
||
2493 |
if (QApplicationPrivate::active_window) { |
|
2494 |
if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { |
|
2495 |
QWidgetList list = topLevelWidgets(); |
|
2496 |
for (int i = 0; i < list.size(); ++i) { |
|
2497 |
QWidget *w = list.at(i); |
|
2498 |
if (w->isVisible() && w->isActiveWindow()) |
|
2499 |
toBeDeactivated.append(w); |
|
2500 |
} |
|
2501 |
} else { |
|
2502 |
toBeDeactivated.append(QApplicationPrivate::active_window); |
|
2503 |
} |
|
2504 |
} |
|
2505 |
||
2506 |
#if !defined(Q_WS_MAC) |
|
2507 |
QWidget *previousActiveWindow = QApplicationPrivate::active_window; |
|
2508 |
#endif |
|
2509 |
QApplicationPrivate::active_window = window; |
|
2510 |
||
2511 |
if (QApplicationPrivate::active_window) { |
|
2512 |
if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { |
|
2513 |
QWidgetList list = topLevelWidgets(); |
|
2514 |
for (int i = 0; i < list.size(); ++i) { |
|
2515 |
QWidget *w = list.at(i); |
|
2516 |
if (w->isVisible() && w->isActiveWindow()) |
|
2517 |
toBeActivated.append(w); |
|
2518 |
} |
|
2519 |
} else { |
|
2520 |
toBeActivated.append(QApplicationPrivate::active_window); |
|
2521 |
} |
|
2522 |
||
2523 |
} |
|
2524 |
||
2525 |
// first the activation/deactivation events |
|
2526 |
QEvent activationChange(QEvent::ActivationChange); |
|
2527 |
QEvent windowActivate(QEvent::WindowActivate); |
|
2528 |
QEvent windowDeactivate(QEvent::WindowDeactivate); |
|
2529 |
||
2530 |
#if !defined(Q_WS_MAC) |
|
2531 |
if (!previousActiveWindow) { |
|
2532 |
QEvent appActivate(QEvent::ApplicationActivate); |
|
2533 |
sendSpontaneousEvent(qApp, &appActivate); |
|
2534 |
} |
|
2535 |
#endif |
|
2536 |
||
2537 |
for (int i = 0; i < toBeActivated.size(); ++i) { |
|
2538 |
QWidget *w = toBeActivated.at(i); |
|
2539 |
sendSpontaneousEvent(w, &windowActivate); |
|
2540 |
sendSpontaneousEvent(w, &activationChange); |
|
2541 |
} |
|
2542 |
||
2543 |
for(int i = 0; i < toBeDeactivated.size(); ++i) { |
|
2544 |
QWidget *w = toBeDeactivated.at(i); |
|
2545 |
sendSpontaneousEvent(w, &windowDeactivate); |
|
2546 |
sendSpontaneousEvent(w, &activationChange); |
|
2547 |
} |
|
2548 |
||
2549 |
#if !defined(Q_WS_MAC) |
|
2550 |
if (!QApplicationPrivate::active_window) { |
|
2551 |
QEvent appDeactivate(QEvent::ApplicationDeactivate); |
|
2552 |
sendSpontaneousEvent(qApp, &appDeactivate); |
|
2553 |
} |
|
2554 |
#endif |
|
2555 |
||
2556 |
if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode() |
|
2557 |
// then focus events |
|
2558 |
if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) { |
|
2559 |
QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); |
|
2560 |
} else if (QApplicationPrivate::active_window) { |
|
2561 |
QWidget *w = QApplicationPrivate::active_window->focusWidget(); |
|
2562 |
if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/) |
|
2563 |
w->setFocus(Qt::ActiveWindowFocusReason); |
|
2564 |
else { |
|
2565 |
w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true); |
|
2566 |
if (w) { |
|
2567 |
w->setFocus(Qt::ActiveWindowFocusReason); |
|
2568 |
} else { |
|
2569 |
// If the focus widget is not in the activate_window, clear the focus |
|
2570 |
w = QApplicationPrivate::focus_widget; |
|
2571 |
if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus) |
|
2572 |
QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason); |
|
2573 |
else if (!QApplicationPrivate::active_window->isAncestorOf(w)) |
|
2574 |
QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); |
|
2575 |
} |
|
2576 |
} |
|
2577 |
} |
|
2578 |
} |
|
2579 |
} |
|
2580 |
||
2581 |
/*!internal |
|
2582 |
* Helper function that returns the new focus widget, but does not set the focus reason. |
|
2583 |
* Returns 0 if a new focus widget could not be found. |
|
2584 |
* Shared with QGraphicsProxyWidgetPrivate::findFocusChild() |
|
2585 |
*/ |
|
2586 |
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next) |
|
2587 |
{ |
|
2588 |
uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus; |
|
2589 |
||
2590 |
QWidget *f = toplevel->focusWidget(); |
|
2591 |
if (!f) |
|
2592 |
f = toplevel; |
|
2593 |
||
2594 |
QWidget *w = f; |
|
2595 |
QWidget *test = f->d_func()->focus_next; |
|
2596 |
while (test && test != f) { |
|
2597 |
if ((test->focusPolicy() & focus_flag) == focus_flag |
|
2598 |
&& !(test->d_func()->extra && test->d_func()->extra->focus_proxy) |
|
2599 |
&& test->isVisibleTo(toplevel) && test->isEnabled() |
|
2600 |
&& !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test)) |
|
2601 |
&& (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) { |
|
2602 |
w = test; |
|
2603 |
if (next) |
|
2604 |
break; |
|
2605 |
} |
|
2606 |
test = test->d_func()->focus_next; |
|
2607 |
} |
|
2608 |
if (w == f) { |
|
2609 |
if (qt_in_tab_key_event) { |
|
2610 |
w->window()->setAttribute(Qt::WA_KeyboardFocusChange); |
|
2611 |
w->update(); |
|
2612 |
} |
|
2613 |
return 0; |
|
2614 |
} |
|
2615 |
return w; |
|
2616 |
} |
|
2617 |
||
2618 |
/*! |
|
2619 |
\fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) |
|
2620 |
\internal |
|
2621 |
||
2622 |
Creates the proper Enter/Leave event when widget \a enter is entered and |
|
2623 |
widget \a leave is left. |
|
2624 |
*/ |
|
2625 |
void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { |
|
2626 |
#if 0 |
|
2627 |
if (leave) { |
|
2628 |
QEvent e(QEvent::Leave); |
|
2629 |
QApplication::sendEvent(leave, & e); |
|
2630 |
} |
|
2631 |
if (enter) { |
|
2632 |
QEvent e(QEvent::Enter); |
|
2633 |
QApplication::sendEvent(enter, & e); |
|
2634 |
} |
|
2635 |
return; |
|
2636 |
#endif |
|
2637 |
||
2638 |
QWidget* w ; |
|
2639 |
if ((!enter && !leave) || (enter == leave)) |
|
2640 |
return; |
|
2641 |
#ifdef ALIEN_DEBUG |
|
2642 |
qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave; |
|
2643 |
#endif |
|
2644 |
QWidgetList leaveList; |
|
2645 |
QWidgetList enterList; |
|
2646 |
||
2647 |
bool sameWindow = leave && enter && leave->window() == enter->window(); |
|
2648 |
if (leave && !sameWindow) { |
|
2649 |
w = leave; |
|
2650 |
do { |
|
2651 |
leaveList.append(w); |
|
2652 |
} while (!w->isWindow() && (w = w->parentWidget())); |
|
2653 |
} |
|
2654 |
if (enter && !sameWindow) { |
|
2655 |
w = enter; |
|
2656 |
do { |
|
2657 |
enterList.prepend(w); |
|
2658 |
} while (!w->isWindow() && (w = w->parentWidget())); |
|
2659 |
} |
|
2660 |
if (sameWindow) { |
|
2661 |
int enterDepth = 0; |
|
2662 |
int leaveDepth = 0; |
|
2663 |
w = enter; |
|
2664 |
while (!w->isWindow() && (w = w->parentWidget())) |
|
2665 |
enterDepth++; |
|
2666 |
w = leave; |
|
2667 |
while (!w->isWindow() && (w = w->parentWidget())) |
|
2668 |
leaveDepth++; |
|
2669 |
QWidget* wenter = enter; |
|
2670 |
QWidget* wleave = leave; |
|
2671 |
while (enterDepth > leaveDepth) { |
|
2672 |
wenter = wenter->parentWidget(); |
|
2673 |
enterDepth--; |
|
2674 |
} |
|
2675 |
while (leaveDepth > enterDepth) { |
|
2676 |
wleave = wleave->parentWidget(); |
|
2677 |
leaveDepth--; |
|
2678 |
} |
|
2679 |
while (!wenter->isWindow() && wenter != wleave) { |
|
2680 |
wenter = wenter->parentWidget(); |
|
2681 |
wleave = wleave->parentWidget(); |
|
2682 |
} |
|
2683 |
||
2684 |
w = leave; |
|
2685 |
while (w != wleave) { |
|
2686 |
leaveList.append(w); |
|
2687 |
w = w->parentWidget(); |
|
2688 |
} |
|
2689 |
w = enter; |
|
2690 |
while (w != wenter) { |
|
2691 |
enterList.prepend(w); |
|
2692 |
w = w->parentWidget(); |
|
2693 |
} |
|
2694 |
} |
|
2695 |
||
2696 |
QEvent leaveEvent(QEvent::Leave); |
|
2697 |
for (int i = 0; i < leaveList.size(); ++i) { |
|
2698 |
w = leaveList.at(i); |
|
2699 |
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { |
|
2700 |
#if defined(Q_WS_WIN) || defined(Q_WS_X11) |
|
2701 |
if (leaveAfterRelease == w) |
|
2702 |
leaveAfterRelease = 0; |
|
2703 |
#endif |
|
2704 |
QApplication::sendEvent(w, &leaveEvent); |
|
2705 |
if (w->testAttribute(Qt::WA_Hover) && |
|
2706 |
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { |
|
2707 |
Q_ASSERT(instance()); |
|
2708 |
QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos)); |
|
2709 |
qApp->d_func()->notify_helper(w, &he); |
|
2710 |
} |
|
2711 |
} |
|
2712 |
} |
|
2713 |
QPoint posEnter = QCursor::pos(); |
|
2714 |
QEvent enterEvent(QEvent::Enter); |
|
2715 |
for (int i = 0; i < enterList.size(); ++i) { |
|
2716 |
w = enterList.at(i); |
|
2717 |
if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { |
|
2718 |
QApplication::sendEvent(w, &enterEvent); |
|
2719 |
if (w->testAttribute(Qt::WA_Hover) && |
|
2720 |
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { |
|
2721 |
QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1)); |
|
2722 |
qApp->d_func()->notify_helper(w, &he); |
|
2723 |
} |
|
2724 |
} |
|
2725 |
} |
|
2726 |
||
2727 |
#ifndef QT_NO_CURSOR |
|
2728 |
// Update cursor for alien/graphics widgets. |
|
2729 |
||
2730 |
const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen))); |
|
2731 |
#if defined(Q_WS_X11) |
|
2732 |
//Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor. |
|
2733 |
// This is not required on Windows as the cursor is reset on every single mouse move. |
|
2734 |
QWidget *parentOfLeavingCursor = 0; |
|
2735 |
for (int i = 0; i < leaveList.size(); ++i) { |
|
2736 |
w = leaveList.at(i); |
|
2737 |
if (!isAlien(w)) |
|
2738 |
break; |
|
2739 |
if (w->testAttribute(Qt::WA_SetCursor)) { |
|
2740 |
QWidget *parent = w->parentWidget(); |
|
2741 |
while (parent && parent->d_func()->data.in_destructor) |
|
2742 |
parent = parent->parentWidget(); |
|
2743 |
parentOfLeavingCursor = parent; |
|
2744 |
//continue looping, we need to find the downest alien widget with a cursor. |
|
2745 |
// (downest on the screen) |
|
2746 |
} |
|
2747 |
} |
|
2748 |
//check that we will not call qt_x11_enforce_cursor twice with the same native widget |
|
2749 |
if (parentOfLeavingCursor && (!enterOnAlien |
|
2750 |
|| parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) { |
|
2751 |
#ifndef QT_NO_GRAPHICSVIEW |
|
2752 |
if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) |
|
2753 |
#endif |
|
2754 |
{ |
|
2755 |
qt_x11_enforce_cursor(parentOfLeavingCursor,true); |
|
2756 |
} |
|
2757 |
} |
|
2758 |
#endif |
|
2759 |
if (enterOnAlien) { |
|
2760 |
QWidget *cursorWidget = enter; |
|
2761 |
while (!cursorWidget->isWindow() && !cursorWidget->isEnabled()) |
|
2762 |
cursorWidget = cursorWidget->parentWidget(); |
|
2763 |
||
2764 |
if (!cursorWidget) |
|
2765 |
return; |
|
2766 |
||
2767 |
#ifndef QT_NO_GRAPHICSVIEW |
|
2768 |
if (cursorWidget->window()->graphicsProxyWidget()) { |
|
2769 |
QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor()); |
|
2770 |
} else |
|
2771 |
#endif |
|
2772 |
{ |
|
2773 |
#if defined(Q_WS_WIN) |
|
2774 |
qt_win_set_cursor(cursorWidget, true); |
|
2775 |
#elif defined(Q_WS_X11) |
|
2776 |
qt_x11_enforce_cursor(cursorWidget, true); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
2777 |
#elif defined(Q_OS_SYMBIAN) |
0 | 2778 |
qt_symbian_set_cursor(cursorWidget, true); |
2779 |
#endif |
|
2780 |
} |
|
2781 |
} |
|
2782 |
#endif |
|
2783 |
} |
|
2784 |
||
2785 |
/* exported for the benefit of testing tools */ |
|
2786 |
Q_GUI_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop) |
|
2787 |
{ |
|
2788 |
return QApplicationPrivate::tryModalHelper(widget, rettop); |
|
2789 |
} |
|
2790 |
||
2791 |
/*! \internal |
|
2792 |
Returns true if \a widget is blocked by a modal window. |
|
2793 |
*/ |
|
2794 |
bool QApplicationPrivate::isBlockedByModal(QWidget *widget) |
|
2795 |
{ |
|
2796 |
widget = widget->window(); |
|
2797 |
if (!modalState()) |
|
2798 |
return false; |
|
2799 |
if (QApplication::activePopupWidget() == widget) |
|
2800 |
return false; |
|
2801 |
||
2802 |
for (int i = 0; i < qt_modal_stack->size(); ++i) { |
|
2803 |
QWidget *modalWidget = qt_modal_stack->at(i); |
|
2804 |
||
2805 |
{ |
|
2806 |
// check if the active modal widget is our widget or a parent of our widget |
|
2807 |
QWidget *w = widget; |
|
2808 |
while (w) { |
|
2809 |
if (w == modalWidget) |
|
2810 |
return false; |
|
2811 |
w = w->parentWidget(); |
|
2812 |
} |
|
2813 |
#ifdef Q_WS_WIN |
|
2814 |
if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid) |
|
2815 |
&& (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid) |
|
2816 |
&& IsChild(modalWidget->data->winid, widget->data->winid)) |
|
2817 |
return false; |
|
2818 |
#endif |
|
2819 |
} |
|
2820 |
||
2821 |
Qt::WindowModality windowModality = modalWidget->windowModality(); |
|
2822 |
if (windowModality == Qt::NonModal) { |
|
2823 |
// determine the modality type if it hasn't been set on the |
|
2824 |
// modalWidget, this normally happens when waiting for a |
|
2825 |
// native dialog. use WindowModal if we are the child of a |
|
2826 |
// group leader; otherwise use ApplicationModal. |
|
2827 |
QWidget *m = modalWidget; |
|
2828 |
while (m && !m->testAttribute(Qt::WA_GroupLeader)) { |
|
2829 |
m = m->parentWidget(); |
|
2830 |
if (m) |
|
2831 |
m = m->window(); |
|
2832 |
} |
|
2833 |
windowModality = (m && m->testAttribute(Qt::WA_GroupLeader)) |
|
2834 |
? Qt::WindowModal |
|
2835 |
: Qt::ApplicationModal; |
|
2836 |
} |
|
2837 |
||
2838 |
switch (windowModality) { |
|
2839 |
case Qt::ApplicationModal: |
|
2840 |
{ |
|
2841 |
QWidget *groupLeaderForWidget = widget; |
|
2842 |
while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) |
|
2843 |
groupLeaderForWidget = groupLeaderForWidget->parentWidget(); |
|
2844 |
||
2845 |
if (groupLeaderForWidget) { |
|
2846 |
// if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children |
|
2847 |
QWidget *m = modalWidget; |
|
2848 |
while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) |
|
2849 |
m = m->parentWidget(); |
|
2850 |
if (m == groupLeaderForWidget) |
|
2851 |
return true; |
|
2852 |
} else if (modalWidget != widget) { |
|
2853 |
return true; |
|
2854 |
} |
|
2855 |
break; |
|
2856 |
} |
|
2857 |
case Qt::WindowModal: |
|
2858 |
{ |
|
2859 |
QWidget *w = widget; |
|
2860 |
do { |
|
2861 |
QWidget *m = modalWidget; |
|
2862 |
do { |
|
2863 |
if (m == w) |
|
2864 |
return true; |
|
2865 |
m = m->parentWidget(); |
|
2866 |
if (m) |
|
2867 |
m = m->window(); |
|
2868 |
} while (m); |
|
2869 |
w = w->parentWidget(); |
|
2870 |
if (w) |
|
2871 |
w = w->window(); |
|
2872 |
} while (w); |
|
2873 |
break; |
|
2874 |
} |
|
2875 |
default: |
|
2876 |
Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless"); |
|
2877 |
break; |
|
2878 |
} |
|
2879 |
} |
|
2880 |
return false; |
|
2881 |
} |
|
2882 |
||
2883 |
/*!\internal |
|
2884 |
*/ |
|
2885 |
void QApplicationPrivate::enterModal(QWidget *widget) |
|
2886 |
{ |
|
2887 |
QSet<QWidget*> blocked; |
|
2888 |
QList<QWidget*> windows = QApplication::topLevelWidgets(); |
|
2889 |
for (int i = 0; i < windows.count(); ++i) { |
|
2890 |
QWidget *window = windows.at(i); |
|
2891 |
if (window->windowType() != Qt::Tool && isBlockedByModal(window)) |
|
2892 |
blocked.insert(window); |
|
2893 |
} |
|
2894 |
||
2895 |
enterModal_sys(widget); |
|
2896 |
||
2897 |
windows = QApplication::topLevelWidgets(); |
|
2898 |
QEvent e(QEvent::WindowBlocked); |
|
2899 |
for (int i = 0; i < windows.count(); ++i) { |
|
2900 |
QWidget *window = windows.at(i); |
|
2901 |
if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window)) |
|
2902 |
QApplication::sendEvent(window, &e); |
|
2903 |
} |
|
2904 |
} |
|
2905 |
||
2906 |
/*!\internal |
|
2907 |
*/ |
|
2908 |
void QApplicationPrivate::leaveModal(QWidget *widget) |
|
2909 |
{ |
|
2910 |
QSet<QWidget*> blocked; |
|
2911 |
QList<QWidget*> windows = QApplication::topLevelWidgets(); |
|
2912 |
for (int i = 0; i < windows.count(); ++i) { |
|
2913 |
QWidget *window = windows.at(i); |
|
2914 |
if (window->windowType() != Qt::Tool && isBlockedByModal(window)) |
|
2915 |
blocked.insert(window); |
|
2916 |
} |
|
2917 |
||
2918 |
leaveModal_sys(widget); |
|
2919 |
||
2920 |
windows = QApplication::topLevelWidgets(); |
|
2921 |
QEvent e(QEvent::WindowUnblocked); |
|
2922 |
for (int i = 0; i < windows.count(); ++i) { |
|
2923 |
QWidget *window = windows.at(i); |
|
2924 |
if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window)) |
|
2925 |
QApplication::sendEvent(window, &e); |
|
2926 |
} |
|
2927 |
} |
|
2928 |
||
2929 |
||
2930 |
||
2931 |
/*!\internal |
|
2932 |
||
2933 |
Called from qapplication_\e{platform}.cpp, returns true |
|
2934 |
if the widget should accept the event. |
|
2935 |
*/ |
|
2936 |
bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) |
|
2937 |
{ |
|
2938 |
QWidget *top = QApplication::activeModalWidget(); |
|
2939 |
if (rettop) |
|
2940 |
*rettop = top; |
|
2941 |
||
2942 |
// the active popup widget always gets the input event |
|
2943 |
if (QApplication::activePopupWidget()) |
|
2944 |
return true; |
|
2945 |
||
2946 |
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) |
|
2947 |
top = QApplicationPrivate::tryModalHelper_sys(top); |
|
2948 |
if (rettop) |
|
2949 |
*rettop = top; |
|
2950 |
#endif |
|
2951 |
||
2952 |
return !isBlockedByModal(widget->window()); |
|
2953 |
} |
|
2954 |
||
2955 |
/* |
|
2956 |
\internal |
|
2957 |
*/ |
|
2958 |
QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint &globalPos, |
|
2959 |
QPoint &pos, QEvent::Type type, |
|
2960 |
Qt::MouseButtons buttons, QWidget *buttonDown, |
|
2961 |
QWidget *alienWidget) |
|
2962 |
{ |
|
2963 |
Q_ASSERT(candidate); |
|
2964 |
||
2965 |
QWidget *mouseGrabber = QWidget::mouseGrabber(); |
|
2966 |
if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease)) |
|
2967 |
&& !buttonDown && !mouseGrabber) { |
|
2968 |
return 0; |
|
2969 |
} |
|
2970 |
||
2971 |
if (alienWidget && alienWidget->internalWinId()) |
|
2972 |
alienWidget = 0; |
|
2973 |
||
2974 |
QWidget *receiver = candidate; |
|
2975 |
||
2976 |
if (!mouseGrabber) |
|
2977 |
mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget; |
|
2978 |
||
2979 |
if (mouseGrabber && mouseGrabber != candidate) { |
|
2980 |
receiver = mouseGrabber; |
|
2981 |
pos = receiver->mapFromGlobal(globalPos); |
|
2982 |
#ifdef ALIEN_DEBUG |
|
2983 |
qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos; |
|
2984 |
#endif |
|
2985 |
} |
|
2986 |
||
2987 |
return receiver; |
|
2988 |
||
2989 |
} |
|
2990 |
||
2991 |
/* |
|
2992 |
\internal |
|
2993 |
*/ |
|
2994 |
bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, |
|
2995 |
QWidget *alienWidget, QWidget *nativeWidget, |
|
2996 |
QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver, |
|
2997 |
bool spontaneous) |
|
2998 |
{ |
|
2999 |
Q_ASSERT(receiver); |
|
3000 |
Q_ASSERT(event); |
|
3001 |
Q_ASSERT(nativeWidget); |
|
3002 |
Q_ASSERT(buttonDown); |
|
3003 |
||
3004 |
if (alienWidget && !isAlien(alienWidget)) |
|
3005 |
alienWidget = 0; |
|
3006 |
||
3007 |
QPointer<QWidget> receiverGuard = receiver; |
|
3008 |
QPointer<QWidget> nativeGuard = nativeWidget; |
|
3009 |
QPointer<QWidget> alienGuard = alienWidget; |
|
3010 |
QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget(); |
|
3011 |
||
3012 |
const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen); |
|
3013 |
||
3014 |
if (*buttonDown) { |
|
3015 |
if (!graphicsWidget) { |
|
3016 |
// Register the widget that shall receive a leave event |
|
3017 |
// after the last button is released. |
|
3018 |
if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber()) |
|
3019 |
leaveAfterRelease = *buttonDown; |
|
3020 |
if (event->type() == QEvent::MouseButtonRelease && !event->buttons()) |
|
3021 |
*buttonDown = 0; |
|
3022 |
} |
|
3023 |
} else if (lastMouseReceiver) { |
|
3024 |
// Dispatch enter/leave if we move: |
|
3025 |
// 1) from an alien widget to another alien widget or |
|
3026 |
// from a native widget to an alien widget (first OR case) |
|
3027 |
// 2) from an alien widget to a native widget (second OR case) |
|
3028 |
if ((alienWidget && alienWidget != lastMouseReceiver) |
|
3029 |
|| (isAlien(lastMouseReceiver) && !alienWidget)) { |
|
3030 |
if (activePopupWidget) { |
|
3031 |
if (!QWidget::mouseGrabber()) |
|
3032 |
dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver); |
|
3033 |
} else { |
|
3034 |
dispatchEnterLeave(receiver, lastMouseReceiver); |
|
3035 |
} |
|
3036 |
||
3037 |
} |
|
3038 |
} |
|
3039 |
||
3040 |
#ifdef ALIEN_DEBUG |
|
3041 |
qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver |
|
3042 |
<< "pos:" << event->pos() << "alien" << alienWidget << "button down" |
|
3043 |
<< *buttonDown << "last" << lastMouseReceiver << "leave after release" |
|
3044 |
<< leaveAfterRelease; |
|
3045 |
#endif |
|
3046 |
||
3047 |
// We need this quard in case someone opens a modal dialog / popup. If that's the case |
|
3048 |
// leaveAfterRelease is set to null, but we shall not update lastMouseReceiver. |
|
3049 |
const bool wasLeaveAfterRelease = leaveAfterRelease != 0; |
|
3050 |
bool result; |
|
3051 |
if (spontaneous) |
|
3052 |
result = QApplication::sendSpontaneousEvent(receiver, event); |
|
3053 |
else |
|
3054 |
result = QApplication::sendEvent(receiver, event); |
|
3055 |
||
3056 |
if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease |
|
3057 |
&& !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) { |
|
3058 |
// Dispatch enter/leave if: |
|
3059 |
// 1) the mouse grabber is an alien widget |
|
3060 |
// 2) the button is released on an alien widget |
|
3061 |
||
3062 |
QWidget *enter = 0; |
|
3063 |
if (nativeGuard) |
|
3064 |
enter = alienGuard ? alienWidget : nativeWidget; |
|
3065 |
else // The receiver is typically deleted on mouse release with drag'n'drop. |
|
3066 |
enter = QApplication::widgetAt(event->globalPos()); |
|
3067 |
||
3068 |
dispatchEnterLeave(enter, leaveAfterRelease); |
|
3069 |
leaveAfterRelease = 0; |
|
3070 |
lastMouseReceiver = enter; |
|
3071 |
} else if (!wasLeaveAfterRelease) { |
|
3072 |
if (activePopupWidget) { |
|
3073 |
if (!QWidget::mouseGrabber()) |
|
3074 |
lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0); |
|
3075 |
} else { |
|
3076 |
lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos()); |
|
3077 |
} |
|
3078 |
} |
|
3079 |
||
3080 |
return result; |
|
3081 |
} |
|
3082 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3083 |
#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) |
0 | 3084 |
/* |
3085 |
This function should only be called when the widget changes visibility, i.e. |
|
3086 |
when the \a widget is shown, hidden or deleted. This function does nothing |
|
3087 |
if the widget is a top-level or native, i.e. not an alien widget. In that |
|
3088 |
case enter/leave events are genereated by the underlying windowing system. |
|
3089 |
*/ |
|
3090 |
extern QPointer<QWidget> qt_last_mouse_receiver; |
|
3091 |
extern QWidget *qt_button_down; |
|
3092 |
void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) |
|
3093 |
{ |
|
3094 |
#ifndef QT_NO_CURSOR |
|
3095 |
#ifdef Q_WS_QWS |
|
3096 |
if (!widget || widget->isWindow()) |
|
3097 |
return; |
|
3098 |
#else |
|
3099 |
if (!widget || widget->internalWinId() || widget->isWindow()) |
|
3100 |
return; |
|
3101 |
#endif |
|
3102 |
const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor; |
|
3103 |
if (!widgetInShow && widget != qt_last_mouse_receiver) |
|
3104 |
return; // Widget was not under the cursor when it was hidden/deleted. |
|
3105 |
||
3106 |
if (widgetInShow && widget->parentWidget()->data->in_show) |
|
3107 |
return; // Ingore recursive show. |
|
3108 |
||
3109 |
QWidget *mouseGrabber = QWidget::mouseGrabber(); |
|
3110 |
if (mouseGrabber && mouseGrabber != widget) |
|
3111 |
return; // Someone else has the grab; enter/leave should not occur. |
|
3112 |
||
3113 |
QWidget *tlw = widget->window(); |
|
3114 |
if (tlw->data->in_destructor || tlw->data->is_closing) |
|
3115 |
return; // Closing down the business. |
|
3116 |
||
3117 |
if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw)) |
|
3118 |
return; // Mouse cursor not inside the widget's top-level. |
|
3119 |
||
3120 |
const QPoint globalPos(QCursor::pos()); |
|
3121 |
QPoint pos = tlw->mapFromGlobal(globalPos); |
|
3122 |
||
3123 |
// Find the current widget under the mouse. If this function was called from |
|
3124 |
// the widget's destructor, we have to make sure childAt() doesn't take into |
|
3125 |
// account widgets that are about to be destructed. |
|
3126 |
QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(pos, widget->data->in_destructor); |
|
3127 |
if (!widgetUnderCursor) |
|
3128 |
widgetUnderCursor = tlw; |
|
3129 |
else |
|
3130 |
pos = widgetUnderCursor->mapFrom(tlw, pos); |
|
3131 |
||
3132 |
if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor)) |
|
3133 |
return; // Mouse cursor not inside the widget or any of its children. |
|
3134 |
||
3135 |
if (widget->data->in_destructor && qt_button_down == widget) |
|
3136 |
qt_button_down = 0; |
|
3137 |
||
3138 |
// Send enter/leave events followed by a mouse move on the entered widget. |
|
3139 |
QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); |
|
3140 |
sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); |
|
3141 |
#endif // QT_NO_CURSOR |
|
3142 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
3143 |
#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC |
0 | 3144 |
|
3145 |
/*! |
|
3146 |
Returns the desktop widget (also called the root window). |
|
3147 |
||
3148 |
The desktop may be composed of multiple screens, so it would be incorrect, |
|
3149 |
for example, to attempt to \e center some widget in the desktop's geometry. |
|
3150 |
QDesktopWidget has various functions for obtaining useful geometries upon |
|
3151 |
the desktop, such as QDesktopWidget::screenGeometry() and |
|
3152 |
QDesktopWidget::availableGeometry(). |
|
3153 |
||
3154 |
On X11, it is also possible to draw on the desktop. |
|
3155 |
*/ |
|
3156 |
QDesktopWidget *QApplication::desktop() |
|
3157 |
{ |
|
3158 |
if (!qt_desktopWidget || // not created yet |
|
3159 |
!(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away |
|
3160 |
qt_desktopWidget = new QDesktopWidget(); |
|
3161 |
} |
|
3162 |
return qt_desktopWidget; |
|
3163 |
} |
|
3164 |
||
3165 |
#ifndef QT_NO_CLIPBOARD |
|
3166 |
/*! |
|
3167 |
Returns a pointer to the application global clipboard. |
|
3168 |
||
3169 |
\note The QApplication object should already be constructed before |
|
3170 |
accessing the clipboard. |
|
3171 |
*/ |
|
3172 |
QClipboard *QApplication::clipboard() |
|
3173 |
{ |
|
3174 |
if (qt_clipboard == 0) { |
|
3175 |
if (!qApp) { |
|
3176 |
qWarning("QApplication: Must construct a QApplication before accessing a QClipboard"); |
|
3177 |
return 0; |
|
3178 |
} |
|
3179 |
qt_clipboard = new QClipboard(0); |
|
3180 |
} |
|
3181 |
return qt_clipboard; |
|
3182 |
} |
|
3183 |
#endif // QT_NO_CLIPBOARD |
|
3184 |
||
3185 |
/*! |
|
3186 |
Sets whether Qt should use the system's standard colors, fonts, etc., to |
|
3187 |
\a on. By default, this is true. |
|
3188 |
||
3189 |
This function must be called before creating the QApplication object, like |
|
3190 |
this: |
|
3191 |
||
3192 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6 |
|
3193 |
||
3194 |
\sa desktopSettingsAware() |
|
3195 |
*/ |
|
3196 |
void QApplication::setDesktopSettingsAware(bool on) |
|
3197 |
{ |
|
3198 |
QApplicationPrivate::obey_desktop_settings = on; |
|
3199 |
} |
|
3200 |
||
3201 |
/*! |
|
3202 |
Returns true if Qt is set to use the system's standard colors, fonts, etc.; |
|
3203 |
otherwise returns false. The default is true. |
|
3204 |
||
3205 |
\sa setDesktopSettingsAware() |
|
3206 |
*/ |
|
3207 |
bool QApplication::desktopSettingsAware() |
|
3208 |
{ |
|
3209 |
return QApplicationPrivate::obey_desktop_settings; |
|
3210 |
} |
|
3211 |
||
3212 |
/*! |
|
3213 |
Returns the current state of the modifier keys on the keyboard. The current |
|
3214 |
state is updated sychronously as the event queue is emptied of events that |
|
3215 |
will spontaneously change the keyboard state (QEvent::KeyPress and |
|
3216 |
QEvent::KeyRelease events). |
|
3217 |
||
3218 |
It should be noted this may not reflect the actual keys held on the input |
|
3219 |
device at the time of calling but rather the modifiers as last reported in |
|
3220 |
one of the above events. If no keys are being held Qt::NoModifier is |
|
3221 |
returned. |
|
3222 |
||
3223 |
\sa mouseButtons() |
|
3224 |
*/ |
|
3225 |
||
3226 |
Qt::KeyboardModifiers QApplication::keyboardModifiers() |
|
3227 |
{ |
|
3228 |
return QApplicationPrivate::modifier_buttons; |
|
3229 |
} |
|
3230 |
||
3231 |
/*! |
|
3232 |
Returns the current state of the buttons on the mouse. The current state is |
|
3233 |
updated syncronously as the event queue is emptied of events that will |
|
3234 |
spontaneously change the mouse state (QEvent::MouseButtonPress and |
|
3235 |
QEvent::MouseButtonRelease events). |
|
3236 |
||
3237 |
It should be noted this may not reflect the actual buttons held on the |
|
3238 |
input device at the time of calling but rather the mouse buttons as last |
|
3239 |
reported in one of the above events. If no mouse buttons are being held |
|
3240 |
Qt::NoButton is returned. |
|
3241 |
||
3242 |
\sa keyboardModifiers() |
|
3243 |
*/ |
|
3244 |
||
3245 |
Qt::MouseButtons QApplication::mouseButtons() |
|
3246 |
{ |
|
3247 |
return QApplicationPrivate::mouse_buttons; |
|
3248 |
} |
|
3249 |
||
3250 |
/*! |
|
3251 |
\fn bool QApplication::isSessionRestored() const |
|
3252 |
||
3253 |
Returns true if the application has been restored from an earlier |
|
3254 |
\l{Session Management}{session}; otherwise returns false. |
|
3255 |
||
3256 |
\sa sessionId(), commitData(), saveState() |
|
3257 |
*/ |
|
3258 |
||
3259 |
||
3260 |
/*! |
|
3261 |
\fn QString QApplication::sessionId() const |
|
3262 |
||
3263 |
Returns the current \l{Session Management}{session's} identifier. |
|
3264 |
||
3265 |
If the application has been restored from an earlier session, this |
|
3266 |
identifier is the same as it was in that previous session. The session |
|
3267 |
identifier is guaranteed to be unique both for different applications |
|
3268 |
and for different instances of the same application. |
|
3269 |
||
3270 |
\sa isSessionRestored(), sessionKey(), commitData(), saveState() |
|
3271 |
*/ |
|
3272 |
||
3273 |
/*! |
|
3274 |
\fn QString QApplication::sessionKey() const |
|
3275 |
||
3276 |
Returns the session key in the current \l{Session Management}{session}. |
|
3277 |
||
3278 |
If the application has been restored from an earlier session, this key is |
|
3279 |
the same as it was when the previous session ended. |
|
3280 |
||
3281 |
The session key changes with every call of commitData() or saveState(). |
|
3282 |
||
3283 |
\sa isSessionRestored(), sessionId(), commitData(), saveState() |
|
3284 |
*/ |
|
3285 |
#ifndef QT_NO_SESSIONMANAGER |
|
3286 |
bool QApplication::isSessionRestored() const |
|
3287 |
{ |
|
3288 |
Q_D(const QApplication); |
|
3289 |
return d->is_session_restored; |
|
3290 |
} |
|
3291 |
||
3292 |
QString QApplication::sessionId() const |
|
3293 |
{ |
|
3294 |
Q_D(const QApplication); |
|
3295 |
return d->session_id; |
|
3296 |
} |
|
3297 |
||
3298 |
QString QApplication::sessionKey() const |
|
3299 |
{ |
|
3300 |
Q_D(const QApplication); |
|
3301 |
return d->session_key; |
|
3302 |
} |
|
3303 |
#endif |
|
3304 |
||
3305 |
||
3306 |
||
3307 |
/*! |
|
3308 |
\since 4.2 |
|
3309 |
\fn void QApplication::commitDataRequest(QSessionManager &manager) |
|
3310 |
||
3311 |
This signal deals with \l{Session Management}{session management}. It is |
|
3312 |
emitted when the QSessionManager wants the application to commit all its |
|
3313 |
data. |
|
3314 |
||
3315 |
Usually this means saving all open files, after getting permission from |
|
3316 |
the user. Furthermore you may want to provide a means by which the user |
|
3317 |
can cancel the shutdown. |
|
3318 |
||
3319 |
You should not exit the application within this signal. Instead, |
|
3320 |
the session manager may or may not do this afterwards, depending on the |
|
3321 |
context. |
|
3322 |
||
3323 |
\warning Within this signal, no user interaction is possible, \e |
|
3324 |
unless you ask the \a manager for explicit permission. See |
|
3325 |
QSessionManager::allowsInteraction() and |
|
3326 |
QSessionManager::allowsErrorInteraction() for details and example |
|
3327 |
usage. |
|
3328 |
||
3329 |
\note You should use Qt::DirectConnection when connecting to this signal. |
|
3330 |
||
3331 |
\sa isSessionRestored(), sessionId(), saveState(), {Session Management} |
|
3332 |
*/ |
|
3333 |
||
3334 |
/*! |
|
3335 |
This function deals with \l{Session Management}{session management}. It is |
|
3336 |
invoked when the QSessionManager wants the application to commit all its |
|
3337 |
data. |
|
3338 |
||
3339 |
Usually this means saving all open files, after getting permission from the |
|
3340 |
user. Furthermore you may want to provide a means by which the user can |
|
3341 |
cancel the shutdown. |
|
3342 |
||
3343 |
You should not exit the application within this function. Instead, the |
|
3344 |
session manager may or may not do this afterwards, depending on the |
|
3345 |
context. |
|
3346 |
||
3347 |
\warning Within this function, no user interaction is possible, \e |
|
3348 |
unless you ask the \a manager for explicit permission. See |
|
3349 |
QSessionManager::allowsInteraction() and |
|
3350 |
QSessionManager::allowsErrorInteraction() for details and example |
|
3351 |
usage. |
|
3352 |
||
3353 |
The default implementation requests interaction and sends a close event to |
|
3354 |
all visible top-level widgets. If any event was rejected, the shutdown is |
|
3355 |
canceled. |
|
3356 |
||
3357 |
\sa isSessionRestored(), sessionId(), saveState(), {Session Management} |
|
3358 |
*/ |
|
3359 |
#ifndef QT_NO_SESSIONMANAGER |
|
3360 |
void QApplication::commitData(QSessionManager& manager ) |
|
3361 |
{ |
|
3362 |
emit commitDataRequest(manager); |
|
3363 |
if (manager.allowsInteraction()) { |
|
3364 |
QWidgetList done; |
|
3365 |
QWidgetList list = QApplication::topLevelWidgets(); |
|
3366 |
bool cancelled = false; |
|
3367 |
for (int i = 0; !cancelled && i < list.size(); ++i) { |
|
3368 |
QWidget* w = list.at(i); |
|
3369 |
if (w->isVisible() && !done.contains(w)) { |
|
3370 |
cancelled = !w->close(); |
|
3371 |
if (!cancelled) |
|
3372 |
done.append(w); |
|
3373 |
list = QApplication::topLevelWidgets(); |
|
3374 |
i = -1; |
|
3375 |
} |
|
3376 |
} |
|
3377 |
if (cancelled) |
|
3378 |
manager.cancel(); |
|
3379 |
} |
|
3380 |
} |
|
3381 |
||
3382 |
/*! |
|
3383 |
\since 4.2 |
|
3384 |
\fn void QApplication::saveStateRequest(QSessionManager &manager) |
|
3385 |
||
3386 |
This signal deals with \l{Session Management}{session management}. It is |
|
3387 |
invoked when the \l{QSessionManager}{session manager} wants the application |
|
3388 |
to preserve its state for a future session. |
|
3389 |
||
3390 |
For example, a text editor would create a temporary file that includes the |
|
3391 |
current contents of its edit buffers, the location of the cursor and other |
|
3392 |
aspects of the current editing session. |
|
3393 |
||
3394 |
You should never exit the application within this signal. Instead, the |
|
3395 |
session manager may or may not do this afterwards, depending on the |
|
3396 |
context. Futhermore, most session managers will very likely request a saved |
|
3397 |
state immediately after the application has been started. This permits the |
|
3398 |
session manager to learn about the application's restart policy. |
|
3399 |
||
3400 |
\warning Within this function, no user interaction is possible, \e |
|
3401 |
unless you ask the \a manager for explicit permission. See |
|
3402 |
QSessionManager::allowsInteraction() and |
|
3403 |
QSessionManager::allowsErrorInteraction() for details. |
|
3404 |
||
3405 |
\note You should use Qt::DirectConnection when connecting to this signal. |
|
3406 |
||
3407 |
\sa isSessionRestored(), sessionId(), commitData(), {Session Management} |
|
3408 |
*/ |
|
3409 |
||
3410 |
/*! |
|
3411 |
This function deals with \l{Session Management}{session management}. It is |
|
3412 |
invoked when the \l{QSessionManager}{session manager} wants the application |
|
3413 |
to preserve its state for a future session. |
|
3414 |
||
3415 |
For example, a text editor would create a temporary file that includes the |
|
3416 |
current contents of its edit buffers, the location of the cursor and other |
|
3417 |
aspects of the current editing session. |
|
3418 |
||
3419 |
You should never exit the application within this function. Instead, the |
|
3420 |
session manager may or may not do this afterwards, depending on the |
|
3421 |
context. Futhermore, most session managers will very likely request a saved |
|
3422 |
state immediately after the application has been started. This permits the |
|
3423 |
session manager to learn about the application's restart policy. |
|
3424 |
||
3425 |
\warning Within this function, no user interaction is possible, \e |
|
3426 |
unless you ask the \a manager for explicit permission. See |
|
3427 |
QSessionManager::allowsInteraction() and |
|
3428 |
QSessionManager::allowsErrorInteraction() for details. |
|
3429 |
||
3430 |
\sa isSessionRestored(), sessionId(), commitData(), {Session Management} |
|
3431 |
*/ |
|
3432 |
||
3433 |
void QApplication::saveState(QSessionManager &manager) |
|
3434 |
{ |
|
3435 |
emit saveStateRequest(manager); |
|
3436 |
} |
|
3437 |
#endif //QT_NO_SESSIONMANAGER |
|
3438 |
/* |
|
3439 |
Sets the time after which a drag should start to \a ms ms. |
|
3440 |
||
3441 |
\sa startDragTime() |
|
3442 |
*/ |
|
3443 |
||
3444 |
void QApplication::setStartDragTime(int ms) |
|
3445 |
{ |
|
3446 |
drag_time = ms; |
|
3447 |
} |
|
3448 |
||
3449 |
/*! |
|
3450 |
\property QApplication::startDragTime |
|
3451 |
\brief the time in milliseconds that a mouse button must be held down |
|
3452 |
before a drag and drop operation will begin |
|
3453 |
||
3454 |
If you support drag and drop in your application, and want to start a drag |
|
3455 |
and drop operation after the user has held down a mouse button for a |
|
3456 |
certain amount of time, you should use this property's value as the delay. |
|
3457 |
||
3458 |
Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for |
|
3459 |
starting a drag. |
|
3460 |
||
3461 |
The default value is 500 ms. |
|
3462 |
||
3463 |
\sa startDragDistance(), {Drag and Drop} |
|
3464 |
*/ |
|
3465 |
||
3466 |
int QApplication::startDragTime() |
|
3467 |
{ |
|
3468 |
return drag_time; |
|
3469 |
} |
|
3470 |
||
3471 |
/* |
|
3472 |
Sets the distance after which a drag should start to \a l pixels. |
|
3473 |
||
3474 |
\sa startDragDistance() |
|
3475 |
*/ |
|
3476 |
||
3477 |
void QApplication::setStartDragDistance(int l) |
|
3478 |
{ |
|
3479 |
drag_distance = l; |
|
3480 |
} |
|
3481 |
||
3482 |
/*! |
|
3483 |
\property QApplication::startDragDistance |
|
3484 |
||
3485 |
If you support drag and drop in your application, and want to start a drag |
|
3486 |
and drop operation after the user has moved the cursor a certain distance |
|
3487 |
with a button held down, you should use this property's value as the |
|
3488 |
minimum distance required. |
|
3489 |
||
3490 |
For example, if the mouse position of the click is stored in \c startPos |
|
3491 |
and the current position (e.g. in the mouse move event) is \c currentPos, |
|
3492 |
you can find out if a drag should be started with code like this: |
|
3493 |
||
3494 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7 |
|
3495 |
||
3496 |
Qt uses this value internally, e.g. in QFileDialog. |
|
3497 |
||
3498 |
The default value is 4 pixels. |
|
3499 |
||
3500 |
\sa startDragTime() QPoint::manhattanLength() {Drag and Drop} |
|
3501 |
*/ |
|
3502 |
||
3503 |
int QApplication::startDragDistance() |
|
3504 |
{ |
|
3505 |
return drag_distance; |
|
3506 |
} |
|
3507 |
||
3508 |
/*! |
|
3509 |
\fn void QApplication::setReverseLayout(bool reverse) |
|
3510 |
||
3511 |
Use setLayoutDirection() instead. |
|
3512 |
*/ |
|
3513 |
||
3514 |
/*! |
|
3515 |
\fn void QApplication::reverseLayout() |
|
3516 |
||
3517 |
Use layoutDirection() instead. |
|
3518 |
*/ |
|
3519 |
||
3520 |
/*! |
|
3521 |
\fn bool QApplication::isRightToLeft() |
|
3522 |
||
3523 |
Returns true if the application's layout direction is |
|
3524 |
Qt::RightToLeft; otherwise returns false. |
|
3525 |
||
3526 |
\sa layoutDirection(), isLeftToRight() |
|
3527 |
*/ |
|
3528 |
||
3529 |
/*! |
|
3530 |
\fn bool QApplication::isLeftToRight() |
|
3531 |
||
3532 |
Returns true if the application's layout direction is |
|
3533 |
Qt::LeftToRight; otherwise returns false. |
|
3534 |
||
3535 |
\sa layoutDirection(), isRightToLeft() |
|
3536 |
*/ |
|
3537 |
||
3538 |
/*! |
|
3539 |
\property QApplication::layoutDirection |
|
3540 |
\brief the default layout direction for this application |
|
3541 |
||
3542 |
On system start-up, the default layout direction depends on the |
|
3543 |
application's language. |
|
3544 |
||
3545 |
\sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() |
|
3546 |
*/ |
|
3547 |
||
3548 |
void QApplication::setLayoutDirection(Qt::LayoutDirection direction) |
|
3549 |
{ |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
3550 |
if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) |
0 | 3551 |
return; |
3552 |
||
3553 |
layout_direction = direction; |
|
3554 |
||
3555 |
QWidgetList list = topLevelWidgets(); |
|
3556 |
for (int i = 0; i < list.size(); ++i) { |
|
3557 |
QWidget *w = list.at(i); |
|
3558 |
QEvent ev(QEvent::ApplicationLayoutDirectionChange); |
|
3559 |
sendEvent(w, &ev); |
|
3560 |
} |
|
3561 |
} |
|
3562 |
||
3563 |
Qt::LayoutDirection QApplication::layoutDirection() |
|
3564 |
{ |
|
3565 |
return layout_direction; |
|
3566 |
} |
|
3567 |
||
3568 |
||
3569 |
/*! |
|
3570 |
\obsolete |
|
3571 |
||
3572 |
Strips out vertical alignment flags and transforms an alignment \a align |
|
3573 |
of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the |
|
3574 |
language used. |
|
3575 |
*/ |
|
3576 |
||
3577 |
#ifdef QT3_SUPPORT |
|
3578 |
Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align) |
|
3579 |
{ |
|
3580 |
return QStyle::visualAlignment(layoutDirection(), align); |
|
3581 |
} |
|
3582 |
#endif |
|
3583 |
||
3584 |
||
3585 |
/*! |
|
3586 |
\fn QCursor *QApplication::overrideCursor() |
|
3587 |
||
3588 |
Returns the active application override cursor. |
|
3589 |
||
3590 |
This function returns 0 if no application cursor has been defined (i.e. the |
|
3591 |
internal cursor stack is empty). |
|
3592 |
||
3593 |
\sa setOverrideCursor(), restoreOverrideCursor() |
|
3594 |
*/ |
|
3595 |
#ifndef QT_NO_CURSOR |
|
3596 |
QCursor *QApplication::overrideCursor() |
|
3597 |
{ |
|
3598 |
return qApp->d_func()->cursor_list.isEmpty() ? 0 : &qApp->d_func()->cursor_list.first(); |
|
3599 |
} |
|
3600 |
||
3601 |
/*! |
|
3602 |
Changes the currently active application override cursor to \a cursor. |
|
3603 |
||
3604 |
This function has no effect if setOverrideCursor() was not called. |
|
3605 |
||
3606 |
\sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), |
|
3607 |
QWidget::setCursor() |
|
3608 |
*/ |
|
3609 |
void QApplication::changeOverrideCursor(const QCursor &cursor) |
|
3610 |
{ |
|
3611 |
if (qApp->d_func()->cursor_list.isEmpty()) |
|
3612 |
return; |
|
3613 |
qApp->d_func()->cursor_list.removeFirst(); |
|
3614 |
#ifdef QT_MAC_USE_COCOA |
|
3615 |
// We use native NSCursor stacks in Cocoa. The currentCursor is the |
|
3616 |
// top of this stack. So to avoid flickering of cursor, we have to |
|
3617 |
// change the cusor instead of pop-ing the existing OverrideCursor |
|
3618 |
// and pushing the new one. |
|
3619 |
qApp->d_func()->cursor_list.prepend(cursor); |
|
3620 |
qt_cocoaChangeOverrideCursor(cursor); |
|
3621 |
return; |
|
3622 |
#endif |
|
3623 |
setOverrideCursor(cursor); |
|
3624 |
} |
|
3625 |
#endif |
|
3626 |
||
3627 |
/*! |
|
3628 |
\fn void QApplication::setOverrideCursor(const QCursor &cursor, bool replace) |
|
3629 |
||
3630 |
Use changeOverrideCursor(\a cursor) (if \a replace is true) or |
|
3631 |
setOverrideCursor(\a cursor) (if \a replace is false). |
|
3632 |
*/ |
|
3633 |
||
3634 |
/*! |
|
3635 |
Enters the main event loop and waits until exit() is called, then returns |
|
3636 |
the value that was set to exit() (which is 0 if exit() is called via |
|
3637 |
quit()). |
|
3638 |
||
3639 |
It is necessary to call this function to start event handling. The main |
|
3640 |
event loop receives events from the window system and dispatches these to |
|
3641 |
the application widgets. |
|
3642 |
||
3643 |
Generally, no user interaction can take place before calling exec(). As a |
|
3644 |
special case, modal widgets like QMessageBox can be used before calling |
|
3645 |
exec(), because modal widgets call exec() to start a local event loop. |
|
3646 |
||
3647 |
To make your application perform idle processing, i.e., executing a special |
|
3648 |
function whenever there are no pending events, use a QTimer with 0 timeout. |
|
3649 |
More advanced idle processing schemes can be achieved using processEvents(). |
|
3650 |
||
3651 |
We recommend that you connect clean-up code to the |
|
3652 |
\l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your |
|
3653 |
application's \c{main()} function. This is because, on some platforms the |
|
3654 |
QApplication::exec() call may not return. For example, on the Windows |
|
3655 |
platform, when the user logs off, the system terminates the process after Qt |
|
3656 |
closes all top-level windows. Hence, there is \e{no guarantee} that the |
|
3657 |
application will have time to exit its event loop and execute code at the |
|
3658 |
end of the \c{main()} function, after the QApplication::exec() call. |
|
3659 |
||
3660 |
\sa quitOnLastWindowClosed, quit(), exit(), processEvents(), |
|
3661 |
QCoreApplication::exec() |
|
3662 |
*/ |
|
3663 |
int QApplication::exec() |
|
3664 |
{ |
|
3665 |
#ifndef QT_NO_ACCESSIBILITY |
|
3666 |
QAccessible::setRootObject(qApp); |
|
3667 |
#endif |
|
3668 |
return QCoreApplication::exec(); |
|
3669 |
} |
|
3670 |
||
3671 |
/*! \reimp |
|
3672 |
*/ |
|
3673 |
bool QApplication::notify(QObject *receiver, QEvent *e) |
|
3674 |
{ |
|
3675 |
Q_D(QApplication); |
|
3676 |
// no events are delivered after ~QCoreApplication() has started |
|
3677 |
if (QApplicationPrivate::is_app_closing) |
|
3678 |
return true; |
|
3679 |
||
3680 |
if (receiver == 0) { // serious error |
|
3681 |
qWarning("QApplication::notify: Unexpected null receiver"); |
|
3682 |
return true; |
|
3683 |
} |
|
3684 |
||
3685 |
#ifndef QT_NO_DEBUG |
|
3686 |
d->checkReceiverThread(receiver); |
|
3687 |
#endif |
|
3688 |
||
3689 |
#ifdef QT3_SUPPORT |
|
3690 |
if (e->type() == QEvent::ChildRemoved && !receiver->d_func()->pendingChildInsertedEvents.isEmpty()) |
|
3691 |
receiver->d_func()->removePendingChildInsertedEvents(static_cast<QChildEvent *>(e)->child()); |
|
3692 |
#endif // QT3_SUPPORT |
|
3693 |
||
3694 |
// capture the current mouse/keyboard state |
|
3695 |
if(e->spontaneous()) { |
|
3696 |
if (e->type() == QEvent::KeyPress |
|
3697 |
|| e->type() == QEvent::KeyRelease) { |
|
3698 |
QKeyEvent *ke = static_cast<QKeyEvent*>(e); |
|
3699 |
QApplicationPrivate::modifier_buttons = ke->modifiers(); |
|
3700 |
} else if(e->type() == QEvent::MouseButtonPress |
|
3701 |
|| e->type() == QEvent::MouseButtonRelease) { |
|
3702 |
QMouseEvent *me = static_cast<QMouseEvent*>(e); |
|
3703 |
QApplicationPrivate::modifier_buttons = me->modifiers(); |
|
3704 |
if(me->type() == QEvent::MouseButtonPress) |
|
3705 |
QApplicationPrivate::mouse_buttons |= me->button(); |
|
3706 |
else |
|
3707 |
QApplicationPrivate::mouse_buttons &= ~me->button(); |
|
3708 |
} |
|
3709 |
#if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT) |
|
3710 |
else if (false |
|
3711 |
# ifndef QT_NO_WHEELEVENT |
|
3712 |
|| e->type() == QEvent::Wheel |
|
3713 |
# endif |
|
3714 |
# ifndef QT_NO_TABLETEVENT |
|
3715 |
|| e->type() == QEvent::TabletMove |
|
3716 |
|| e->type() == QEvent::TabletPress |
|
3717 |
|| e->type() == QEvent::TabletRelease |
|
3718 |
# endif |
|
3719 |
) { |
|
3720 |
QInputEvent *ie = static_cast<QInputEvent*>(e); |
|
3721 |
QApplicationPrivate::modifier_buttons = ie->modifiers(); |
|
3722 |
} |
|
3723 |
#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT |
|
3724 |
} |
|
3725 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
3726 |
#ifndef QT_NO_GESTURES |
0 | 3727 |
// walk through parents and check for gestures |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3728 |
if (d->gestureManager) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3729 |
switch (e->type()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3730 |
case QEvent::Paint: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3731 |
case QEvent::MetaCall: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3732 |
case QEvent::DeferredDelete: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3733 |
case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3734 |
case QEvent::Drop: case QEvent::DragResponse: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3735 |
case QEvent::ChildAdded: case QEvent::ChildPolished: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3736 |
#ifdef QT3_SUPPORT |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3737 |
case QEvent::ChildInsertedRequest: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3738 |
case QEvent::ChildInserted: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3739 |
case QEvent::LayoutHint: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3740 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3741 |
case QEvent::ChildRemoved: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3742 |
case QEvent::UpdateRequest: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3743 |
case QEvent::UpdateLater: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3744 |
case QEvent::AccessibilityPrepare: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3745 |
case QEvent::LocaleChange: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3746 |
case QEvent::Style: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3747 |
case QEvent::IconDrag: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3748 |
case QEvent::StyleChange: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3749 |
case QEvent::AccessibilityHelp: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3750 |
case QEvent::AccessibilityDescription: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3751 |
case QEvent::GraphicsSceneDragEnter: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3752 |
case QEvent::GraphicsSceneDragMove: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3753 |
case QEvent::GraphicsSceneDragLeave: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3754 |
case QEvent::GraphicsSceneDrop: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3755 |
case QEvent::DynamicPropertyChange: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3756 |
case QEvent::NetworkReplyUpdated: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3757 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3758 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3759 |
if (receiver->isWidgetType()) { |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3760 |
if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3761 |
return true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3762 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3763 |
// a special case for events that go to QGesture objects. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3764 |
// We pass the object to the gesture manager and it'll figure |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3765 |
// out if it's QGesture or not. |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3766 |
if (d->gestureManager->filterEvent(receiver, e)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3767 |
return true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3768 |
} |
0 | 3769 |
} |
3770 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
3771 |
#endif // QT_NO_GESTURES |
0 | 3772 |
|
3773 |
// User input and window activation makes tooltips sleep |
|
3774 |
switch (e->type()) { |
|
3775 |
case QEvent::Wheel: |
|
3776 |
case QEvent::ActivationChange: |
|
3777 |
case QEvent::KeyPress: |
|
3778 |
case QEvent::KeyRelease: |
|
3779 |
case QEvent::FocusOut: |
|
3780 |
case QEvent::FocusIn: |
|
3781 |
case QEvent::MouseButtonPress: |
|
3782 |
case QEvent::MouseButtonRelease: |
|
3783 |
case QEvent::MouseButtonDblClick: |
|
3784 |
d->toolTipFallAsleep.stop(); |
|
3785 |
// fall-through |
|
3786 |
case QEvent::Leave: |
|
3787 |
d->toolTipWakeUp.stop(); |
|
3788 |
default: |
|
3789 |
break; |
|
3790 |
} |
|
3791 |
||
3792 |
bool res = false; |
|
3793 |
if (!receiver->isWidgetType()) { |
|
3794 |
res = d->notify_helper(receiver, e); |
|
3795 |
} else switch (e->type()) { |
|
3796 |
#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT) |
|
3797 |
case QEvent::Accel: |
|
3798 |
{ |
|
3799 |
if (d->use_compat()) { |
|
3800 |
QKeyEvent* key = static_cast<QKeyEvent*>(e); |
|
3801 |
res = d->notify_helper(receiver, e); |
|
3802 |
||
3803 |
if (!res && !key->isAccepted()) |
|
3804 |
res = d->qt_dispatchAccelEvent(static_cast<QWidget *>(receiver), key); |
|
3805 |
||
3806 |
// next lines are for compatibility with Qt <= 3.0.x: old |
|
3807 |
// QAccel was listening on toplevel widgets |
|
3808 |
if (!res && !key->isAccepted() && !static_cast<QWidget *>(receiver)->isWindow()) |
|
3809 |
res = d->notify_helper(static_cast<QWidget *>(receiver)->window(), e); |
|
3810 |
} |
|
3811 |
break; |
|
3812 |
} |
|
3813 |
#endif //QT3_SUPPORT && !QT_NO_SHORTCUT |
|
3814 |
case QEvent::ShortcutOverride: |
|
3815 |
case QEvent::KeyPress: |
|
3816 |
case QEvent::KeyRelease: |
|
3817 |
{ |
|
3818 |
bool isWidget = receiver->isWidgetType(); |
|
3819 |
bool isGraphicsWidget = false; |
|
3820 |
#ifndef QT_NO_GRAPHICSVIEW |
|
3821 |
isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver); |
|
3822 |
#endif |
|
3823 |
if (!isWidget && !isGraphicsWidget) { |
|
3824 |
res = d->notify_helper(receiver, e); |
|
3825 |
break; |
|
3826 |
} |
|
3827 |
||
3828 |
QKeyEvent* key = static_cast<QKeyEvent*>(e); |
|
3829 |
#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT) |
|
3830 |
if (d->use_compat() && d->qt_tryComposeUnicode(static_cast<QWidget*>(receiver), key)) |
|
3831 |
break; |
|
3832 |
#endif |
|
3833 |
if (key->type()==QEvent::KeyPress) { |
|
3834 |
#ifndef QT_NO_SHORTCUT |
|
3835 |
// Try looking for a Shortcut before sending key events |
|
3836 |
if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key))) |
|
3837 |
return res; |
|
3838 |
#endif |
|
3839 |
qt_in_tab_key_event = (key->key() == Qt::Key_Backtab |
|
3840 |
|| key->key() == Qt::Key_Tab |
|
3841 |
|| key->key() == Qt::Key_Left |
|
3842 |
|| key->key() == Qt::Key_Up |
|
3843 |
|| key->key() == Qt::Key_Right |
|
3844 |
|| key->key() == Qt::Key_Down); |
|
3845 |
} |
|
3846 |
bool def = key->isAccepted(); |
|
3847 |
QPointer<QObject> pr = receiver; |
|
3848 |
while (receiver) { |
|
3849 |
if (def) |
|
3850 |
key->accept(); |
|
3851 |
else |
|
3852 |
key->ignore(); |
|
3853 |
res = d->notify_helper(receiver, e); |
|
3854 |
QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0; |
|
3855 |
#ifndef QT_NO_GRAPHICSVIEW |
|
3856 |
QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0; |
|
3857 |
#endif |
|
3858 |
||
3859 |
if ((res && key->isAccepted()) |
|
3860 |
/* |
|
3861 |
QLineEdit will emit a signal on Key_Return, but |
|
3862 |
ignore the event, and sometimes the connected |
|
3863 |
slot deletes the QLineEdit (common in itemview |
|
3864 |
delegates), so we have to check if the widget |
|
3865 |
was destroyed even if the event was ignored (to |
|
3866 |
prevent a crash) |
|
3867 |
||
3868 |
note that we don't have to reset pw while |
|
3869 |
propagating (because the original receiver will |
|
3870 |
be destroyed if one of its ancestors is) |
|
3871 |
*/ |
|
3872 |
|| !pr |
|
3873 |
|| (isWidget && (w->isWindow() || !w->parentWidget())) |
|
3874 |
#ifndef QT_NO_GRAPHICSVIEW |
|
3875 |
|| (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget())) |
|
3876 |
#endif |
|
3877 |
) { |
|
3878 |
break; |
|
3879 |
} |
|
3880 |
||
3881 |
#ifndef QT_NO_GRAPHICSVIEW |
|
3882 |
receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget(); |
|
3883 |
#else |
|
3884 |
receiver = w->parentWidget(); |
|
3885 |
#endif |
|
3886 |
} |
|
3887 |
qt_in_tab_key_event = false; |
|
3888 |
} |
|
3889 |
break; |
|
3890 |
case QEvent::MouseButtonPress: |
|
3891 |
case QEvent::MouseButtonRelease: |
|
3892 |
case QEvent::MouseButtonDblClick: |
|
3893 |
case QEvent::MouseMove: |
|
3894 |
{ |
|
3895 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
3896 |
||
3897 |
QMouseEvent* mouse = static_cast<QMouseEvent*>(e); |
|
3898 |
QPoint relpos = mouse->pos(); |
|
3899 |
||
3900 |
if (e->spontaneous()) { |
|
3901 |
#ifndef QT_NO_IM |
|
3902 |
QInputContext *ic = w->inputContext(); |
|
3903 |
if (ic |
|
3904 |
&& w->testAttribute(Qt::WA_InputMethodEnabled) |
|
3905 |
&& ic->filterEvent(mouse)) |
|
3906 |
return true; |
|
3907 |
#endif |
|
3908 |
||
3909 |
if (e->type() == QEvent::MouseButtonPress) { |
|
3910 |
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, |
|
3911 |
Qt::ClickFocus, |
|
3912 |
Qt::MouseFocusReason); |
|
3913 |
} |
|
3914 |
||
3915 |
// ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms |
|
3916 |
// like Mac OS X (probably others too), can optimize their views by not |
|
3917 |
// dispatching mouse move events. We have attributes to control hover, |
|
3918 |
// and mouse tracking, but as long as we are deciding to implement this |
|
3919 |
// feature without choice of opting-in or out, you ALWAYS have to have |
|
3920 |
// tracking enabled. Therefore, the other properties give a false sense of |
|
3921 |
// performance enhancement. |
|
3922 |
if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) { |
|
3923 |
d->toolTipWidget = w; |
|
3924 |
d->toolTipPos = relpos; |
|
3925 |
d->toolTipGlobalPos = mouse->globalPos(); |
|
3926 |
d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this); |
|
3927 |
} |
|
3928 |
} |
|
3929 |
||
3930 |
bool eventAccepted = mouse->isAccepted(); |
|
3931 |
||
3932 |
QPointer<QWidget> pw = w; |
|
3933 |
while (w) { |
|
3934 |
QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(), |
|
3935 |
mouse->modifiers()); |
|
3936 |
me.spont = mouse->spontaneous(); |
|
3937 |
// throw away any mouse-tracking-only mouse events |
|
3938 |
if (!w->hasMouseTracking() |
|
3939 |
&& mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) { |
|
3940 |
// but still send them through all application event filters (normally done by notify_helper) |
|
3941 |
for (int i = 0; i < d->eventFilters.size(); ++i) { |
|
3942 |
register QObject *obj = d->eventFilters.at(i); |
|
3943 |
if (!obj) |
|
3944 |
continue; |
|
3945 |
if (obj->d_func()->threadData != w->d_func()->threadData) { |
|
3946 |
qWarning("QApplication: Object event filter cannot be in a different thread."); |
|
3947 |
continue; |
|
3948 |
} |
|
3949 |
if (obj->eventFilter(w, w == receiver ? mouse : &me)) |
|
3950 |
break; |
|
3951 |
} |
|
3952 |
res = true; |
|
3953 |
} else { |
|
3954 |
w->setAttribute(Qt::WA_NoMouseReplay, false); |
|
3955 |
res = d->notify_helper(w, w == receiver ? mouse : &me); |
|
3956 |
e->spont = false; |
|
3957 |
} |
|
3958 |
eventAccepted = (w == receiver ? mouse : &me)->isAccepted(); |
|
3959 |
if (res && eventAccepted) |
|
3960 |
break; |
|
3961 |
if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) |
|
3962 |
break; |
|
3963 |
relpos += w->pos(); |
|
3964 |
w = w->parentWidget(); |
|
3965 |
} |
|
3966 |
||
3967 |
mouse->setAccepted(eventAccepted); |
|
3968 |
||
3969 |
if (e->type() == QEvent::MouseMove) { |
|
3970 |
if (!pw) |
|
3971 |
break; |
|
3972 |
||
3973 |
w = static_cast<QWidget *>(receiver); |
|
3974 |
relpos = mouse->pos(); |
|
3975 |
QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos); |
|
3976 |
while (w) { |
|
3977 |
if (w->testAttribute(Qt::WA_Hover) && |
|
3978 |
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { |
|
3979 |
QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff); |
|
3980 |
d->notify_helper(w, &he); |
|
3981 |
} |
|
3982 |
if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) |
|
3983 |
break; |
|
3984 |
relpos += w->pos(); |
|
3985 |
w = w->parentWidget(); |
|
3986 |
} |
|
3987 |
} |
|
3988 |
||
3989 |
d->hoverGlobalPos = mouse->globalPos(); |
|
3990 |
} |
|
3991 |
break; |
|
3992 |
#ifndef QT_NO_WHEELEVENT |
|
3993 |
case QEvent::Wheel: |
|
3994 |
{ |
|
3995 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
3996 |
QWheelEvent* wheel = static_cast<QWheelEvent*>(e); |
|
3997 |
QPoint relpos = wheel->pos(); |
|
3998 |
bool eventAccepted = wheel->isAccepted(); |
|
3999 |
||
4000 |
if (e->spontaneous()) { |
|
4001 |
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, |
|
4002 |
Qt::WheelFocus, |
|
4003 |
Qt::MouseFocusReason); |
|
4004 |
} |
|
4005 |
||
4006 |
while (w) { |
|
4007 |
QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(), |
|
4008 |
wheel->modifiers(), wheel->orientation()); |
|
4009 |
we.spont = wheel->spontaneous(); |
|
4010 |
res = d->notify_helper(w, w == receiver ? wheel : &we); |
|
4011 |
eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted(); |
|
4012 |
e->spont = false; |
|
4013 |
if ((res && eventAccepted) |
|
4014 |
|| w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) |
|
4015 |
break; |
|
4016 |
||
4017 |
relpos += w->pos(); |
|
4018 |
w = w->parentWidget(); |
|
4019 |
} |
|
4020 |
wheel->setAccepted(eventAccepted); |
|
4021 |
} |
|
4022 |
break; |
|
4023 |
#endif |
|
4024 |
#ifndef QT_NO_CONTEXTMENU |
|
4025 |
case QEvent::ContextMenu: |
|
4026 |
{ |
|
4027 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
4028 |
QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e); |
|
4029 |
QPoint relpos = context->pos(); |
|
4030 |
bool eventAccepted = context->isAccepted(); |
|
4031 |
while (w) { |
|
4032 |
QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers()); |
|
4033 |
ce.spont = e->spontaneous(); |
|
4034 |
res = d->notify_helper(w, w == receiver ? context : &ce); |
|
4035 |
eventAccepted = ((w == receiver) ? context : &ce)->isAccepted(); |
|
4036 |
e->spont = false; |
|
4037 |
||
4038 |
if ((res && eventAccepted) |
|
4039 |
|| w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) |
|
4040 |
break; |
|
4041 |
||
4042 |
relpos += w->pos(); |
|
4043 |
w = w->parentWidget(); |
|
4044 |
} |
|
4045 |
context->setAccepted(eventAccepted); |
|
4046 |
} |
|
4047 |
break; |
|
4048 |
#endif // QT_NO_CONTEXTMENU |
|
4049 |
#ifndef QT_NO_TABLETEVENT |
|
4050 |
case QEvent::TabletMove: |
|
4051 |
case QEvent::TabletPress: |
|
4052 |
case QEvent::TabletRelease: |
|
4053 |
{ |
|
4054 |
QWidget *w = static_cast<QWidget *>(receiver); |
|
4055 |
QTabletEvent *tablet = static_cast<QTabletEvent*>(e); |
|
4056 |
QPoint relpos = tablet->pos(); |
|
4057 |
bool eventAccepted = tablet->isAccepted(); |
|
4058 |
while (w) { |
|
4059 |
QTabletEvent te(tablet->type(), relpos, tablet->globalPos(), |
|
4060 |
tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(), |
|
4061 |
tablet->pressure(), tablet->xTilt(), tablet->yTilt(), |
|
4062 |
tablet->tangentialPressure(), tablet->rotation(), tablet->z(), |
|
4063 |
tablet->modifiers(), tablet->uniqueId()); |
|
4064 |
te.spont = e->spontaneous(); |
|
4065 |
res = d->notify_helper(w, w == receiver ? tablet : &te); |
|
4066 |
eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted(); |
|
4067 |
e->spont = false; |
|
4068 |
if ((res && eventAccepted) |
|
4069 |
|| w->isWindow() |
|
4070 |
|| w->testAttribute(Qt::WA_NoMousePropagation)) |
|
4071 |
break; |
|
4072 |
||
4073 |
relpos += w->pos(); |
|
4074 |
w = w->parentWidget(); |
|
4075 |
} |
|
4076 |
tablet->setAccepted(eventAccepted); |
|
4077 |
qt_tabletChokeMouse = tablet->isAccepted(); |
|
4078 |
} |
|
4079 |
break; |
|
4080 |
#endif // QT_NO_TABLETEVENT |
|
4081 |
||
4082 |
#if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS) |
|
4083 |
case QEvent::ToolTip: |
|
4084 |
case QEvent::WhatsThis: |
|
4085 |
case QEvent::QueryWhatsThis: |
|
4086 |
{ |
|
4087 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
4088 |
QHelpEvent *help = static_cast<QHelpEvent*>(e); |
|
4089 |
QPoint relpos = help->pos(); |
|
4090 |
bool eventAccepted = help->isAccepted(); |
|
4091 |
while (w) { |
|
4092 |
QHelpEvent he(help->type(), relpos, help->globalPos()); |
|
4093 |
he.spont = e->spontaneous(); |
|
4094 |
res = d->notify_helper(w, w == receiver ? help : &he); |
|
4095 |
e->spont = false; |
|
4096 |
eventAccepted = (w == receiver ? help : &he)->isAccepted(); |
|
4097 |
if ((res && eventAccepted) || w->isWindow()) |
|
4098 |
break; |
|
4099 |
||
4100 |
relpos += w->pos(); |
|
4101 |
w = w->parentWidget(); |
|
4102 |
} |
|
4103 |
help->setAccepted(eventAccepted); |
|
4104 |
} |
|
4105 |
break; |
|
4106 |
#endif |
|
4107 |
#if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS) |
|
4108 |
case QEvent::StatusTip: |
|
4109 |
case QEvent::WhatsThisClicked: |
|
4110 |
{ |
|
4111 |
QWidget *w = static_cast<QWidget *>(receiver); |
|
4112 |
while (w) { |
|
4113 |
res = d->notify_helper(w, e); |
|
4114 |
if ((res && e->isAccepted()) || w->isWindow()) |
|
4115 |
break; |
|
4116 |
w = w->parentWidget(); |
|
4117 |
} |
|
4118 |
} |
|
4119 |
break; |
|
4120 |
#endif |
|
4121 |
||
4122 |
#ifndef QT_NO_DRAGANDDROP |
|
4123 |
case QEvent::DragEnter: { |
|
4124 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
4125 |
QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e); |
|
4126 |
#ifdef Q_WS_MAC |
|
4127 |
// HIView has a slight difference in how it delivers events to children and parents |
|
4128 |
// It will not give a leave to a child's parent when it enters a child. |
|
4129 |
QWidget *currentTarget = QDragManager::self()->currentTarget(); |
|
4130 |
if (currentTarget) { |
|
4131 |
// Assume currentTarget did not get a leave |
|
4132 |
QDragLeaveEvent event; |
|
4133 |
QApplication::sendEvent(currentTarget, &event); |
|
4134 |
} |
|
4135 |
#endif |
|
4136 |
#ifndef QT_NO_GRAPHICSVIEW |
|
4137 |
// QGraphicsProxyWidget handles its own propagation, |
|
4138 |
// and we must not change QDragManagers currentTarget. |
|
4139 |
QWExtra *extra = w->window()->d_func()->extra; |
|
4140 |
if (extra && extra->proxyWidget) { |
|
4141 |
res = d->notify_helper(w, dragEvent); |
|
4142 |
break; |
|
4143 |
} |
|
4144 |
#endif |
|
4145 |
while (w) { |
|
4146 |
if (w->isEnabled() && w->acceptDrops()) { |
|
4147 |
res = d->notify_helper(w, dragEvent); |
|
4148 |
if (res && dragEvent->isAccepted()) { |
|
4149 |
QDragManager::self()->setCurrentTarget(w); |
|
4150 |
break; |
|
4151 |
} |
|
4152 |
} |
|
4153 |
if (w->isWindow()) |
|
4154 |
break; |
|
4155 |
dragEvent->p = w->mapToParent(dragEvent->p); |
|
4156 |
w = w->parentWidget(); |
|
4157 |
} |
|
4158 |
} |
|
4159 |
break; |
|
4160 |
case QEvent::DragMove: |
|
4161 |
case QEvent::Drop: |
|
4162 |
case QEvent::DragLeave: { |
|
4163 |
QWidget* w = static_cast<QWidget *>(receiver); |
|
4164 |
#ifndef QT_NO_GRAPHICSVIEW |
|
4165 |
// QGraphicsProxyWidget handles its own propagation, |
|
4166 |
// and we must not change QDragManagers currentTarget. |
|
4167 |
QWExtra *extra = w->window()->d_func()->extra; |
|
4168 |
bool isProxyWidget = extra && extra->proxyWidget; |
|
4169 |
if (!isProxyWidget) |
|
4170 |
#endif |
|
4171 |
w = QDragManager::self()->currentTarget(); |
|
4172 |
||
4173 |
if (!w) { |
|
4174 |
#ifdef Q_WS_MAC |
|
4175 |
// HIView has a slight difference in how it delivers events to children and parents |
|
4176 |
// It will not give an enter to a child's parent when it leaves the child. |
|
4177 |
if (e->type() == QEvent::DragLeave) |
|
4178 |
break; |
|
4179 |
// Assume that w did not get an enter. |
|
4180 |
QDropEvent *dropEvent = static_cast<QDropEvent *>(e); |
|
4181 |
QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(), |
|
4182 |
dropEvent->mimeData(), dropEvent->mouseButtons(), |
|
4183 |
dropEvent->keyboardModifiers()); |
|
4184 |
QApplication::sendEvent(receiver, &dragEnterEvent); |
|
4185 |
w = QDragManager::self()->currentTarget(); |
|
4186 |
if (!w) |
|
4187 |
#endif |
|
4188 |
break; |
|
4189 |
} |
|
4190 |
if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { |
|
4191 |
QDropEvent *dragEvent = static_cast<QDropEvent *>(e); |
|
4192 |
QWidget *origReciver = static_cast<QWidget *>(receiver); |
|
4193 |
while (origReciver && w != origReciver) { |
|
4194 |
dragEvent->p = origReciver->mapToParent(dragEvent->p); |
|
4195 |
origReciver = origReciver->parentWidget(); |
|
4196 |
} |
|
4197 |
} |
|
4198 |
res = d->notify_helper(w, e); |
|
4199 |
if (e->type() != QEvent::DragMove |
|
4200 |
#ifndef QT_NO_GRAPHICSVIEW |
|
4201 |
&& !isProxyWidget |
|
4202 |
#endif |
|
4203 |
) |
|
4204 |
QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop); |
|
4205 |
} |
|
4206 |
break; |
|
4207 |
#endif |
|
4208 |
case QEvent::TouchBegin: |
|
4209 |
// Note: TouchUpdate and TouchEnd events are never propagated |
|
4210 |
{ |
|
4211 |
QWidget *widget = static_cast<QWidget *>(receiver); |
|
4212 |
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); |
|
4213 |
bool eventAccepted = touchEvent->isAccepted(); |
|
4214 |
if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) { |
|
4215 |
// give the widget focus if the focus policy allows it |
|
4216 |
QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, |
|
4217 |
Qt::ClickFocus, |
|
4218 |
Qt::MouseFocusReason); |
|
4219 |
} |
|
4220 |
||
4221 |
while (widget) { |
|
4222 |
// first, try to deliver the touch event |
|
4223 |
bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); |
|
4224 |
touchEvent->setWidget(widget); |
|
4225 |
touchEvent->setAccepted(acceptTouchEvents); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4226 |
QWeakPointer<QWidget> p = widget; |
0 | 4227 |
res = acceptTouchEvents && d->notify_helper(widget, touchEvent); |
4228 |
eventAccepted = touchEvent->isAccepted(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4229 |
if (p.isNull()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4230 |
// widget was deleted |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4231 |
widget = 0; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4232 |
} else { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4233 |
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4234 |
} |
0 | 4235 |
touchEvent->spont = false; |
4236 |
if (res && eventAccepted) { |
|
4237 |
// the first widget to accept the TouchBegin gets an implicit grab. |
|
4238 |
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { |
|
4239 |
const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); |
|
4240 |
d->widgetForTouchPointId[touchPoint.id()] = widget; |
|
4241 |
} |
|
4242 |
break; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4243 |
} else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { |
0 | 4244 |
break; |
4245 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4246 |
QPoint offset = widget->pos(); |
0 | 4247 |
widget = widget->parentWidget(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4248 |
touchEvent->setWidget(widget); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4249 |
for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4250 |
QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4251 |
QRectF rect = pt.rect(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4252 |
rect.moveCenter(offset); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4253 |
pt.d->rect = rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4254 |
pt.d->startPos = pt.startPos() + offset; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4255 |
pt.d->lastPos = pt.lastPos() + offset; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4256 |
} |
0 | 4257 |
} |
4258 |
||
4259 |
touchEvent->setAccepted(eventAccepted); |
|
4260 |
break; |
|
4261 |
} |
|
4262 |
case QEvent::RequestSoftwareInputPanel: |
|
4263 |
case QEvent::CloseSoftwareInputPanel: |
|
4264 |
#ifndef QT_NO_IM |
|
4265 |
if (receiver->isWidgetType()) { |
|
4266 |
QWidget *w = static_cast<QWidget *>(receiver); |
|
4267 |
QInputContext *ic = w->inputContext(); |
|
4268 |
if (ic && ic->filterEvent(e)) { |
|
4269 |
break; |
|
4270 |
} |
|
4271 |
} |
|
4272 |
#endif |
|
4273 |
res = d->notify_helper(receiver, e); |
|
4274 |
break; |
|
4275 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
4276 |
#ifndef QT_NO_GESTURES |
0 | 4277 |
case QEvent::NativeGesture: |
4278 |
{ |
|
4279 |
// only propagate the first gesture event (after the GID_BEGIN) |
|
4280 |
QWidget *w = static_cast<QWidget *>(receiver); |
|
4281 |
while (w) { |
|
4282 |
e->ignore(); |
|
4283 |
res = d->notify_helper(w, e); |
|
4284 |
if ((res && e->isAccepted()) || w->isWindow()) |
|
4285 |
break; |
|
4286 |
w = w->parentWidget(); |
|
4287 |
} |
|
4288 |
break; |
|
4289 |
} |
|
4290 |
case QEvent::Gesture: |
|
4291 |
case QEvent::GestureOverride: |
|
4292 |
{ |
|
4293 |
if (receiver->isWidgetType()) { |
|
4294 |
QWidget *w = static_cast<QWidget *>(receiver); |
|
4295 |
QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4296 |
QList<QGesture *> allGestures = gestureEvent->gestures(); |
0 | 4297 |
|
4298 |
bool eventAccepted = gestureEvent->isAccepted(); |
|
4299 |
bool wasAccepted = eventAccepted; |
|
4300 |
while (w) { |
|
4301 |
// send only gestures the widget expects |
|
4302 |
QList<QGesture *> gestures; |
|
4303 |
QWidgetPrivate *wd = w->d_func(); |
|
4304 |
for (int i = 0; i < allGestures.size();) { |
|
4305 |
QGesture *g = allGestures.at(i); |
|
4306 |
Qt::GestureType type = g->gestureType(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4307 |
QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit = |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4308 |
wd->gestureContext.find(type); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4309 |
bool deliver = contextit != wd->gestureContext.end() && |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4310 |
(g->state() == Qt::GestureStarted || w == receiver || |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4311 |
(contextit.value() & Qt::ReceivePartialGestures)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4312 |
if (deliver) { |
0 | 4313 |
allGestures.removeAt(i); |
4314 |
gestures.append(g); |
|
4315 |
} else { |
|
4316 |
++i; |
|
4317 |
} |
|
4318 |
} |
|
4319 |
if (!gestures.isEmpty()) { // we have gestures for this w |
|
4320 |
QGestureEvent ge(gestures); |
|
4321 |
ge.t = gestureEvent->t; |
|
4322 |
ge.spont = gestureEvent->spont; |
|
4323 |
ge.m_accept = wasAccepted; |
|
4324 |
ge.d_func()->accepted = gestureEvent->d_func()->accepted; |
|
4325 |
res = d->notify_helper(w, &ge); |
|
4326 |
gestureEvent->spont = false; |
|
4327 |
eventAccepted = ge.isAccepted(); |
|
4328 |
for (int i = 0; i < gestures.size(); ++i) { |
|
4329 |
QGesture *g = gestures.at(i); |
|
4330 |
if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) { |
|
4331 |
// if the gesture was accepted, mark the target widget for it |
|
4332 |
gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; |
|
4333 |
gestureEvent->setAccepted(g, true); |
|
4334 |
} else if (!eventAccepted && !ge.isAccepted(g)) { |
|
4335 |
// if the gesture was explicitly ignored by the application, |
|
4336 |
// put it back so a parent can get it |
|
4337 |
allGestures.append(g); |
|
4338 |
} |
|
4339 |
} |
|
4340 |
} |
|
4341 |
if (allGestures.isEmpty()) // everything delivered |
|
4342 |
break; |
|
4343 |
if (w->isWindow()) |
|
4344 |
break; |
|
4345 |
w = w->parentWidget(); |
|
4346 |
} |
|
4347 |
foreach (QGesture *g, allGestures) |
|
4348 |
gestureEvent->setAccepted(g, false); |
|
4349 |
gestureEvent->m_accept = false; // to make sure we check individual gestures |
|
4350 |
} else { |
|
4351 |
res = d->notify_helper(receiver, e); |
|
4352 |
} |
|
4353 |
break; |
|
4354 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
4355 |
#endif // QT_NO_GESTURES |
0 | 4356 |
default: |
4357 |
res = d->notify_helper(receiver, e); |
|
4358 |
break; |
|
4359 |
} |
|
4360 |
||
4361 |
return res; |
|
4362 |
} |
|
4363 |
||
4364 |
bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) |
|
4365 |
{ |
|
4366 |
// send to all application event filters |
|
4367 |
if (sendThroughApplicationEventFilters(receiver, e)) |
|
4368 |
return true; |
|
4369 |
||
4370 |
if (receiver->isWidgetType()) { |
|
4371 |
QWidget *widget = static_cast<QWidget *>(receiver); |
|
4372 |
||
4373 |
#if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR)) |
|
4374 |
// toggle HasMouse widget state on enter and leave |
|
4375 |
if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) && |
|
4376 |
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window())) |
|
4377 |
widget->setAttribute(Qt::WA_UnderMouse, true); |
|
4378 |
else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave) |
|
4379 |
widget->setAttribute(Qt::WA_UnderMouse, false); |
|
4380 |
#endif |
|
4381 |
||
4382 |
if (QLayout *layout=widget->d_func()->layout) { |
|
4383 |
layout->widgetEvent(e); |
|
4384 |
} |
|
4385 |
} |
|
4386 |
||
4387 |
// send to all receiver event filters |
|
4388 |
if (sendThroughObjectEventFilters(receiver, e)) |
|
4389 |
return true; |
|
4390 |
||
4391 |
// deliver the event |
|
4392 |
bool consumed = receiver->event(e); |
|
4393 |
e->spont = false; |
|
4394 |
return consumed; |
|
4395 |
} |
|
4396 |
||
4397 |
||
4398 |
/*! |
|
4399 |
\class QSessionManager |
|
4400 |
\brief The QSessionManager class provides access to the session manager. |
|
4401 |
||
4402 |
A session manager in a desktop environment (in which Qt GUI applications |
|
4403 |
live) keeps track of a session, which is a group of running applications, |
|
4404 |
each of which has a particular state. The state of an application contains |
|
4405 |
(most notably) the documents the application has open and the position and |
|
4406 |
size of its windows. |
|
4407 |
||
4408 |
The session manager is used to save the session, e.g., when the machine is |
|
4409 |
shut down, and to restore a session, e.g., when the machine is started up. |
|
4410 |
We recommend that you use QSettings to save an application's settings, |
|
4411 |
for example, window positions, recently used files, etc. When the |
|
4412 |
application is restarted by the session manager, you can restore the |
|
4413 |
settings. |
|
4414 |
||
4415 |
QSessionManager provides an interface between the application and the |
|
4416 |
session manager so that the program can work well with the session manager. |
|
4417 |
In Qt, session management requests for action are handled by the two |
|
4418 |
virtual functions QApplication::commitData() and QApplication::saveState(). |
|
4419 |
Both provide a reference to a session manager object as argument, to allow |
|
4420 |
the application to communicate with the session manager. The session |
|
4421 |
manager can only be accessed through these functions. |
|
4422 |
||
4423 |
No user interaction is possible \e unless the application gets explicit |
|
4424 |
permission from the session manager. You ask for permission by calling |
|
4425 |
allowsInteraction() or, if it is really urgent, allowsErrorInteraction(). |
|
4426 |
Qt does not enforce this, but the session manager may. |
|
4427 |
||
4428 |
You can try to abort the shutdown process by calling cancel(). The default |
|
4429 |
commitData() function does this if some top-level window rejected its |
|
4430 |
closeEvent(). |
|
4431 |
||
4432 |
For sophisticated session managers provided on Unix/X11, QSessionManager |
|
4433 |
offers further possibilities to fine-tune an application's session |
|
4434 |
management behavior: setRestartCommand(), setDiscardCommand(), |
|
4435 |
setRestartHint(), setProperty(), requestPhase2(). See the respective |
|
4436 |
function descriptions for further details. |
|
4437 |
||
4438 |
\sa QApplication, {Session Management} |
|
4439 |
*/ |
|
4440 |
||
4441 |
/*! \enum QSessionManager::RestartHint |
|
4442 |
||
4443 |
This enum type defines the circumstances under which this application wants |
|
4444 |
to be restarted by the session manager. The current values are: |
|
4445 |
||
4446 |
\value RestartIfRunning If the application is still running when the |
|
4447 |
session is shut down, it wants to be restarted |
|
4448 |
at the start of the next session. |
|
4449 |
||
4450 |
\value RestartAnyway The application wants to be started at the |
|
4451 |
start of the next session, no matter what. |
|
4452 |
(This is useful for utilities that run just |
|
4453 |
after startup and then quit.) |
|
4454 |
||
4455 |
\value RestartImmediately The application wants to be started immediately |
|
4456 |
whenever it is not running. |
|
4457 |
||
4458 |
\value RestartNever The application does not want to be restarted |
|
4459 |
automatically. |
|
4460 |
||
4461 |
The default hint is \c RestartIfRunning. |
|
4462 |
*/ |
|
4463 |
||
4464 |
||
4465 |
/*! |
|
4466 |
\fn QString QSessionManager::sessionId() const |
|
4467 |
||
4468 |
Returns the identifier of the current session. |
|
4469 |
||
4470 |
If the application has been restored from an earlier session, this |
|
4471 |
identifier is the same as it was in the earlier session. |
|
4472 |
||
4473 |
\sa sessionKey(), QApplication::sessionId() |
|
4474 |
*/ |
|
4475 |
||
4476 |
/*! |
|
4477 |
\fn QString QSessionManager::sessionKey() const |
|
4478 |
||
4479 |
Returns the session key in the current session. |
|
4480 |
||
4481 |
If the application has been restored from an earlier session, this key is |
|
4482 |
the same as it was when the previous session ended. |
|
4483 |
||
4484 |
The session key changes with every call of commitData() or saveState(). |
|
4485 |
||
4486 |
\sa sessionId(), QApplication::sessionKey() |
|
4487 |
*/ |
|
4488 |
||
4489 |
/*! |
|
4490 |
\fn void* QSessionManager::handle() const |
|
4491 |
||
4492 |
\internal |
|
4493 |
*/ |
|
4494 |
||
4495 |
/*! |
|
4496 |
\fn bool QSessionManager::allowsInteraction() |
|
4497 |
||
4498 |
Asks the session manager for permission to interact with the user. Returns |
|
4499 |
true if interaction is permitted; otherwise returns false. |
|
4500 |
||
4501 |
The rationale behind this mechanism is to make it possible to synchronize |
|
4502 |
user interaction during a shutdown. Advanced session managers may ask all |
|
4503 |
applications simultaneously to commit their data, resulting in a much |
|
4504 |
faster shutdown. |
|
4505 |
||
4506 |
When the interaction is completed we strongly recommend releasing the user |
|
4507 |
interaction semaphore with a call to release(). This way, other |
|
4508 |
applications may get the chance to interact with the user while your |
|
4509 |
application is still busy saving data. (The semaphore is implicitly |
|
4510 |
released when the application exits.) |
|
4511 |
||
4512 |
If the user decides to cancel the shutdown process during the interaction |
|
4513 |
phase, you must tell the session manager that this has happened by calling |
|
4514 |
cancel(). |
|
4515 |
||
4516 |
Here's an example of how an application's QApplication::commitData() might |
|
4517 |
be implemented: |
|
4518 |
||
4519 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8 |
|
4520 |
||
4521 |
If an error occurred within the application while saving its data, you may |
|
4522 |
want to try allowsErrorInteraction() instead. |
|
4523 |
||
4524 |
\sa QApplication::commitData(), release(), cancel() |
|
4525 |
*/ |
|
4526 |
||
4527 |
||
4528 |
/*! |
|
4529 |
\fn bool QSessionManager::allowsErrorInteraction() |
|
4530 |
||
4531 |
Returns true if error interaction is permitted; otherwise returns false. |
|
4532 |
||
4533 |
This is similar to allowsInteraction(), but also enables the application to |
|
4534 |
tell the user about any errors that occur. Session managers may give error |
|
4535 |
interaction requests higher priority, which means that it is more likely |
|
4536 |
that an error interaction is permitted. However, you are still not |
|
4537 |
guaranteed that the session manager will allow interaction. |
|
4538 |
||
4539 |
\sa allowsInteraction(), release(), cancel() |
|
4540 |
*/ |
|
4541 |
||
4542 |
/*! |
|
4543 |
\fn void QSessionManager::release() |
|
4544 |
||
4545 |
Releases the session manager's interaction semaphore after an interaction |
|
4546 |
phase. |
|
4547 |
||
4548 |
\sa allowsInteraction(), allowsErrorInteraction() |
|
4549 |
*/ |
|
4550 |
||
4551 |
/*! |
|
4552 |
\fn void QSessionManager::cancel() |
|
4553 |
||
4554 |
Tells the session manager to cancel the shutdown process. Applications |
|
4555 |
should not call this function without asking the user first. |
|
4556 |
||
4557 |
\sa allowsInteraction(), allowsErrorInteraction() |
|
4558 |
*/ |
|
4559 |
||
4560 |
/*! |
|
4561 |
\fn void QSessionManager::setRestartHint(RestartHint hint) |
|
4562 |
||
4563 |
Sets the application's restart hint to \a hint. On application startup, the |
|
4564 |
hint is set to \c RestartIfRunning. |
|
4565 |
||
4566 |
\note These flags are only hints, a session manager may or may not respect |
|
4567 |
them. |
|
4568 |
||
4569 |
We recommend setting the restart hint in QApplication::saveState() because |
|
4570 |
most session managers perform a checkpoint shortly after an application's |
|
4571 |
startup. |
|
4572 |
||
4573 |
\sa restartHint() |
|
4574 |
*/ |
|
4575 |
||
4576 |
/*! |
|
4577 |
\fn QSessionManager::RestartHint QSessionManager::restartHint() const |
|
4578 |
||
4579 |
Returns the application's current restart hint. The default is |
|
4580 |
\c RestartIfRunning. |
|
4581 |
||
4582 |
\sa setRestartHint() |
|
4583 |
*/ |
|
4584 |
||
4585 |
/*! |
|
4586 |
\fn void QSessionManager::setRestartCommand(const QStringList& command) |
|
4587 |
||
4588 |
If the session manager is capable of restoring sessions it will execute |
|
4589 |
\a command in order to restore the application. The command defaults to |
|
4590 |
||
4591 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9 |
|
4592 |
||
4593 |
The \c -session option is mandatory; otherwise QApplication cannot tell |
|
4594 |
whether it has been restored or what the current session identifier is. |
|
4595 |
See QApplication::isSessionRestored() and QApplication::sessionId() for |
|
4596 |
details. |
|
4597 |
||
4598 |
If your application is very simple, it may be possible to store the entire |
|
4599 |
application state in additional command line options. This is usually a |
|
4600 |
very bad idea because command lines are often limited to a few hundred |
|
4601 |
bytes. Instead, use QSettings, temporary files, or a database for this |
|
4602 |
purpose. By marking the data with the unique sessionId(), you will be able |
|
4603 |
to restore the application in a future session. |
|
4604 |
||
4605 |
\sa restartCommand(), setDiscardCommand(), setRestartHint() |
|
4606 |
*/ |
|
4607 |
||
4608 |
/*! |
|
4609 |
\fn QStringList QSessionManager::restartCommand() const |
|
4610 |
||
4611 |
Returns the currently set restart command. |
|
4612 |
||
4613 |
To iterate over the list, you can use the \l foreach pseudo-keyword: |
|
4614 |
||
4615 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10 |
|
4616 |
||
4617 |
\sa setRestartCommand(), restartHint() |
|
4618 |
*/ |
|
4619 |
||
4620 |
/*! |
|
4621 |
\fn void QSessionManager::setDiscardCommand(const QStringList& list) |
|
4622 |
||
4623 |
Sets the discard command to the given \a list. |
|
4624 |
||
4625 |
\sa discardCommand(), setRestartCommand() |
|
4626 |
*/ |
|
4627 |
||
4628 |
||
4629 |
/*! |
|
4630 |
\fn QStringList QSessionManager::discardCommand() const |
|
4631 |
||
4632 |
Returns the currently set discard command. |
|
4633 |
||
4634 |
To iterate over the list, you can use the \l foreach pseudo-keyword: |
|
4635 |
||
4636 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11 |
|
4637 |
||
4638 |
\sa setDiscardCommand(), restartCommand(), setRestartCommand() |
|
4639 |
*/ |
|
4640 |
||
4641 |
/*! |
|
4642 |
\fn void QSessionManager::setManagerProperty(const QString &name, const QString &value) |
|
4643 |
\overload |
|
4644 |
||
4645 |
Low-level write access to the application's identification and state |
|
4646 |
records are kept in the session manager. |
|
4647 |
||
4648 |
The property called \a name has its value set to the string \a value. |
|
4649 |
*/ |
|
4650 |
||
4651 |
/*! |
|
4652 |
\fn void QSessionManager::setManagerProperty(const QString& name, |
|
4653 |
const QStringList& value) |
|
4654 |
||
4655 |
Low-level write access to the application's identification and state record |
|
4656 |
are kept in the session manager. |
|
4657 |
||
4658 |
The property called \a name has its value set to the string list \a value. |
|
4659 |
*/ |
|
4660 |
||
4661 |
/*! |
|
4662 |
\fn bool QSessionManager::isPhase2() const |
|
4663 |
||
4664 |
Returns true if the session manager is currently performing a second |
|
4665 |
session management phase; otherwise returns false. |
|
4666 |
||
4667 |
\sa requestPhase2() |
|
4668 |
*/ |
|
4669 |
||
4670 |
/*! |
|
4671 |
\fn void QSessionManager::requestPhase2() |
|
4672 |
||
4673 |
Requests a second session management phase for the application. The |
|
4674 |
application may then return immediately from the QApplication::commitData() |
|
4675 |
or QApplication::saveState() function, and they will be called again once |
|
4676 |
most or all other applications have finished their session management. |
|
4677 |
||
4678 |
The two phases are useful for applications such as the X11 window manager |
|
4679 |
that need to store information about another application's windows and |
|
4680 |
therefore have to wait until these applications have completed their |
|
4681 |
respective session management tasks. |
|
4682 |
||
4683 |
\note If another application has requested a second phase it may get called |
|
4684 |
before, simultaneously with, or after your application's second phase. |
|
4685 |
||
4686 |
\sa isPhase2() |
|
4687 |
*/ |
|
4688 |
||
4689 |
/***************************************************************************** |
|
4690 |
Stubbed session management support |
|
4691 |
*****************************************************************************/ |
|
4692 |
#ifndef QT_NO_SESSIONMANAGER |
|
4693 |
#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS) |
|
4694 |
||
4695 |
#if defined(Q_OS_WINCE) |
|
4696 |
HRESULT qt_CoCreateGuid(GUID* guid) |
|
4697 |
{ |
|
4698 |
// We will use the following information to create the GUID |
|
4699 |
// 1. absolute path to application |
|
4700 |
wchar_t tempFilename[MAX_PATH]; |
|
4701 |
if (!GetModuleFileName(0, tempFilename, MAX_PATH)) |
|
4702 |
return S_FALSE; |
|
4703 |
unsigned int hash = qHash(QString::fromWCharArray(tempFilename)); |
|
4704 |
guid->Data1 = hash; |
|
4705 |
// 2. creation time of file |
|
4706 |
QFileInfo info(QString::fromWCharArray(tempFilename)); |
|
4707 |
guid->Data2 = qHash(info.created().toTime_t()); |
|
4708 |
// 3. current system time |
|
4709 |
guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t()); |
|
4710 |
return S_OK; |
|
4711 |
} |
|
4712 |
#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID) |
|
4713 |
#define CoCreateGuid qt_CoCreateGuid |
|
4714 |
#endif |
|
4715 |
||
4716 |
#endif |
|
4717 |
||
4718 |
class QSessionManagerPrivate : public QObjectPrivate |
|
4719 |
{ |
|
4720 |
public: |
|
4721 |
QStringList restartCommand; |
|
4722 |
QStringList discardCommand; |
|
4723 |
QString sessionId; |
|
4724 |
QString sessionKey; |
|
4725 |
QSessionManager::RestartHint restartHint; |
|
4726 |
}; |
|
4727 |
||
4728 |
QSessionManager* qt_session_manager_self = 0; |
|
4729 |
QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key) |
|
4730 |
: QObject(*new QSessionManagerPrivate, app) |
|
4731 |
{ |
|
4732 |
Q_D(QSessionManager); |
|
4733 |
setObjectName(QLatin1String("qt_sessionmanager")); |
|
4734 |
qt_session_manager_self = this; |
|
4735 |
#if defined(Q_WS_WIN) |
|
4736 |
wchar_t guidstr[40]; |
|
4737 |
GUID guid; |
|
4738 |
CoCreateGuid(&guid); |
|
4739 |
StringFromGUID2(guid, guidstr, 40); |
|
4740 |
id = QString::fromWCharArray(guidstr); |
|
4741 |
CoCreateGuid(&guid); |
|
4742 |
StringFromGUID2(guid, guidstr, 40); |
|
4743 |
key = QString::fromWCharArray(guidstr); |
|
4744 |
#endif |
|
4745 |
d->sessionId = id; |
|
4746 |
d->sessionKey = key; |
|
4747 |
d->restartHint = RestartIfRunning; |
|
4748 |
} |
|
4749 |
||
4750 |
QSessionManager::~QSessionManager() |
|
4751 |
{ |
|
4752 |
qt_session_manager_self = 0; |
|
4753 |
} |
|
4754 |
||
4755 |
QString QSessionManager::sessionId() const |
|
4756 |
{ |
|
4757 |
Q_D(const QSessionManager); |
|
4758 |
return d->sessionId; |
|
4759 |
} |
|
4760 |
||
4761 |
QString QSessionManager::sessionKey() const |
|
4762 |
{ |
|
4763 |
Q_D(const QSessionManager); |
|
4764 |
return d->sessionKey; |
|
4765 |
} |
|
4766 |
||
4767 |
||
4768 |
#if defined(Q_WS_X11) || defined(Q_WS_MAC) |
|
4769 |
void* QSessionManager::handle() const |
|
4770 |
{ |
|
4771 |
return 0; |
|
4772 |
} |
|
4773 |
#endif |
|
4774 |
||
4775 |
#if !defined(Q_WS_WIN) |
|
4776 |
bool QSessionManager::allowsInteraction() |
|
4777 |
{ |
|
4778 |
return true; |
|
4779 |
} |
|
4780 |
||
4781 |
bool QSessionManager::allowsErrorInteraction() |
|
4782 |
{ |
|
4783 |
return true; |
|
4784 |
} |
|
4785 |
void QSessionManager::release() |
|
4786 |
{ |
|
4787 |
} |
|
4788 |
||
4789 |
void QSessionManager::cancel() |
|
4790 |
{ |
|
4791 |
} |
|
4792 |
#endif |
|
4793 |
||
4794 |
||
4795 |
void QSessionManager::setRestartHint(QSessionManager::RestartHint hint) |
|
4796 |
{ |
|
4797 |
Q_D(QSessionManager); |
|
4798 |
d->restartHint = hint; |
|
4799 |
} |
|
4800 |
||
4801 |
QSessionManager::RestartHint QSessionManager::restartHint() const |
|
4802 |
{ |
|
4803 |
Q_D(const QSessionManager); |
|
4804 |
return d->restartHint; |
|
4805 |
} |
|
4806 |
||
4807 |
void QSessionManager::setRestartCommand(const QStringList& command) |
|
4808 |
{ |
|
4809 |
Q_D(QSessionManager); |
|
4810 |
d->restartCommand = command; |
|
4811 |
} |
|
4812 |
||
4813 |
QStringList QSessionManager::restartCommand() const |
|
4814 |
{ |
|
4815 |
Q_D(const QSessionManager); |
|
4816 |
return d->restartCommand; |
|
4817 |
} |
|
4818 |
||
4819 |
void QSessionManager::setDiscardCommand(const QStringList& command) |
|
4820 |
{ |
|
4821 |
Q_D(QSessionManager); |
|
4822 |
d->discardCommand = command; |
|
4823 |
} |
|
4824 |
||
4825 |
QStringList QSessionManager::discardCommand() const |
|
4826 |
{ |
|
4827 |
Q_D(const QSessionManager); |
|
4828 |
return d->discardCommand; |
|
4829 |
} |
|
4830 |
||
4831 |
void QSessionManager::setManagerProperty(const QString&, const QString&) |
|
4832 |
{ |
|
4833 |
} |
|
4834 |
||
4835 |
void QSessionManager::setManagerProperty(const QString&, const QStringList&) |
|
4836 |
{ |
|
4837 |
} |
|
4838 |
||
4839 |
bool QSessionManager::isPhase2() const |
|
4840 |
{ |
|
4841 |
return false; |
|
4842 |
} |
|
4843 |
||
4844 |
void QSessionManager::requestPhase2() |
|
4845 |
{ |
|
4846 |
} |
|
4847 |
||
4848 |
#endif |
|
4849 |
#endif // QT_NO_SESSIONMANAGER |
|
4850 |
||
4851 |
/*! |
|
4852 |
\typedef QApplication::ColorMode |
|
4853 |
\compat |
|
4854 |
||
4855 |
Use ColorSpec instead. |
|
4856 |
*/ |
|
4857 |
||
4858 |
/*! |
|
4859 |
\fn Qt::MacintoshVersion QApplication::macVersion() |
|
4860 |
||
4861 |
Use QSysInfo::MacintoshVersion instead. |
|
4862 |
*/ |
|
4863 |
||
4864 |
/*! |
|
4865 |
\fn QApplication::ColorMode QApplication::colorMode() |
|
4866 |
||
4867 |
Use colorSpec() instead, and use ColorSpec as the enum type. |
|
4868 |
*/ |
|
4869 |
||
4870 |
/*! |
|
4871 |
\fn void QApplication::setColorMode(ColorMode mode) |
|
4872 |
||
4873 |
Use setColorSpec() instead, and pass a ColorSpec value instead. |
|
4874 |
*/ |
|
4875 |
||
4876 |
/*! |
|
4877 |
\fn bool QApplication::hasGlobalMouseTracking() |
|
4878 |
||
4879 |
This feature does not exist anymore. This function always returns true |
|
4880 |
in Qt 4. |
|
4881 |
*/ |
|
4882 |
||
4883 |
/*! |
|
4884 |
\fn void QApplication::setGlobalMouseTracking(bool dummy) |
|
4885 |
||
4886 |
This function does nothing in Qt 4. The \a dummy parameter is ignored. |
|
4887 |
*/ |
|
4888 |
||
4889 |
/*! |
|
4890 |
\fn void QApplication::flushX() |
|
4891 |
||
4892 |
Use flush() instead. |
|
4893 |
*/ |
|
4894 |
||
4895 |
/*! |
|
4896 |
\fn void QApplication::setWinStyleHighlightColor(const QColor &c) |
|
4897 |
||
4898 |
Use the palette instead. |
|
4899 |
||
4900 |
\oldcode |
|
4901 |
app.setWinStyleHighlightColor(color); |
|
4902 |
\newcode |
|
4903 |
QPalette palette(QApplication::palette()); |
|
4904 |
palette.setColor(QPalette::Highlight, color); |
|
4905 |
QApplication::setPalette(palette); |
|
4906 |
\endcode |
|
4907 |
*/ |
|
4908 |
||
4909 |
/*! |
|
4910 |
\fn void QApplication::setPalette(const QPalette &pal, bool b, const char* className = 0) |
|
4911 |
||
4912 |
Use the two-argument overload instead. |
|
4913 |
*/ |
|
4914 |
||
4915 |
/*! |
|
4916 |
\fn void QApplication::setFont(const QFont &font, bool b, const char* className = 0) |
|
4917 |
||
4918 |
Use the two-argument overload instead. |
|
4919 |
*/ |
|
4920 |
||
4921 |
/*! |
|
4922 |
\fn const QColor &QApplication::winStyleHighlightColor() |
|
4923 |
||
4924 |
Use QApplication::palette().color(QPalette::Active, QPalette::Highlight) instead. |
|
4925 |
*/ |
|
4926 |
||
4927 |
/*! |
|
4928 |
\fn QWidget *QApplication::widgetAt(int x, int y, bool child) |
|
4929 |
||
4930 |
Use the two-argument widgetAt() overload to get the child widget. To get |
|
4931 |
the top-level widget do this: |
|
4932 |
||
4933 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12 |
|
4934 |
*/ |
|
4935 |
||
4936 |
/*! |
|
4937 |
\fn QWidget *QApplication::widgetAt(const QPoint &point, bool child) |
|
4938 |
||
4939 |
Use the single-argument widgetAt() overload to get the child widget. To get |
|
4940 |
the top-level widget do this: |
|
4941 |
||
4942 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13 |
|
4943 |
*/ |
|
4944 |
||
4945 |
#ifdef QT3_SUPPORT |
|
4946 |
QWidget *QApplication::mainWidget() |
|
4947 |
{ |
|
4948 |
return QApplicationPrivate::main_widget; |
|
4949 |
} |
|
4950 |
#endif |
|
4951 |
bool QApplicationPrivate::inPopupMode() const |
|
4952 |
{ |
|
4953 |
return QApplicationPrivate::popupWidgets != 0; |
|
4954 |
} |
|
4955 |
||
4956 |
/*! |
|
4957 |
\property QApplication::quitOnLastWindowClosed |
|
4958 |
||
4959 |
\brief whether the application implicitly quits when the last window is |
|
4960 |
closed. |
|
4961 |
||
4962 |
The default is true. |
|
4963 |
||
4964 |
If this property is true, the applications quits when the last visible |
|
4965 |
primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose |
|
4966 |
attribute set is closed. By default this attribute is set for all widgets |
|
4967 |
except for sub-windows. Refer to \l{Qt::WindowType} for a detailed list of |
|
4968 |
Qt::Window objects. |
|
4969 |
||
4970 |
\sa quit(), QWidget::close() |
|
4971 |
*/ |
|
4972 |
||
4973 |
void QApplication::setQuitOnLastWindowClosed(bool quit) |
|
4974 |
{ |
|
4975 |
QApplicationPrivate::quitOnLastWindowClosed = quit; |
|
4976 |
} |
|
4977 |
||
4978 |
bool QApplication::quitOnLastWindowClosed() |
|
4979 |
{ |
|
4980 |
return QApplicationPrivate::quitOnLastWindowClosed; |
|
4981 |
} |
|
4982 |
||
4983 |
void QApplicationPrivate::emitLastWindowClosed() |
|
4984 |
{ |
|
4985 |
if (qApp && qApp->d_func()->in_exec) { |
|
4986 |
if (QApplicationPrivate::quitOnLastWindowClosed) { |
|
4987 |
// get ready to quit, this event might be removed if the |
|
4988 |
// event loop is re-entered, however |
|
4989 |
QApplication::postEvent(qApp, new QEvent(QEvent::Quit)); |
|
4990 |
} |
|
4991 |
emit qApp->lastWindowClosed(); |
|
4992 |
} |
|
4993 |
} |
|
4994 |
||
4995 |
/*! \variable QApplication::NormalColors |
|
4996 |
\compat |
|
4997 |
||
4998 |
Use \l NormalColor instead. |
|
4999 |
*/ |
|
5000 |
||
5001 |
/*! \variable QApplication::CustomColors |
|
5002 |
\compat |
|
5003 |
||
5004 |
Use \l CustomColor instead. |
|
5005 |
*/ |
|
5006 |
||
5007 |
#ifdef QT_KEYPAD_NAVIGATION |
|
5008 |
/*! |
|
5009 |
Sets the kind of focus navigation Qt should use to \a mode. |
|
5010 |
||
5011 |
This feature is available in Qt for Embedded Linux, Symbian and Windows CE |
|
5012 |
only. |
|
5013 |
||
5014 |
\note On Windows CE this feature is disabled by default for touch device |
|
5015 |
mkspecs. To enable keypad navigation, build Qt with |
|
5016 |
QT_KEYPAD_NAVIGATION defined. |
|
5017 |
||
5018 |
\note On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a |
|
5019 |
virtual mouse cursor on non touchscreen devices, which is controlled |
|
5020 |
by the cursor keys if there is no analog pointer device. |
|
5021 |
On other platforms and on touchscreen devices, it has the same |
|
5022 |
meaning as Qt::NavigationModeNone. |
|
5023 |
||
5024 |
\since 4.6 |
|
5025 |
||
5026 |
\sa keypadNavigationEnabled() |
|
5027 |
*/ |
|
5028 |
void QApplication::setNavigationMode(Qt::NavigationMode mode) |
|
5029 |
{ |
|
5030 |
#ifdef Q_OS_SYMBIAN |
|
5031 |
QApplicationPrivate::setNavigationMode(mode); |
|
5032 |
#else |
|
5033 |
QApplicationPrivate::navigationMode = mode; |
|
5034 |
#endif |
|
5035 |
} |
|
5036 |
||
5037 |
/*! |
|
5038 |
Returns what kind of focus navigation Qt is using. |
|
5039 |
||
5040 |
This feature is available in Qt for Embedded Linux, Symbian and Windows CE |
|
5041 |
only. |
|
5042 |
||
5043 |
\note On Windows CE this feature is disabled by default for touch device |
|
5044 |
mkspecs. To enable keypad navigation, build Qt with |
|
5045 |
QT_KEYPAD_NAVIGATION defined. |
|
5046 |
||
5047 |
\note On Symbian, the default mode is Qt::NavigationModeNone for touch |
|
5048 |
devices, and Qt::NavigationModeKeypadDirectional. |
|
5049 |
||
5050 |
\since 4.6 |
|
5051 |
||
5052 |
\sa keypadNavigationEnabled() |
|
5053 |
*/ |
|
5054 |
Qt::NavigationMode QApplication::navigationMode() |
|
5055 |
{ |
|
5056 |
return QApplicationPrivate::navigationMode; |
|
5057 |
} |
|
5058 |
||
5059 |
/*! |
|
5060 |
Sets whether Qt should use focus navigation suitable for use with a |
|
5061 |
minimal keypad. |
|
5062 |
||
5063 |
This feature is available in Qt for Embedded Linux, Symbian and Windows CE |
|
5064 |
only. |
|
5065 |
||
5066 |
\note On Windows CE this feature is disabled by default for touch device |
|
5067 |
mkspecs. To enable keypad navigation, build Qt with |
|
5068 |
QT_KEYPAD_NAVIGATION defined. |
|
5069 |
||
5070 |
\deprecated |
|
5071 |
||
5072 |
\sa setNavigationMode() |
|
5073 |
*/ |
|
5074 |
void QApplication::setKeypadNavigationEnabled(bool enable) |
|
5075 |
{ |
|
5076 |
if (enable) { |
|
5077 |
#ifdef Q_OS_SYMBIAN |
|
5078 |
QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional); |
|
5079 |
#else |
|
5080 |
QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder); |
|
5081 |
#endif |
|
5082 |
} |
|
5083 |
else { |
|
5084 |
QApplication::setNavigationMode(Qt::NavigationModeNone); |
|
5085 |
} |
|
5086 |
} |
|
5087 |
||
5088 |
/*! |
|
5089 |
Returns true if Qt is set to use keypad navigation; otherwise returns |
|
5090 |
false. The default value is true on Symbian, but false on other platforms. |
|
5091 |
||
5092 |
This feature is available in Qt for Embedded Linux, Symbian and Windows CE |
|
5093 |
only. |
|
5094 |
||
5095 |
\note On Windows CE this feature is disabled by default for touch device |
|
5096 |
mkspecs. To enable keypad navigation, build Qt with |
|
5097 |
QT_KEYPAD_NAVIGATION defined. |
|
5098 |
||
5099 |
\deprecated |
|
5100 |
||
5101 |
\sa navigationMode() |
|
5102 |
*/ |
|
5103 |
bool QApplication::keypadNavigationEnabled() |
|
5104 |
{ |
|
5105 |
return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder || |
|
5106 |
QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional; |
|
5107 |
} |
|
5108 |
#endif |
|
5109 |
||
5110 |
/*! |
|
5111 |
\fn void QApplication::alert(QWidget *widget, int msec) |
|
5112 |
\since 4.3 |
|
5113 |
||
5114 |
Causes an alert to be shown for \a widget if the window is not the active |
|
5115 |
window. The alert is shown for \a msec miliseconds. If \a msec is zero (the |
|
5116 |
default), then the alert is shown indefinitely until the window becomes |
|
5117 |
active again. |
|
5118 |
||
5119 |
Currently this function does nothing on Qt for Embedded Linux. |
|
5120 |
||
5121 |
On Mac OS X, this works more at the application level and will cause the |
|
5122 |
application icon to bounce in the dock. |
|
5123 |
||
5124 |
On Windows, this causes the window's taskbar entry to flash for a time. If |
|
5125 |
\a msec is zero, the flashing will stop and the taskbar entry will turn a |
|
5126 |
different color (currently orange). |
|
5127 |
||
5128 |
On X11, this will cause the window to be marked as "demands attention", the |
|
5129 |
window must not be hidden (i.e. not have hide() called on it, but be |
|
5130 |
visible in some sort of way) in order for this to work. |
|
5131 |
*/ |
|
5132 |
||
5133 |
/*! |
|
5134 |
\property QApplication::cursorFlashTime |
|
5135 |
\brief the text cursor's flash (blink) time in milliseconds |
|
5136 |
||
5137 |
The flash time is the time required to display, invert and restore the |
|
5138 |
caret display. Usually the text cursor is displayed for half the cursor |
|
5139 |
flash time, then hidden for the same amount of time, but this may vary. |
|
5140 |
||
5141 |
The default value on X11 is 1000 milliseconds. On Windows, the |
|
5142 |
\gui{Control Panel} value is used and setting this property sets the cursor |
|
5143 |
flash time for all applications. |
|
5144 |
||
5145 |
We recommend that widgets do not cache this value as it may change at any |
|
5146 |
time if the user changes the global desktop settings. |
|
5147 |
*/ |
|
5148 |
||
5149 |
/*! |
|
5150 |
\property QApplication::doubleClickInterval |
|
5151 |
\brief the time limit in milliseconds that distinguishes a double click |
|
5152 |
from two consecutive mouse clicks |
|
5153 |
||
5154 |
The default value on X11 is 400 milliseconds. On Windows and Mac OS, the |
|
5155 |
operating system's value is used. However, on Windows and Symbian OS, |
|
5156 |
calling this function sets the double click interval for all applications. |
|
5157 |
*/ |
|
5158 |
||
5159 |
/*! |
|
5160 |
\property QApplication::keyboardInputInterval |
|
5161 |
\brief the time limit in milliseconds that distinguishes a key press |
|
5162 |
from two consecutive key presses |
|
5163 |
\since 4.2 |
|
5164 |
||
5165 |
The default value on X11 is 400 milliseconds. On Windows and Mac OS, the |
|
5166 |
operating system's value is used. |
|
5167 |
*/ |
|
5168 |
||
5169 |
/*! |
|
5170 |
\property QApplication::wheelScrollLines |
|
5171 |
\brief the number of lines to scroll a widget, when the |
|
5172 |
mouse wheel is rotated. |
|
5173 |
||
5174 |
If the value exceeds the widget's number of visible lines, the widget |
|
5175 |
should interpret the scroll operation as a single \e{page up} or |
|
5176 |
\e{page down}. If the widget is an \l{QAbstractItemView}{item view class}, |
|
5177 |
then the result of scrolling one \e line depends on the setting of the |
|
5178 |
widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll |
|
5179 |
one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item} |
|
5180 |
or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}. |
|
5181 |
||
5182 |
By default, this property has a value of 3. |
|
5183 |
*/ |
|
5184 |
||
5185 |
/*! |
|
5186 |
\fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) |
|
5187 |
||
5188 |
Enables the UI effect \a effect if \a enable is true, otherwise the effect |
|
5189 |
will not be used. |
|
5190 |
||
5191 |
\note All effects are disabled on screens running at less than 16-bit color |
|
5192 |
depth. |
|
5193 |
||
5194 |
\sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware() |
|
5195 |
*/ |
|
5196 |
||
5197 |
/*! |
|
5198 |
\fn bool QApplication::isEffectEnabled(Qt::UIEffect effect) |
|
5199 |
||
5200 |
Returns true if \a effect is enabled; otherwise returns false. |
|
5201 |
||
5202 |
By default, Qt will try to use the desktop settings. To prevent this, call |
|
5203 |
setDesktopSettingsAware(false). |
|
5204 |
||
5205 |
\note All effects are disabled on screens running at less than 16-bit color |
|
5206 |
depth. |
|
5207 |
||
5208 |
\sa setEffectEnabled(), Qt::UIEffect |
|
5209 |
*/ |
|
5210 |
||
5211 |
/*! |
|
5212 |
\fn QWidget *QApplication::mainWidget() |
|
5213 |
||
5214 |
Returns the main application widget, or 0 if there is no main widget. |
|
5215 |
*/ |
|
5216 |
||
5217 |
/*! |
|
5218 |
\fn void QApplication::setMainWidget(QWidget *mainWidget) |
|
5219 |
||
5220 |
Sets the application's main widget to \a mainWidget. |
|
5221 |
||
5222 |
In most respects the main widget is like any other widget, except that if |
|
5223 |
it is closed, the application exits. QApplication does \e not take |
|
5224 |
ownership of the \a mainWidget, so if you create your main widget on the |
|
5225 |
heap you must delete it yourself. |
|
5226 |
||
5227 |
You need not have a main widget; connecting lastWindowClosed() to quit() |
|
5228 |
is an alternative. |
|
5229 |
||
5230 |
On X11, this function also resizes and moves the main widget according |
|
5231 |
to the \e -geometry command-line option, so you should set the default |
|
5232 |
geometry (using \l QWidget::setGeometry()) before calling setMainWidget(). |
|
5233 |
||
5234 |
\sa mainWidget(), exec(), quit() |
|
5235 |
*/ |
|
5236 |
||
5237 |
/*! |
|
5238 |
\fn void QApplication::beep() |
|
5239 |
||
5240 |
Sounds the bell, using the default volume and sound. The function is \e not |
|
5241 |
available in Qt for Embedded Linux. |
|
5242 |
*/ |
|
5243 |
||
5244 |
/*! |
|
5245 |
\fn void QApplication::setOverrideCursor(const QCursor &cursor) |
|
5246 |
||
5247 |
Sets the application override cursor to \a cursor. |
|
5248 |
||
5249 |
Application override cursors are intended for showing the user that the |
|
5250 |
application is in a special state, for example during an operation that |
|
5251 |
might take some time. |
|
5252 |
||
5253 |
This cursor will be displayed in all the application's widgets until |
|
5254 |
restoreOverrideCursor() or another setOverrideCursor() is called. |
|
5255 |
||
5256 |
Application cursors are stored on an internal stack. setOverrideCursor() |
|
5257 |
pushes the cursor onto the stack, and restoreOverrideCursor() pops the |
|
5258 |
active cursor off the stack. changeOverrideCursor() changes the curently |
|
5259 |
active application override cursor. |
|
5260 |
||
5261 |
Every setOverrideCursor() must eventually be followed by a corresponding |
|
5262 |
restoreOverrideCursor(), otherwise the stack will never be emptied. |
|
5263 |
||
5264 |
Example: |
|
5265 |
\snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0 |
|
5266 |
||
5267 |
\sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), |
|
5268 |
QWidget::setCursor() |
|
5269 |
*/ |
|
5270 |
||
5271 |
/*! |
|
5272 |
\fn void QApplication::restoreOverrideCursor() |
|
5273 |
||
5274 |
Undoes the last setOverrideCursor(). |
|
5275 |
||
5276 |
If setOverrideCursor() has been called twice, calling |
|
5277 |
restoreOverrideCursor() will activate the first cursor set. Calling this |
|
5278 |
function a second time restores the original widgets' cursors. |
|
5279 |
||
5280 |
\sa setOverrideCursor(), overrideCursor() |
|
5281 |
*/ |
|
5282 |
||
5283 |
/*! |
|
5284 |
\macro qApp |
|
5285 |
\relates QApplication |
|
5286 |
||
5287 |
A global pointer referring to the unique application object. It is |
|
5288 |
equivalent to the pointer returned by the QCoreApplication::instance() |
|
5289 |
function except that, in GUI applications, it is a pointer to a |
|
5290 |
QApplication instance. |
|
5291 |
||
5292 |
Only one application object can be created. |
|
5293 |
||
5294 |
\sa QCoreApplication::instance() |
|
5295 |
*/ |
|
5296 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5297 |
#ifndef QT_NO_IM |
0 | 5298 |
// ************************************************************************ |
5299 |
// Input Method support |
|
5300 |
// ************************************************************************ |
|
5301 |
||
5302 |
/*! |
|
5303 |
This function replaces the QInputContext instance used by the application |
|
5304 |
with \a inputContext. |
|
5305 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5306 |
Qt takes ownership of the given \a inputContext. |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5307 |
|
0 | 5308 |
\sa inputContext() |
5309 |
*/ |
|
5310 |
void QApplication::setInputContext(QInputContext *inputContext) |
|
5311 |
{ |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5312 |
if (inputContext == QApplicationPrivate::inputContext) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5313 |
return; |
0 | 5314 |
if (!inputContext) { |
5315 |
qWarning("QApplication::setInputContext: called with 0 input context"); |
|
5316 |
return; |
|
5317 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5318 |
delete QApplicationPrivate::inputContext; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5319 |
QApplicationPrivate::inputContext = inputContext; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5320 |
QApplicationPrivate::inputContext->setParent(this); |
0 | 5321 |
} |
5322 |
||
5323 |
/*! |
|
5324 |
Returns the QInputContext instance used by the application. |
|
5325 |
||
5326 |
\sa setInputContext() |
|
5327 |
*/ |
|
5328 |
QInputContext *QApplication::inputContext() const |
|
5329 |
{ |
|
5330 |
Q_D(const QApplication); |
|
5331 |
Q_UNUSED(d);// only static members being used. |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5332 |
if (QApplicationPrivate::is_app_closing) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5333 |
return d->inputContext; |
0 | 5334 |
#ifdef Q_WS_X11 |
5335 |
if (!X11) |
|
5336 |
return 0; |
|
5337 |
if (!d->inputContext) { |
|
5338 |
QApplication *that = const_cast<QApplication *>(this); |
|
5339 |
QInputContext *qic = QInputContextFactory::create(X11->default_im, that); |
|
5340 |
// fallback to default X Input Method. |
|
5341 |
if (!qic) |
|
5342 |
qic = QInputContextFactory::create(QLatin1String("xim"), that); |
|
5343 |
that->d_func()->inputContext = qic; |
|
5344 |
} |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5345 |
#elif defined(Q_OS_SYMBIAN) |
0 | 5346 |
if (!d->inputContext) { |
5347 |
QApplication *that = const_cast<QApplication *>(this); |
|
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5348 |
const QStringList keys = QInputContextFactory::keys(); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5349 |
// Try hbim and coefep first, then try others. |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5350 |
if (keys.contains(QLatin1String("hbim"))) { |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5351 |
that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5352 |
} else if (keys.contains(QLatin1String("coefep"))) { |
25
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5353 |
that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5354 |
} else { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5355 |
for (int c = 0; c < keys.size() && !d->inputContext; ++c) { |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5356 |
that->d_func()->inputContext = QInputContextFactory::create(keys[c], that); |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5357 |
} |
e24348a560a6
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
5358 |
} |
0 | 5359 |
} |
5360 |
#endif |
|
5361 |
return d->inputContext; |
|
5362 |
} |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5363 |
#endif // QT_NO_IM |
0 | 5364 |
|
5365 |
//Returns the current platform used by keyBindings |
|
5366 |
uint QApplicationPrivate::currentPlatform(){ |
|
5367 |
uint platform = KB_Win; |
|
5368 |
#ifdef Q_WS_MAC |
|
5369 |
platform = KB_Mac; |
|
5370 |
#elif defined Q_WS_X11 |
|
5371 |
platform = KB_X11; |
|
5372 |
if (X11->desktopEnvironment == DE_KDE) |
|
5373 |
platform |= KB_KDE; |
|
5374 |
if (X11->desktopEnvironment == DE_GNOME) |
|
5375 |
platform |= KB_Gnome; |
|
5376 |
if (X11->desktopEnvironment == DE_CDE) |
|
5377 |
platform |= KB_CDE; |
|
5378 |
#elif defined(Q_OS_SYMBIAN) |
|
5379 |
platform = KB_S60; |
|
5380 |
#endif |
|
5381 |
return platform; |
|
5382 |
} |
|
5383 |
||
5384 |
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event) |
|
5385 |
{ |
|
5386 |
return QCoreApplication::sendSpontaneousEvent(receiver, event); |
|
5387 |
} |
|
5388 |
||
5389 |
||
5390 |
/*! |
|
5391 |
\since 4.2 |
|
5392 |
||
5393 |
Returns the current keyboard input locale. |
|
5394 |
*/ |
|
5395 |
QLocale QApplication::keyboardInputLocale() |
|
5396 |
{ |
|
5397 |
if (!QApplicationPrivate::checkInstance("keyboardInputLocale")) |
|
5398 |
return QLocale::c(); |
|
5399 |
return qt_keymapper_private()->keyboardInputLocale; |
|
5400 |
} |
|
5401 |
||
5402 |
/*! |
|
5403 |
\since 4.2 |
|
5404 |
||
5405 |
Returns the current keyboard input direction. |
|
5406 |
*/ |
|
5407 |
Qt::LayoutDirection QApplication::keyboardInputDirection() |
|
5408 |
{ |
|
5409 |
if (!QApplicationPrivate::checkInstance("keyboardInputDirection")) |
|
5410 |
return Qt::LeftToRight; |
|
5411 |
return qt_keymapper_private()->keyboardInputDirection; |
|
5412 |
} |
|
5413 |
||
5414 |
void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, |
|
5415 |
Qt::FocusPolicy focusPolicy, |
|
5416 |
Qt::FocusReason focusReason) |
|
5417 |
{ |
|
5418 |
QWidget *focusWidget = widget; |
|
5419 |
while (focusWidget) { |
|
5420 |
if (focusWidget->isEnabled() |
|
5421 |
&& QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) { |
|
5422 |
focusWidget->setFocus(focusReason); |
|
5423 |
break; |
|
5424 |
} |
|
5425 |
if (focusWidget->isWindow()) |
|
5426 |
break; |
|
5427 |
focusWidget = focusWidget->parentWidget(); |
|
5428 |
} |
|
5429 |
} |
|
5430 |
||
5431 |
bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) |
|
5432 |
{ |
|
5433 |
QWidget *f = w; |
|
5434 |
while (f->d_func()->extra && f->d_func()->extra->focus_proxy) |
|
5435 |
f = f->d_func()->extra->focus_proxy; |
|
5436 |
||
5437 |
if ((w->focusPolicy() & policy) != policy) |
|
5438 |
return false; |
|
5439 |
if (w != f && (f->focusPolicy() & policy) != policy) |
|
5440 |
return false; |
|
5441 |
return true; |
|
5442 |
} |
|
5443 |
||
5444 |
/*! \fn QDecoration &QApplication::qwsDecoration() |
|
5445 |
Return the QWSDecoration used for decorating windows. |
|
5446 |
||
5447 |
\warning This method is non-portable. It is only available in |
|
5448 |
Qt for Embedded Linux. |
|
5449 |
||
5450 |
\sa QDecoration |
|
5451 |
*/ |
|
5452 |
||
5453 |
/*! |
|
5454 |
\fn void QApplication::qwsSetDecoration(QDecoration *decoration) |
|
5455 |
||
5456 |
Sets the QDecoration derived class to use for decorating the |
|
5457 |
windows used by Qt for Embedded Linux to the \a decoration |
|
5458 |
specified. |
|
5459 |
||
5460 |
This method is non-portable. It is only available in Qt for Embedded Linux. |
|
5461 |
||
5462 |
\sa QDecoration |
|
5463 |
*/ |
|
5464 |
||
5465 |
/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) |
|
5466 |
\overload |
|
5467 |
||
5468 |
Requests a QDecoration object for \a decoration from the |
|
5469 |
QDecorationFactory. |
|
5470 |
||
5471 |
The string must be one of the QDecorationFactory::keys(). Keys are case |
|
5472 |
insensitive. |
|
5473 |
||
5474 |
A later call to the QApplication constructor will override the requested |
|
5475 |
style when a "-style" option is passed in as a commandline parameter. |
|
5476 |
||
5477 |
Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object |
|
5478 |
returned is set as the application's GUI style. |
|
5479 |
*/ |
|
5480 |
||
5481 |
/*! |
|
5482 |
\fn bool QApplication::qwsEventFilter(QWSEvent *event) |
|
5483 |
||
5484 |
This virtual function is only implemented under Qt for Embedded Linux. |
|
5485 |
||
5486 |
If you create an application that inherits QApplication and |
|
5487 |
reimplement this function, you get direct access to all QWS (Q |
|
5488 |
Window System) events that the are received from the QWS master |
|
5489 |
process. The events are passed in the \a event parameter. |
|
5490 |
||
5491 |
Return true if you want to stop the event from being processed. |
|
5492 |
Return false for normal event dispatching. The default |
|
5493 |
implementation returns false. |
|
5494 |
*/ |
|
5495 |
||
5496 |
/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors) |
|
5497 |
Set Qt for Embedded Linux custom color table. |
|
5498 |
||
5499 |
Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. |
|
5500 |
The remaining 40 colors may be used by setting a custom color |
|
5501 |
table in the QWS master process before any clients connect. |
|
5502 |
||
5503 |
\a colorTable is an array of up to 40 custom colors. \a start is |
|
5504 |
the starting index (0-39) and \a numColors is the number of colors |
|
5505 |
to be set (1-40). |
|
5506 |
||
5507 |
This method is non-portable. It is available \e only in |
|
5508 |
Qt for Embedded Linux. |
|
5509 |
||
5510 |
\note The custom colors will not be used by the default screen |
|
5511 |
driver. To make use of the new colors, implement a custom screen |
|
5512 |
driver, or use QDirectPainter. |
|
5513 |
*/ |
|
5514 |
||
5515 |
/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event) |
|
5516 |
\internal |
|
5517 |
*/ |
|
5518 |
||
5519 |
/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) |
|
5520 |
\internal |
|
5521 |
*/ |
|
5522 |
||
5523 |
/*! \fn int QApplication::x11ProcessEvent(XEvent* event) |
|
5524 |
This function does the core processing of individual X |
|
5525 |
\a{event}s, normally by dispatching Qt events to the right |
|
5526 |
destination. |
|
5527 |
||
5528 |
It returns 1 if the event was consumed by special handling, 0 if |
|
5529 |
the \a event was consumed by normal handling, and -1 if the \a |
|
5530 |
event was for an unrecognized widget. |
|
5531 |
||
5532 |
\sa x11EventFilter() |
|
5533 |
*/ |
|
5534 |
||
5535 |
/*! |
|
5536 |
\fn bool QApplication::x11EventFilter(XEvent *event) |
|
5537 |
||
5538 |
\warning This virtual function is only implemented under X11. |
|
5539 |
||
5540 |
If you create an application that inherits QApplication and |
|
5541 |
reimplement this function, you get direct access to all X events |
|
5542 |
that the are received from the X server. The events are passed in |
|
5543 |
the \a event parameter. |
|
5544 |
||
5545 |
Return true if you want to stop the event from being processed. |
|
5546 |
Return false for normal event dispatching. The default |
|
5547 |
implementation returns false. |
|
5548 |
||
5549 |
It is only the directly addressed messages that are filtered. |
|
5550 |
You must install an event filter directly on the event |
|
5551 |
dispatcher, which is returned by |
|
5552 |
QAbstractEventDispatcher::instance(), to handle system wide |
|
5553 |
messages. |
|
5554 |
||
5555 |
\sa x11ProcessEvent() |
|
5556 |
*/ |
|
5557 |
||
5558 |
/*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus) |
|
5559 |
\internal |
|
5560 |
\since 4.1 |
|
5561 |
||
5562 |
If \a gotFocus is true, \a widget will become the active window. |
|
5563 |
Otherwise the active window is reset to 0. |
|
5564 |
*/ |
|
5565 |
||
5566 |
/*! \fn void QApplication::winMouseButtonUp() |
|
5567 |
\internal |
|
5568 |
*/ |
|
5569 |
||
5570 |
/*! \fn void QApplication::syncX() |
|
5571 |
Synchronizes with the X server in the X11 implementation. |
|
5572 |
This normally takes some time. Does nothing on other platforms. |
|
5573 |
*/ |
|
5574 |
||
5575 |
void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) |
|
5576 |
{ |
|
5577 |
for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { |
|
5578 |
QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i]; |
|
5579 |
||
5580 |
// preserve the sub-pixel resolution |
|
5581 |
QRectF rect = touchPoint.screenRect(); |
|
5582 |
const QPointF screenPos = rect.center(); |
|
5583 |
const QPointF delta = screenPos - screenPos.toPoint(); |
|
5584 |
||
5585 |
rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5586 |
touchPoint.d->rect = rect; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5587 |
if (touchPoint.state() == Qt::TouchPointPressed) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5588 |
touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5589 |
touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5590 |
} |
0 | 5591 |
} |
5592 |
} |
|
5593 |
||
5594 |
void QApplicationPrivate::initializeMultitouch() |
|
5595 |
{ |
|
5596 |
widgetForTouchPointId.clear(); |
|
5597 |
appCurrentTouchPoints.clear(); |
|
5598 |
||
5599 |
initializeMultitouch_sys(); |
|
5600 |
} |
|
5601 |
||
5602 |
void QApplicationPrivate::cleanupMultitouch() |
|
5603 |
{ |
|
5604 |
cleanupMultitouch_sys(); |
|
5605 |
||
5606 |
widgetForTouchPointId.clear(); |
|
5607 |
appCurrentTouchPoints.clear(); |
|
5608 |
} |
|
5609 |
||
5610 |
int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos) |
|
5611 |
{ |
|
5612 |
int closestTouchPointId = -1; |
|
5613 |
qreal closestDistance = qreal(0.); |
|
5614 |
foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) { |
|
5615 |
qreal distance = QLineF(screenPos, touchPoint.screenPos()).length(); |
|
5616 |
if (closestTouchPointId == -1 || distance < closestDistance) { |
|
5617 |
closestTouchPointId = touchPoint.id(); |
|
5618 |
closestDistance = distance; |
|
5619 |
} |
|
5620 |
} |
|
5621 |
return closestTouchPointId; |
|
5622 |
} |
|
5623 |
||
5624 |
void QApplicationPrivate::translateRawTouchEvent(QWidget *window, |
|
5625 |
QTouchEvent::DeviceType deviceType, |
|
5626 |
const QList<QTouchEvent::TouchPoint> &touchPoints) |
|
5627 |
{ |
|
5628 |
QApplicationPrivate *d = self; |
|
5629 |
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; |
|
5630 |
QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents; |
|
5631 |
||
5632 |
for (int i = 0; i < touchPoints.count(); ++i) { |
|
5633 |
QTouchEvent::TouchPoint touchPoint = touchPoints.at(i); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5634 |
// explicitly detach from the original touch point that we got, so even |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5635 |
// if the touchpoint structs are reused, we will make a copy that we'll |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5636 |
// deliver to the user (which might want to store the struct for later use). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5637 |
touchPoint.d = touchPoint.d->detach(); |
0 | 5638 |
|
5639 |
// update state |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5640 |
QWeakPointer<QWidget> widget; |
0 | 5641 |
switch (touchPoint.state()) { |
5642 |
case Qt::TouchPointPressed: |
|
5643 |
{ |
|
5644 |
if (deviceType == QTouchEvent::TouchPad) { |
|
5645 |
// on touch-pads, send all touch points to the same widget |
|
5646 |
widget = d->widgetForTouchPointId.isEmpty() |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5647 |
? QWeakPointer<QWidget>() |
0 | 5648 |
: d->widgetForTouchPointId.constBegin().value(); |
5649 |
} |
|
5650 |
||
5651 |
if (!widget) { |
|
5652 |
// determine which widget this event will go to |
|
5653 |
if (!window) |
|
5654 |
window = QApplication::topLevelAt(touchPoint.screenPos().toPoint()); |
|
5655 |
if (!window) |
|
5656 |
continue; |
|
5657 |
widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); |
|
5658 |
if (!widget) |
|
5659 |
widget = window; |
|
5660 |
} |
|
5661 |
||
5662 |
if (deviceType == QTouchEvent::TouchScreen) { |
|
5663 |
int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5664 |
QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data(); |
0 | 5665 |
if (closestWidget |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5666 |
&& (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) { |
0 | 5667 |
widget = closestWidget; |
5668 |
} |
|
5669 |
} |
|
5670 |
||
5671 |
d->widgetForTouchPointId[touchPoint.id()] = widget; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5672 |
touchPoint.d->startScreenPos = touchPoint.screenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5673 |
touchPoint.d->lastScreenPos = touchPoint.screenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5674 |
touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5675 |
touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); |
0 | 5676 |
if (touchPoint.pressure() < qreal(0.)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5677 |
touchPoint.d->pressure = qreal(1.); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5678 |
|
0 | 5679 |
d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint); |
5680 |
break; |
|
5681 |
} |
|
5682 |
case Qt::TouchPointReleased: |
|
5683 |
{ |
|
5684 |
widget = d->widgetForTouchPointId.take(touchPoint.id()); |
|
5685 |
if (!widget) |
|
5686 |
continue; |
|
5687 |
||
5688 |
QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5689 |
touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5690 |
touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5691 |
touchPoint.d->startPos = previousTouchPoint.startPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5692 |
touchPoint.d->lastPos = previousTouchPoint.pos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5693 |
touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5694 |
touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); |
0 | 5695 |
if (touchPoint.pressure() < qreal(0.)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5696 |
touchPoint.d->pressure = qreal(0.); |
0 | 5697 |
break; |
5698 |
} |
|
5699 |
default: |
|
5700 |
widget = d->widgetForTouchPointId.value(touchPoint.id()); |
|
5701 |
if (!widget) |
|
5702 |
continue; |
|
5703 |
||
5704 |
Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id())); |
|
5705 |
QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5706 |
touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5707 |
touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5708 |
touchPoint.d->startPos = previousTouchPoint.startPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5709 |
touchPoint.d->lastPos = previousTouchPoint.pos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5710 |
touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5711 |
touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); |
0 | 5712 |
if (touchPoint.pressure() < qreal(0.)) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5713 |
touchPoint.d->pressure = qreal(1.); |
0 | 5714 |
d->appCurrentTouchPoints[touchPoint.id()] = touchPoint; |
5715 |
break; |
|
5716 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5717 |
Q_ASSERT(widget.data() != 0); |
0 | 5718 |
|
5719 |
// make the *scene* functions return the same as the *screen* functions |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5720 |
touchPoint.d->sceneRect = touchPoint.screenRect(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5721 |
touchPoint.d->startScenePos = touchPoint.startScreenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5722 |
touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5723 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
5724 |
StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()]; |
0 | 5725 |
maskAndPoints.first |= touchPoint.state(); |
5726 |
if (touchPoint.isPrimary()) |
|
5727 |
maskAndPoints.first |= Qt::TouchPointPrimary; |
|
5728 |
maskAndPoints.second.append(touchPoint); |
|
5729 |
} |
|
5730 |
||
5731 |
if (widgetsNeedingEvents.isEmpty()) |
|
5732 |
return; |
|
5733 |
||
5734 |
QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin(); |
|
5735 |
const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); |
|
5736 |
for (; it != end; ++it) { |
|
5737 |
QWidget *widget = it.key(); |
|
5738 |
if (!QApplicationPrivate::tryModalHelper(widget, 0)) |
|
5739 |
continue; |
|
5740 |
||
5741 |
QEvent::Type eventType; |
|
5742 |
switch (it.value().first & Qt::TouchPointStateMask) { |
|
5743 |
case Qt::TouchPointPressed: |
|
5744 |
eventType = QEvent::TouchBegin; |
|
5745 |
break; |
|
5746 |
case Qt::TouchPointReleased: |
|
5747 |
eventType = QEvent::TouchEnd; |
|
5748 |
break; |
|
5749 |
case Qt::TouchPointStationary: |
|
5750 |
// don't send the event if nothing changed |
|
5751 |
continue; |
|
5752 |
default: |
|
5753 |
eventType = QEvent::TouchUpdate; |
|
5754 |
break; |
|
5755 |
} |
|
5756 |
||
5757 |
QTouchEvent touchEvent(eventType, |
|
5758 |
deviceType, |
|
5759 |
QApplication::keyboardModifiers(), |
|
5760 |
it.value().first, |
|
5761 |
it.value().second); |
|
5762 |
updateTouchPointsForWidget(widget, &touchEvent); |
|
5763 |
||
5764 |
switch (touchEvent.type()) { |
|
5765 |
case QEvent::TouchBegin: |
|
5766 |
{ |
|
5767 |
// if the TouchBegin handler recurses, we assume that means the event |
|
5768 |
// has been implicitly accepted and continue to send touch events |
|
5769 |
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); |
|
5770 |
(void ) QApplication::sendSpontaneousEvent(widget, &touchEvent); |
|
5771 |
break; |
|
5772 |
} |
|
5773 |
default: |
|
5774 |
if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) { |
|
5775 |
if (touchEvent.type() == QEvent::TouchEnd) |
|
5776 |
widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false); |
|
5777 |
(void) QApplication::sendSpontaneousEvent(widget, &touchEvent); |
|
5778 |
} |
|
5779 |
break; |
|
5780 |
} |
|
5781 |
} |
|
5782 |
} |
|
5783 |
||
5784 |
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, |
|
5785 |
QTouchEvent::DeviceType deviceType, |
|
5786 |
const QList<QTouchEvent::TouchPoint> &touchPoints) |
|
5787 |
{ |
|
5788 |
QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); |
|
5789 |
} |
|
5790 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5791 |
#ifndef QT_NO_GESTURES |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5792 |
QGestureManager* QGestureManager::instance() |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5793 |
{ |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5794 |
QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5795 |
if (!qAppPriv->gestureManager) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5796 |
qAppPriv->gestureManager = new QGestureManager(qApp); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5797 |
return qAppPriv->gestureManager; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5798 |
} |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
5799 |
#endif // QT_NO_GESTURES |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
5800 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5801 |
// These pixmaps approximate the images in the Windows User Interface Guidelines. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5802 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5803 |
// XPM |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5804 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5805 |
static const char * const move_xpm[] = { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5806 |
"11 20 3 1", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5807 |
". c None", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5808 |
#if defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5809 |
"a c #000000", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5810 |
"X c #FFFFFF", // Windows cursor is traditionally white |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5811 |
#else |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5812 |
"a c #FFFFFF", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5813 |
"X c #000000", // X11 cursor is traditionally black |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5814 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5815 |
"aa.........", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5816 |
"aXa........", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5817 |
"aXXa.......", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5818 |
"aXXXa......", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5819 |
"aXXXXa.....", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5820 |
"aXXXXXa....", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5821 |
"aXXXXXXa...", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5822 |
"aXXXXXXXa..", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5823 |
"aXXXXXXXXa.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5824 |
"aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5825 |
"aXXXXXXaaaa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5826 |
"aXXXaXXa...", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5827 |
"aXXaaXXa...", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5828 |
"aXa..aXXa..", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5829 |
"aa...aXXa..", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5830 |
"a.....aXXa.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5831 |
"......aXXa.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5832 |
".......aXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5833 |
".......aXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5834 |
"........aa."}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5835 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5836 |
#ifdef Q_WS_WIN |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5837 |
/* XPM */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5838 |
static const char * const ignore_xpm[] = { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5839 |
"24 30 3 1", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5840 |
". c None", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5841 |
"a c #000000", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5842 |
"X c #FFFFFF", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5843 |
"aa......................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5844 |
"aXa.....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5845 |
"aXXa....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5846 |
"aXXXa...................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5847 |
"aXXXXa..................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5848 |
"aXXXXXa.................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5849 |
"aXXXXXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5850 |
"aXXXXXXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5851 |
"aXXXXXXXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5852 |
"aXXXXXXXXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5853 |
"aXXXXXXaaaa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5854 |
"aXXXaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5855 |
"aXXaaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5856 |
"aXa..aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5857 |
"aa...aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5858 |
"a.....aXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5859 |
"......aXXa.....XXXX.....", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5860 |
".......aXXa..XXaaaaXX...", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5861 |
".......aXXa.XaaaaaaaaX..", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5862 |
"........aa.XaaaXXXXaaaX.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5863 |
"...........XaaaaX..XaaX.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5864 |
"..........XaaXaaaX..XaaX", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5865 |
"..........XaaXXaaaX.XaaX", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5866 |
"..........XaaX.XaaaXXaaX", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5867 |
"..........XaaX..XaaaXaaX", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5868 |
"...........XaaX..XaaaaX.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5869 |
"...........XaaaXXXXaaaX.", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5870 |
"............XaaaaaaaaX..", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5871 |
".............XXaaaaXX...", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5872 |
"...............XXXX....."}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5873 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5874 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5875 |
/* XPM */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5876 |
static const char * const copy_xpm[] = { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5877 |
"24 30 3 1", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5878 |
". c None", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5879 |
"a c #000000", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5880 |
"X c #FFFFFF", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5881 |
#if defined(Q_WS_WIN) // Windows cursor is traditionally white |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5882 |
"aa......................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5883 |
"aXa.....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5884 |
"aXXa....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5885 |
"aXXXa...................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5886 |
"aXXXXa..................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5887 |
"aXXXXXa.................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5888 |
"aXXXXXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5889 |
"aXXXXXXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5890 |
"aXXXXXXXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5891 |
"aXXXXXXXXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5892 |
"aXXXXXXaaaa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5893 |
"aXXXaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5894 |
"aXXaaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5895 |
"aXa..aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5896 |
"aa...aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5897 |
"a.....aXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5898 |
"......aXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5899 |
".......aXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5900 |
".......aXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5901 |
"........aa...aaaaaaaaaaa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5902 |
#else |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5903 |
"XX......................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5904 |
"XaX.....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5905 |
"XaaX....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5906 |
"XaaaX...................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5907 |
"XaaaaX..................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5908 |
"XaaaaaX.................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5909 |
"XaaaaaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5910 |
"XaaaaaaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5911 |
"XaaaaaaaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5912 |
"XaaaaaaaaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5913 |
"XaaaaaaXXXX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5914 |
"XaaaXaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5915 |
"XaaXXaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5916 |
"XaX..XaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5917 |
"XX...XaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5918 |
"X.....XaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5919 |
"......XaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5920 |
".......XaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5921 |
".......XaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5922 |
"........XX...aaaaaaaaaaa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5923 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5924 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5925 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5926 |
".............aXXXXaXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5927 |
".............aXXXXaXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5928 |
".............aXXaaaaaXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5929 |
".............aXXXXaXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5930 |
".............aXXXXaXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5931 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5932 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5933 |
".............aaaaaaaaaaa"}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5934 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5935 |
/* XPM */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5936 |
static const char * const link_xpm[] = { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5937 |
"24 30 3 1", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5938 |
". c None", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5939 |
"a c #000000", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5940 |
"X c #FFFFFF", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5941 |
#if defined(Q_WS_WIN) // Windows cursor is traditionally white |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5942 |
"aa......................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5943 |
"aXa.....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5944 |
"aXXa....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5945 |
"aXXXa...................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5946 |
"aXXXXa..................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5947 |
"aXXXXXa.................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5948 |
"aXXXXXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5949 |
"aXXXXXXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5950 |
"aXXXXXXXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5951 |
"aXXXXXXXXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5952 |
"aXXXXXXaaaa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5953 |
"aXXXaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5954 |
"aXXaaXXa................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5955 |
"aXa..aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5956 |
"aa...aXXa...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5957 |
"a.....aXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5958 |
"......aXXa..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5959 |
".......aXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5960 |
".......aXXa.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5961 |
"........aa...aaaaaaaaaaa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5962 |
#else |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5963 |
"XX......................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5964 |
"XaX.....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5965 |
"XaaX....................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5966 |
"XaaaX...................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5967 |
"XaaaaX..................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5968 |
"XaaaaaX.................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5969 |
"XaaaaaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5970 |
"XaaaaaaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5971 |
"XaaaaaaaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5972 |
"XaaaaaaaaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5973 |
"XaaaaaaXXXX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5974 |
"XaaaXaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5975 |
"XaaXXaaX................", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5976 |
"XaX..XaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5977 |
"XX...XaaX...............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5978 |
"X.....XaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5979 |
"......XaaX..............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5980 |
".......XaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5981 |
".......XaaX.............", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5982 |
"........XX...aaaaaaaaaaa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5983 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5984 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5985 |
".............aXXXaaaaXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5986 |
".............aXXXXaaaXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5987 |
".............aXXXaaaaXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5988 |
".............aXXaaaXaXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5989 |
".............aXXaaXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5990 |
".............aXXaXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5991 |
".............aXXXaXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5992 |
".............aXXXXXXXXXa", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5993 |
".............aaaaaaaaaaa"}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5994 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5995 |
QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5996 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5997 |
#if defined(Q_WS_X11) || defined(Q_WS_WIN) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5998 |
if (!move_cursor) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
5999 |
move_cursor = new QPixmap((const char **)move_xpm); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6000 |
copy_cursor = new QPixmap((const char **)copy_xpm); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6001 |
link_cursor = new QPixmap((const char **)link_xpm); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6002 |
#ifdef Q_WS_WIN |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6003 |
ignore_cursor = new QPixmap((const char **)ignore_xpm); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6004 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6005 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6006 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6007 |
switch (cshape) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6008 |
case Qt::DragMoveCursor: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6009 |
return *move_cursor; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6010 |
case Qt::DragCopyCursor: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6011 |
return *copy_cursor; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6012 |
case Qt::DragLinkCursor: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6013 |
return *link_cursor; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6014 |
#ifdef Q_WS_WIN |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6015 |
case Qt::ForbiddenCursor: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6016 |
return *ignore_cursor; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6017 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6018 |
default: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6019 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6020 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6021 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6022 |
return QPixmap(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6023 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
25
diff
changeset
|
6024 |
|
0 | 6025 |
QT_END_NAMESPACE |
6026 |
||
6027 |
#include "moc_qapplication.cpp" |