summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fletcher <ben.fletcher@me.com>2023-03-11 22:10:12 -0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-06 19:25:16 +0000
commit9f4ef17852623ac4f09c0443d0d74f84738355b8 (patch)
treec26d692c85af2199fb44b11d74dc759125a0443d
parentf02d2112e0bb278b5ef45ab6408987861fc60ecf (diff)
downloadqtlocation-9f4ef17852623ac4f09c0443d0d74f84738355b8.tar.gz
MapView: add bearing / tilt wheel functionality; also with Magic Mouse
In Qt 5, Map had bearing / tilt mouse wheel functionality with keyboard modifiers; that feature is now restored. We allow the wheel to zoom, to change the bearing if the Shift key is held, or to change the tilt if the Control key is held. This is redundant when you're using a touchpad that can provide the pinch-zoom feature; but we need it with the Magic Mouse on macOS, because the cocoa plugin can't distinguish it from a trackpad, even though it can't provide the pinch gesture. So we enable these features for both mouse and touchpad devices on macOS. Also allow mouse and touchpad with the minimal_map example. There's a similar issue on Wayland, but let's try to fix the Wayland plugin to distinguish these devices properly. Task-number: QTBUG-87646 Task-number: QTBUG-112394 Change-Id: I9e516a52e941b0b05cd0114afafde2767d80f4ff Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 13d2a4e31dbef2b48ebc44978368539ba96fded8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--examples/location/minimal_map/main.qml5
-rw-r--r--src/location/maps/MapView.qml17
2 files changed, 21 insertions, 1 deletions
diff --git a/examples/location/minimal_map/main.qml b/examples/location/minimal_map/main.qml
index d536943e..7093ceb6 100644
--- a/examples/location/minimal_map/main.qml
+++ b/examples/location/minimal_map/main.qml
@@ -43,6 +43,11 @@ Window {
}
WheelHandler {
id: wheel
+ // workaround for QTBUG-87646 / QTBUG-112394:
+ // Magic Mouse pretends to be a trackpad but doesn't work with PinchHandler
+ acceptedDevices: Qt.platform.pluginName === "cocoa"
+ ? PointerDevice.Mouse | PointerDevice.TouchPad
+ : PointerDevice.Mouse
rotationScale: 1/120
property: "zoomLevel"
}
diff --git a/src/location/maps/MapView.qml b/src/location/maps/MapView.qml
index 76af2d65..70d2105e 100644
--- a/src/location/maps/MapView.qml
+++ b/src/location/maps/MapView.qml
@@ -103,9 +103,24 @@ Item {
}
WheelHandler {
id: wheel
+ // workaround for QTBUG-87646 / QTBUG-112394:
+ // Magic Mouse pretends to be a trackpad but doesn't work with PinchHandler
+ acceptedDevices: Qt.platform.pluginName === "cocoa"
+ ? PointerDevice.Mouse | PointerDevice.TouchPad
+ : PointerDevice.Mouse
onWheel: (event) => {
const loc = map.toCoordinate(wheel.point.position)
- map.zoomLevel += event.angleDelta.y / 120
+ switch (event.modifiers) {
+ case Qt.NoModifier:
+ map.zoomLevel += event.angleDelta.y / 120
+ break
+ case Qt.ShiftModifier:
+ map.bearing += event.angleDelta.y / 15
+ break
+ case Qt.ControlModifier:
+ map.tilt += event.angleDelta.y / 15
+ break
+ }
map.alignCoordinateToPoint(loc, wheel.point.position)
}
}