diff options
-rw-r--r-- | examples/location/minimal_map/main.qml | 5 | ||||
-rw-r--r-- | src/location/maps/MapView.qml | 17 |
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) } } |