summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Fletcher <ben.fletcher@me.com>2023-03-11 22:10:12 -0800
committerShawn Rutledge <shawn.rutledge@qt.io>2023-04-06 21:00:22 +0200
commit13d2a4e31dbef2b48ebc44978368539ba96fded8 (patch)
tree683be4b4010fe01d54b1fd4e0974f4f36472d807
parent5a98760f7954b9ad612fe2ae2a47887bffb26613 (diff)
downloadqtlocation-13d2a4e31dbef2b48ebc44978368539ba96fded8.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. Pick-to: 6.5 Task-number: QTBUG-87646 Task-number: QTBUG-112394 Change-Id: I9e516a52e941b0b05cd0114afafde2767d80f4ff Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-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)
}
}