aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2017-12-06 11:33:27 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-12-11 07:57:41 +0000
commit433c39f8a96d60d71598dc9f3ec9425b12de7d78 (patch)
tree565a62f714efeee730dc417e7d2fa6951efca767 /tests/manual
parent8283bc83857ed8c7d85b61d2dc3b35fa4e96a037 (diff)
map manual test: re-render the SVG after significant change in scale
The reason for using SVG is to be able to render it quickly at lower resolutions but with higher quality after zooming in, and it's good to have an example which demonstrates how. Change-Id: I04107b724ef5c844c8b3eaa2f46750bd66d7d718 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/pointer/map.qml13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/manual/pointer/map.qml b/tests/manual/pointer/map.qml
index 6f827bab4e..6ab6badfd0 100644
--- a/tests/manual/pointer/map.qml
+++ b/tests/manual/pointer/map.qml
@@ -38,14 +38,15 @@ Item {
color: "aqua"
x: (parent.width - width) / 2
y: (parent.height - height) / 2
- width: image.implicitWidth
- height: image.implicitHeight
+ width: image.width
+ height: image.height
Image {
id: image
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
source: "resources/map.svgz"
+ Component.onCompleted: { width = implicitWidth; height = implicitHeight }
}
}
@@ -54,9 +55,17 @@ Item {
target: map
minimumScale: 0.1
maximumScale: 10
+ onActiveChanged: if (!active) reRenderIfNecessary()
}
DragHandler {
target: map
}
+
+ function reRenderIfNecessary() {
+ var newSourceWidth = image.sourceSize.width * pinch.scale
+ var ratio = newSourceWidth / image.sourceSize.width
+ if (ratio > 1.1 || ratio < 0.9)
+ image.sourceSize.width = newSourceWidth
+ }
}