diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-26 13:50:54 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-26 15:53:39 +0000 |
commit | 3326439361d3ec4e60bcdb189e6bfb75189136ca (patch) | |
tree | 445d502e9edea0b686164b2207fed8310f943a14 /src/quicktemplates2/qquickdrawer.cpp | |
parent | cf67bb976e082105994ff00a2616129833edb857 (diff) |
Revise the press/move/release handlers
Otherwise the handlers are not able to control whether presses, moves
and releases should be blocked or not.
a) outside a non-modal popup,
b) to popup children/content, or
b) outside a modal popups's background dimming
Change-Id: I637295fc3122cdcddb7727ec3939ec6a68a3cf98
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdrawer.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index c2597cc4..66ba74a2 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -330,36 +330,42 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event) static const qreal openCloseVelocityThreshold = 300; -void QQuickDrawerPrivate::handlePress(const QPointF &point, ulong timestamp) +bool QQuickDrawerPrivate::handlePress(QQuickItem *item, const QPointF &point, ulong timestamp) { - QQuickPopupPrivate::handlePress(point, timestamp); + if (!QQuickPopupPrivate::handlePress(item, point, timestamp)) + return false; offset = 0; pressPoint = point; velocityCalculator.startMeasuring(point, timestamp); + + return true; } -void QQuickDrawerPrivate::handleMove(const QPointF &point, ulong timestamp) +bool QQuickDrawerPrivate::handleMove(QQuickItem *item, const QPointF &point, ulong timestamp) { Q_Q(QQuickDrawer); - QQuickPopupPrivate::handleMove(point, timestamp); + if (!QQuickPopupPrivate::handleMove(item, point, timestamp)) + return false; // limit/reset the offset to the edge of the drawer when pushed from the outside if (qFuzzyCompare(position, 1.0) && !popupItem->contains(popupItem->mapFromScene(point))) offset = 0; - if (popupItem->keepMouseGrab() || popupItem->keepTouchGrab()) + bool isGrabbed = popupItem->keepMouseGrab() || popupItem->keepTouchGrab(); + if (isGrabbed) q->setPosition(positionAt(point) - offset); + + return isGrabbed; } -void QQuickDrawerPrivate::handleRelease(const QPointF &point, ulong timestamp) +bool QQuickDrawerPrivate::handleRelease(QQuickItem *item, const QPointF &point, ulong timestamp) { pressPoint = QPointF(); if (!popupItem->keepMouseGrab() && !popupItem->keepTouchGrab()) { velocityCalculator.reset(); - QQuickPopupPrivate::handleRelease(point, timestamp); - return; + return QQuickPopupPrivate::handleRelease(item, point, timestamp); } velocityCalculator.stopMeasuring(point, timestamp); @@ -414,8 +420,11 @@ void QQuickDrawerPrivate::handleRelease(const QPointF &point, ulong timestamp) } } + bool wasGrabbed = popupItem->keepMouseGrab() || popupItem->keepTouchGrab(); popupItem->setKeepMouseGrab(false); popupItem->setKeepTouchGrab(false); + + return wasGrabbed; } void QQuickDrawerPrivate::handleUngrab() @@ -610,8 +619,7 @@ bool QQuickDrawer::childMouseEventFilter(QQuickItem *child, QEvent *event) return d->grabMouse(child, static_cast<QMouseEvent *>(event)); case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: - d->handleMouseEvent(child, static_cast<QMouseEvent *>(event)); - break; + return d->handleMouseEvent(child, static_cast<QMouseEvent *>(event)); default: break; } |