diff options
author | Michal Policht <michpolicht@gmail.com> | 2017-09-01 19:56:39 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-09-06 06:47:19 +0000 |
commit | 3512d1b617fb66f13a01e8763e395fcf69b0b5b7 (patch) | |
tree | 53f8988c11d36e391859212466e0c24d96f8ac2e /src/quicktemplates2/qquickdrawer.cpp | |
parent | 60eaf0f9432697416abdc758e003c9ac44962324 (diff) |
Fix non-modal drawer drag/swipe open and close
Function QQuickPopupPrivate::blockInput() has been overridden in
QQuickDrawerPrivate to accept events that occur while mouse/touch is
grabbed and events within drag area.
Task-number: QTBUG-59652
Change-Id: Icf4129e702a351b266ea9c4544830185c315fc37
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index c63d40d1..6ccac70c 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -246,7 +246,7 @@ void QQuickDrawerPrivate::resizeOverlay() dimmer->setSize(geometry.size()); } -static bool isWithinDragMargin(QQuickDrawer *drawer, const QPointF &pos) +static bool isWithinDragMargin(const QQuickDrawer *drawer, const QPointF &pos) { switch (drawer->edge()) { case Qt::LeftEdge: @@ -393,6 +393,30 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event) static const qreal openCloseVelocityThreshold = 300; +bool QQuickDrawerPrivate::blockInput(QQuickItem *item, const QPointF &point) const +{ + Q_Q(const QQuickDrawer); + + // We want all events, if mouse/touch is already grabbed. + if (popupItem->keepMouseGrab() || popupItem->keepTouchGrab()) + return true; + + // Don't block input to drawer's children/content. + if (popupItem->isAncestorOf(item)) + return false; + + // Don't block outside a drawer's background dimming + if (dimmer && !dimmer->contains(dimmer->mapFromScene(point))) + return false; + + // Accept all events within drag area. + if (isWithinDragMargin(q, point)) + return true; + + // Accept all other events if drawer is modal. + return modal; +} + bool QQuickDrawerPrivate::handlePress(QQuickItem *item, const QPointF &point, ulong timestamp) { offset = 0; |