on xenial help sign in
added a test, and slightly improve sourceSize calculation in LazyImage "fit" format
commit82fd6e49f8c9d71d91e91e4bad69dc21ff85661c authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 21 Mar 2014, 11:48 (13 years ago) parentb21bc6b
2 files changed+8−2
qml/Components/LazyImage.qml+2−2 tests/qmltests/Components/tst_LazyImage.qml+6
qml/Components/LazyImage.qml+2−2
@@ -99,10 +99,10 @@ Item {
9999 horizontalAlignment: Image.AlignHCenter
100100 verticalAlignment: Image.AlignVCenter
101101 sourceSize.width: root.scaleTo == "width" ? root.width
102− : root.scaleTo == "fit" && root.width < root.height ? root.width
102+ : root.scaleTo == "fit" && root.width <= root.height ? root.width
103103 : 0
104104 sourceSize.height: root.scaleTo == "height" ? root.height
105− : root.scaleTo == "fit" && root.height < root.width ? root.height
105+ : root.scaleTo == "fit" && root.height <= root.width ? root.height
106106 : 0
107107 }
108108 }
tests/qmltests/Components/tst_LazyImage.qml+6
@@ -168,6 +168,12 @@ Rectangle {
168168 compare(data.image.initialHeight, data.initialHeight);
169169 compare(data.image.initialWidth, data.initialWidth);
170170
171+ // check the sourceSize
172+ var sourceHeight = (data.image.scaleTo === "height" || (data.image.scaleTo === "fit" && data.height <= data.width)) ? data.height : 0
173+ var sourceWidth = (data.image.scaleTo === "width" || (data.image.scaleTo === "fit" && data.width <= data.height)) ? data.width : 0
174+ compare(data.image.sourceSize.height, sourceHeight);
175+ compare(data.image.sourceSize.width, sourceWidth);
176+
171177 // check the shape dimensions
172178 var shape = findChild(data.image, "shape");
173179 compare(shape.width, data.imageWidth);