From a566125b9fcc023237b442e5b9a838d40455c8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 18 Jan 2019 14:39:00 +0100 Subject: Fix axis constraints API and documentation: This should have been done properly for 5.12. Since this API was introduced in 5.12.0, we simply hide the documentation for the old properties and make sure the properties we want to expose are documented: * Document the xAxis and yAxis properties. * Deprecate the {min,max}imum{X,Y} properties, and hide them in the documentation. Fixes: QTBUG-73137 Change-Id: Ic749bcfec63dc4772f193ccae2a2750c20cb63aa Reviewed-by: Shawn Rutledge --- src/quick/handlers/qquickpinchhandler.cpp | 56 ++++++++++++++++++++----------- src/quick/handlers/qquickpinchhandler_p.h | 22 +++++++----- 2 files changed, 51 insertions(+), 27 deletions(-) (limited to 'src/quick/handlers') diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp index e6442e7258..95ac0985f0 100644 --- a/src/quick/handlers/qquickpinchhandler.cpp +++ b/src/quick/handlers/qquickpinchhandler.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qquickpinchhandler_p.h" +#include #include #include #include @@ -151,57 +152,48 @@ void QQuickPinchHandler::setMaximumRotation(qreal maximumRotation) emit maximumRotationChanged(); } -/*! - \qmlproperty real QtQuick::PinchHandler::minimumX +#if QT_DEPRECATED_SINCE(5, 12) +void QQuickPinchHandler::warnAboutMinMaxDeprecated() const +{ + qmlWarning(this) << "min and max constraints are now part of the xAxis and yAxis properties"; +} - The minimum acceptable x coordinate of the centroid -*/ void QQuickPinchHandler::setMinimumX(qreal minX) { + warnAboutMinMaxDeprecated(); if (m_minimumX == minX) return; m_minimumX = minX; emit minimumXChanged(); } -/*! - \qmlproperty real QtQuick::PinchHandler::maximumX - - The maximum acceptable x coordinate of the centroid -*/ void QQuickPinchHandler::setMaximumX(qreal maxX) { + warnAboutMinMaxDeprecated(); if (m_maximumX == maxX) return; m_maximumX = maxX; emit maximumXChanged(); } -/*! - \qmlproperty real QtQuick::PinchHandler::minimumY - - The minimum acceptable y coordinate of the centroid -*/ void QQuickPinchHandler::setMinimumY(qreal minY) { + warnAboutMinMaxDeprecated(); if (m_minimumY == minY) return; m_minimumY = minY; emit minimumYChanged(); } -/*! - \qmlproperty real QtQuick::PinchHandler::maximumY - - The maximum acceptable y coordinate of the centroid -*/ void QQuickPinchHandler::setMaximumY(qreal maxY) { + warnAboutMinMaxDeprecated(); if (m_maximumY == maxY) return; m_maximumY = maxY; emit maximumYChanged(); } +#endif bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event) { @@ -229,6 +221,32 @@ bool QQuickPinchHandler::wantsPointerEvent(QQuickPointerEvent *event) return true; } +/*! + \qmlpropertygroup QtQuick::PinchHandler::xAxis + \qmlproperty real QtQuick::PinchHandler::xAxis.minimum + \qmlproperty real QtQuick::PinchHandler::xAxis.maximum + \qmlproperty bool QtQuick::PinchHandler::xAxis.enabled + + \c xAxis controls the constraints for horizontal translation of the \l target item. + + \c minimum is the minimum acceptable x coordinate of the translation. + \c maximum is the maximum acceptable x coordinate of the translation. + If \c enabled is true, horizontal dragging is allowed. + */ + +/*! + \qmlpropertygroup QtQuick::PinchHandler::yAxis + \qmlproperty real QtQuick::PinchHandler::yAxis.minimum + \qmlproperty real QtQuick::PinchHandler::yAxis.maximum + \qmlproperty bool QtQuick::PinchHandler::yAxis.enabled + + \c yAxis controls the constraints for vertical translation of the \l target item. + + \c minimum is the minimum acceptable y coordinate of the translation. + \c maximum is the maximum acceptable y coordinate of the translation. + If \c enabled is true, vertical dragging is allowed. + */ + /*! \qmlproperty int QtQuick::PinchHandler::minimumTouchPoints diff --git a/src/quick/handlers/qquickpinchhandler_p.h b/src/quick/handlers/qquickpinchhandler_p.h index 8f24d18166..11d895468c 100644 --- a/src/quick/handlers/qquickpinchhandler_p.h +++ b/src/quick/handlers/qquickpinchhandler_p.h @@ -70,10 +70,12 @@ class Q_AUTOTEST_EXPORT QQuickPinchHandler : public QQuickMultiPointHandler Q_PROPERTY(qreal activeScale READ activeScale NOTIFY updated) Q_PROPERTY(qreal rotation READ rotation NOTIFY updated) Q_PROPERTY(QVector2D translation READ translation NOTIFY updated) - Q_PROPERTY(qreal minimumX READ minimumX WRITE setMinimumX NOTIFY minimumXChanged) - Q_PROPERTY(qreal maximumX READ maximumX WRITE setMaximumX NOTIFY maximumXChanged) - Q_PROPERTY(qreal minimumY READ minimumY WRITE setMinimumY NOTIFY minimumYChanged) - Q_PROPERTY(qreal maximumY READ maximumY WRITE setMaximumY NOTIFY maximumYChanged) +#if QT_DEPRECATED_SINCE(5, 12) + Q_PROPERTY(qreal minimumX READ minimumX WRITE setMinimumX NOTIFY minimumXChanged) // ### Qt 6: remove + Q_PROPERTY(qreal maximumX READ maximumX WRITE setMaximumX NOTIFY maximumXChanged) // ### Qt 6: remove + Q_PROPERTY(qreal minimumY READ minimumY WRITE setMinimumY NOTIFY minimumYChanged) // ### Qt 6: remove + Q_PROPERTY(qreal maximumY READ maximumY WRITE setMaximumY NOTIFY maximumYChanged) // ### Qt 6: remove +#endif Q_PROPERTY(QQuickDragAxis * xAxis READ xAxis CONSTANT) Q_PROPERTY(QQuickDragAxis * yAxis READ yAxis CONSTANT) @@ -96,14 +98,18 @@ public: qreal scale() const { return m_accumulatedScale; } qreal activeScale() const { return m_activeScale; } qreal rotation() const { return m_activeRotation; } - qreal minimumX() const { return m_minimumX; } + +#if QT_DEPRECATED_SINCE(5, 12) + void warnAboutMinMaxDeprecated() const; + qreal minimumX() const { warnAboutMinMaxDeprecated(); return m_minimumX; } void setMinimumX(qreal minX); - qreal maximumX() const { return m_maximumX; } + qreal maximumX() const { warnAboutMinMaxDeprecated(); return m_maximumX; } void setMaximumX(qreal maxX); - qreal minimumY() const { return m_minimumY; } + qreal minimumY() const { warnAboutMinMaxDeprecated(); return m_minimumY; } void setMinimumY(qreal minY); - qreal maximumY() const { return m_maximumY; } + qreal maximumY() const { warnAboutMinMaxDeprecated(); return m_maximumY; } void setMaximumY(qreal maxY); +#endif QQuickDragAxis *xAxis() { return &m_xAxis; } QQuickDragAxis *yAxis() { return &m_yAxis; } -- cgit v1.2.3 From 8ab6ded97633bf7f74e7ca4de35ed56d07f358d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Mon, 4 Feb 2019 15:16:45 +0100 Subject: Fix bug where QQMPH kept an exclusive grab when no buttons were pressed This happened if you moved the mouse while doing a multitouch operation. More specifically this caused the bug: 1. Open qtdeclarative/tests/manual/pointer/map.qml 2. Rotate the map with two fingers (Do not release fingers). 3. Move mouse (no buttons pressed). 4. Release both fingers. 5. Move mouse again (error: the draghandler has a grab and thus the map is dragged even if no buttons are down). This happened because if you moved the mouse while having two fingers down, Windows would generate a *mouse*move* event with Left button or Right button pressed (which wasn't the case on the physical device but it's probably because of a bug in how mouse events are synthesized from touch on Windows). This caused the QQuickMultiPointHandler to do a passive grab. Then, when releasing the fingers it would not send a mouse release event (just plain touch release events), so the QQuickMultiPointHandler would keep the passive grab it had. All subsequent mouse move events would then be dispatched to the QQuickMultiPointHandler where it would assume that the button was pressed until it got a release event (but button was never pressed so that wouldn't happen). Eventually it would perform an exclusive grab, and dragging was initiated. Change-Id: I42b3133c5fde93c7f92f1cb28705156a69f9ad1c Reviewed-by: Shawn Rutledge --- src/quick/handlers/qquickmultipointhandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/quick/handlers') diff --git a/src/quick/handlers/qquickmultipointhandler.cpp b/src/quick/handlers/qquickmultipointhandler.cpp index 228c99bb12..baa68e5e53 100644 --- a/src/quick/handlers/qquickmultipointhandler.cpp +++ b/src/quick/handlers/qquickmultipointhandler.cpp @@ -162,6 +162,10 @@ QVector QQuickMultiPointHandler::eligiblePoints(QQuickPointe bool stealingAllowed = event->isPressEvent() || event->isReleaseEvent(); for (int i = 0; i < c; ++i) { QQuickEventPoint *p = event->point(i); + if (QQuickPointerMouseEvent *me = event->asPointerMouseEvent()) { + if (me->buttons() == Qt::NoButton) + continue; + } if (!stealingAllowed) { QObject *exclusiveGrabber = p->exclusiveGrabber(); if (exclusiveGrabber && exclusiveGrabber != this && !canGrab(p)) -- cgit v1.2.3