on xenial help sign in
Fix regression making pan not possible in Zoomable Image

Qt never seems to send two presses standalone since that confuses code that still works on mouse events, the second one is always part of a move. Also make the test check panning works so that it may be harder to regress again Fixes: #1433506 Approved by: Andrea Cimitan

commit7d0dbe594ea9a544af675149b3fc77be01f1324e authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 20 Mar 2015, 11:56 (12 years ago) parent37ad6e00589c65
3 files changed+22−15
qml/Components/ZoomableImage.qml+14−14 tests/qmltests/Components/tst_ZoomableImage.qml+7 tests/utils/modules/Unity/Test/UnityTestCase.qml+1−1
qml/Components/ZoomableImage.qml+14−14
@@ -107,6 +107,20 @@ Item {
107107 }
108108 }
109109
110+ PinchArea {
111+ id: pinchArea
112+ objectName: "pinchArea"
113+ property real minScale: 1.0
114+ anchors.fill: parent
115+ enabled: zoomable ? zoomable : false
116+
117+ pinch.target: image
118+ pinch.minimumScale: minScale
119+ pinch.maximumScale: 10
120+
121+ onPinchFinished: flickable.returnToBounds()
122+ }
123+
110124 MouseArea {
111125 id: mouseArea
112126 objectName: "mouseArea"
@@ -139,18 +153,4 @@ Item {
139153 }
140154 }
141155 }
142−
143− PinchArea {
144− id: pinchArea
145− objectName: "pinchArea"
146− property real minScale: 1.0
147− anchors.fill: flickable
148− enabled: zoomable ? zoomable : false
149−
150− pinch.target: image
151− pinch.minimumScale: minScale
152− pinch.maximumScale: 10
153−
154− onPinchFinished: flickable.returnToBounds()
155− }
156156}
tests/qmltests/Components/tst_ZoomableImage.qml+7
@@ -182,6 +182,13 @@ Rectangle {
182182 compare(flickable.contentWidth, Math.max(imageRenderer.width * image.scale, flickable.width));
183183 compare(flickable.contentHeight, Math.max(imageRenderer.height * image.scale, flickable.height));
184184
185+ // try pan it a bit
186+ var contentX = flickable.contentX;
187+ var contentY = flickable.contentY;
188+ touchFlick(zoomableImage, units.gu(1), units.gu(1), units.gu(10), units.gu(10));
189+ tryCompare(flickable, "moving", false)
190+ tryCompareFunction(function() { return flickable.contentX != contentX && flickable.contentY != contentY; }, zoomableImage.zoomable)
191+
185192 wait(3000); // have to delay between two consequent pinch event.
186193 // pinch zoom-out
187194 touchPinch(zoomableImage, x1End, y1End, x1Start, y1Start, x2End, y2End, x2Start, y2Start);
tests/utils/modules/Unity/Test/UnityTestCase.qml+1−1
@@ -315,7 +315,7 @@ TestCase {
315315 event1.press(0, x1Start, y1Start);
316316 event1.commit();
317317 // second finger
318− event1.stationary(0);
318+ event1.move(0, x1Start, y1Start);
319319 event1.press(1, x2Start, y2Start);
320320 event1.commit();
321321