diff options
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 319 |
1 files changed, 154 insertions, 165 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 5743f0e451..a1392e10dc 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -48,12 +48,12 @@ #if QT_CONFIG(whatsthis) #include <QtWidgets/QWhatsThis> #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include <QtGui/qaccessible_base.h> +#include "private/qaccessiblewidgetfactory_p.h" #endif #include "private/qkeymapper_p.h" -#include "private/qaccessiblewidgetfactory_p.h" #include <qthread.h> #include <private/qthread_p.h> @@ -80,6 +80,10 @@ #include <qtwidgets_tracepoints_p.h> +#ifdef Q_OS_MACOS +#include <QtCore/private/qcore_mac_p.h> +#endif + #include <algorithm> #include <iterator> @@ -96,6 +100,13 @@ QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; +Q_TRACE_PREFIX(qtwidgets, + "#include <qcoreevent.h>" +); +Q_TRACE_METADATA(qtwidgets, "ENUM { AUTO, RANGE User ... MaxUser } QEvent::Type;"); +Q_TRACE_POINT(qtwidgets, QApplication_notify_entry, QObject *receiver, QEvent *event, QEvent::Type type); +Q_TRACE_POINT(qtwidgets, QApplication_notify_exit, bool consumed, bool filtered); + // Helper macro for static functions to check on the existence of the application class. #define CHECK_QAPP_INSTANCE(...) \ if (Q_LIKELY(QCoreApplication::instance())) { \ @@ -111,8 +122,8 @@ QApplicationPrivate *QApplicationPrivate::self = nullptr; bool QApplicationPrivate::autoSipEnabled = true; -QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) - : QApplicationPrivateBase(argc, argv, flags) +QApplicationPrivate::QApplicationPrivate(int &argc, char **argv) + : QGuiApplicationPrivate(argc, argv) { application_type = QApplicationPrivate::Gui; @@ -299,7 +310,6 @@ QWidget *QApplication::topLevelAt(const QPoint &pos) */ void qt_init_tooltip_palette(); -void qt_cleanup(); QStyle *QApplicationPrivate::app_style = nullptr; // default application style #ifndef QT_NO_STYLE_STYLESHEET @@ -442,9 +452,9 @@ void QApplicationPrivate::process_cmdline() #ifdef Q_QDOC QApplication::QApplication(int &argc, char **argv) #else -QApplication::QApplication(int &argc, char **argv, int _internal) +QApplication::QApplication(int &argc, char **argv, int) #endif - : QGuiApplication(*new QApplicationPrivate(argc, argv, _internal)) + : QGuiApplication(*new QApplicationPrivate(argc, argv)) { Q_D(QApplication); d->init(); @@ -475,7 +485,7 @@ void QApplicationPrivate::init() initialize(); eventDispatcher->startingUp(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) // factory for accessible interfaces for widgets shipped with Qt QAccessible::installFactory(&qAccessibleFactory); #endif @@ -485,8 +495,11 @@ void QApplicationPrivate::init() void qt_init_tooltip_palette() { #if QT_CONFIG(tooltip) - if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette)) - QToolTip::setPalette(*toolTipPalette); + if (const QPalette *toolTipPalette = QGuiApplicationPrivate::platformTheme()->palette(QPlatformTheme::ToolTipPalette)) { + QPalette toolTipPal = *toolTipPalette; + toolTipPal.setResolveMask(0); + QToolTip::setPalette(toolTipPal); + } #endif } @@ -516,6 +529,8 @@ void QApplicationPrivate::initialize() qWarning("QApplication: invalid style override '%s' passed, ignoring it.\n" "\tAvailable styles: %s", qPrintable(styleOverride), qPrintable(QStyleFactory::keys().join(", "_L1))); + // Clear styleOverride so it is not picked by Qt Quick Controls (QTBUG-100563) + styleOverride.clear(); } } @@ -692,7 +707,10 @@ QApplication::~QApplication() d->cleanupMultitouch(); - qt_cleanup(); + QPixmapCache::clear(); + QColormap::cleanup(); + + QApplicationPrivate::active_window = nullptr; //### this should not be necessary if (QApplicationPrivate::widgetCount) qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances); @@ -703,14 +721,6 @@ QApplication::~QApplication() QApplicationPrivate::widgetCount = false; } -void qt_cleanup() -{ - QPixmapCache::clear(); - QColormap::cleanup(); - - QApplicationPrivate::active_window = nullptr; //### this should not be necessary -} - /*! \fn QWidget *QApplication::widgetAt(const QPoint &point) @@ -772,35 +782,54 @@ QWidget *QApplication::widgetAt(const QPoint &p) */ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) { - if ((event->type() == QEvent::UpdateRequest - || event->type() == QEvent::LayoutRequest - || event->type() == QEvent::Resize - || event->type() == QEvent::Move - || event->type() == QEvent::LanguageChange)) { - for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) { - const QPostEvent &cur = *it; - if (cur.receiver != receiver || cur.event == nullptr || cur.event->type() != event->type()) - continue; - if (cur.event->type() == QEvent::LayoutRequest - || cur.event->type() == QEvent::UpdateRequest) { - ; - } else if (cur.event->type() == QEvent::Resize) { - static_cast<QResizeEvent *>(cur.event)->m_size = - static_cast<const QResizeEvent *>(event)->size(); - } else if (cur.event->type() == QEvent::Move) { - static_cast<QMoveEvent *>(cur.event)->m_pos = - static_cast<const QMoveEvent *>(event)->pos(); - } else if (cur.event->type() == QEvent::LanguageChange) { - ; - } else { - continue; - } - delete event; - return true; + // Only compress the following events: + const QEvent::Type type = event->type(); + switch (type) { + case QEvent::UpdateRequest: + case QEvent::UpdateLater: + case QEvent::LayoutRequest: + case QEvent::Resize: + case QEvent::Move: + case QEvent::LanguageChange: + break; + default: + return QGuiApplication::compressEvent(event, receiver, postedEvents); + } + + for (const auto &postedEvent : std::as_const(*postedEvents)) { + + // Continue, unless a valid event of the same type exists for the same receiver + if (postedEvent.receiver != receiver + || !postedEvent.event + || postedEvent.event->type() != type) { + continue; } - return false; + + // Handle type specific compression + switch (type) { + case QEvent::Resize: + static_cast<QResizeEvent *>(postedEvent.event)->m_size = + static_cast<const QResizeEvent *>(event)->size(); + break; + case QEvent::Move: + static_cast<QMoveEvent *>(postedEvent.event)->m_pos = + static_cast<const QMoveEvent *>(event)->pos(); + break; + case QEvent::UpdateLater: + static_cast<QUpdateLaterEvent *>(postedEvent.event)->m_region += + static_cast<const QUpdateLaterEvent *>(event)->region(); + break; + case QEvent::UpdateRequest: + case QEvent::LanguageChange: + case QEvent::LayoutRequest: + break; + default: + continue; + } + delete event; + return true; } - return QGuiApplication::compressEvent(event, receiver, postedEvents); + return false; } /*! @@ -1065,6 +1094,12 @@ QPalette QApplicationPrivate::basePalette() const if (const QPalette *themePalette = platformTheme() ? platformTheme()->palette() : nullptr) palette = themePalette->resolve(palette); + // This palette now is Qt-generated, so reset the resolve mask. This allows + // QStyle::polish implementations to respect palettes that are user provided, + // by checking if the palette has a brush set for a color that the style might + // otherwise overwrite. + palette.setResolveMask(0); + // Finish off by letting the application style polish the palette. This will // not result in the polished palette becoming a user-set palette, as the // resulting base palette is only used as a fallback, with the resolve mask @@ -1181,7 +1216,7 @@ void QApplicationPrivate::handlePaletteChanged(const char *className) } #if QT_CONFIG(graphicsview) - for (auto scene : qAsConst(scene_list)) + for (auto scene : std::as_const(scene_list)) QCoreApplication::sendEvent(scene, &event); #endif @@ -1631,7 +1666,8 @@ void QApplication::aboutQt() bool QApplication::event(QEvent *e) { Q_D(QApplication); - if (e->type() == QEvent::Quit) { + switch (e->type()) { + case QEvent::Quit: // FIXME: This logic first tries to close all windows, and then // checks whether it was successful, but the conditions used in // closeAllWindows() differ from the verification logic below. @@ -1651,7 +1687,7 @@ bool QApplication::event(QEvent *e) // closeAllWindows(). FIXME: Unify all this close magic through closeAllWindows. return QCoreApplication::event(e); #ifndef Q_OS_WIN - } else if (e->type() == QEvent::LocaleChange) { + case QEvent::LocaleChange: { // on Windows the event propagation is taken care by the // WM_SETTINGCHANGE event handler. const QWidgetList list = topLevelWidgets(); @@ -1661,8 +1697,10 @@ bool QApplication::event(QEvent *e) w->d_func()->setLocale_helper(QLocale(), true); } } + break; + } #endif - } else if (e->type() == QEvent::Timer) { + case QEvent::Timer: { QTimerEvent *te = static_cast<QTimerEvent*>(e); Q_ASSERT(te != nullptr); if (te->timerId() == d->toolTipWakeUp.timerId()) { @@ -1691,15 +1729,16 @@ bool QApplication::event(QEvent *e) } else if (te->timerId() == d->toolTipFallAsleep.timerId()) { d->toolTipFallAsleep.stop(); } + break; + } #if QT_CONFIG(whatsthis) - } else if (e->type() == QEvent::EnterWhatsThisMode) { + case QEvent::EnterWhatsThisMode: QWhatsThis::enterWhatsThisMode(); return true; #endif - } - - if (e->type() == QEvent::LanguageChange || e->type() == QEvent::ApplicationFontChange || - e->type() == QEvent::ApplicationPaletteChange) { + case QEvent::LanguageChange: + case QEvent::ApplicationFontChange: + case QEvent::ApplicationPaletteChange: { // QGuiApplication::event does not account for the cases where // there is a top level widget without a window handle. So they // need to have the event posted here @@ -1708,6 +1747,10 @@ bool QApplication::event(QEvent *e) if (!w->windowHandle() && (w->windowType() != Qt::Desktop)) postEvent(w, new QEvent(e->type())); } + break; + } + default: + break; } return QGuiApplication::event(e); @@ -1739,6 +1782,7 @@ void QApplicationPrivate::notifyLayoutDirectionChange() /*! \fn void QApplication::setActiveWindow(QWidget* active) + \deprecated [6.5] Use QWidget::activateWindow() instead. Sets the active window to the \a active widget in response to a system event. The function is called from the platform specific event handlers. @@ -1755,8 +1799,15 @@ void QApplicationPrivate::notifyLayoutDirectionChange() \sa activeWindow(), QWidget::activateWindow() */ +#if QT_DEPRECATED_SINCE(6,5) void QApplication::setActiveWindow(QWidget* act) { + QApplicationPrivate::setActiveWindow(act); +} +#endif + +void QApplicationPrivate::setActiveWindow(QWidget* act) +{ QWidget* window = act?act->window():nullptr; if (QApplicationPrivate::active_window == window) @@ -1773,8 +1824,8 @@ void QApplication::setActiveWindow(QWidget* act) QWidgetList toBeDeactivated; if (QApplicationPrivate::active_window) { - if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { - const QWidgetList list = topLevelWidgets(); + if (QApplication::style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { + const QWidgetList list = QApplication::topLevelWidgets(); for (auto *w : list) { if (w->isVisible() && w->isActiveWindow()) toBeDeactivated.append(w); @@ -1795,8 +1846,8 @@ void QApplication::setActiveWindow(QWidget* act) QApplicationPrivate::active_window = window; if (QApplicationPrivate::active_window) { - if (style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { - const QWidgetList list = topLevelWidgets(); + if (QApplication::style()->styleHint(QStyle::SH_Widget_ShareActivation, nullptr, QApplicationPrivate::active_window)) { + const QWidgetList list = QApplication::topLevelWidgets(); for (auto *w : list) { if (w->isVisible() && w->isActiveWindow()) toBeActivated.append(w); @@ -1814,14 +1865,14 @@ void QApplication::setActiveWindow(QWidget* act) for (int i = 0; i < toBeActivated.size(); ++i) { QWidget *w = toBeActivated.at(i); - sendSpontaneousEvent(w, &windowActivate); - sendSpontaneousEvent(w, &activationChange); + QApplication::sendSpontaneousEvent(w, &windowActivate); + QApplication::sendSpontaneousEvent(w, &activationChange); } for(int i = 0; i < toBeDeactivated.size(); ++i) { QWidget *w = toBeDeactivated.at(i); - sendSpontaneousEvent(w, &windowDeactivate); - sendSpontaneousEvent(w, &activationChange); + QApplication::sendSpontaneousEvent(w, &windowDeactivate); + QApplication::sendSpontaneousEvent(w, &activationChange); } if (QApplicationPrivate::popupWidgets == nullptr) { // !inPopupMode() @@ -1884,7 +1935,7 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) #endif QWindow *focusWindow = QGuiApplicationPrivate::focus_window; QWidget *focusWidget = qt_tlw_for_window(focusWindow); - QApplication::setActiveWindow(focusWidget); + QApplicationPrivate::setActiveWindow(focusWidget); // QTBUG-37126, Active X controls may set the focus on native child widgets. if (focusWindow && focusWidget && focusWindow != focusWidget->windowHandle()) { if (QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(focusWindow)) @@ -1924,7 +1975,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool f = toplevel; QWidget *w = f; - QWidget *test = f->d_func()->focus_next; + QWidget *test = f->nextInFocusChain(); bool seenWindow = false; bool focusWidgetAfterWindow = false; while (test && test != f) { @@ -1955,7 +2006,7 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool if (next) break; } - test = test->d_func()->focus_next; + test = test->nextInFocusChain(); } if (wrappingOccurred != nullptr) @@ -1980,19 +2031,6 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool */ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF) { -#if 0 - if (leave) { - QEvent e(QEvent::Leave); - QCoreApplication::sendEvent(leave, & e); - } - if (enter) { - const QPoint windowPos = enter->window()->mapFromGlobal(globalPos); - QEnterEvent e(enter->mapFromGlobal(globalPos), windowPos, globalPos); - QCoreApplication::sendEvent(enter, & e); - } - return; -#endif - if ((!enter && !leave) || (enter == leave)) return; @@ -2062,7 +2100,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con const QPointF globalPos = qIsInf(globalPosF.x()) ? QPointF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) : globalPosF; - const QPointF windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos); + const QPointF windowPos = std::as_const(enterList).back()->window()->mapFromGlobal(globalPos); for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) { auto *w = *it; if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) { @@ -2071,8 +2109,9 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con QCoreApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverEnter, localPos, QPointF(-1, -1), globalPos, + QHoverEvent he(QEvent::HoverEnter, windowPos, QPointF(-1, -1), globalPos, QGuiApplication::keyboardModifiers()); + QMutableEventPoint::setPosition(he.point(0), localPos); qApp->d_func()->notify_helper(w, &he); } } @@ -2149,80 +2188,16 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) return window && self->isWindowBlocked(window); } -bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const +Qt::WindowModality QApplicationPrivate::defaultModality() const { - QWindow *unused = nullptr; - if (Q_UNLIKELY(!window)) { - qWarning().nospace() << "window == 0 passed."; - return false; - } - if (!blockingWindow) - blockingWindow = &unused; + return Qt::ApplicationModal; +} - if (modalWindowList.isEmpty()) { - *blockingWindow = nullptr; - return false; - } +bool QApplicationPrivate::windowNeverBlocked(QWindow *window) const +{ QWidget *popupWidget = QApplication::activePopupWidget(); QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : nullptr; - if (popupWindow == window || (!popupWindow && QWindowPrivate::get(window)->isPopup())) { - *blockingWindow = nullptr; - return false; - } - - for (int i = 0; i < modalWindowList.count(); ++i) { - QWindow *modalWindow = modalWindowList.at(i); - - // A window is not blocked by another modal window if the two are - // the same, or if the window is a child of the modal window. - if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) { - *blockingWindow = nullptr; - return false; - } - - Qt::WindowModality windowModality = modalWindow->modality(); - if (windowModality == Qt::NonModal) { - // If modality type hasn't been set on the modalWindow's widget, as - // when waiting for a native dialog, use ApplicationModal. - windowModality = Qt::ApplicationModal; - } - - switch (windowModality) { - case Qt::ApplicationModal: - if (modalWindow != window) { - *blockingWindow = modalWindow; - return true; - } - break; - case Qt::WindowModal: - { - QWindow *w = window; - do { - QWindow *m = modalWindow; - do { - if (m == w) { - *blockingWindow = m; - return true; - } - QWindow *p = m->parent(); - if (!p) - p = m->transientParent(); - m = p; - } while (m); - QWindow *p = w->parent(); - if (!p) - p = w->transientParent(); - w = p; - } while (w); - break; - } - default: - Q_ASSERT_X(false, "QApplication", "internal error, a modal window cannot be modeless"); - break; - } - } - *blockingWindow = nullptr; - return false; + return popupWindow == window || (!popupWindow && QWindowPrivate::get(window)->isPopup()); } /*!\internal @@ -2505,7 +2480,7 @@ void QApplication::setStartDragTime(int ms) The default value is 500 ms. - \sa startDragDistance(), {Drag and Drop} + \sa startDragDistance(), {Drag and Drop in Qt}{Drag and Drop} */ int QApplication::startDragTime() @@ -2544,7 +2519,7 @@ void QApplication::setStartDragDistance(int l) The default value (if the platform doesn't provide a different default) is 10 pixels. - \sa startDragTime(), QPoint::manhattanLength(), {Drag and Drop} + \sa startDragTime(), QPoint::manhattanLength(), {Drag and Drop in Qt}{Drag and Drop} */ int QApplication::startDragDistance() @@ -2566,8 +2541,9 @@ int QApplication::startDragDistance() exec(), because modal widgets call exec() to start a local event loop. To make your application perform idle processing, i.e., executing a special - function whenever there are no pending events, use a QTimer with 0 timeout. - More advanced idle processing schemes can be achieved using processEvents(). + function whenever there are no pending events, use a QChronoTimer with 0ns + timeout. More advanced idle processing schemes can be achieved using + processEvents(). We recommend that you connect clean-up code to the \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your @@ -2676,6 +2652,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) Q_FALLTHROUGH(); case QEvent::Leave: d->toolTipWakeUp.stop(); + break; default: break; } @@ -2700,6 +2677,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) || key == Qt::Key_Up || key == Qt::Key_Right || key == Qt::Key_Down); + break; } default: break; @@ -2815,7 +2793,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (w) { if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverMove, relpos, mouse->globalPosition(), relpos - diff, mouse->modifiers()); + QHoverEvent he(QEvent::HoverMove, mouse->scenePosition(), mouse->globalPosition(), relpos - diff, mouse->modifiers()); + QMutableEventPoint::setPosition(he.point(0), relpos); d->notify_helper(w, &he); } if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) @@ -2960,6 +2939,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) tablet->tangentialPressure(), tablet->rotation(), tablet->z(), tablet->modifiers(), tablet->button(), tablet->buttons()); te.m_spont = e->spontaneous(); + te.setTimestamp(tablet->timestamp()); te.setAccepted(false); res = d->notify_helper(w, w == receiver ? tablet : &te); eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted(); @@ -3055,8 +3035,16 @@ bool QApplication::notify(QObject *receiver, QEvent *e) #endif w = qobject_cast<QWidget *>(QDragManager::self()->currentTarget()); - if (!w) - break; + if (!w) { + // The widget that received DragEnter didn't accept the event, so we have no + // current drag target in the QDragManager. But DragLeave still needs to be + // dispatched so that enter/leave events are in balance (and so that UnderMouse + // gets cleared). + if (e->type() == QEvent::DragLeave) + w = static_cast<QWidget *>(receiver); + else + break; + } if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { QDropEvent *dragEvent = static_cast<QDropEvent *>(e); QWidget *origReceiver = static_cast<QWidget *>(receiver); @@ -3073,15 +3061,16 @@ bool QApplication::notify(QObject *receiver, QEvent *e) ) QDragManager::self()->setCurrentTarget(nullptr, e->type() == QEvent::Drop); break; -#endif } +#endif // QT_CONFIG(draganddrop) case QEvent::TouchBegin: { // Note: TouchUpdate and TouchEnd events are never propagated QMutableTouchEvent *touchEvent = QMutableTouchEvent::from(static_cast<QTouchEvent *>(e)); bool eventAccepted = touchEvent->isAccepted(); bool acceptTouchEvents = w->testAttribute(Qt::WA_AcceptTouchEvents); - if (acceptTouchEvents && e->spontaneous()) { + if (acceptTouchEvents && e->spontaneous() + && touchEvent->device()->type() != QInputDevice::DeviceType::TouchPad) { const QPoint localPos = touchEvent->points()[0].position().toPoint(); QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, localPos); } @@ -3220,7 +3209,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; w = w->parentWidget(); } - for (QGesture *g : qAsConst(allGestures)) + for (QGesture *g : std::as_const(allGestures)) gestureEvent->setAccepted(g, false); gestureEvent->m_accept = false; // to make sure we check individual gestures break; @@ -3371,7 +3360,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) qt_popup_down = nullptr; } - if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup + if (QApplicationPrivate::popupWidgets->size() == 0) { // this was the last popup delete QApplicationPrivate::popupWidgets; QApplicationPrivate::popupWidgets = nullptr; qt_popup_down_closed = false; @@ -3416,7 +3405,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) // can become nullptr due to setFocus() above if (QApplicationPrivate::popupWidgets && - QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard + QApplicationPrivate::popupWidgets->size() == 1) // grab mouse/keyboard grabForPopup(aw); } @@ -3431,7 +3420,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) popupWidgets = new QWidgetList; popupWidgets->append(popup); // add to end of list - if (QApplicationPrivate::popupWidgets->count() == 1) // grab mouse/keyboard + if (QApplicationPrivate::popupWidgets->size() == 1) // grab mouse/keyboard grabForPopup(popup); // popups are not focus-handled by the window system (the first @@ -3439,7 +3428,7 @@ void QApplicationPrivate::openPopup(QWidget *popup) // new popup gets the focus if (popup->focusWidget()) { popup->focusWidget()->setFocus(Qt::PopupFocusReason); - } else if (popupWidgets->count() == 1) { // this was the first popup + } else if (popupWidgets->size() == 1) { // this was the first popup if (QWidget *fw = QApplication::focusWidget()) { QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason); QCoreApplication::sendEvent(fw, &e); |