diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-07-25 18:55:36 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-28 07:31:11 -0700 |
commit | 8c7d1a1163ba22cd1b5e75b723affacc9d0cfd1c (patch) | |
tree | 425773ae0a8b44b7a2079cd71e348fc2b16cc332 /mobile-widgets/qml | |
parent | f94aa61009214d5e1d73eb6b19af482bca09e05a (diff) | |
download | subsurface-8c7d1a1163ba22cd1b5e75b723affacc9d0cfd1c.tar.gz |
mapwidget.qml: add zoom-in and zoom-out buttons
The buttons are positioned bellow the "toggle map type" button
and increment / decrement the zoom by "zoomStep" (2 for now).
Also clamp the zoom-in level to "map.maximumZoomLevel".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r-- | mobile-widgets/qml/MapWidget.qml | 52 | ||||
-rw-r--r-- | mobile-widgets/qml/icons/mapwidget-zoom-in.png | bin | 0 -> 256 bytes | |||
-rw-r--r-- | mobile-widgets/qml/icons/mapwidget-zoom-out.png | bin | 0 -> 242 bytes |
3 files changed, 52 insertions, 0 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index b07858c3a..4794533be 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -114,6 +114,8 @@ Item { function doubleClickHandler(coord) { newCenter = coord newZoom = zoomLevel + zoomStep + if (newZoom > maximumZoomLevel) + newZoom = maximumZoomLevel mapAnimationClick.restart() } @@ -167,6 +169,56 @@ Item { } } + Image { + id: imageZoomIn + x: 10 + (toggleImage.width - imageZoomIn.width) * 0.5; y: toggleImage.y + toggleImage.height + 10 + source: "qrc:///mapwidget-zoom-in" + SequentialAnimation { + id: imageZoomInAnimation + PropertyAnimation { + target: imageZoomIn; property: "scale"; from: 1.0; to: 0.8; duration: 120 + } + PropertyAnimation { + target: imageZoomIn; property: "scale"; from: 0.8; to: 1.0; duration: 80 + } + } + MouseArea { + anchors.fill: parent + onClicked: { + map.newCenter = map.center + map.newZoom = map.zoomLevel + map.zoomStep + if (map.newZoom > map.maximumZoomLevel) + map.newZoom = map.maximumZoomLevel + mapAnimationClick.restart() + imageZoomInAnimation.restart() + } + } + } + + Image { + id: imageZoomOut + x: imageZoomIn.x; y: imageZoomIn.y + imageZoomIn.height + 10 + source: "qrc:///mapwidget-zoom-out" + SequentialAnimation { + id: imageZoomOutAnimation + PropertyAnimation { + target: imageZoomOut; property: "scale"; from: 1.0; to: 0.8; duration: 120 + } + PropertyAnimation { + target: imageZoomOut; property: "scale"; from: 0.8; to: 1.0; duration: 80 + } + } + MouseArea { + anchors.fill: parent + onClicked: { + map.newCenter = map.center + map.newZoom = map.zoomLevel - map.zoomStep + mapAnimationClick.restart() + imageZoomOutAnimation.restart() + } + } + } + function openLocationInGoogleMaps(latitude, longitude) { var loc = latitude + " " + longitude var url = "https://www.google.com/maps/place/" + loc + "/@" + loc + ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0" diff --git a/mobile-widgets/qml/icons/mapwidget-zoom-in.png b/mobile-widgets/qml/icons/mapwidget-zoom-in.png Binary files differnew file mode 100644 index 000000000..8c2521c3e --- /dev/null +++ b/mobile-widgets/qml/icons/mapwidget-zoom-in.png diff --git a/mobile-widgets/qml/icons/mapwidget-zoom-out.png b/mobile-widgets/qml/icons/mapwidget-zoom-out.png Binary files differnew file mode 100644 index 000000000..bd372f17d --- /dev/null +++ b/mobile-widgets/qml/icons/mapwidget-zoom-out.png |