From 8c7d1a1163ba22cd1b5e75b723affacc9d0cfd1c Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 25 Jul 2017 18:55:36 +0300 Subject: [PATCH] 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 --- mobile-widgets/qml/MapWidget.qml | 52 ++++++++++++++++++ .../qml/icons/mapwidget-zoom-in.png | Bin 0 -> 256 bytes .../qml/icons/mapwidget-zoom-out.png | Bin 0 -> 242 bytes subsurface.qrc | 2 + 4 files changed, 54 insertions(+) create mode 100644 mobile-widgets/qml/icons/mapwidget-zoom-in.png create mode 100644 mobile-widgets/qml/icons/mapwidget-zoom-out.png 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 new file mode 100644 index 0000000000000000000000000000000000000000..8c2521c3e81f97edb2bef5c3383e6c290859154a GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={WI14-?iy0WWg+Z8+Vb&Z8pdd@S zqpu?a!^U}uK91i(I+8ttd>I(3R2di=ni&{={s+=87#M;$7#Kw(7#OUkGcbtfUyqWX z090G%>EaktaqG=AL%stFJj}jFr=+Jm{qKMBl<}rz%+V7UOzpUG&|Ir x{G1|xkCD|cP)VuuhwjbCzj+xL{{LrYxUyJoDOc*$3ZM%ZJYD@<);T3K0RZpFSMvY> literal 0 HcmV?d00001 diff --git a/mobile-widgets/qml/icons/mapwidget-zoom-out.png b/mobile-widgets/qml/icons/mapwidget-zoom-out.png new file mode 100644 index 0000000000000000000000000000000000000000..bd372f17d2ea4cc3bd58b1d74a63f19b53e886de GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1SJ1Ryj={WI14-?iy0WWg+Z8+Vb&Z8pdd@S zqpu?a!^U}uK91i(I+8ttd>I(3R2di=ni&{={s+=87#M;$7#Kw(7#OUkGcbtfUyqWX z092dd>EaktaqG=BL#_h`9IO}ePd+h>+50~*#tkw3E6&DWu4_@|Ph+|QSx!Pui z6|VxSL)X3*5nR80w{-*aVMT`qhQ_m*RpQ3Cb55S|-}m5Q+#gpK4uK!y3U_UH{WHtS=S6elLv~Xg>pkr>mdKI;Vst02P%`a{vGU literal 0 HcmV?d00001 diff --git a/subsurface.qrc b/subsurface.qrc index 017451c3c..55c5e2c02 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -7,6 +7,8 @@ mobile-widgets/qml/icons/mapwidget-toggle-satellite.png mobile-widgets/qml/icons/mapwidget-toggle-street.png mobile-widgets/qml/icons/mapwidget-context-menu.png + mobile-widgets/qml/icons/mapwidget-zoom-in.png + mobile-widgets/qml/icons/mapwidget-zoom-out.png icons/star.svg icons/subsurface-icon.png icons/subsurface-mobile-icon.png