diff options
-rw-r--r-- | src/quick/handlers/qquickdraghandler.cpp | 11 | ||||
-rw-r--r-- | src/quick/handlers/qquickdraghandler_p.h | 5 | ||||
-rw-r--r-- | src/quick/handlers/qquickpinchhandler.cpp | 4 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointerhandler.cpp | 4 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointersinglehandler.cpp | 11 | ||||
-rw-r--r-- | src/quick/handlers/qquickpointersinglehandler_p.h | 1 | ||||
-rw-r--r-- | tests/manual/pointer/content/Slider.qml | 2 | ||||
-rw-r--r-- | tests/manual/pointer/joystick.qml | 2 |
8 files changed, 20 insertions, 20 deletions
diff --git a/src/quick/handlers/qquickdraghandler.cpp b/src/quick/handlers/qquickdraghandler.cpp index a1c3486bd0..dc3116e300 100644 --- a/src/quick/handlers/qquickdraghandler.cpp +++ b/src/quick/handlers/qquickdraghandler.cpp @@ -59,7 +59,6 @@ QT_BEGIN_NAMESPACE QQuickDragHandler::QQuickDragHandler(QObject *parent) : QQuickPointerSingleHandler(parent) - , m_dragging(false) { } @@ -88,7 +87,7 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point) delta.setX(0); if (!m_yAxis.enabled()) delta.setY(0); - if (m_dragging) { + if (active()) { if (target() && target()->parentItem()) { QPointF pos = target()->parentItem()->mapFromScene(m_startPos + delta); enforceAxisConstraints(&pos); @@ -96,17 +95,9 @@ void QQuickDragHandler::handleEventPoint(QQuickEventPoint *point) } } else if ((m_xAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.x(), Qt::XAxis, point)) || (m_yAxis.enabled() && QQuickWindowPrivate::dragOverThreshold(delta.y(), Qt::YAxis, point))) { - m_dragging = true; setGrab(point, true); - emit draggingChanged(); } } break; - case QQuickEventPoint::Released: - if (m_dragging) { - m_dragging = false; - emit draggingChanged(); - } - break; default: break; } diff --git a/src/quick/handlers/qquickdraghandler_p.h b/src/quick/handlers/qquickdraghandler_p.h index e7cb675025..8f27d51b4f 100644 --- a/src/quick/handlers/qquickdraghandler_p.h +++ b/src/quick/handlers/qquickdraghandler_p.h @@ -90,7 +90,6 @@ class Q_AUTOTEST_EXPORT QQuickDragHandler : public QQuickPointerSingleHandler Q_OBJECT Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT) Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT) - Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged) public: QQuickDragHandler(QObject *parent = 0); @@ -101,13 +100,10 @@ public: QQuickDragAxis *xAxis() { return &m_xAxis; } QQuickDragAxis *yAxis() { return &m_yAxis; } - bool dragging() const { return m_dragging; } - Q_INVOKABLE void enforceConstraints(); Q_SIGNALS: // void gestureStarted(QQuickGestureEvent *gesture); - void draggingChanged(); protected: bool wantsEventPoint(QQuickEventPoint *point) override; @@ -117,7 +113,6 @@ private: void enforceAxisConstraints(QPointF *localPos); private: - bool m_dragging; QPointF m_startPos; QQuickDragAxis m_xAxis; QQuickDragAxis m_yAxis; diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp index 45d8235dff..4832d300c2 100644 --- a/src/quick/handlers/qquickpinchhandler.cpp +++ b/src/quick/handlers/qquickpinchhandler.cpp @@ -224,6 +224,10 @@ void QQuickPinchHandler::onActiveChanged() void QQuickPinchHandler::handlePointerEventImpl(QQuickPointerEvent *event) { Q_UNUSED(event) + // TODO wait for the drag threshold before setting active + // but the old behavior was that whenever we "want" all the points, we're active + // so that behavior is retained here temporarily + setActive(m_currentPoints.count() > 0 && m_currentPoints.at(0)->state() != QQuickEventPoint::Released); if (Q_UNLIKELY(lcPinchHandler().isDebugEnabled())) { for (QQuickEventPoint *point : qAsConst(m_currentPoints)) diff --git a/src/quick/handlers/qquickpointerhandler.cpp b/src/quick/handlers/qquickpointerhandler.cpp index d51835a24b..ed08eed93e 100644 --- a/src/quick/handlers/qquickpointerhandler.cpp +++ b/src/quick/handlers/qquickpointerhandler.cpp @@ -140,9 +140,7 @@ QQuickItem *QQuickPointerHandler::target() const void QQuickPointerHandler::handlePointerEvent(QQuickPointerEvent *event) { - const bool wants = wantsPointerEvent(event); - setActive(wants); - if (wants) + if (wantsPointerEvent(event)) handlePointerEventImpl(event); else setActive(false); diff --git a/src/quick/handlers/qquickpointersinglehandler.cpp b/src/quick/handlers/qquickpointersinglehandler.cpp index 5b2d6b0801..3a67d66e8c 100644 --- a/src/quick/handlers/qquickpointersinglehandler.cpp +++ b/src/quick/handlers/qquickpointersinglehandler.cpp @@ -101,6 +101,11 @@ void QQuickPointerSingleHandler::handlePointerEventImpl(QQuickPointerEvent *even } else { setPressedButtons(event->buttons()); handleEventPoint(currentPoint); + if (currentPoint->state() == QQuickEventPoint::Released) { + m_currentPointId = 0; + setPressedButtons(Qt::NoButton); + setGrab(currentPoint, false); + } } bool grab = currentPoint->isAccepted() && currentPoint->state() != QQuickEventPoint::Released; setGrab(currentPoint, grab); @@ -120,6 +125,12 @@ void QQuickPointerSingleHandler::handleGrabCancel(QQuickEventPoint *point) setPressedButtons(Qt::NoButton); } +void QQuickPointerSingleHandler::onGrabChanged(QQuickEventPoint *point) +{ + bool grabbing = (point->grabber() == this); + setActive(grabbing); +} + void QQuickPointerSingleHandler::setPressedButtons(Qt::MouseButtons buttons) { if (buttons != m_pressedButtons) { diff --git a/src/quick/handlers/qquickpointersinglehandler_p.h b/src/quick/handlers/qquickpointersinglehandler_p.h index 69a3263271..e3c6bfaddf 100644 --- a/src/quick/handlers/qquickpointersinglehandler_p.h +++ b/src/quick/handlers/qquickpointersinglehandler_p.h @@ -77,6 +77,7 @@ protected: quint64 currentPointId() const { return m_currentPointId; } QQuickEventPoint *currentPoint(QQuickPointerEvent *ev) { return ev->pointById(m_currentPointId); } void handleGrabCancel(QQuickEventPoint *point) override; + void onGrabChanged(QQuickEventPoint *point) override; private: void setPressedButtons(Qt::MouseButtons buttons); diff --git a/tests/manual/pointer/content/Slider.qml b/tests/manual/pointer/content/Slider.qml index 363f6911d4..cd52dfac80 100644 --- a/tests/manual/pointer/content/Slider.qml +++ b/tests/manual/pointer/content/Slider.qml @@ -70,7 +70,7 @@ Item { anchors.horizontalCenterOffset: 1 radius: 5 color: "#4400FFFF" - visible: dragHandler.dragging + opacity: dragHandler.active ? 1 : 0 } Image { id: knob diff --git a/tests/manual/pointer/joystick.qml b/tests/manual/pointer/joystick.qml index 7959eaea42..bcc4564471 100644 --- a/tests/manual/pointer/joystick.qml +++ b/tests/manual/pointer/joystick.qml @@ -58,7 +58,7 @@ Rectangle { } states: [ State { - when: dragHandler.dragging + when: dragHandler.active AnchorChanges { target: knob anchors.horizontalCenter: undefined |