aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-07-08 22:53:59 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-07-09 13:17:06 +0200
commiteb169146ceb8167214e0ea4f41b530fe8b2cc6a1 (patch)
tree8904aab96475797d65cee463177e4cd1beb6eef7
parenta04d98787dc5c816569a6eecce695a8d80257c05 (diff)
Respect PinchHandler min/maximumPointCount props with native gestures
QNativeGestureEvent::fingerCount() is new in 6.2, and on Wayland touchpads it's actually populated, so we can now do this. Fixes: QTBUG-95070 Pick-to: 6.2 Change-Id: Ia365ff34003be8ae8f7f860c195f08b66f6c4a4e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/quick/handlers/qquickpinchhandler.cpp5
-rw-r--r--tests/manual/pointer/pinchHandler.qml3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/quick/handlers/qquickpinchhandler.cpp b/src/quick/handlers/qquickpinchhandler.cpp
index e1e4feae1a..bdacc6f46d 100644
--- a/src/quick/handlers/qquickpinchhandler.cpp
+++ b/src/quick/handlers/qquickpinchhandler.cpp
@@ -92,7 +92,7 @@ Q_LOGGING_CATEGORY(lcPinchHandler, "qt.quick.handler.pinch")
but if it's a disallowed number, it does not scale or rotate
its \l target, and the \l active property remains \c false.
- \sa PinchArea, QPointerEvent::pointCount()
+ \sa PinchArea, QPointerEvent::pointCount(), QNativeGestureEvent::fingerCount()
*/
QQuickPinchHandler::QQuickPinchHandler(QQuickItem *parent)
@@ -170,7 +170,8 @@ bool QQuickPinchHandler::wantsPointerEvent(QPointerEvent *event)
#if QT_CONFIG(gestures)
if (event->type() == QEvent::NativeGesture) {
const auto gesture = static_cast<const QNativeGestureEvent *>(event);
- if (minimumPointCount() == 2) {
+ if (!gesture->fingerCount() || (gesture->fingerCount() >= minimumPointCount() &&
+ gesture->fingerCount() <= maximumPointCount())) {
switch (gesture->gestureType()) {
case Qt::BeginNativeGesture:
case Qt::EndNativeGesture:
diff --git a/tests/manual/pointer/pinchHandler.qml b/tests/manual/pointer/pinchHandler.qml
index 93169da60a..e7f4530c4c 100644
--- a/tests/manual/pointer/pinchHandler.qml
+++ b/tests/manual/pointer/pinchHandler.qml
@@ -65,10 +65,11 @@ Rectangle {
minimumScale: 0.5
maximumScale: 3
minimumPointCount: 3
+ maximumPointCount: 6 // mutants are allowed; using both hands is not normal for a pinch gesture, but we can't tell
}
Text {
- text: "Pinch with 3 fingers to scale, rotate and translate"
+ text: "Pinch with 3 or more fingers to scale, rotate and translate"
+ getTransformationDetails(parent, grandparentPinch)
}