diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-20 15:48:37 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-21 21:39:22 +0000 |
commit | 29668bf3ebef803d67aa4e0bff8cc784149996a9 (patch) | |
tree | 033cae0028ffd2dc4357bd5b43781fbd1c8181c1 | |
parent | 85230f227f38d56572ad4650dda9fcce3942f86d (diff) |
Move resizeOverlay() to QQuickPopupPrivate
This is a preparation step for making drawers movable. Drawer must
be later able to resize the overlay to fit the area of the window
that is covered by the drawer. For example, if the Drawer is below
the header, it can resize the overlay so that it won't be on top of
the header.
Change-Id: I2cfd025a31f3a517575f3dbf9b972dcd6957715c
Task-number: QTBUG-53168
Task-number: QTBUG-55360
Task-number: QTBUG-53609
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickoverlay.cpp | 14 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay_p_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 10 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup_p_p.h | 1 |
4 files changed, 13 insertions, 13 deletions
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index a1fdffb3..dbbc82bb 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -113,7 +113,7 @@ void QQuickOverlayPrivate::createOverlay(QQuickPopup *popup) QQuickPopupPrivate *p = QQuickPopupPrivate::get(popup); if (!p->dimmer) p->dimmer = createDimmer(popup->isModal() ? modal : modeless, popup, q); - resizeOverlay(popup); + p->resizeOverlay(); } void QQuickOverlayPrivate::destroyOverlay(QQuickPopup *popup) @@ -126,16 +126,6 @@ void QQuickOverlayPrivate::destroyOverlay(QQuickPopup *popup) } } -void QQuickOverlayPrivate::resizeOverlay(QQuickPopup *popup) -{ - Q_Q(QQuickOverlay); - QQuickPopupPrivate *p = QQuickPopupPrivate::get(popup); - if (p->dimmer) { - p->dimmer->setWidth(q->width()); - p->dimmer->setHeight(q->height()); - } -} - void QQuickOverlayPrivate::toggleOverlay() { Q_Q(QQuickOverlay); @@ -320,7 +310,7 @@ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &old Q_D(QQuickOverlay); QQuickItem::geometryChanged(newGeometry, oldGeometry); for (QQuickPopup *popup : qAsConst(d->allPopups)) - d->resizeOverlay(popup); + QQuickPopupPrivate::get(popup)->resizeOverlay(); } void QQuickOverlay::mousePressEvent(QMouseEvent *event) diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index 6dc2853c..6201908e 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -78,7 +78,6 @@ public: void createOverlay(QQuickPopup *popup); void destroyOverlay(QQuickPopup *popup); - void resizeOverlay(QQuickPopup *popup); void toggleOverlay(); QVector<QQuickPopup *> stackingOrderPopups() const; diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index d3280040..8c0e5990 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -689,6 +689,16 @@ void QQuickPopupPrivate::reposition() popupItem->setHeight(rect.height()); } +void QQuickPopupPrivate::resizeOverlay() +{ + if (!dimmer) + return; + + qreal w = window ? window->width() : 0; + qreal h = window ? window->height() : 0; + dimmer->setSize(QSizeF(w, h)); +} + void QQuickPopupPositioner::removeAncestorListeners(QQuickItem *item) { if (item == m_parentItem) diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index 745a7f83..321adaf5 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -157,6 +157,7 @@ public: void init(); bool tryClose(QQuickItem *item, QMouseEvent *event); virtual void reposition(); + virtual void resizeOverlay(); virtual bool prepareEnterTransition(); virtual bool prepareExitTransition(); |