| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | static void initResources() | - |
| 22 | { | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | extern int qInitResources_qstyle (); | - |
| 28 | do { extern int qInitResources_qstyle (); qInitResources_qstyle (); } while (0); | - |
| 29 | | - |
| 30 | extern int qInitResources_qmessagebox (); | - |
| 31 | do { extern int qInitResources_qmessagebox (); qInitResources_qmessagebox (); } while (0); | - |
| 32 | | - |
| 33 | } | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | __attribute__((visibility("default"))) void qt_call_post_routines(); | - |
| 38 | | - |
| 39 | QApplicationPrivate *QApplicationPrivate::self = 0; | - |
| 40 | | - |
| 41 | static void initSystemPalette() | - |
| 42 | { | - |
| 43 | if (!QApplicationPrivate::sys_pal) { | - |
| 44 | QPalette defaultPlatte; | - |
| 45 | if (QApplicationPrivate::app_style) | - |
| 46 | defaultPlatte = QApplicationPrivate::app_style->standardPalette(); | - |
| 47 | if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) { | - |
| 48 | QApplicationPrivate::setSystemPalette(themePalette->resolve(defaultPlatte)); | - |
| 49 | QApplicationPrivate::initializeWidgetPaletteHash(); | - |
| 50 | } else { | - |
| 51 | QApplicationPrivate::setSystemPalette(defaultPlatte); | - |
| 52 | } | - |
| 53 | } | - |
| 54 | } | - |
| 55 | | - |
| 56 | static void clearSystemPalette() | - |
| 57 | { | - |
| 58 | delete QApplicationPrivate::sys_pal; | - |
| 59 | QApplicationPrivate::sys_pal = 0; | - |
| 60 | } | - |
| 61 | | - |
| 62 | | - |
| 63 | | - |
| 64 | | - |
| 65 | | - |
| 66 | bool QApplicationPrivate::autoSipEnabled = true; | - |
| 67 | | - |
| 68 | | - |
| 69 | QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) | - |
| 70 | : QGuiApplicationPrivate(argc, argv, flags) | - |
| 71 | { | - |
| 72 | application_type = QApplicationPrivate::Gui; | - |
| 73 | | - |
| 74 | | - |
| 75 | gestureManager = 0; | - |
| 76 | gestureWidget = 0; | - |
| 77 | | - |
| 78 | | - |
| 79 | if (!self) | - |
| 80 | self = this; | - |
| 81 | } | - |
| 82 | | - |
| 83 | QApplicationPrivate::~QApplicationPrivate() | - |
| 84 | { | - |
| 85 | if (self == this) | - |
| 86 | self = 0; | - |
| 87 | } | - |
| 88 | void qt_init(QApplicationPrivate *priv, int type | - |
| 89 | ); | - |
| 90 | void qt_cleanup(); | - |
| 91 | | - |
| 92 | QStyle *QApplicationPrivate::app_style = 0; | - |
| 93 | QString QApplicationPrivate::styleOverride; | - |
| 94 | | - |
| 95 | | - |
| 96 | QString QApplicationPrivate::styleSheet; | - |
| 97 | | - |
| 98 | QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; | - |
| 99 | | - |
| 100 | int QApplicationPrivate::app_cspec = QApplication::NormalColor; | - |
| 101 | | - |
| 102 | QPalette *QApplicationPrivate::sys_pal = 0; | - |
| 103 | QPalette *QApplicationPrivate::set_pal = 0; | - |
| 104 | | - |
| 105 | QFont *QApplicationPrivate::sys_font = 0; | - |
| 106 | QFont *QApplicationPrivate::set_font = 0; | - |
| 107 | | - |
| 108 | QIcon *QApplicationPrivate::app_icon = 0; | - |
| 109 | QWidget *QApplicationPrivate::main_widget = 0; | - |
| 110 | QWidget *QApplicationPrivate::focus_widget = 0; | - |
| 111 | QWidget *QApplicationPrivate::hidden_focus_widget = 0; | - |
| 112 | QWidget *QApplicationPrivate::active_window = 0; | - |
| 113 | | - |
| 114 | int QApplicationPrivate::wheel_scroll_lines; | - |
| 115 | | - |
| 116 | bool qt_in_tab_key_event = false; | - |
| 117 | int qt_antialiasing_threshold = -1; | - |
| 118 | QSize QApplicationPrivate::app_strut = QSize(0,0); | - |
| 119 | int QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect; | - |
| 120 | bool QApplicationPrivate::widgetCount = false; | - |
| 121 | bool QApplicationPrivate::load_testability = false; | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | | - |
| 126 | | - |
| 127 | bool qt_tabletChokeMouse = false; | - |
| 128 | | - |
| 129 | inline bool QApplicationPrivate::isAlien(QWidget *widget) | - |
| 130 | { | - |
| 131 | return widget && !widget->isWindow(); | - |
| 132 | } | - |
| 133 | | - |
| 134 | bool __attribute__((visibility("default"))) qt_tab_all_widgets() | - |
| 135 | { | - |
| 136 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) | - |
| 137 | return theme->themeHint(QPlatformTheme::TabAllWidgets).toBool(); | - |
| 138 | return true; | - |
| 139 | } | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | static PaletteHash *app_palettes() { static QGlobalStatic<PaletteHash > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { PaletteHash *x = new PaletteHash; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<PaletteHash > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } | - |
| 144 | PaletteHash *qt_app_palettes_hash() | - |
| 145 | { | - |
| 146 | return app_palettes(); | - |
| 147 | } | - |
| 148 | | - |
| 149 | static FontHash *app_fonts() { static QGlobalStatic<FontHash > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { FontHash *x = new FontHash; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<FontHash > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } | - |
| 150 | FontHash *qt_app_fonts_hash() | - |
| 151 | { | - |
| 152 | return app_fonts(); | - |
| 153 | } | - |
| 154 | | - |
| 155 | QWidgetList *QApplicationPrivate::popupWidgets = 0; | - |
| 156 | | - |
| 157 | QDesktopWidget *qt_desktopWidget = 0; | - |
| 158 | | - |
| 159 | | - |
| 160 | | - |
| 161 | | - |
| 162 | void QApplicationPrivate::process_cmdline() | - |
| 163 | { | - |
| 164 | | - |
| 165 | if (!qt_is_gui_used || !argc) | - |
| 166 | return; | - |
| 167 | | - |
| 168 | int i, j; | - |
| 169 | | - |
| 170 | j = 1; | - |
| 171 | for (i=1; i<argc; i++) { | - |
| 172 | if (argv[i] && *argv[i] != '-') { | - |
| 173 | argv[j++] = argv[i]; | - |
| 174 | continue; | - |
| 175 | } | - |
| 176 | QByteArray arg = argv[i]; | - |
| 177 | arg = arg; | - |
| 178 | QString s; | - |
| 179 | if (arg == "-qdevel" || arg == "-qdebug") { | - |
| 180 | | - |
| 181 | } else if (arg.indexOf("-style=", 0) != -1) { | - |
| 182 | s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower()); | - |
| 183 | } else if (arg == "-style" && i < argc-1) { | - |
| 184 | s = QString::fromLocal8Bit(argv[++i]).toLower(); | - |
| 185 | | - |
| 186 | } else if (arg == "-stylesheet" && i < argc -1) { | - |
| 187 | styleSheet = QLatin1String("file:///"); | - |
| 188 | styleSheet.append(QString::fromLocal8Bit(argv[++i])); | - |
| 189 | } else if (arg.indexOf("-stylesheet=") != -1) { | - |
| 190 | styleSheet = QLatin1String("file:///"); | - |
| 191 | styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12))); | - |
| 192 | | - |
| 193 | } else if (qstrcmp(arg, "-widgetcount") == 0) { | - |
| 194 | widgetCount = true; | - |
| 195 | } else if (qstrcmp(arg, "-testability") == 0) { | - |
| 196 | load_testability = true; | - |
| 197 | } else { | - |
| 198 | argv[j++] = argv[i]; | - |
| 199 | } | - |
| 200 | if (!s.isEmpty()) { | - |
| 201 | if (app_style) { | - |
| 202 | delete app_style; | - |
| 203 | app_style = 0; | - |
| 204 | } | - |
| 205 | styleOverride = s; | - |
| 206 | } | - |
| 207 | } | - |
| 208 | | - |
| 209 | if(j < argc) { | - |
| 210 | argv[j] = 0; | - |
| 211 | argc = j; | - |
| 212 | } | - |
| 213 | } | - |
| 214 | QApplication::QApplication(int &argc, char **argv, int _internal) | - |
| 215 | | - |
| 216 | : QGuiApplication(*new QApplicationPrivate(argc, argv, _internal)) | - |
| 217 | { QApplicationPrivate * const d = d_func(); d->construct(); } | - |
| 218 | | - |
| 219 | | - |
| 220 | | - |
| 221 | | - |
| 222 | void QApplicationPrivate::construct() | - |
| 223 | { | - |
| 224 | initResources(); | - |
| 225 | | - |
| 226 | qt_is_gui_used = (application_type != QApplicationPrivate::Tty); | - |
| 227 | process_cmdline(); | - |
| 228 | | - |
| 229 | | - |
| 230 | qt_init(this, application_type); | - |
| 231 | initialize(); | - |
| 232 | eventDispatcher->startingUp(); | - |
| 233 | | - |
| 234 | | - |
| 235 | | - |
| 236 | | - |
| 237 | | - |
| 238 | | - |
| 239 | | - |
| 240 | if(load_testability) { | - |
| 241 | QLibrary testLib(QLatin1String("qttestability")); | - |
| 242 | if (testLib.load()) { | - |
| 243 | typedef void (*TasInitialize)(void); | - |
| 244 | TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); | - |
| 245 | if (initFunction) { | - |
| 246 | initFunction(); | - |
| 247 | } else { | - |
| 248 | QMessageLogger("kernel/qapplication.cpp", 569, __PRETTY_FUNCTION__).critical("Library qttestability resolve failed!"); | - |
| 249 | } | - |
| 250 | } else { | - |
| 251 | QMessageLogger("kernel/qapplication.cpp", 572, __PRETTY_FUNCTION__).critical("Library qttestability load failed!"); | - |
| 252 | } | - |
| 253 | } | - |
| 254 | | - |
| 255 | } | - |
| 256 | | - |
| 257 | | - |
| 258 | void qRegisterGuiStateMachine(); | - |
| 259 | void qUnregisterGuiStateMachine(); | - |
| 260 | | - |
| 261 | extern void qRegisterWidgetsVariant(); | - |
| 262 | | - |
| 263 | | - |
| 264 | | - |
| 265 | | - |
| 266 | | - |
| 267 | | - |
| 268 | void QApplicationPrivate::initialize() | - |
| 269 | { | - |
| 270 | QWidgetPrivate::mapper = new QWidgetMapper; | - |
| 271 | QWidgetPrivate::allWidgets = new QWidgetSet; | - |
| 272 | | - |
| 273 | | - |
| 274 | qRegisterWidgetsVariant(); | - |
| 275 | | - |
| 276 | if (application_type != QApplicationPrivate::Tty) partially evaluated: application_type != QApplicationPrivate::Tty| yes Evaluation Count:215 | no Evaluation Count:0 |
| 0-215 |
| 277 | (void) QApplication::style(); executed: (void) QApplication::style();Execution Count:215 | 215 |
| 278 | | - |
| 279 | | - |
| 280 | qRegisterGuiStateMachine(); | - |
| 281 | | - |
| 282 | | - |
| 283 | is_app_running = true; | - |
| 284 | | - |
| 285 | QApplication * const q = q_func(); | - |
| 286 | | - |
| 287 | if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0) partially evaluated: qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0| no Evaluation Count:0 | yes Evaluation Count:215 |
| 0-215 |
| 288 | q->setAttribute(Qt::AA_NativeWindows); never executed: q->setAttribute(Qt::AA_NativeWindows); | 0 |
| 289 | QApplicationPrivate::wheel_scroll_lines = 3; | - |
| 290 | | - |
| 291 | | - |
| 292 | if (qt_is_gui_used) partially evaluated: qt_is_gui_used| yes Evaluation Count:215 | no Evaluation Count:0 |
| 0-215 |
| 293 | initializeMultitouch(); executed: initializeMultitouch();Execution Count:215 | 215 |
| 294 | | - |
| 295 | if (QApplication::desktopSettingsAware()) partially evaluated: QApplication::desktopSettingsAware()| yes Evaluation Count:215 | no Evaluation Count:0 |
| 0-215 |
| 296 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) partially evaluated: const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()| yes Evaluation Count:215 | no Evaluation Count:0 |
| 0-215 |
| 297 | QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); executed: QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt();Execution Count:215 | 215 |
| 298 | } executed: }Execution Count:215 | 215 |
| 299 | QWidget *QApplication::activePopupWidget() | - |
| 300 | { | - |
| 301 | return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ? | - |
| 302 | QApplicationPrivate::popupWidgets->last() : 0; | - |
| 303 | } | - |
| 304 | QWidget *QApplication::activeModalWidget() | - |
| 305 | { | - |
| 306 | QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow()); | - |
| 307 | return widgetWindow ? widgetWindow->widget() : 0; | - |
| 308 | } | - |
| 309 | | - |
| 310 | | - |
| 311 | | - |
| 312 | | - |
| 313 | | - |
| 314 | | - |
| 315 | QApplication::~QApplication() | - |
| 316 | { | - |
| 317 | QApplicationPrivate * const d = d_func(); | - |
| 318 | | - |
| 319 | | - |
| 320 | qt_call_post_routines(); | - |
| 321 | | - |
| 322 | | - |
| 323 | d->toolTipWakeUp.stop(); | - |
| 324 | d->toolTipFallAsleep.stop(); | - |
| 325 | | - |
| 326 | QApplicationPrivate::is_app_closing = true; | - |
| 327 | QApplicationPrivate::is_app_running = false; | - |
| 328 | | - |
| 329 | delete QWidgetPrivate::mapper; | - |
| 330 | QWidgetPrivate::mapper = 0; | - |
| 331 | | - |
| 332 | | - |
| 333 | if (QWidgetPrivate::allWidgets) { | - |
| 334 | QWidgetSet *mySet = QWidgetPrivate::allWidgets; | - |
| 335 | QWidgetPrivate::allWidgets = 0; | - |
| 336 | for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) { | - |
| 337 | register QWidget *w = *it; | - |
| 338 | if (!w->parent()) | - |
| 339 | w->destroy(true, true); | - |
| 340 | } | - |
| 341 | delete mySet; | - |
| 342 | } | - |
| 343 | | - |
| 344 | delete qt_desktopWidget; | - |
| 345 | qt_desktopWidget = 0; | - |
| 346 | | - |
| 347 | delete QApplicationPrivate::app_pal; | - |
| 348 | QApplicationPrivate::app_pal = 0; | - |
| 349 | clearSystemPalette(); | - |
| 350 | delete QApplicationPrivate::set_pal; | - |
| 351 | QApplicationPrivate::set_pal = 0; | - |
| 352 | app_palettes()->clear(); | - |
| 353 | | - |
| 354 | delete QApplicationPrivate::sys_font; | - |
| 355 | QApplicationPrivate::sys_font = 0; | - |
| 356 | delete QApplicationPrivate::set_font; | - |
| 357 | QApplicationPrivate::set_font = 0; | - |
| 358 | app_fonts()->clear(); | - |
| 359 | | - |
| 360 | delete QApplicationPrivate::app_style; | - |
| 361 | QApplicationPrivate::app_style = 0; | - |
| 362 | delete QApplicationPrivate::app_icon; | - |
| 363 | QApplicationPrivate::app_icon = 0; | - |
| 364 | | - |
| 365 | | - |
| 366 | if (qt_is_gui_used) | - |
| 367 | delete QDragManager::self(); | - |
| 368 | | - |
| 369 | | - |
| 370 | d->cleanupMultitouch(); | - |
| 371 | | - |
| 372 | qt_cleanup(); | - |
| 373 | | - |
| 374 | if (QApplicationPrivate::widgetCount) | - |
| 375 | QMessageLogger("kernel/qapplication.cpp", 741745, __PRETTY_FUNCTION__).debug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances); | - |
| 376 | | - |
| 377 | QApplicationPrivate::obey_desktop_settings = true; | - |
| 378 | | - |
| 379 | QApplicationPrivate::app_strut = QSize(0, 0); | - |
| 380 | QApplicationPrivate::enabledAnimations = QPlatformTheme::GeneralUiEffect; | - |
| 381 | QApplicationPrivate::widgetCount = false; | - |
| 382 | | - |
| 383 | | - |
| 384 | | - |
| 385 | qUnregisterGuiStateMachine(); | - |
| 386 | | - |
| 387 | } | - |
| 388 | QWidget *QApplication::widgetAt(const QPoint &p) | - |
| 389 | { | - |
| 390 | QWidget *window = QApplication::topLevelAt(p); | - |
| 391 | if (!window) | - |
| 392 | return 0; | - |
| 393 | | - |
| 394 | QWidget *child = 0; | - |
| 395 | | - |
| 396 | if (!window->testAttribute(Qt::WA_TransparentForMouseEvents)) | - |
| 397 | child = window->childAt(window->mapFromGlobal(p)); | - |
| 398 | | - |
| 399 | if (child) | - |
| 400 | return child; | - |
| 401 | | - |
| 402 | if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) { | - |
| 403 | | - |
| 404 | | - |
| 405 | | - |
| 406 | int x = p.x(); | - |
| 407 | int y = p.y(); | - |
| 408 | QRegion oldmask = window->mask(); | - |
| 409 | QPoint wpoint = window->mapFromGlobal(QPoint(x, y)); | - |
| 410 | QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask) | - |
| 411 | - QRegion(wpoint.x(), wpoint.y(), 1, 1); | - |
| 412 | window->setMask(newmask); | - |
| 413 | QWidget *recurse = 0; | - |
| 414 | if (QApplication::topLevelAt(p) != window) | - |
| 415 | recurse = widgetAt(x, y); | - |
| 416 | if (oldmask.isEmpty()) | - |
| 417 | window->clearMask(); | - |
| 418 | else | - |
| 419 | window->setMask(oldmask); | - |
| 420 | return recurse; | - |
| 421 | } | - |
| 422 | return window; | - |
| 423 | } | - |
| 424 | bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) | - |
| 425 | { | - |
| 426 | if ((event->type() == QEvent::UpdateRequest | - |
| 427 | || event->type() == QEvent::LayoutRequest | - |
| 428 | || event->type() == QEvent::Resize | - |
| 429 | || event->type() == QEvent::Move | - |
| 430 | || event->type() == QEvent::LanguageChange | - |
| 431 | || event->type() == QEvent::InputMethod)) { | - |
| 432 | for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) { | - |
| 433 | const QPostEvent &cur = *it; | - |
| 434 | if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type()) | - |
| 435 | continue; | - |
| 436 | if (cur.event->type() == QEvent::LayoutRequest | - |
| 437 | || cur.event->type() == QEvent::UpdateRequest) { | - |
| 438 | ; | - |
| 439 | } else if (cur.event->type() == QEvent::Resize) { | - |
| 440 | ((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s; | - |
| 441 | } else if (cur.event->type() == QEvent::Move) { | - |
| 442 | ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p; | - |
| 443 | } else if (cur.event->type() == QEvent::LanguageChange) { | - |
| 444 | ; | - |
| 445 | } else if ( cur.event->type() == QEvent::InputMethod ) { | - |
| 446 | *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event; | - |
| 447 | } else { | - |
| 448 | continue; | - |
| 449 | } | - |
| 450 | delete event; | - |
| 451 | return true; | - |
| 452 | } | - |
| 453 | return false; | - |
| 454 | } | - |
| 455 | return QGuiApplication::compressEvent(event, receiver, postedEvents); | - |
| 456 | } | - |
| 457 | void QApplication::setAutoSipEnabled(const bool enabled) | - |
| 458 | { | - |
| 459 | QApplicationPrivate::autoSipEnabled = enabled; | - |
| 460 | } | - |
| 461 | | - |
| 462 | bool QApplication::autoSipEnabled() const | - |
| 463 | { | - |
| 464 | return QApplicationPrivate::autoSipEnabled; | - |
| 465 | } | - |
| 466 | | - |
| 467 | | - |
| 468 | | - |
| 469 | QString QApplication::styleSheet() const | - |
| 470 | { | - |
| 471 | return QApplicationPrivate::styleSheet; | - |
| 472 | } | - |
| 473 | | - |
| 474 | void QApplication::setStyleSheet(const QString& styleSheet) | - |
| 475 | { | - |
| 476 | QApplicationPrivate::styleSheet = styleSheet; | - |
| 477 | QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplicationPrivate::app_style); | - |
| 478 | if (styleSheet.isEmpty()) { | - |
| 479 | if (!proxy) | - |
| 480 | return; | - |
| 481 | setStyle(proxy->base); | - |
| 482 | } else if (proxy) { | - |
| 483 | proxy->repolish((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 484 | } else { | - |
| 485 | QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style); | - |
| 486 | QApplicationPrivate::app_style->setParent(newProxy); | - |
| 487 | setStyle(newProxy); | - |
| 488 | } | - |
| 489 | } | - |
| 490 | QStyle *QApplication::style() | - |
| 491 | { | - |
| 492 | if (QApplicationPrivate::app_style) | - |
| 493 | return QApplicationPrivate::app_style; | - |
| 494 | if (!qobject_cast<QApplication *>(QCoreApplication::instance())) { | - |
| 495 | qt_noop(); | - |
| 496 | return 0; | - |
| 497 | } | - |
| 498 | | - |
| 499 | if (!QApplicationPrivate::app_style) { | - |
| 500 | | - |
| 501 | | - |
| 502 | QString style; | - |
| 503 | | - |
| 504 | | - |
| 505 | | - |
| 506 | QString envStyle; | - |
| 507 | | - |
| 508 | if (!QApplicationPrivate::styleOverride.isEmpty()) { | - |
| 509 | style = QApplicationPrivate::styleOverride; | - |
| 510 | } else if (!envStyle.isEmpty()) { | - |
| 511 | style = envStyle; | - |
| 512 | } else { | - |
| 513 | style = QApplicationPrivate::desktopStyleKey(); | - |
| 514 | } | - |
| 515 | | - |
| 516 | QStyle *&app_style = QApplicationPrivate::app_style; | - |
| 517 | app_style = QStyleFactory::create(style); | - |
| 518 | if (!app_style) { | - |
| 519 | QStringList styles = QStyleFactory::keys(); | - |
| 520 | for (int i = 0; i < styles.size(); ++i) { | - |
| 521 | if ((app_style = QStyleFactory::create(styles.at(i)))) | - |
| 522 | break; | - |
| 523 | } | - |
| 524 | } | - |
| 525 | if (!app_style) { | - |
| 526 | qt_noop(); | - |
| 527 | return 0; | - |
| 528 | } | - |
| 529 | } | - |
| 530 | | - |
| 531 | QApplicationPrivate::app_style->setParent((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 532 | | - |
| 533 | initSystemPalette(); | - |
| 534 | | - |
| 535 | if (QApplicationPrivate::set_pal) | - |
| 536 | QApplication::setPalette(*QApplicationPrivate::set_pal); | - |
| 537 | | - |
| 538 | | - |
| 539 | if (!QApplicationPrivate::styleSheet.isEmpty()) { | - |
| 540 | (static_cast<QApplication *>(QCoreApplication::instance()))->setStyleSheet(QApplicationPrivate::styleSheet); | - |
| 541 | } else | - |
| 542 | | - |
| 543 | QApplicationPrivate::app_style->polish((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 544 | | - |
| 545 | return QApplicationPrivate::app_style; | - |
| 546 | } | - |
| 547 | void QApplication::setStyle(QStyle *style) | - |
| 548 | { | - |
| 549 | if (!style || style == QApplicationPrivate::app_style) | - |
| 550 | return; | - |
| 551 | | - |
| 552 | QWidgetList all = allWidgets(); | - |
| 553 | | - |
| 554 | | - |
| 555 | if (QApplicationPrivate::app_style) { | - |
| 556 | if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { | - |
| 557 | for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { | - |
| 558 | register QWidget *w = *it; | - |
| 559 | if (!(w->windowType() == Qt::Desktop) && | - |
| 560 | w->testAttribute(Qt::WA_WState_Polished)) { | - |
| 561 | QApplicationPrivate::app_style->unpolish(w); | - |
| 562 | } | - |
| 563 | } | - |
| 564 | } | - |
| 565 | QApplicationPrivate::app_style->unpolish((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 566 | } | - |
| 567 | | - |
| 568 | QStyle *old = QApplicationPrivate::app_style; | - |
| 569 | | - |
| 570 | | - |
| 571 | if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) { | - |
| 572 | | - |
| 573 | QStyleSheetStyle *newProxy = new QStyleSheetStyle(style); | - |
| 574 | style->setParent(newProxy); | - |
| 575 | QApplicationPrivate::app_style = newProxy; | - |
| 576 | } else | - |
| 577 | | - |
| 578 | QApplicationPrivate::app_style = style; | - |
| 579 | QApplicationPrivate::app_style->setParent((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 580 | | - |
| 581 | | - |
| 582 | | - |
| 583 | | - |
| 584 | if (QApplicationPrivate::set_pal) { | - |
| 585 | QApplication::setPalette(*QApplicationPrivate::set_pal); | - |
| 586 | } else if (QApplicationPrivate::sys_pal) { | - |
| 587 | QApplicationPrivate::initializeWidgetPaletteHash(); | - |
| 588 | QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, 0, false); | - |
| 589 | } else if (!QApplicationPrivate::sys_pal) { | - |
| 590 | | - |
| 591 | QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); | - |
| 592 | } | - |
| 593 | | - |
| 594 | | - |
| 595 | QApplicationPrivate::app_style->polish((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 596 | | - |
| 597 | | - |
| 598 | if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { | - |
| 599 | for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) { | - |
| 600 | register QWidget *w = *it1; | - |
| 601 | if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) { | - |
| 602 | if (w->style() == QApplicationPrivate::app_style) | - |
| 603 | QApplicationPrivate::app_style->polish(w); | - |
| 604 | | - |
| 605 | else | - |
| 606 | w->setStyleSheet(w->styleSheet()); | - |
| 607 | | - |
| 608 | } | - |
| 609 | } | - |
| 610 | | - |
| 611 | for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) { | - |
| 612 | register QWidget *w = *it2; | - |
| 613 | if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) { | - |
| 614 | QEvent e(QEvent::StyleChange); | - |
| 615 | QApplication::sendEvent(w, &e); | - |
| 616 | w->update(); | - |
| 617 | } | - |
| 618 | } | - |
| 619 | } | - |
| 620 | | - |
| 621 | | - |
| 622 | if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) { | - |
| 623 | oldProxy->deref(); | - |
| 624 | } else | - |
| 625 | | - |
| 626 | if (old && old->parent() == (static_cast<QApplication *>(QCoreApplication::instance()))) { | - |
| 627 | delete old; | - |
| 628 | } | - |
| 629 | | - |
| 630 | if (QApplicationPrivate::focus_widget) { | - |
| 631 | QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason); | - |
| 632 | QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in); | - |
| 633 | QApplicationPrivate::focus_widget->update(); | - |
| 634 | } | - |
| 635 | } | - |
| 636 | QStyle* QApplication::setStyle(const QString& style) | - |
| 637 | { | - |
| 638 | QStyle *s = QStyleFactory::create(style); | - |
| 639 | if (!s) | - |
| 640 | return 0; | - |
| 641 | | - |
| 642 | setStyle(s); | - |
| 643 | return s; | - |
| 644 | } | - |
| 645 | | - |
| 646 | | - |
| 647 | | - |
| 648 | | - |
| 649 | | - |
| 650 | | - |
| 651 | | - |
| 652 | int QApplication::colorSpec() | - |
| 653 | { | - |
| 654 | return QApplicationPrivate::app_cspec; | - |
| 655 | } | - |
| 656 | void QApplication::setColorSpec(int spec) | - |
| 657 | { | - |
| 658 | if ((static_cast<QApplication *>(QCoreApplication::instance()))) | - |
| 659 | QMessageLogger("kernel/qapplication.cpp", 12181222, __PRETTY_FUNCTION__).warning("QApplication::setColorSpec: This function must be " | - |
| 660 | "called before the QApplication object is created"); | - |
| 661 | QApplicationPrivate::app_cspec = spec; | - |
| 662 | } | - |
| 663 | QSize QApplication::globalStrut() | - |
| 664 | { | - |
| 665 | return QApplicationPrivate::app_strut; | - |
| 666 | } | - |
| 667 | | - |
| 668 | void QApplication::setGlobalStrut(const QSize& strut) | - |
| 669 | { | - |
| 670 | QApplicationPrivate::app_strut = strut; | - |
| 671 | } | - |
| 672 | QPalette QApplication::palette(const QWidget* w) | - |
| 673 | { | - |
| 674 | PaletteHash *hash = app_palettes(); | - |
| 675 | if (w && hash && hash->size()) { | - |
| 676 | QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className()); | - |
| 677 | if (it != hash->constEnd()) | - |
| 678 | return *it; | - |
| 679 | for (it = hash->constBegin(); it != hash->constEnd(); ++it) { | - |
| 680 | if (w->inherits(it.key())) | - |
| 681 | return it.value(); | - |
| 682 | } | - |
| 683 | } | - |
| 684 | return palette(); | - |
| 685 | } | - |
| 686 | QPalette QApplication::palette(const char *className) | - |
| 687 | { | - |
| 688 | if (!QApplicationPrivate::app_pal) | - |
| 689 | palette(); | - |
| 690 | PaletteHash *hash = app_palettes(); | - |
| 691 | if (className && hash && hash->size()) { | - |
| 692 | QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className); | - |
| 693 | if (it != hash->constEnd()) | - |
| 694 | return *it; | - |
| 695 | } | - |
| 696 | return *QApplicationPrivate::app_pal; | - |
| 697 | } | - |
| 698 | | - |
| 699 | void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash) | - |
| 700 | { | - |
| 701 | QPalette pal = palette; | - |
| 702 | | - |
| 703 | if (QApplicationPrivate::app_style) | - |
| 704 | QApplicationPrivate::app_style->polish(pal); | - |
| 705 | | - |
| 706 | bool all = false; | - |
| 707 | PaletteHash *hash = app_palettes(); | - |
| 708 | if (!className) { | - |
| 709 | if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal)) | - |
| 710 | return; | - |
| 711 | if (!QApplicationPrivate::app_pal) | - |
| 712 | QApplicationPrivate::app_pal = new QPalette(pal); | - |
| 713 | else | - |
| 714 | *QApplicationPrivate::app_pal = pal; | - |
| 715 | if (hash && hash->size()) { | - |
| 716 | all = true; | - |
| 717 | if (clearWidgetPaletteHash) | - |
| 718 | hash->clear(); | - |
| 719 | } | - |
| 720 | } else if (hash) { | - |
| 721 | hash->insert(className, pal); | - |
| 722 | } | - |
| 723 | | - |
| 724 | if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { | - |
| 725 | | - |
| 726 | QEvent e(QEvent::ApplicationPaletteChange); | - |
| 727 | QApplication::sendEvent(QApplication::instance(), &e); | - |
| 728 | | - |
| 729 | QWidgetList wids = QApplication::allWidgets(); | - |
| 730 | for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) { | - |
| 731 | register QWidget *w = *it; | - |
| 732 | if (all || (!className && w->isWindow()) || w->inherits(className)) | - |
| 733 | QApplication::sendEvent(w, &e); | - |
| 734 | } | - |
| 735 | | - |
| 736 | | - |
| 737 | | - |
| 738 | QList<QGraphicsScene *> &scenes = (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list; | - |
| 739 | for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin(); | - |
| 740 | it != scenes.constEnd(); ++it) { | - |
| 741 | QApplication::sendEvent(*it, &e); | - |
| 742 | } | - |
| 743 | | - |
| 744 | } | - |
| 745 | if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { | - |
| 746 | if (!QApplicationPrivate::set_pal) | - |
| 747 | QApplicationPrivate::set_pal = new QPalette(palette); | - |
| 748 | else | - |
| 749 | *QApplicationPrivate::set_pal = palette; | - |
| 750 | } | - |
| 751 | } | - |
| 752 | void QApplication::setPalette(const QPalette &palette, const char* className) | - |
| 753 | { | - |
| 754 | QApplicationPrivate::setPalette_helper(palette, className, true); | - |
| 755 | } | - |
| 756 | | - |
| 757 | | - |
| 758 | | - |
| 759 | void QApplicationPrivate::setSystemPalette(const QPalette &pal) | - |
| 760 | { | - |
| 761 | QPalette adjusted; | - |
| 762 | adjusted = pal; | - |
| 763 | | - |
| 764 | | - |
| 765 | if (!sys_pal) | - |
| 766 | sys_pal = new QPalette(adjusted); | - |
| 767 | else | - |
| 768 | *sys_pal = adjusted; | - |
| 769 | | - |
| 770 | | - |
| 771 | if (!QApplicationPrivate::set_pal) | - |
| 772 | QApplication::setPalette(*sys_pal); | - |
| 773 | } | - |
| 774 | | - |
| 775 | | - |
| 776 | | - |
| 777 | | - |
| 778 | | - |
| 779 | | - |
| 780 | QFont QApplication::font() | - |
| 781 | { | - |
| 782 | return QGuiApplication::font(); | - |
| 783 | } | - |
| 784 | QFont QApplication::font(const QWidget *widget) | - |
| 785 | { | - |
| 786 | FontHash *hash = app_fonts(); | - |
| 787 | | - |
| 788 | if (widget && hash && hash->size()) { | - |
| 789 | QHash<QByteArray, QFont>::ConstIterator it = | - |
| 790 | hash->constFind(widget->metaObject()->className()); | - |
| 791 | if (it != hash->constEnd()) | - |
| 792 | return it.value(); | - |
| 793 | for (it = hash->constBegin(); it != hash->constEnd(); ++it) { | - |
| 794 | if (widget->inherits(it.key())) | - |
| 795 | return it.value(); | - |
| 796 | } | - |
| 797 | } | - |
| 798 | return font(); | - |
| 799 | } | - |
| 800 | QFont QApplication::font(const char *className) | - |
| 801 | { | - |
| 802 | FontHash *hash = app_fonts(); | - |
| 803 | if (className && hash && hash->size()) { | - |
| 804 | QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(className); | - |
| 805 | if (it != hash->constEnd()) | - |
| 806 | return *it; | - |
| 807 | } | - |
| 808 | return font(); | - |
| 809 | } | - |
| 810 | void QApplication::setFont(const QFont &font, const char *className) | - |
| 811 | { | - |
| 812 | bool all = false; | - |
| 813 | FontHash *hash = app_fonts(); | - |
| 814 | if (!className) { | - |
| 815 | QGuiApplication::setFont(font); | - |
| 816 | if (hash && hash->size()) { | - |
| 817 | all = true; | - |
| 818 | hash->clear(); | - |
| 819 | } | - |
| 820 | } else if (hash) { | - |
| 821 | hash->insert(className, font); | - |
| 822 | } | - |
| 823 | if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { | - |
| 824 | | - |
| 825 | QEvent e(QEvent::ApplicationFontChange); | - |
| 826 | QApplication::sendEvent(QApplication::instance(), &e); | - |
| 827 | | - |
| 828 | QWidgetList wids = QApplication::allWidgets(); | - |
| 829 | for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) { | - |
| 830 | register QWidget *w = *it; | - |
| 831 | if (all || (!className && w->isWindow()) || w->inherits(className)) | - |
| 832 | sendEvent(w, &e); | - |
| 833 | } | - |
| 834 | | - |
| 835 | | - |
| 836 | | - |
| 837 | QList<QGraphicsScene *> &scenes = (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list; | - |
| 838 | for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin(); | - |
| 839 | it != scenes.constEnd(); ++it) { | - |
| 840 | QApplication::sendEvent(*it, &e); | - |
| 841 | } | - |
| 842 | | - |
| 843 | } | - |
| 844 | if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) { | - |
| 845 | if (!QApplicationPrivate::set_font) | - |
| 846 | QApplicationPrivate::set_font = new QFont(font); | - |
| 847 | else | - |
| 848 | *QApplicationPrivate::set_font = font; | - |
| 849 | } | - |
| 850 | } | - |
| 851 | | - |
| 852 | | - |
| 853 | | - |
| 854 | void QApplicationPrivate::setSystemFont(const QFont &font) | - |
| 855 | { | - |
| 856 | if (!sys_font) | - |
| 857 | sys_font = new QFont(font); | - |
| 858 | else | - |
| 859 | *sys_font = font; | - |
| 860 | | - |
| 861 | if (!QApplicationPrivate::set_font) | - |
| 862 | QApplication::setFont(*sys_font); | - |
| 863 | } | - |
| 864 | | - |
| 865 | | - |
| 866 | | - |
| 867 | QString QApplicationPrivate::desktopStyleKey() | - |
| 868 | { | - |
| 869 | | - |
| 870 | | - |
| 871 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { | - |
| 872 | const QStringList availableKeys = QStyleFactory::keys(); | - |
| 873 | for (QForeachContainer<__typeof__(theme->themeHint(QPlatformTheme::StyleNames).toStringList())> _container_(theme->themeHint(QPlatformTheme::StyleNames).toStringList()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QString &style = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
| 874 | if (availableKeys.contains(style, Qt::CaseInsensitive)) | - |
| 875 | return style; | - |
| 876 | } | - |
| 877 | return QString(); | - |
| 878 | } | - |
| 879 | | - |
| 880 | | - |
| 881 | | - |
| 882 | | - |
| 883 | | - |
| 884 | | - |
| 885 | | - |
| 886 | QIcon QApplication::windowIcon() | - |
| 887 | { | - |
| 888 | return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon(); | - |
| 889 | } | - |
| 890 | | - |
| 891 | void QApplication::setWindowIcon(const QIcon &icon) | - |
| 892 | { | - |
| 893 | if (!QApplicationPrivate::app_icon) | - |
| 894 | QApplicationPrivate::app_icon = new QIcon(); | - |
| 895 | *QApplicationPrivate::app_icon = icon; | - |
| 896 | if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { | - |
| 897 | QEvent e(QEvent::ApplicationWindowIconChange); | - |
| 898 | QWidgetList all = QApplication::allWidgets(); | - |
| 899 | for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { | - |
| 900 | register QWidget *w = *it; | - |
| 901 | if (w->isWindow()) | - |
| 902 | sendEvent(w, &e); | - |
| 903 | } | - |
| 904 | } | - |
| 905 | } | - |
| 906 | QWidgetList QApplication::topLevelWidgets() | - |
| 907 | { | - |
| 908 | QWidgetList list; | - |
| 909 | QWidgetList all = allWidgets(); | - |
| 910 | | - |
| 911 | for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { | - |
| 912 | QWidget *w = *it; | - |
| 913 | if (w->isWindow() && w->windowType() != Qt::Desktop) | - |
| 914 | list.append(w); | - |
| 915 | } | - |
| 916 | return list; | - |
| 917 | } | - |
| 918 | QWidgetList QApplication::allWidgets() | - |
| 919 | { | - |
| 920 | if (QWidgetPrivate::allWidgets) | - |
| 921 | return QWidgetPrivate::allWidgets->toList(); | - |
| 922 | return QWidgetList(); | - |
| 923 | } | - |
| 924 | QWidget *QApplication::focusWidget() | - |
| 925 | { | - |
| 926 | return QApplicationPrivate::focus_widget; | - |
| 927 | } | - |
| 928 | | - |
| 929 | void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) | - |
| 930 | { | - |
| 931 | | - |
| 932 | if (focus && focus->window()->graphicsProxyWidget()) | - |
| 933 | return; | - |
| 934 | | - |
| 935 | | - |
| 936 | hidden_focus_widget = 0; | - |
| 937 | | - |
| 938 | if (focus != focus_widget) { | - |
| 939 | if (focus && focus->isHidden()) { | - |
| 940 | hidden_focus_widget = focus; | - |
| 941 | return; | - |
| 942 | } | - |
| 943 | | - |
| 944 | if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason) | - |
| 945 | && qt_in_tab_key_event) | - |
| 946 | focus->window()->setAttribute(Qt::WA_KeyboardFocusChange); | - |
| 947 | else if (focus && reason == Qt::ShortcutFocusReason) { | - |
| 948 | focus->window()->setAttribute(Qt::WA_KeyboardFocusChange); | - |
| 949 | } | - |
| 950 | QWidget *prev = focus_widget; | - |
| 951 | focus_widget = focus; | - |
| 952 | | - |
| 953 | if(focus_widget) | - |
| 954 | focus_widget->d_func()->setFocus_sys(); | - |
| 955 | | - |
| 956 | if (reason != Qt::NoFocusReason) { | - |
| 957 | | - |
| 958 | | - |
| 959 | if (prev) { | - |
| 960 | | - |
| 961 | | - |
| 962 | | - |
| 963 | | - |
| 964 | | - |
| 965 | | - |
| 966 | QFocusEvent out(QEvent::FocusOut, reason); | - |
| 967 | QPointer<QWidget> that = prev; | - |
| 968 | QApplication::sendEvent(prev, &out); | - |
| 969 | if (that) | - |
| 970 | QApplication::sendEvent(that->style(), &out); | - |
| 971 | } | - |
| 972 | if(focus && QApplicationPrivate::focus_widget == focus) { | - |
| 973 | QFocusEvent in(QEvent::FocusIn, reason); | - |
| 974 | QPointer<QWidget> that = focus; | - |
| 975 | QApplication::sendEvent(focus, &in); | - |
| 976 | if (that) | - |
| 977 | QApplication::sendEvent(that->style(), &in); | - |
| 978 | } | - |
| 979 | (static_cast<QApplication *>(QCoreApplication::instance()))->focusChanged(prev, focus_widget); | - |
| 980 | } | - |
| 981 | } | - |
| 982 | } | - |
| 983 | QWidget *QApplication::activeWindow() | - |
| 984 | { | - |
| 985 | return QApplicationPrivate::active_window; | - |
| 986 | } | - |
| 987 | | - |
| 988 | | - |
| 989 | | - |
| 990 | | - |
| 991 | | - |
| 992 | | - |
| 993 | | - |
| 994 | QFontMetrics QApplication::fontMetrics() | - |
| 995 | { | - |
| 996 | return desktop()->fontMetrics(); | - |
| 997 | } | - |
| 998 | void QApplication::closeAllWindows() | - |
| 999 | { | - |
| 1000 | bool did_close = true; | - |
| 1001 | QWidget *w; | - |
| 1002 | while ((w = activeModalWidget()) && did_close) { | - |
| 1003 | if (!w->isVisible() || w->data->is_closing) | - |
| 1004 | break; | - |
| 1005 | did_close = w->close(); | - |
| 1006 | } | - |
| 1007 | QWidgetList list = QApplication::topLevelWidgets(); | - |
| 1008 | for (int i = 0; did_close && i < list.size(); ++i) { | - |
| 1009 | w = list.at(i); | - |
| 1010 | if (w->isVisible() | - |
| 1011 | && w->windowType() != Qt::Desktop | - |
| 1012 | && !w->data->is_closing) { | - |
| 1013 | did_close = w->close(); | - |
| 1014 | list = QApplication::topLevelWidgets(); | - |
| 1015 | i = -1; | - |
| 1016 | } | - |
| 1017 | } | - |
| 1018 | } | - |
| 1019 | void QApplication::aboutQt() | - |
| 1020 | { | - |
| 1021 | | - |
| 1022 | QMessageBox::aboutQt(activeWindow()); | - |
| 1023 | | - |
| 1024 | } | - |
| 1025 | bool QApplication::event(QEvent *e) | - |
| 1026 | { | - |
| 1027 | QApplicationPrivate * const d = d_func(); | - |
| 1028 | if(e->type() == QEvent::Close) { | - |
| 1029 | QCloseEvent *ce = static_cast<QCloseEvent*>(e); | - |
| 1030 | ce->accept(); | - |
| 1031 | closeAllWindows(); | - |
| 1032 | | - |
| 1033 | QWidgetList list = topLevelWidgets(); | - |
| 1034 | for (int i = 0; i < list.size(); ++i) { | - |
| 1035 | QWidget *w = list.at(i); | - |
| 1036 | if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) && | - |
| 1037 | (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) { | - |
| 1038 | ce->ignore(); | - |
| 1039 | break; | - |
| 1040 | } | - |
| 1041 | } | - |
| 1042 | if (ce->isAccepted()) { | - |
| 1043 | return true; | - |
| 1044 | } | - |
| 1045 | | - |
| 1046 | } else if (e->type() == QEvent::LocaleChange) { | - |
| 1047 | | - |
| 1048 | | - |
| 1049 | QWidgetList list = topLevelWidgets(); | - |
| 1050 | for (int i = 0; i < list.size(); ++i) { | - |
| 1051 | QWidget *w = list.at(i); | - |
| 1052 | if (!(w->windowType() == Qt::Desktop)) { | - |
| 1053 | if (!w->testAttribute(Qt::WA_SetLocale)) | - |
| 1054 | w->d_func()->setLocale_helper(QLocale(), true); | - |
| 1055 | } | - |
| 1056 | } | - |
| 1057 | | - |
| 1058 | } else if (e->type() == QEvent::Timer) { | - |
| 1059 | QTimerEvent *te = static_cast<QTimerEvent*>(e); | - |
| 1060 | qt_noop(); | - |
| 1061 | if (te->timerId() == d->toolTipWakeUp.timerId()) { | - |
| 1062 | d->toolTipWakeUp.stop(); | - |
| 1063 | if (d->toolTipWidget) { | - |
| 1064 | QWidget *w = d->toolTipWidget->window(); | - |
| 1065 | | - |
| 1066 | | - |
| 1067 | | - |
| 1068 | bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips); | - |
| 1069 | while (w && !showToolTip) { | - |
| 1070 | showToolTip = w->isActiveWindow(); | - |
| 1071 | w = w->parentWidget(); | - |
| 1072 | w = w ? w->window() : 0; | - |
| 1073 | } | - |
| 1074 | if (showToolTip) { | - |
| 1075 | QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos); | - |
| 1076 | QApplication::sendEvent(d->toolTipWidget, &e); | - |
| 1077 | if (e.isAccepted()) | - |
| 1078 | d->toolTipFallAsleep.start(2000, this); | - |
| 1079 | } | - |
| 1080 | } | - |
| 1081 | } else if (te->timerId() == d->toolTipFallAsleep.timerId()) { | - |
| 1082 | d->toolTipFallAsleep.stop(); | - |
| 1083 | } | - |
| 1084 | } | - |
| 1085 | | - |
| 1086 | if(e->type() == QEvent::LanguageChange) { | - |
| 1087 | QWidgetList list = topLevelWidgets(); | - |
| 1088 | for (int i = 0; i < list.size(); ++i) { | - |
| 1089 | QWidget *w = list.at(i); | - |
| 1090 | if (!(w->windowType() == Qt::Desktop)) | - |
| 1091 | postEvent(w, new QEvent(QEvent::LanguageChange)); | - |
| 1092 | } | - |
| 1093 | } | - |
| 1094 | | - |
| 1095 | return QGuiApplication::event(e); | - |
| 1096 | } | - |
| 1097 | void QApplicationPrivate::notifyLayoutDirectionChange() | - |
| 1098 | { | - |
| 1099 | QWidgetList list = QApplication::topLevelWidgets(); | - |
| 1100 | for (int i = 0; i < list.size(); ++i) { | - |
| 1101 | QWidget *w = list.at(i); | - |
| 1102 | QEvent ev(QEvent::ApplicationLayoutDirectionChange); | - |
| 1103 | QCoreApplication::sendEvent(w, &ev); | - |
| 1104 | } | - |
| 1105 | } | - |
| 1106 | void QApplication::setActiveWindow(QWidget* act) | - |
| 1107 | { | - |
| 1108 | QWidget* window = act?act->window():0; | - |
| 1109 | | - |
| 1110 | if (QApplicationPrivate::active_window == window) | - |
| 1111 | return; | - |
| 1112 | | - |
| 1113 | | - |
| 1114 | if (window && window->graphicsProxyWidget()) { | - |
| 1115 | | - |
| 1116 | return; | - |
| 1117 | } | - |
| 1118 | | - |
| 1119 | | - |
| 1120 | QWidgetList toBeActivated; | - |
| 1121 | QWidgetList toBeDeactivated; | - |
| 1122 | | - |
| 1123 | if (QApplicationPrivate::active_window) { | - |
| 1124 | if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { | - |
| 1125 | QWidgetList list = topLevelWidgets(); | - |
| 1126 | for (int i = 0; i < list.size(); ++i) { | - |
| 1127 | QWidget *w = list.at(i); | - |
| 1128 | if (w->isVisible() && w->isActiveWindow()) | - |
| 1129 | toBeDeactivated.append(w); | - |
| 1130 | } | - |
| 1131 | } else { | - |
| 1132 | toBeDeactivated.append(QApplicationPrivate::active_window); | - |
| 1133 | } | - |
| 1134 | } | - |
| 1135 | | - |
| 1136 | if (QApplicationPrivate::focus_widget) { | - |
| 1137 | if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) | - |
| 1138 | (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit(); | - |
| 1139 | | - |
| 1140 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); | - |
| 1141 | QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); | - |
| 1142 | } | - |
| 1143 | | - |
| 1144 | QApplicationPrivate::active_window = window; | - |
| 1145 | | - |
| 1146 | if (QApplicationPrivate::active_window) { | - |
| 1147 | if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) { | - |
| 1148 | QWidgetList list = topLevelWidgets(); | - |
| 1149 | for (int i = 0; i < list.size(); ++i) { | - |
| 1150 | QWidget *w = list.at(i); | - |
| 1151 | if (w->isVisible() && w->isActiveWindow()) | - |
| 1152 | toBeActivated.append(w); | - |
| 1153 | } | - |
| 1154 | } else { | - |
| 1155 | toBeActivated.append(QApplicationPrivate::active_window); | - |
| 1156 | } | - |
| 1157 | | - |
| 1158 | } | - |
| 1159 | | - |
| 1160 | | - |
| 1161 | QEvent activationChange(QEvent::ActivationChange); | - |
| 1162 | QEvent windowActivate(QEvent::WindowActivate); | - |
| 1163 | QEvent windowDeactivate(QEvent::WindowDeactivate); | - |
| 1164 | | - |
| 1165 | for (int i = 0; i < toBeActivated.size(); ++i) { | - |
| 1166 | QWidget *w = toBeActivated.at(i); | - |
| 1167 | sendSpontaneousEvent(w, &windowActivate); | - |
| 1168 | sendSpontaneousEvent(w, &activationChange); | - |
| 1169 | } | - |
| 1170 | | - |
| 1171 | for(int i = 0; i < toBeDeactivated.size(); ++i) { | - |
| 1172 | QWidget *w = toBeDeactivated.at(i); | - |
| 1173 | sendSpontaneousEvent(w, &windowDeactivate); | - |
| 1174 | sendSpontaneousEvent(w, &activationChange); | - |
| 1175 | } | - |
| 1176 | | - |
| 1177 | if (QApplicationPrivate::popupWidgets == 0) { | - |
| 1178 | | - |
| 1179 | if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) { | - |
| 1180 | QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); | - |
| 1181 | } else if (QApplicationPrivate::active_window) { | - |
| 1182 | QWidget *w = QApplicationPrivate::active_window->focusWidget(); | - |
| 1183 | if (w && w->isVisible() ) | - |
| 1184 | w->setFocus(Qt::ActiveWindowFocusReason); | - |
| 1185 | else { | - |
| 1186 | w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true); | - |
| 1187 | if (w) { | - |
| 1188 | w->setFocus(Qt::ActiveWindowFocusReason); | - |
| 1189 | } else { | - |
| 1190 | | - |
| 1191 | w = QApplicationPrivate::focus_widget; | - |
| 1192 | if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus) | - |
| 1193 | QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason); | - |
| 1194 | else if (!QApplicationPrivate::active_window->isAncestorOf(w)) | - |
| 1195 | QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason); | - |
| 1196 | } | - |
| 1197 | } | - |
| 1198 | } | - |
| 1199 | } | - |
| 1200 | } | - |
| 1201 | | - |
| 1202 | | - |
| 1203 | | - |
| 1204 | | - |
| 1205 | | - |
| 1206 | | - |
| 1207 | QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next) | - |
| 1208 | { | - |
| 1209 | uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus; | - |
| 1210 | | - |
| 1211 | QWidget *f = toplevel->focusWidget(); | - |
| 1212 | if (!f) | - |
| 1213 | f = toplevel; | - |
| 1214 | | - |
| 1215 | QWidget *w = f; | - |
| 1216 | QWidget *test = f->d_func()->focus_next; | - |
| 1217 | while (test && test != f) { | - |
| 1218 | if ((test->focusPolicy() & focus_flag) == focus_flag | - |
| 1219 | && !(test->d_func()->extra && test->d_func()->extra->focus_proxy) | - |
| 1220 | && test->isVisibleTo(toplevel) && test->isEnabled() | - |
| 1221 | && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test)) | - |
| 1222 | && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) { | - |
| 1223 | w = test; | - |
| 1224 | if (next) | - |
| 1225 | break; | - |
| 1226 | } | - |
| 1227 | test = test->d_func()->focus_next; | - |
| 1228 | } | - |
| 1229 | if (w == f) { | - |
| 1230 | if (qt_in_tab_key_event) { | - |
| 1231 | w->window()->setAttribute(Qt::WA_KeyboardFocusChange); | - |
| 1232 | w->update(); | - |
| 1233 | } | - |
| 1234 | return 0; | - |
| 1235 | } | - |
| 1236 | return w; | - |
| 1237 | } | - |
| 1238 | void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF) | - |
| 1239 | { | - |
| 1240 | const QPoint globalPos = globalPosF.toPoint(); | - |
| 1241 | QWidget* w ; | - |
| 1242 | if ((!enter && !leave) || (enter == leave)) | - |
| 1243 | return; | - |
| 1244 | | - |
| 1245 | | - |
| 1246 | | - |
| 1247 | QWidgetList leaveList; | - |
| 1248 | QWidgetList enterList; | - |
| 1249 | | - |
| 1250 | bool sameWindow = leave && enter && leave->window() == enter->window(); | - |
| 1251 | if (leave && !sameWindow) { | - |
| 1252 | w = leave; | - |
| 1253 | do { | - |
| 1254 | leaveList.append(w); | - |
| 1255 | } while (!w->isWindow() && (w = w->parentWidget())); | - |
| 1256 | } | - |
| 1257 | if (enter && !sameWindow) { | - |
| 1258 | w = enter; | - |
| 1259 | do { | - |
| 1260 | enterList.prepend(w); | - |
| 1261 | } while (!w->isWindow() && (w = w->parentWidget())); | - |
| 1262 | } | - |
| 1263 | if (sameWindow) { | - |
| 1264 | int enterDepth = 0; | - |
| 1265 | int leaveDepth = 0; | - |
| 1266 | w = enter; | - |
| 1267 | while (!w->isWindow() && (w = w->parentWidget())) | - |
| 1268 | enterDepth++; | - |
| 1269 | w = leave; | - |
| 1270 | while (!w->isWindow() && (w = w->parentWidget())) | - |
| 1271 | leaveDepth++; | - |
| 1272 | QWidget* wenter = enter; | - |
| 1273 | QWidget* wleave = leave; | - |
| 1274 | while (enterDepth > leaveDepth) { | - |
| 1275 | wenter = wenter->parentWidget(); | - |
| 1276 | enterDepth--; | - |
| 1277 | } | - |
| 1278 | while (leaveDepth > enterDepth) { | - |
| 1279 | wleave = wleave->parentWidget(); | - |
| 1280 | leaveDepth--; | - |
| 1281 | } | - |
| 1282 | while (!wenter->isWindow() && wenter != wleave) { | - |
| 1283 | wenter = wenter->parentWidget(); | - |
| 1284 | wleave = wleave->parentWidget(); | - |
| 1285 | } | - |
| 1286 | | - |
| 1287 | w = leave; | - |
| 1288 | while (w != wleave) { | - |
| 1289 | leaveList.append(w); | - |
| 1290 | w = w->parentWidget(); | - |
| 1291 | } | - |
| 1292 | w = enter; | - |
| 1293 | while (w != wenter) { | - |
| 1294 | enterList.prepend(w); | - |
| 1295 | w = w->parentWidget(); | - |
| 1296 | } | - |
| 1297 | } | - |
| 1298 | | - |
| 1299 | QEvent leaveEvent(QEvent::Leave); | - |
| 1300 | for (int i = 0; i < leaveList.size(); ++i) { | - |
| 1301 | w = leaveList.at(i); | - |
| 1302 | if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { | - |
| 1303 | QApplication::sendEvent(w, &leaveEvent); | - |
| 1304 | if (w->testAttribute(Qt::WA_Hover) && | - |
| 1305 | (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { | - |
| 1306 | qt_noop(); | - |
| 1307 | QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos), | - |
| 1308 | QApplication::keyboardModifiers()); | - |
| 1309 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->notify_helper(w, &he); | - |
| 1310 | } | - |
| 1311 | } | - |
| 1312 | } | - |
| 1313 | if (!enterList.isEmpty()) { | - |
| 1314 | const QPoint windowPos = enterList.front()->window()->mapFromGlobal(globalPos); | - |
| 1315 | for (int i = 0; i < enterList.size(); ++i) { | - |
| 1316 | w = enterList.at(i); | - |
| 1317 | if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { | - |
| 1318 | const QPointF localPos = w->mapFromGlobal(globalPos); | - |
| 1319 | QEnterEvent enterEvent(localPos, windowPos, globalPosF); | - |
| 1320 | QApplication::sendEvent(w, &enterEvent); | - |
| 1321 | if (w->testAttribute(Qt::WA_Hover) && | - |
| 1322 | (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { | - |
| 1323 | QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1), | - |
| 1324 | QApplication::keyboardModifiers()); | - |
| 1325 | (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->notify_helper(w, &he); | - |
| 1326 | } | - |
| 1327 | } | - |
| 1328 | } | - |
| 1329 | } | - |
| 1330 | | - |
| 1331 | | - |
| 1332 | | - |
| 1333 | | - |
| 1334 | const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen))); | - |
| 1335 | | - |
| 1336 | | - |
| 1337 | QWidget *parentOfLeavingCursor = 0; | - |
| 1338 | for (int i = 0; i < leaveList.size(); ++i) { | - |
| 1339 | w = leaveList.at(i); | - |
| 1340 | if (!isAlien(w)) | - |
| 1341 | break; | - |
| 1342 | if (w->testAttribute(Qt::WA_SetCursor)) { | - |
| 1343 | QWidget *parent = w->parentWidget(); | - |
| 1344 | while (parent && parent->d_func()->data.in_destructor) | - |
| 1345 | parent = parent->parentWidget(); | - |
| 1346 | parentOfLeavingCursor = parent; | - |
| 1347 | | - |
| 1348 | | - |
| 1349 | } | - |
| 1350 | } | - |
| 1351 | | - |
| 1352 | if (parentOfLeavingCursor && (!enterOnAlien | - |
| 1353 | || parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) { | - |
| 1354 | | - |
| 1355 | if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) | - |
| 1356 | | - |
| 1357 | { | - |
| 1358 | if (enter == QApplication::desktop()) { | - |
| 1359 | qt_qpa_set_cursor(enter, true); | - |
| 1360 | } else { | - |
| 1361 | qt_qpa_set_cursor(parentOfLeavingCursor, true); | - |
| 1362 | } | - |
| 1363 | } | - |
| 1364 | } | - |
| 1365 | if (enterOnAlien) { | - |
| 1366 | QWidget *cursorWidget = enter; | - |
| 1367 | while (!cursorWidget->isWindow() && !cursorWidget->isEnabled()) | - |
| 1368 | cursorWidget = cursorWidget->parentWidget(); | - |
| 1369 | | - |
| 1370 | if (!cursorWidget) | - |
| 1371 | return; | - |
| 1372 | | - |
| 1373 | | - |
| 1374 | if (cursorWidget->window()->graphicsProxyWidget()) { | - |
| 1375 | QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor()); | - |
| 1376 | } else | - |
| 1377 | | - |
| 1378 | { | - |
| 1379 | qt_qpa_set_cursor(cursorWidget, true); | - |
| 1380 | } | - |
| 1381 | } | - |
| 1382 | | - |
| 1383 | } | - |
| 1384 | | - |
| 1385 | | - |
| 1386 | __attribute__((visibility("default"))) bool qt_tryModalHelper(QWidget *widget, QWidget **rettop) | - |
| 1387 | { | - |
| 1388 | return QApplicationPrivate::tryModalHelper(widget, rettop); | - |
| 1389 | } | - |
| 1390 | | - |
| 1391 | | - |
| 1392 | | - |
| 1393 | | - |
| 1394 | bool QApplicationPrivate::isBlockedByModal(QWidget *widget) | - |
| 1395 | { | - |
| 1396 | widget = widget->window(); | - |
| 1397 | QWindow *window = widget->windowHandle(); | - |
| 1398 | return window && self->isWindowBlocked(window); | - |
| 1399 | } | - |
| 1400 | | - |
| 1401 | bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const | - |
| 1402 | { | - |
| 1403 | QWindow *unused = 0; | - |
| 1404 | if (!window) { | - |
| 1405 | QMessageLogger("kernel/qapplication.cpp", 22282232, __PRETTY_FUNCTION__).warning().nospace() << "window == 0 passed."; | - |
| 1406 | return false; | - |
| 1407 | } | - |
| 1408 | if (!blockingWindow) | - |
| 1409 | blockingWindow = &unused; | - |
| 1410 | | - |
| 1411 | if (modalWindowList.isEmpty()) { | - |
| 1412 | *blockingWindow = 0; | - |
| 1413 | return false; | - |
| 1414 | } | - |
| 1415 | QWidget *popupWidget = QApplication::activePopupWidget(); | - |
| 1416 | QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0; | - |
| 1417 | if (popupWindow == window) { | - |
| 1418 | *blockingWindow = 0; | - |
| 1419 | return false; | - |
| 1420 | } | - |
| 1421 | | - |
| 1422 | for (int i = 0; i < modalWindowList.count(); ++i) { | - |
| 1423 | QWindow *modalWindow = modalWindowList.at(i); | - |
| 1424 | | - |
| 1425 | { | - |
| 1426 | | - |
| 1427 | QWindow *w = window; | - |
| 1428 | while (w) { | - |
| 1429 | if (w == modalWindow) { | - |
| 1430 | *blockingWindow = 0; | - |
| 1431 | return false; | - |
| 1432 | } | - |
| 1433 | QWindow *p = w->parent(); | - |
| 1434 | if (!p) | - |
| 1435 | p = w->transientParent(); | - |
| 1436 | w = p; | - |
| 1437 | } | - |
| 1438 | | - |
| 1439 | | - |
| 1440 | | - |
| 1441 | const QPlatformWindow *platWin = window->handle(); | - |
| 1442 | const QPlatformWindow *modalPlatWin = modalWindow->handle(); | - |
| 1443 | if (platWin && modalPlatWin && platWin->isEmbedded(modalPlatWin)) | - |
| 1444 | return false; | - |
| 1445 | } | - |
| 1446 | | - |
| 1447 | Qt::WindowModality windowModality = modalWindow->modality(); | - |
| 1448 | QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow); | - |
| 1449 | if (windowModality == Qt::NonModal) { | - |
| 1450 | | - |
| 1451 | | - |
| 1452 | | - |
| 1453 | | - |
| 1454 | QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; | - |
| 1455 | while (m && !m->testAttribute(Qt::WA_GroupLeader)) { | - |
| 1456 | m = m->parentWidget(); | - |
| 1457 | if (m) | - |
| 1458 | m = m->window(); | - |
| 1459 | } | - |
| 1460 | windowModality = (m && m->testAttribute(Qt::WA_GroupLeader)) | - |
| 1461 | ? Qt::WindowModal | - |
| 1462 | : Qt::ApplicationModal; | - |
| 1463 | } | - |
| 1464 | | - |
| 1465 | switch (windowModality) { | - |
| 1466 | case Qt::ApplicationModal: | - |
| 1467 | { | - |
| 1468 | QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(window); | - |
| 1469 | QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0; | - |
| 1470 | while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) | - |
| 1471 | groupLeaderForWidget = groupLeaderForWidget->parentWidget(); | - |
| 1472 | | - |
| 1473 | if (groupLeaderForWidget) { | - |
| 1474 | | - |
| 1475 | QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; | - |
| 1476 | while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) | - |
| 1477 | m = m->parentWidget(); | - |
| 1478 | if (m == groupLeaderForWidget) { | - |
| 1479 | *blockingWindow = m->windowHandle(); | - |
| 1480 | return true; | - |
| 1481 | } | - |
| 1482 | } else if (modalWindow != window) { | - |
| 1483 | *blockingWindow = modalWindow; | - |
| 1484 | return true; | - |
| 1485 | } | - |
| 1486 | break; | - |
| 1487 | } | - |
| 1488 | case Qt::WindowModal: | - |
| 1489 | { | - |
| 1490 | QWindow *w = window; | - |
| 1491 | do { | - |
| 1492 | QWindow *m = modalWindow; | - |
| 1493 | do { | - |
| 1494 | if (m == w) { | - |
| 1495 | *blockingWindow = m; | - |
| 1496 | return true; | - |
| 1497 | } | - |
| 1498 | QWindow *p = m->parent(); | - |
| 1499 | if (!p) | - |
| 1500 | p = m->transientParent(); | - |
| 1501 | m = p; | - |
| 1502 | } while (m); | - |
| 1503 | QWindow *p = w->parent(); | - |
| 1504 | if (!p) | - |
| 1505 | p = w->transientParent(); | - |
| 1506 | w = p; | - |
| 1507 | } while (w); | - |
| 1508 | break; | - |
| 1509 | } | - |
| 1510 | default: | - |
| 1511 | qt_noop(); | - |
| 1512 | break; | - |
| 1513 | } | - |
| 1514 | } | - |
| 1515 | *blockingWindow = 0; | - |
| 1516 | return false; | - |
| 1517 | } | - |
| 1518 | | - |
| 1519 | | - |
| 1520 | | - |
| 1521 | | - |
| 1522 | | - |
| 1523 | | - |
| 1524 | bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) | - |
| 1525 | { | - |
| 1526 | QWidget *top = QApplication::activeModalWidget(); | - |
| 1527 | if (rettop) | - |
| 1528 | *rettop = top; | - |
| 1529 | | - |
| 1530 | | - |
| 1531 | if (QApplication::activePopupWidget()) | - |
| 1532 | return true; | - |
| 1533 | | - |
| 1534 | return !isBlockedByModal(widget->window()); | - |
| 1535 | } | - |
| 1536 | | - |
| 1537 | | - |
| 1538 | | - |
| 1539 | | - |
| 1540 | QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint &windowPos, | - |
| 1541 | QPoint *pos, QEvent::Type type, | - |
| 1542 | Qt::MouseButtons buttons, QWidget *buttonDown, | - |
| 1543 | QWidget *alienWidget) | - |
| 1544 | { | - |
| 1545 | qt_noop(); | - |
| 1546 | | - |
| 1547 | QWidget *mouseGrabber = QWidget::mouseGrabber(); | - |
| 1548 | if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease)) | - |
| 1549 | && !buttonDown && !mouseGrabber) { | - |
| 1550 | return 0; | - |
| 1551 | } | - |
| 1552 | | - |
| 1553 | if (alienWidget && alienWidget->internalWinId()) | - |
| 1554 | alienWidget = 0; | - |
| 1555 | | - |
| 1556 | QWidget *receiver = candidate; | - |
| 1557 | | - |
| 1558 | if (!mouseGrabber) | - |
| 1559 | mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget; | - |
| 1560 | | - |
| 1561 | if (mouseGrabber && mouseGrabber != candidate) { | - |
| 1562 | receiver = mouseGrabber; | - |
| 1563 | *pos = receiver->mapFromGlobal(candidate->mapToGlobal(windowPos)); | - |
| 1564 | | - |
| 1565 | | - |
| 1566 | | - |
| 1567 | } | - |
| 1568 | | - |
| 1569 | return receiver; | - |
| 1570 | | - |
| 1571 | } | - |
| 1572 | | - |
| 1573 | | - |
| 1574 | | - |
| 1575 | | - |
| 1576 | bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, | - |
| 1577 | QWidget *alienWidget, QWidget *nativeWidget, | - |
| 1578 | QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver, | - |
| 1579 | bool spontaneous) | - |
| 1580 | { | - |
| 1581 | qt_noop(); | - |
| 1582 | qt_noop(); | - |
| 1583 | qt_noop(); | - |
| 1584 | qt_noop(); | - |
| 1585 | | - |
| 1586 | if (alienWidget && !isAlien(alienWidget)) | - |
| 1587 | alienWidget = 0; | - |
| 1588 | | - |
| 1589 | QPointer<QWidget> receiverGuard = receiver; | - |
| 1590 | QPointer<QWidget> nativeGuard = nativeWidget; | - |
| 1591 | QPointer<QWidget> alienGuard = alienWidget; | - |
| 1592 | QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget(); | - |
| 1593 | | - |
| 1594 | const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen); | - |
| 1595 | | - |
| 1596 | bool widgetUnderMouse = QRectF(receiver->rect()).contains(event->localPos()); | - |
| 1597 | | - |
| 1598 | | - |
| 1599 | | - |
| 1600 | | - |
| 1601 | if (leaveAfterRelease && !*buttonDown && !event->buttons()) | - |
| 1602 | leaveAfterRelease = 0; | - |
| 1603 | | - |
| 1604 | if (*buttonDown) { | - |
| 1605 | if (!graphicsWidget) { | - |
| 1606 | | - |
| 1607 | | - |
| 1608 | if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber()) | - |
| 1609 | leaveAfterRelease = *buttonDown; | - |
| 1610 | if (event->type() == QEvent::MouseButtonRelease && !event->buttons()) | - |
| 1611 | *buttonDown = 0; | - |
| 1612 | } | - |
| 1613 | } else if (lastMouseReceiver && widgetUnderMouse) { | - |
| 1614 | | - |
| 1615 | | - |
| 1616 | | - |
| 1617 | | - |
| 1618 | if ((alienWidget && alienWidget != lastMouseReceiver) | - |
| 1619 | || (isAlien(lastMouseReceiver) && !alienWidget)) { | - |
| 1620 | if (activePopupWidget) { | - |
| 1621 | if (!QWidget::mouseGrabber()) | - |
| 1622 | dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver, event->screenPos()); | - |
| 1623 | } else { | - |
| 1624 | dispatchEnterLeave(receiver, lastMouseReceiver, event->screenPos()); | - |
| 1625 | } | - |
| 1626 | | - |
| 1627 | } | - |
| 1628 | } | - |
| 1629 | const bool wasLeaveAfterRelease = leaveAfterRelease != 0; | - |
| 1630 | bool result; | - |
| 1631 | if (spontaneous) | - |
| 1632 | result = QApplication::sendSpontaneousEvent(receiver, event); | - |
| 1633 | else | - |
| 1634 | result = QApplication::sendEvent(receiver, event); | - |
| 1635 | | - |
| 1636 | if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease | - |
| 1637 | && !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) { | - |
| 1638 | | - |
| 1639 | | - |
| 1640 | | - |
| 1641 | QWidget *enter = 0; | - |
| 1642 | if (nativeGuard) | - |
| 1643 | enter = alienGuard ? alienWidget : nativeWidget; | - |
| 1644 | else | - |
| 1645 | enter = QApplication::widgetAt(event->globalPos()); | - |
| 1646 | dispatchEnterLeave(enter, leaveAfterRelease, event->screenPos()); | - |
| 1647 | leaveAfterRelease = 0; | - |
| 1648 | lastMouseReceiver = enter; | - |
| 1649 | } else if (!wasLeaveAfterRelease) { | - |
| 1650 | if (activePopupWidget) { | - |
| 1651 | if (!QWidget::mouseGrabber()) | - |
| 1652 | lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0); | - |
| 1653 | } else { | - |
| 1654 | lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos()); | - |
| 1655 | } | - |
| 1656 | } | - |
| 1657 | | - |
| 1658 | return result; | - |
| 1659 | } | - |
| 1660 | | - |
| 1661 | | - |
| 1662 | | - |
| 1663 | | - |
| 1664 | | - |
| 1665 | | - |
| 1666 | | - |
| 1667 | extern QPointer<QWidget> qt_last_mouse_receiver; | - |
| 1668 | extern QWidget *qt_button_down; | - |
| 1669 | void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) | - |
| 1670 | { | - |
| 1671 | | - |
| 1672 | if (!widget || widget->isWindow()) | - |
| 1673 | return; | - |
| 1674 | const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor; | - |
| 1675 | if (!widgetInShow && widget != qt_last_mouse_receiver) | - |
| 1676 | return; | - |
| 1677 | | - |
| 1678 | if (widgetInShow && widget->parentWidget()->data->in_show) | - |
| 1679 | return; | - |
| 1680 | | - |
| 1681 | QWidget *mouseGrabber = QWidget::mouseGrabber(); | - |
| 1682 | if (mouseGrabber && mouseGrabber != widget) | - |
| 1683 | return; | - |
| 1684 | | - |
| 1685 | QWidget *tlw = widget->window(); | - |
| 1686 | if (tlw->data->in_destructor || tlw->data->is_closing) | - |
| 1687 | return; | - |
| 1688 | | - |
| 1689 | if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw)) | - |
| 1690 | return; | - |
| 1691 | | - |
| 1692 | const QPoint globalPos(QCursor::pos()); | - |
| 1693 | QPoint windowPos = tlw->mapFromGlobal(globalPos); | - |
| 1694 | | - |
| 1695 | | - |
| 1696 | | - |
| 1697 | | - |
| 1698 | QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(windowPos, widget->data->in_destructor); | - |
| 1699 | if (!widgetUnderCursor) | - |
| 1700 | widgetUnderCursor = tlw; | - |
| 1701 | QPoint pos = widgetUnderCursor->mapFrom(tlw, windowPos); | - |
| 1702 | | - |
| 1703 | if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor)) | - |
| 1704 | return; | - |
| 1705 | | - |
| 1706 | if (widget->data->in_destructor && qt_button_down == widget) | - |
| 1707 | qt_button_down = 0; | - |
| 1708 | | - |
| 1709 | | - |
| 1710 | QMouseEvent e(QEvent::MouseMove, pos, windowPos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier); | - |
| 1711 | sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); | - |
| 1712 | | - |
| 1713 | } | - |
| 1714 | QDesktopWidget *QApplication::desktop() | - |
| 1715 | { | - |
| 1716 | if (!qt_desktopWidget || | - |
| 1717 | !(qt_desktopWidget->windowType() == Qt::Desktop)) { | - |
| 1718 | qt_desktopWidget = new QDesktopWidget(); | - |
| 1719 | } | - |
| 1720 | return qt_desktopWidget; | - |
| 1721 | } | - |
| 1722 | | - |
| 1723 | | - |
| 1724 | | - |
| 1725 | | - |
| 1726 | | - |
| 1727 | | - |
| 1728 | | - |
| 1729 | void QApplication::setStartDragTime(int ms) | - |
| 1730 | { | - |
| 1731 | (void)ms; | - |
| 1732 | } | - |
| 1733 | int QApplication::startDragTime() | - |
| 1734 | { | - |
| 1735 | return (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->startDragTime(); | - |
| 1736 | } | - |
| 1737 | | - |
| 1738 | | - |
| 1739 | | - |
| 1740 | | - |
| 1741 | | - |
| 1742 | | - |
| 1743 | | - |
| 1744 | void QApplication::setStartDragDistance(int l) | - |
| 1745 | { | - |
| 1746 | (void)l;; | - |
| 1747 | } | - |
| 1748 | int QApplication::startDragDistance() | - |
| 1749 | { | - |
| 1750 | return (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->startDragDistance(); | - |
| 1751 | } | - |
| 1752 | int QApplication::exec() | - |
| 1753 | { | - |
| 1754 | return QGuiApplication::exec(); | - |
| 1755 | } | - |
| 1756 | | - |
| 1757 | bool QApplicationPrivate::shouldQuit() | - |
| 1758 | { | - |
| 1759 | | - |
| 1760 | | - |
| 1761 | | - |
| 1762 | QWidgetList list = QApplication::topLevelWidgets(); | - |
| 1763 | for (int i = 0; i < list.size(); ++i) { | - |
| 1764 | QWidget *w = list.at(i); | - |
| 1765 | if (w->isVisible() && !w->parentWidget() && w->testAttribute(Qt::WA_QuitOnClose)) | - |
| 1766 | return false; | - |
| 1767 | } | - |
| 1768 | return QGuiApplicationPrivate::shouldQuit(); | - |
| 1769 | } | - |
| 1770 | | - |
| 1771 | static inline void closeAllPopups() | - |
| 1772 | { | - |
| 1773 | | - |
| 1774 | | - |
| 1775 | int maxiter = 1024; | - |
| 1776 | QWidget *popup; | - |
| 1777 | while ((popup = QApplication::activePopupWidget()) && maxiter--) | - |
| 1778 | popup->close(); | - |
| 1779 | } | - |
| 1780 | | - |
| 1781 | | - |
| 1782 | | - |
| 1783 | bool QApplication::notify(QObject *receiver, QEvent *e) | - |
| 1784 | { | - |
| 1785 | QApplicationPrivate * const d = d_func(); | - |
| 1786 | | - |
| 1787 | if (QApplicationPrivate::is_app_closing) | - |
| 1788 | return true; | - |
| 1789 | | - |
| 1790 | if (receiver == 0) { | - |
| 1791 | QMessageLogger("kernel/qapplication.cpp", 27062710, __PRETTY_FUNCTION__).warning("QApplication::notify: Unexpected null receiver"); | - |
| 1792 | return true; | - |
| 1793 | } | - |
| 1794 | | - |
| 1795 | | - |
| 1796 | | - |
| 1797 | | - |
| 1798 | | - |
| 1799 | if (receiver->isWindowType()) | - |
| 1800 | QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e); | - |
| 1801 | | - |
| 1802 | if(e->spontaneous()) { | - |
| 1803 | | - |
| 1804 | | - |
| 1805 | | - |
| 1806 | | - |
| 1807 | switch (e->type()) { | - |
| 1808 | case QEvent::MouseButtonPress: | - |
| 1809 | { | - |
| 1810 | QMouseEvent *me = static_cast<QMouseEvent*>(e); | - |
| 1811 | QApplicationPrivate::modifier_buttons = me->modifiers(); | - |
| 1812 | QApplicationPrivate::mouse_buttons |= me->button(); | - |
| 1813 | break; | - |
| 1814 | } | - |
| 1815 | case QEvent::MouseButtonRelease: | - |
| 1816 | { | - |
| 1817 | QMouseEvent *me = static_cast<QMouseEvent*>(e); | - |
| 1818 | QApplicationPrivate::modifier_buttons = me->modifiers(); | - |
| 1819 | QApplicationPrivate::mouse_buttons &= ~me->button(); | - |
| 1820 | break; | - |
| 1821 | } | - |
| 1822 | case QEvent::KeyPress: | - |
| 1823 | case QEvent::KeyRelease: | - |
| 1824 | case QEvent::MouseMove: | - |
| 1825 | | - |
| 1826 | case QEvent::Wheel: | - |
| 1827 | | - |
| 1828 | case QEvent::TouchBegin: | - |
| 1829 | case QEvent::TouchUpdate: | - |
| 1830 | case QEvent::TouchEnd: | - |
| 1831 | | - |
| 1832 | case QEvent::TabletMove: | - |
| 1833 | case QEvent::TabletPress: | - |
| 1834 | case QEvent::TabletRelease: | - |
| 1835 | | - |
| 1836 | { | - |
| 1837 | QInputEvent *ie = static_cast<QInputEvent*>(e); | - |
| 1838 | QApplicationPrivate::modifier_buttons = ie->modifiers(); | - |
| 1839 | break; | - |
| 1840 | } | - |
| 1841 | default: | - |
| 1842 | break; | - |
| 1843 | } | - |
| 1844 | } | - |
| 1845 | | - |
| 1846 | | - |
| 1847 | | - |
| 1848 | if (d->gestureManager) { | - |
| 1849 | switch (e->type()) { | - |
| 1850 | case QEvent::Paint: | - |
| 1851 | case QEvent::MetaCall: | - |
| 1852 | case QEvent::DeferredDelete: | - |
| 1853 | case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave: | - |
| 1854 | case QEvent::Drop: case QEvent::DragResponse: | - |
| 1855 | case QEvent::ChildAdded: case QEvent::ChildPolished: | - |
| 1856 | case QEvent::ChildRemoved: | - |
| 1857 | case QEvent::UpdateRequest: | - |
| 1858 | case QEvent::UpdateLater: | - |
| 1859 | case QEvent::LocaleChange: | - |
| 1860 | case QEvent::Style: | - |
| 1861 | case QEvent::IconDrag: | - |
| 1862 | case QEvent::StyleChange: | - |
| 1863 | case QEvent::GraphicsSceneDragEnter: | - |
| 1864 | case QEvent::GraphicsSceneDragMove: | - |
| 1865 | case QEvent::GraphicsSceneDragLeave: | - |
| 1866 | case QEvent::GraphicsSceneDrop: | - |
| 1867 | case QEvent::DynamicPropertyChange: | - |
| 1868 | case QEvent::NetworkReplyUpdated: | - |
| 1869 | break; | - |
| 1870 | default: | - |
| 1871 | if (receiver->isWidgetType()) { | - |
| 1872 | if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) | - |
| 1873 | return true; | - |
| 1874 | } else { | - |
| 1875 | | - |
| 1876 | | - |
| 1877 | | - |
| 1878 | if (d->gestureManager->filterEvent(receiver, e)) | - |
| 1879 | return true; | - |
| 1880 | } | - |
| 1881 | } | - |
| 1882 | } | - |
| 1883 | | - |
| 1884 | | - |
| 1885 | switch (e->type()) { | - |
| 1886 | case QEvent::ApplicationDeactivate: | - |
| 1887 | | - |
| 1888 | | - |
| 1889 | closeAllPopups(); | - |
| 1890 | break; | - |
| 1891 | case QEvent::Wheel: | - |
| 1892 | case QEvent::ActivationChange: | - |
| 1893 | case QEvent::KeyPress: | - |
| 1894 | case QEvent::KeyRelease: | - |
| 1895 | case QEvent::FocusOut: | - |
| 1896 | case QEvent::FocusIn: | - |
| 1897 | case QEvent::MouseButtonPress: | - |
| 1898 | case QEvent::MouseButtonRelease: | - |
| 1899 | case QEvent::MouseButtonDblClick: | - |
| 1900 | d->toolTipFallAsleep.stop(); | - |
| 1901 | | - |
| 1902 | case QEvent::Leave: | - |
| 1903 | d->toolTipWakeUp.stop(); | - |
| 1904 | default: | - |
| 1905 | break; | - |
| 1906 | } | - |
| 1907 | | - |
| 1908 | bool res = false; | - |
| 1909 | if (!receiver->isWidgetType()) { | - |
| 1910 | res = d->notify_helper(receiver, e); | - |
| 1911 | } else switch (e->type()) { | - |
| 1912 | case QEvent::ShortcutOverride: | - |
| 1913 | case QEvent::KeyPress: | - |
| 1914 | case QEvent::KeyRelease: | - |
| 1915 | { | - |
| 1916 | bool isWidget = receiver->isWidgetType(); | - |
| 1917 | bool isGraphicsWidget = false; | - |
| 1918 | | - |
| 1919 | isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver); | - |
| 1920 | | - |
| 1921 | if (!isWidget && !isGraphicsWidget) { | - |
| 1922 | res = d->notify_helper(receiver, e); | - |
| 1923 | break; | - |
| 1924 | } | - |
| 1925 | | - |
| 1926 | QKeyEvent* key = static_cast<QKeyEvent*>(e); | - |
| 1927 | if (key->type()==QEvent::KeyPress) { | - |
| 1928 | | - |
| 1929 | | - |
| 1930 | if ((res = (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->shortcutMap.tryShortcutEvent(receiver, key))) | - |
| 1931 | return res; | - |
| 1932 | | - |
| 1933 | qt_in_tab_key_event = (key->key() == Qt::Key_Backtab | - |
| 1934 | || key->key() == Qt::Key_Tab | - |
| 1935 | || key->key() == Qt::Key_Left | - |
| 1936 | || key->key() == Qt::Key_Up | - |
| 1937 | || key->key() == Qt::Key_Right | - |
| 1938 | || key->key() == Qt::Key_Down); | - |
| 1939 | } | - |
| 1940 | bool def = key->isAccepted(); | - |
| 1941 | QPointer<QObject> pr = receiver; | - |
| 1942 | while (receiver) { | - |
| 1943 | if (def) | - |
| 1944 | key->accept(); | - |
| 1945 | else | - |
| 1946 | key->ignore(); | - |
| 1947 | res = d->notify_helper(receiver, e); | - |
| 1948 | QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0; | - |
| 1949 | | - |
| 1950 | QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0; | - |
| 1951 | | - |
| 1952 | | - |
| 1953 | if ((res && key->isAccepted()) | - |
| 1954 | || !pr | - |
| 1955 | || (isWidget && (w->isWindow() || !w->parentWidget())) | - |
| 1956 | | - |
| 1957 | || (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget())) | - |
| 1958 | | - |
| 1959 | ) { | - |
| 1960 | break; | - |
| 1961 | } | - |
| 1962 | | - |
| 1963 | | - |
| 1964 | receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget(); | - |
| 1965 | | - |
| 1966 | | - |
| 1967 | | - |
| 1968 | } | - |
| 1969 | qt_in_tab_key_event = false; | - |
| 1970 | } | - |
| 1971 | break; | - |
| 1972 | case QEvent::MouseButtonPress: | - |
| 1973 | case QEvent::MouseButtonRelease: | - |
| 1974 | case QEvent::MouseButtonDblClick: | - |
| 1975 | case QEvent::MouseMove: | - |
| 1976 | { | - |
| 1977 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 1978 | | - |
| 1979 | QMouseEvent* mouse = static_cast<QMouseEvent*>(e); | - |
| 1980 | QPoint relpos = mouse->pos(); | - |
| 1981 | | - |
| 1982 | if (e->spontaneous()) { | - |
| 1983 | | - |
| 1984 | if (e->type() == QEvent::MouseButtonPress) { | - |
| 1985 | QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, | - |
| 1986 | Qt::ClickFocus, | - |
| 1987 | Qt::MouseFocusReason); | - |
| 1988 | } | - |
| 1989 | if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) { | - |
| 1990 | d->toolTipWidget = w; | - |
| 1991 | d->toolTipPos = relpos; | - |
| 1992 | d->toolTipGlobalPos = mouse->globalPos(); | - |
| 1993 | d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this); | - |
| 1994 | } | - |
| 1995 | } | - |
| 1996 | | - |
| 1997 | bool eventAccepted = mouse->isAccepted(); | - |
| 1998 | | - |
| 1999 | QPointer<QWidget> pw = w; | - |
| 2000 | while (w) { | - |
| 2001 | QMouseEvent me(mouse->type(), relpos, mouse->windowPos(), mouse->globalPos(), mouse->button(), mouse->buttons(), | - |
| 2002 | mouse->modifiers()); | - |
| 2003 | me.spont = mouse->spontaneous(); | - |
| 2004 | me.setTimestamp(mouse->timestamp()); | - |
| 2005 | | - |
| 2006 | if (!w->hasMouseTracking() | - |
| 2007 | && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) { | - |
| 2008 | | - |
| 2009 | for (int i = 0; d->extraData && i < d->extraData->eventFilters.size(); ++i) { | - |
| 2010 | register QObject *obj = d->extraData->eventFilters.at(i); | - |
| 2011 | if (!obj) | - |
| 2012 | continue; | - |
| 2013 | if (obj->d_func()->threadData != w->d_func()->threadData) { | - |
| 2014 | QMessageLogger("kernel/qapplication.cpp", 29492953, __PRETTY_FUNCTION__).warning("QApplication: Object event filter cannot be in a different thread."); | - |
| 2015 | continue; | - |
| 2016 | } | - |
| 2017 | if (obj->eventFilter(w, w == receiver ? mouse : &me)) | - |
| 2018 | break; | - |
| 2019 | } | - |
| 2020 | res = true; | - |
| 2021 | } else { | - |
| 2022 | w->setAttribute(Qt::WA_NoMouseReplay, false); | - |
| 2023 | res = d->notify_helper(w, w == receiver ? mouse : &me); | - |
| 2024 | e->spont = false; | - |
| 2025 | } | - |
| 2026 | eventAccepted = (w == receiver ? mouse : &me)->isAccepted(); | - |
| 2027 | if (res && eventAccepted) | - |
| 2028 | break; | - |
| 2029 | if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) | - |
| 2030 | break; | - |
| 2031 | relpos += w->pos(); | - |
| 2032 | w = w->parentWidget(); | - |
| 2033 | } | - |
| 2034 | | - |
| 2035 | mouse->setAccepted(eventAccepted); | - |
| 2036 | | - |
| 2037 | if (e->type() == QEvent::MouseMove) { | - |
| 2038 | if (!pw) | - |
| 2039 | break; | - |
| 2040 | | - |
| 2041 | w = static_cast<QWidget *>(receiver); | - |
| 2042 | relpos = mouse->pos(); | - |
| 2043 | QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos); | - |
| 2044 | while (w) { | - |
| 2045 | if (w->testAttribute(Qt::WA_Hover) && | - |
| 2046 | (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { | - |
| 2047 | QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff, mouse->modifiers()); | - |
| 2048 | d->notify_helper(w, &he); | - |
| 2049 | } | - |
| 2050 | if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) | - |
| 2051 | break; | - |
| 2052 | relpos += w->pos(); | - |
| 2053 | w = w->parentWidget(); | - |
| 2054 | } | - |
| 2055 | } | - |
| 2056 | | - |
| 2057 | d->hoverGlobalPos = mouse->globalPos(); | - |
| 2058 | } | - |
| 2059 | break; | - |
| 2060 | | - |
| 2061 | case QEvent::Wheel: | - |
| 2062 | { | - |
| 2063 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 2064 | QWheelEvent* wheel = static_cast<QWheelEvent*>(e); | - |
| 2065 | QPoint relpos = wheel->pos(); | - |
| 2066 | bool eventAccepted = wheel->isAccepted(); | - |
| 2067 | | - |
| 2068 | if (e->spontaneous()) { | - |
| 2069 | QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, | - |
| 2070 | Qt::WheelFocus, | - |
| 2071 | Qt::MouseFocusReason); | - |
| 2072 | } | - |
| 2073 | | - |
| 2074 | while (w) { | - |
| 2075 | QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), | - |
| 2076 | wheel->modifiers()); | - |
| 2077 | we.spont = wheel->spontaneous(); | - |
| 2078 | res = d->notify_helper(w, w == receiver ? wheel : &we); | - |
| 2079 | eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted(); | - |
| 2080 | e->spont = false; | - |
| 2081 | if ((res && eventAccepted) | - |
| 2082 | || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) | - |
| 2083 | break; | - |
| 2084 | | - |
| 2085 | relpos += w->pos(); | - |
| 2086 | w = w->parentWidget(); | - |
| 2087 | } | - |
| 2088 | wheel->setAccepted(eventAccepted); | - |
| 2089 | } | - |
| 2090 | break; | - |
| 2091 | | - |
| 2092 | | - |
| 2093 | case QEvent::ContextMenu: | - |
| 2094 | { | - |
| 2095 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 2096 | QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e); | - |
| 2097 | QPoint relpos = context->pos(); | - |
| 2098 | bool eventAccepted = context->isAccepted(); | - |
| 2099 | while (w) { | - |
| 2100 | QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers()); | - |
| 2101 | ce.spont = e->spontaneous(); | - |
| 2102 | res = d->notify_helper(w, w == receiver ? context : &ce); | - |
| 2103 | eventAccepted = ((w == receiver) ? context : &ce)->isAccepted(); | - |
| 2104 | e->spont = false; | - |
| 2105 | | - |
| 2106 | if ((res && eventAccepted) | - |
| 2107 | || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) | - |
| 2108 | break; | - |
| 2109 | | - |
| 2110 | relpos += w->pos(); | - |
| 2111 | w = w->parentWidget(); | - |
| 2112 | } | - |
| 2113 | context->setAccepted(eventAccepted); | - |
| 2114 | } | - |
| 2115 | break; | - |
| 2116 | | - |
| 2117 | | - |
| 2118 | case QEvent::TabletMove: | - |
| 2119 | case QEvent::TabletPress: | - |
| 2120 | case QEvent::TabletRelease: | - |
| 2121 | { | - |
| 2122 | QWidget *w = static_cast<QWidget *>(receiver); | - |
| 2123 | QTabletEvent *tablet = static_cast<QTabletEvent*>(e); | - |
| 2124 | QPointF relpos = tablet->posF(); | - |
| 2125 | bool eventAccepted = tablet->isAccepted(); | - |
| 2126 | while (w) { | - |
| 2127 | QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(), | - |
| 2128 | tablet->device(), tablet->pointerType(), | - |
| 2129 | tablet->pressure(), tablet->xTilt(), tablet->yTilt(), | - |
| 2130 | tablet->tangentialPressure(), tablet->rotation(), tablet->z(), | - |
| 2131 | tablet->modifiers(), tablet->uniqueId()); | - |
| 2132 | te.spont = e->spontaneous(); | - |
| 2133 | res = d->notify_helper(w, w == receiver ? tablet : &te); | - |
| 2134 | eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted(); | - |
| 2135 | e->spont = false; | - |
| 2136 | if ((res && eventAccepted) | - |
| 2137 | || w->isWindow() | - |
| 2138 | || w->testAttribute(Qt::WA_NoMousePropagation)) | - |
| 2139 | break; | - |
| 2140 | | - |
| 2141 | relpos += w->pos(); | - |
| 2142 | w = w->parentWidget(); | - |
| 2143 | } | - |
| 2144 | tablet->setAccepted(eventAccepted); | - |
| 2145 | qt_tabletChokeMouse = tablet->isAccepted(); | - |
| 2146 | } | - |
| 2147 | break; | - |
| 2148 | | - |
| 2149 | | - |
| 2150 | | - |
| 2151 | case QEvent::ToolTip: | - |
| 2152 | case QEvent::WhatsThis: | - |
| 2153 | case QEvent::QueryWhatsThis: | - |
| 2154 | { | - |
| 2155 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 2156 | QHelpEvent *help = static_cast<QHelpEvent*>(e); | - |
| 2157 | QPoint relpos = help->pos(); | - |
| 2158 | bool eventAccepted = help->isAccepted(); | - |
| 2159 | while (w) { | - |
| 2160 | QHelpEvent he(help->type(), relpos, help->globalPos()); | - |
| 2161 | he.spont = e->spontaneous(); | - |
| 2162 | res = d->notify_helper(w, w == receiver ? help : &he); | - |
| 2163 | e->spont = false; | - |
| 2164 | eventAccepted = (w == receiver ? help : &he)->isAccepted(); | - |
| 2165 | if ((res && eventAccepted) || w->isWindow()) | - |
| 2166 | break; | - |
| 2167 | | - |
| 2168 | relpos += w->pos(); | - |
| 2169 | w = w->parentWidget(); | - |
| 2170 | } | - |
| 2171 | help->setAccepted(eventAccepted); | - |
| 2172 | } | - |
| 2173 | break; | - |
| 2174 | | - |
| 2175 | | - |
| 2176 | case QEvent::StatusTip: | - |
| 2177 | case QEvent::WhatsThisClicked: | - |
| 2178 | { | - |
| 2179 | QWidget *w = static_cast<QWidget *>(receiver); | - |
| 2180 | while (w) { | - |
| 2181 | res = d->notify_helper(w, e); | - |
| 2182 | if ((res && e->isAccepted()) || w->isWindow()) | - |
| 2183 | break; | - |
| 2184 | w = w->parentWidget(); | - |
| 2185 | } | - |
| 2186 | } | - |
| 2187 | break; | - |
| 2188 | | - |
| 2189 | | - |
| 2190 | | - |
| 2191 | case QEvent::DragEnter: { | - |
| 2192 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 2193 | QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e); | - |
| 2194 | | - |
| 2195 | | - |
| 2196 | | - |
| 2197 | QWExtra *extra = w->window()->d_func()->extra; | - |
| 2198 | if (extra && extra->proxyWidget) { | - |
| 2199 | res = d->notify_helper(w, dragEvent); | - |
| 2200 | break; | - |
| 2201 | } | - |
| 2202 | | - |
| 2203 | while (w) { | - |
| 2204 | if (w->isEnabled() && w->acceptDrops()) { | - |
| 2205 | res = d->notify_helper(w, dragEvent); | - |
| 2206 | if (res && dragEvent->isAccepted()) { | - |
| 2207 | QDragManager::self()->setCurrentTarget(w); | - |
| 2208 | break; | - |
| 2209 | } | - |
| 2210 | } | - |
| 2211 | if (w->isWindow()) | - |
| 2212 | break; | - |
| 2213 | dragEvent->p = w->mapToParent(dragEvent->p.toPoint()); | - |
| 2214 | w = w->parentWidget(); | - |
| 2215 | } | - |
| 2216 | } | - |
| 2217 | break; | - |
| 2218 | case QEvent::DragMove: | - |
| 2219 | case QEvent::Drop: | - |
| 2220 | case QEvent::DragLeave: { | - |
| 2221 | QWidget* w = static_cast<QWidget *>(receiver); | - |
| 2222 | | - |
| 2223 | | - |
| 2224 | | - |
| 2225 | QWExtra *extra = w->window()->d_func()->extra; | - |
| 2226 | bool isProxyWidget = extra && extra->proxyWidget; | - |
| 2227 | if (!isProxyWidget) | - |
| 2228 | | - |
| 2229 | w = qobject_cast<QWidget *>(QDragManager::self()->currentTarget()); | - |
| 2230 | | - |
| 2231 | if (!w) { | - |
| 2232 | break; | - |
| 2233 | } | - |
| 2234 | if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { | - |
| 2235 | QDropEvent *dragEvent = static_cast<QDropEvent *>(e); | - |
| 2236 | QWidget *origReciver = static_cast<QWidget *>(receiver); | - |
| 2237 | while (origReciver && w != origReciver) { | - |
| 2238 | dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint()); | - |
| 2239 | origReciver = origReciver->parentWidget(); | - |
| 2240 | } | - |
| 2241 | } | - |
| 2242 | res = d->notify_helper(w, e); | - |
| 2243 | if (e->type() != QEvent::DragMove | - |
| 2244 | | - |
| 2245 | && !isProxyWidget | - |
| 2246 | | - |
| 2247 | ) | - |
| 2248 | QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop); | - |
| 2249 | } | - |
| 2250 | break; | - |
| 2251 | | - |
| 2252 | | - |
| 2253 | case QEvent::TouchUpdate: | - |
| 2254 | case QEvent::TouchEnd: | - |
| 2255 | { | - |
| 2256 | QWidget *widget = static_cast<QWidget *>(receiver); | - |
| 2257 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); | - |
| 2258 | const bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); | - |
| 2259 | | - |
| 2260 | touchEvent->setTarget(widget); | - |
| 2261 | touchEvent->setAccepted(acceptTouchEvents); | - |
| 2262 | | - |
| 2263 | res = acceptTouchEvents && d->notify_helper(widget, touchEvent); | - |
| 2264 | | - |
| 2265 | | - |
| 2266 | if (!touchEvent->isAccepted()) | - |
| 2267 | res = d->translateTouchToMouse(widget, touchEvent); | - |
| 2268 | break; | - |
| 2269 | } | - |
| 2270 | | - |
| 2271 | case QEvent::TouchBegin: | - |
| 2272 | | - |
| 2273 | { | - |
| 2274 | QWidget *widget = static_cast<QWidget *>(receiver); | - |
| 2275 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); | - |
| 2276 | bool eventAccepted = touchEvent->isAccepted(); | - |
| 2277 | if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) { | - |
| 2278 | | - |
| 2279 | QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, | - |
| 2280 | Qt::ClickFocus, | - |
| 2281 | Qt::MouseFocusReason); | - |
| 2282 | } | - |
| 2283 | | - |
| 2284 | while (widget) { | - |
| 2285 | | - |
| 2286 | bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); | - |
| 2287 | touchEvent->setTarget(widget); | - |
| 2288 | touchEvent->setAccepted(acceptTouchEvents); | - |
| 2289 | QPointer<QWidget> p = widget; | - |
| 2290 | res = acceptTouchEvents && d->notify_helper(widget, touchEvent); | - |
| 2291 | | - |
| 2292 | | - |
| 2293 | if (!touchEvent->isAccepted()) { | - |
| 2294 | res = d->translateTouchToMouse(widget, touchEvent); | - |
| 2295 | eventAccepted = touchEvent->isAccepted(); | - |
| 2296 | if (eventAccepted) | - |
| 2297 | break; | - |
| 2298 | } | - |
| 2299 | | - |
| 2300 | eventAccepted = touchEvent->isAccepted(); | - |
| 2301 | if (p.isNull()) { | - |
| 2302 | | - |
| 2303 | widget = 0; | - |
| 2304 | } else { | - |
| 2305 | widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted); | - |
| 2306 | } | - |
| 2307 | touchEvent->spont = false; | - |
| 2308 | if (res && eventAccepted) { | - |
| 2309 | | - |
| 2310 | for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { | - |
| 2311 | const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i); | - |
| 2312 | d->activeTouchPoints[QGuiApplicationPrivate::ActiveTouchPointsKey(touchEvent->device(), touchPoint.id())].target = widget; | - |
| 2313 | } | - |
| 2314 | break; | - |
| 2315 | } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) { | - |
| 2316 | break; | - |
| 2317 | } | - |
| 2318 | QPoint offset = widget->pos(); | - |
| 2319 | widget = widget->parentWidget(); | - |
| 2320 | touchEvent->setTarget(widget); | - |
| 2321 | for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { | - |
| 2322 | QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; | - |
| 2323 | QRectF rect = pt.rect(); | - |
| 2324 | rect.moveCenter(offset); | - |
| 2325 | pt.d->rect = rect; | - |
| 2326 | pt.d->startPos = pt.startPos() + offset; | - |
| 2327 | pt.d->lastPos = pt.lastPos() + offset; | - |
| 2328 | } | - |
| 2329 | } | - |
| 2330 | | - |
| 2331 | touchEvent->setAccepted(eventAccepted); | - |
| 2332 | break; | - |
| 2333 | } | - |
| 2334 | case QEvent::RequestSoftwareInputPanel: | - |
| 2335 | inputMethod()->show(); | - |
| 2336 | break; | - |
| 2337 | case QEvent::CloseSoftwareInputPanel: | - |
| 2338 | inputMethod()->hide(); | - |
| 2339 | break; | - |
| 2340 | | - |
| 2341 | | - |
| 2342 | case QEvent::NativeGesture: | - |
| 2343 | { | - |
| 2344 | | - |
| 2345 | QWidget *w = static_cast<QWidget *>(receiver); | - |
| 2346 | while (w) { | - |
| 2347 | e->ignore(); | - |
| 2348 | res = d->notify_helper(w, e); | - |
| 2349 | if ((res && e->isAccepted()) || w->isWindow()) | - |
| 2350 | break; | - |
| 2351 | w = w->parentWidget(); | - |
| 2352 | } | - |
| 2353 | break; | - |
| 2354 | } | - |
| 2355 | case QEvent::Gesture: | - |
| 2356 | case QEvent::GestureOverride: | - |
| 2357 | { | - |
| 2358 | if (receiver->isWidgetType()) { | - |
| 2359 | QWidget *w = static_cast<QWidget *>(receiver); | - |
| 2360 | QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e); | - |
| 2361 | QList<QGesture *> allGestures = gestureEvent->gestures(); | - |
| 2362 | | - |
| 2363 | bool eventAccepted = gestureEvent->isAccepted(); | - |
| 2364 | bool wasAccepted = eventAccepted; | - |
| 2365 | while (w) { | - |
| 2366 | | - |
| 2367 | QList<QGesture *> gestures; | - |
| 2368 | QWidgetPrivate *wd = w->d_func(); | - |
| 2369 | for (int i = 0; i < allGestures.size();) { | - |
| 2370 | QGesture *g = allGestures.at(i); | - |
| 2371 | Qt::GestureType type = g->gestureType(); | - |
| 2372 | QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit = | - |
| 2373 | wd->gestureContext.find(type); | - |
| 2374 | bool deliver = contextit != wd->gestureContext.end() && | - |
| 2375 | (g->state() == Qt::GestureStarted || w == receiver || | - |
| 2376 | (contextit.value() & Qt::ReceivePartialGestures)); | - |
| 2377 | if (deliver) { | - |
| 2378 | allGestures.removeAt(i); | - |
| 2379 | gestures.append(g); | - |
| 2380 | } else { | - |
| 2381 | ++i; | - |
| 2382 | } | - |
| 2383 | } | - |
| 2384 | if (!gestures.isEmpty()) { | - |
| 2385 | QGestureEvent ge(gestures); | - |
| 2386 | ge.t = gestureEvent->t; | - |
| 2387 | ge.spont = gestureEvent->spont; | - |
| 2388 | ge.m_accept = wasAccepted; | - |
| 2389 | ge.m_accepted = gestureEvent->m_accepted; | - |
| 2390 | res = d->notify_helper(w, &ge); | - |
| 2391 | gestureEvent->spont = false; | - |
| 2392 | eventAccepted = ge.isAccepted(); | - |
| 2393 | for (int i = 0; i < gestures.size(); ++i) { | - |
| 2394 | QGesture *g = gestures.at(i); | - |
| 2395 | | - |
| 2396 | | - |
| 2397 | if (eventAccepted || ge.isAccepted(g)) { | - |
| 2398 | | - |
| 2399 | gestureEvent->m_targetWidgets[g->gestureType()] = w; | - |
| 2400 | gestureEvent->setAccepted(g, true); | - |
| 2401 | } else { | - |
| 2402 | | - |
| 2403 | | - |
| 2404 | allGestures.append(g); | - |
| 2405 | } | - |
| 2406 | } | - |
| 2407 | } | - |
| 2408 | if (allGestures.isEmpty()) | - |
| 2409 | break; | - |
| 2410 | if (w->isWindow()) | - |
| 2411 | break; | - |
| 2412 | w = w->parentWidget(); | - |
| 2413 | } | - |
| 2414 | for (QForeachContainer<__typeof__(allGestures)> _container_(allGestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
| 2415 | gestureEvent->setAccepted(g, false); | - |
| 2416 | gestureEvent->m_accept = false; | - |
| 2417 | } else { | - |
| 2418 | res = d->notify_helper(receiver, e); | - |
| 2419 | } | - |
| 2420 | break; | - |
| 2421 | } | - |
| 2422 | | - |
| 2423 | default: | - |
| 2424 | res = d->notify_helper(receiver, e); | - |
| 2425 | break; | - |
| 2426 | } | - |
| 2427 | | - |
| 2428 | return res; | - |
| 2429 | } | - |
| 2430 | | - |
| 2431 | bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) | - |
| 2432 | { | - |
| 2433 | | - |
| 2434 | if (sendThroughApplicationEventFilters(receiver, e)) | - |
| 2435 | return true; | - |
| 2436 | | - |
| 2437 | if (receiver->isWidgetType()) { | - |
| 2438 | QWidget *widget = static_cast<QWidget *>(receiver); | - |
| 2439 | | - |
| 2440 | | - |
| 2441 | | - |
| 2442 | if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) && | - |
| 2443 | (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window())) | - |
| 2444 | widget->setAttribute(Qt::WA_UnderMouse, true); | - |
| 2445 | else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave) | - |
| 2446 | widget->setAttribute(Qt::WA_UnderMouse, false); | - |
| 2447 | | - |
| 2448 | | - |
| 2449 | if (QLayout *layout=widget->d_func()->layout) { | - |
| 2450 | layout->widgetEvent(e); | - |
| 2451 | } | - |
| 2452 | } | - |
| 2453 | | - |
| 2454 | | - |
| 2455 | if (sendThroughObjectEventFilters(receiver, e)) | - |
| 2456 | return true; | - |
| 2457 | | - |
| 2458 | | - |
| 2459 | bool consumed = receiver->event(e); | - |
| 2460 | e->spont = false; | - |
| 2461 | return consumed; | - |
| 2462 | } | - |
| 2463 | | - |
| 2464 | bool QApplicationPrivate::inPopupMode() | - |
| 2465 | { | - |
| 2466 | return QApplicationPrivate::popupWidgets != 0; | - |
| 2467 | } | - |
| 2468 | void QApplication::setCursorFlashTime(int msecs) | - |
| 2469 | { | - |
| 2470 | (void)msecs;; | - |
| 2471 | } | - |
| 2472 | | - |
| 2473 | int QApplication::cursorFlashTime() | - |
| 2474 | { | - |
| 2475 | return (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->cursorFlashTime(); | - |
| 2476 | } | - |
| 2477 | void QApplication::setDoubleClickInterval(int ms) | - |
| 2478 | { | - |
| 2479 | (void)ms;; | - |
| 2480 | } | - |
| 2481 | | - |
| 2482 | int QApplication::doubleClickInterval() | - |
| 2483 | { | - |
| 2484 | return (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->mouseDoubleClickInterval(); | - |
| 2485 | } | - |
| 2486 | void QApplication::setKeyboardInputInterval(int ms) | - |
| 2487 | { | - |
| 2488 | (void)ms;; | - |
| 2489 | } | - |
| 2490 | | - |
| 2491 | int QApplication::keyboardInputInterval() | - |
| 2492 | { | - |
| 2493 | return (static_cast<QApplication *>(QCoreApplication::instance()))->styleHints()->keyboardInputInterval(); | - |
| 2494 | } | - |
| 2495 | bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event) | - |
| 2496 | { | - |
| 2497 | return QGuiApplication::sendSpontaneousEvent(receiver, event); | - |
| 2498 | } | - |
| 2499 | | - |
| 2500 | | - |
| 2501 | void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, | - |
| 2502 | Qt::FocusPolicy focusPolicy, | - |
| 2503 | Qt::FocusReason focusReason) | - |
| 2504 | { | - |
| 2505 | QWidget *focusWidget = widget; | - |
| 2506 | while (focusWidget) { | - |
| 2507 | if (focusWidget->isEnabled() | - |
| 2508 | && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) { | - |
| 2509 | focusWidget->setFocus(focusReason); | - |
| 2510 | break; | - |
| 2511 | } | - |
| 2512 | if (focusWidget->isWindow()) | - |
| 2513 | break; | - |
| 2514 | focusWidget = focusWidget->parentWidget(); | - |
| 2515 | } | - |
| 2516 | } | - |
| 2517 | | - |
| 2518 | bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) | - |
| 2519 | { | - |
| 2520 | QWidget *f = w; | - |
| 2521 | while (f->d_func()->extra && f->d_func()->extra->focus_proxy) | - |
| 2522 | f = f->d_func()->extra->focus_proxy; | - |
| 2523 | | - |
| 2524 | if ((w->focusPolicy() & policy) != policy) | - |
| 2525 | return false; | - |
| 2526 | if (w != f && (f->focusPolicy() & policy) != policy) | - |
| 2527 | return false; | - |
| 2528 | return true; | - |
| 2529 | } | - |
| 2530 | | - |
| 2531 | void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) | - |
| 2532 | { | - |
| 2533 | for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { | - |
| 2534 | QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i]; | - |
| 2535 | | - |
| 2536 | | - |
| 2537 | QRectF rect = touchPoint.screenRect(); | - |
| 2538 | const QPointF screenPos = rect.center(); | - |
| 2539 | const QPointF delta = screenPos - screenPos.toPoint(); | - |
| 2540 | | - |
| 2541 | rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta); | - |
| 2542 | touchPoint.d->rect = rect; | - |
| 2543 | touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; | - |
| 2544 | touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; | - |
| 2545 | } | - |
| 2546 | } | - |
| 2547 | | - |
| 2548 | void QApplicationPrivate::initializeMultitouch() | - |
| 2549 | { | - |
| 2550 | initializeMultitouch_sys(); | - |
| 2551 | } | - |
| 2552 | | - |
| 2553 | void QApplicationPrivate::cleanupMultitouch() | - |
| 2554 | { | - |
| 2555 | cleanupMultitouch_sys(); | - |
| 2556 | } | - |
| 2557 | | - |
| 2558 | QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos) | - |
| 2559 | { | - |
| 2560 | int closestTouchPointId = -1; | - |
| 2561 | QObject *closestTarget = 0; | - |
| 2562 | qreal closestDistance = qreal(0.); | - |
| 2563 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it = activeTouchPoints.constBegin(), | - |
| 2564 | ite = activeTouchPoints.constEnd(); | - |
| 2565 | while (it != ite) { | - |
| 2566 | if (it.key().device == device) { | - |
| 2567 | const QTouchEvent::TouchPoint &touchPoint = it->touchPoint; | - |
| 2568 | qreal dx = screenPos.x() - touchPoint.screenPos().x(); | - |
| 2569 | qreal dy = screenPos.y() - touchPoint.screenPos().y(); | - |
| 2570 | qreal distance = dx * dx + dy * dy; | - |
| 2571 | if (closestTouchPointId == -1 || distance < closestDistance) { | - |
| 2572 | closestTouchPointId = touchPoint.id(); | - |
| 2573 | closestDistance = distance; | - |
| 2574 | closestTarget = it.value().target.data(); | - |
| 2575 | } | - |
| 2576 | } | - |
| 2577 | ++it; | - |
| 2578 | } | - |
| 2579 | return static_cast<QWidget *>(closestTarget); | - |
| 2580 | } | - |
| 2581 | | - |
| 2582 | class WidgetAttributeSaver | - |
| 2583 | { | - |
| 2584 | public: | - |
| 2585 | explicit WidgetAttributeSaver(QWidget *widget, Qt::WidgetAttribute attribute, bool forcedValue) | - |
| 2586 | : m_widget(widget), | - |
| 2587 | m_attribute(attribute), | - |
| 2588 | m_savedValue(widget->testAttribute(attribute)) | - |
| 2589 | { | - |
| 2590 | widget->setAttribute(attribute, forcedValue); | - |
| 2591 | } | - |
| 2592 | | - |
| 2593 | ~WidgetAttributeSaver() | - |
| 2594 | { | - |
| 2595 | m_widget->setAttribute(m_attribute, m_savedValue); | - |
| 2596 | } | - |
| 2597 | | - |
| 2598 | private: | - |
| 2599 | QWidget * const m_widget; | - |
| 2600 | const Qt::WidgetAttribute m_attribute; | - |
| 2601 | const bool m_savedValue; | - |
| 2602 | }; | - |
| 2603 | | - |
| 2604 | bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *event) | - |
| 2605 | { | - |
| 2606 | QApplication * const q = q_func(); | - |
| 2607 | | - |
| 2608 | | - |
| 2609 | if (!QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SynthesizeMouseFromTouchEvents).toBool()) | - |
| 2610 | return false; | - |
| 2611 | | - |
| 2612 | for (QForeachContainer<__typeof__(event->touchPoints())> _container_(event->touchPoints()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QTouchEvent::TouchPoint &p = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
| 2613 | const QEvent::Type eventType = (p.state() & Qt::TouchPointPressed) ? QEvent::MouseButtonPress | - |
| 2614 | : (p.state() & Qt::TouchPointReleased) ? QEvent::MouseButtonRelease | - |
| 2615 | : (p.state() & Qt::TouchPointMoved) ? QEvent::MouseMove | - |
| 2616 | : QEvent::None; | - |
| 2617 | | - |
| 2618 | if (eventType == QEvent::None) | - |
| 2619 | continue; | - |
| 2620 | | - |
| 2621 | const QPoint pos = widget->mapFromGlobal(p.screenPos().toPoint()); | - |
| 2622 | | - |
| 2623 | QMouseEvent mouseEvent(eventType, pos, | - |
| 2624 | Qt::LeftButton, Qt::LeftButton, | - |
| 2625 | event->modifiers()); | - |
| 2626 | mouseEvent.setAccepted(true); | - |
| 2627 | mouseEvent.setTimestamp(event->timestamp()); | - |
| 2628 | | - |
| 2629 | | - |
| 2630 | | - |
| 2631 | | - |
| 2632 | | - |
| 2633 | WidgetAttributeSaver saver(widget, Qt::WA_NoMousePropagation, true); | - |
| 2634 | | - |
| 2635 | | - |
| 2636 | | - |
| 2637 | | - |
| 2638 | const bool res = q->sendSpontaneousEvent(widget, &mouseEvent); | - |
| 2639 | event->setAccepted(mouseEvent.isAccepted()); | - |
| 2640 | | - |
| 2641 | if (mouseEvent.isAccepted()) | - |
| 2642 | return res; | - |
| 2643 | } | - |
| 2644 | | - |
| 2645 | return false; | - |
| 2646 | } | - |
| 2647 | | - |
| 2648 | void QApplicationPrivate::translateRawTouchEvent(QWidget *window, | - |
| 2649 | QTouchDevice *device, | - |
| 2650 | const QList<QTouchEvent::TouchPoint> &touchPoints, | - |
| 2651 | ulong timestamp) | - |
| 2652 | { | - |
| 2653 | QApplicationPrivate *d = self; | - |
| 2654 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - |
| 2655 | QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents; | - |
| 2656 | | - |
| 2657 | for (int i = 0; i < touchPoints.count(); ++i) { | - |
| 2658 | QTouchEvent::TouchPoint touchPoint = touchPoints.at(i); | - |
| 2659 | | - |
| 2660 | | - |
| 2661 | | - |
| 2662 | touchPoint.d = touchPoint.d->detach(); | - |
| 2663 | | - |
| 2664 | | - |
| 2665 | QPointer<QObject> target; | - |
| 2666 | ActiveTouchPointsKey touchInfoKey(device, touchPoint.id()); | - |
| 2667 | ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; | - |
| 2668 | if (touchPoint.state() == Qt::TouchPointPressed) { | - |
| 2669 | if (device->type() == QTouchDevice::TouchPad) { | - |
| 2670 | | - |
| 2671 | target = d->activeTouchPoints.isEmpty() | - |
| 2672 | ? QPointer<QObject>() | - |
| 2673 | : d->activeTouchPoints.constBegin().value().target; | - |
| 2674 | } | - |
| 2675 | | - |
| 2676 | if (!target) { | - |
| 2677 | | - |
| 2678 | if (!window) | - |
| 2679 | window = QApplication::topLevelAt(touchPoint.screenPos().toPoint()); | - |
| 2680 | if (!window) | - |
| 2681 | continue; | - |
| 2682 | target = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint())); | - |
| 2683 | if (!target) | - |
| 2684 | target = window; | - |
| 2685 | } | - |
| 2686 | | - |
| 2687 | if (device->type() == QTouchDevice::TouchScreen) { | - |
| 2688 | QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); | - |
| 2689 | QWidget *widget = static_cast<QWidget *>(target.data()); | - |
| 2690 | if (closestWidget | - |
| 2691 | && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) { | - |
| 2692 | target = closestWidget; | - |
| 2693 | } | - |
| 2694 | } | - |
| 2695 | | - |
| 2696 | touchInfo.target = target; | - |
| 2697 | } else { | - |
| 2698 | target = touchInfo.target; | - |
| 2699 | if (!target) | - |
| 2700 | continue; | - |
| 2701 | } | - |
| 2702 | qt_noop(); | - |
| 2703 | | - |
| 2704 | StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[static_cast<QWidget *>(target.data())]; | - |
| 2705 | maskAndPoints.first |= touchPoint.state(); | - |
| 2706 | maskAndPoints.second.append(touchPoint); | - |
| 2707 | } | - |
| 2708 | | - |
| 2709 | if (widgetsNeedingEvents.isEmpty()) | - |
| 2710 | return; | - |
| 2711 | | - |
| 2712 | QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin(); | - |
| 2713 | const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd(); | - |
| 2714 | for (; it != end; ++it) { | - |
| 2715 | QWidget *widget = it.key(); | - |
| 2716 | if (!QApplicationPrivate::tryModalHelper(widget, 0)) | - |
| 2717 | continue; | - |
| 2718 | | - |
| 2719 | QEvent::Type eventType; | - |
| 2720 | switch (it.value().first) { | - |
| 2721 | case Qt::TouchPointPressed: | - |
| 2722 | eventType = QEvent::TouchBegin; | - |
| 2723 | break; | - |
| 2724 | case Qt::TouchPointReleased: | - |
| 2725 | eventType = QEvent::TouchEnd; | - |
| 2726 | break; | - |
| 2727 | case Qt::TouchPointStationary: | - |
| 2728 | | - |
| 2729 | continue; | - |
| 2730 | default: | - |
| 2731 | eventType = QEvent::TouchUpdate; | - |
| 2732 | break; | - |
| 2733 | } | - |
| 2734 | | - |
| 2735 | QTouchEvent touchEvent(eventType, | - |
| 2736 | device, | - |
| 2737 | QApplication::keyboardModifiers(), | - |
| 2738 | it.value().first, | - |
| 2739 | it.value().second); | - |
| 2740 | updateTouchPointsForWidget(widget, &touchEvent); | - |
| 2741 | touchEvent.setTimestamp(timestamp); | - |
| 2742 | touchEvent.setWindow(window->windowHandle()); | - |
| 2743 | touchEvent.setTarget(widget); | - |
| 2744 | | - |
| 2745 | switch (touchEvent.type()) { | - |
| 2746 | case QEvent::TouchBegin: | - |
| 2747 | { | - |
| 2748 | | - |
| 2749 | | - |
| 2750 | widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); | - |
| 2751 | (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent); | - |
| 2752 | break; | - |
| 2753 | } | - |
| 2754 | default: | - |
| 2755 | if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) { | - |
| 2756 | if (touchEvent.type() == QEvent::TouchEnd) | - |
| 2757 | widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false); | - |
| 2758 | (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); | - |
| 2759 | } | - |
| 2760 | break; | - |
| 2761 | } | - |
| 2762 | } | - |
| 2763 | } | - |
| 2764 | | - |
| 2765 | void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp) | - |
| 2766 | { | - |
| 2767 | QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers()); | - |
| 2768 | touchEvent.setTimestamp(timestamp); | - |
| 2769 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it | - |
| 2770 | = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); | - |
| 2771 | QSet<QWidget *> widgetsNeedingCancel; | - |
| 2772 | while (it != ite) { | - |
| 2773 | QWidget *widget = static_cast<QWidget *>(it->target.data()); | - |
| 2774 | if (widget) | - |
| 2775 | widgetsNeedingCancel.insert(widget); | - |
| 2776 | ++it; | - |
| 2777 | } | - |
| 2778 | for (QSet<QWidget *>::const_iterator widIt = widgetsNeedingCancel.constBegin(), | - |
| 2779 | widItEnd = widgetsNeedingCancel.constEnd(); widIt != widItEnd; ++widIt) { | - |
| 2780 | QWidget *widget = *widIt; | - |
| 2781 | touchEvent.setWindow(widget->windowHandle()); | - |
| 2782 | touchEvent.setTarget(widget); | - |
| 2783 | QApplication::sendSpontaneousEvent(widget, &touchEvent); | - |
| 2784 | } | - |
| 2785 | } | - |
| 2786 | | - |
| 2787 | void QApplicationPrivate::notifyThemeChanged() | - |
| 2788 | { | - |
| 2789 | QGuiApplicationPrivate::notifyThemeChanged(); | - |
| 2790 | clearSystemPalette(); | - |
| 2791 | initSystemPalette(); | - |
| 2792 | } | - |
| 2793 | | - |
| 2794 | | - |
| 2795 | void QApplicationPrivate::notifyDragStarted(const QDrag *drag) | - |
| 2796 | { | - |
| 2797 | | - |
| 2798 | QGuiApplicationPrivate::notifyDragStarted(drag); | - |
| 2799 | qt_button_down = 0; | - |
| 2800 | } | - |
| 2801 | | - |
| 2802 | | - |
| 2803 | | - |
| 2804 | QGestureManager* QGestureManager::instance() | - |
| 2805 | { | - |
| 2806 | QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); | - |
| 2807 | if (!qAppPriv) | - |
| 2808 | return 0; | - |
| 2809 | if (!qAppPriv->gestureManager) | - |
| 2810 | qAppPriv->gestureManager = new QGestureManager((static_cast<QApplication *>(QCoreApplication::instance()))); | - |
| 2811 | return qAppPriv->gestureManager; | - |
| 2812 | } | - |
| 2813 | | - |
| 2814 | | - |
| 2815 | QPixmap QApplicationPrivate::applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const | - |
| 2816 | { | - |
| 2817 | QStyleOption opt(0); | - |
| 2818 | opt.palette = QGuiApplication::palette(); | - |
| 2819 | return QApplication::style()->generatedIconPixmap(mode, base, &opt); | - |
| 2820 | } | - |
| 2821 | | - |
| 2822 | | - |
| 2823 | | - |
| 2824 | | - |
| | |