From c1563a67b7cce03c27367fab4d470b9ee129bd1f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 3 Sep 2016 19:50:40 +0200 Subject: QQuickOverlay: keep track of all drawers Required by the subsequent patches. Done separately keep the other patches smaller and easier to review. Change-Id: Id5d13e19f98155cfd3d0474c7d3839808133bab1 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickoverlay.cpp | 17 +++++------------ src/quicktemplates2/qquickoverlay_p_p.h | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index ae90a5f8..f45b1049 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -178,11 +178,14 @@ QQuickOverlayPrivate::QQuickOverlayPrivate() : void QQuickOverlayPrivate::addPopup(QQuickPopup *popup) { allPopups += popup; + if (QQuickDrawer *drawer = qobject_cast(popup)) + allDrawers += drawer; } void QQuickOverlayPrivate::removePopup(QQuickPopup *popup) { allPopups.removeOne(popup); + allDrawers.removeOne(static_cast(popup)); } QQuickOverlay::QQuickOverlay(QQuickItem *parent) @@ -283,14 +286,9 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data) d->createOverlay(popup); QObjectPrivate::connect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay); QObjectPrivate::connect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay); - - QQuickDrawer *drawer = qobject_cast(popup); - if (drawer) { - d->drawers.append(drawer); - } else { + if (!qobject_cast(popup)) { if (popup->isModal()) ++d->modalPopups; - QObjectPrivate::connect(popup, &QQuickPopup::aboutToShow, d, &QQuickOverlayPrivate::popupAboutToShow); QObjectPrivate::connect(popup, &QQuickPopup::aboutToHide, d, &QQuickOverlayPrivate::popupAboutToHide); } @@ -299,14 +297,9 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data) d->destroyOverlay(popup); QObjectPrivate::disconnect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay); QObjectPrivate::disconnect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay); - - QQuickDrawer *drawer = qobject_cast(popup); - if (drawer) { - d->drawers.removeOne(drawer); - } else { + if (!qobject_cast(popup)) { if (popup->isModal()) --d->modalPopups; - QObjectPrivate::disconnect(popup, &QQuickPopup::aboutToShow, d, &QQuickOverlayPrivate::popupAboutToShow); QObjectPrivate::disconnect(popup, &QQuickPopup::aboutToHide, d, &QQuickOverlayPrivate::popupAboutToHide); } diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index a3d2cda7..7e63a99b 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -87,9 +87,9 @@ public: QQmlComponent *modal; QQmlComponent *modeless; - QVector drawers; QVector popups; QVector allPopups; + QVector allDrawers; QPointer mouseGrabberPopup; int modalPopups; }; -- cgit v1.2.3