diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-03 19:50:40 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-05 16:36:00 +0000 |
commit | c1563a67b7cce03c27367fab4d470b9ee129bd1f (patch) | |
tree | 544433a000be8d7100cefe79c35c5fe7df714dc0 /src | |
parent | 5f9f81a1d43fd840d37982aadbe49f7343c3cbaa (diff) |
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 <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickoverlay.cpp | 17 | ||||
-rw-r--r-- | 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<QQuickDrawer *>(popup)) + allDrawers += drawer; } void QQuickOverlayPrivate::removePopup(QQuickPopup *popup) { allPopups.removeOne(popup); + allDrawers.removeOne(static_cast<QQuickDrawer *>(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<QQuickDrawer *>(popup); - if (drawer) { - d->drawers.append(drawer); - } else { + if (!qobject_cast<QQuickDrawer *>(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<QQuickDrawer *>(popup); - if (drawer) { - d->drawers.removeOne(drawer); - } else { + if (!qobject_cast<QQuickDrawer *>(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<QQuickDrawer *> drawers; QVector<QQuickPopup *> popups; QVector<QQuickPopup *> allPopups; + QVector<QQuickDrawer *> allDrawers; QPointer<QQuickPopup> mouseGrabberPopup; int modalPopups; }; |