on xenial help sign in
Shrink artShape when artImage not set.
commitbf51e0892ae07680b8bed5d7a2507456ae9229f9 authorMichał Karnicki <michal.karnicki@canonical.com> dateTue 28 Jan 2014, 18:13 (13 years ago) parentdea9530
2 files changed+12−2
qml/Dash/Card.qml+9−2 tests/qmltests/Dash/tst_Card.qml+3
qml/Dash/Card.qml+9−2
@@ -38,9 +38,16 @@ Item {
3838 UbuntuShape {
3939 id: artShape
4040 objectName: "artShape"
41− width: image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
42− height: image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
41+ width: {
42+ if (!visible) return 0
43+ return image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
44+ }
45+ height: {
46+ if (!visible) return 0
47+ return image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
48+ }
4349 anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
50+ anchors.left: template && template["card-layout"] === "horizontal" ? parent.left : undefined
4451 visible: cardData && cardData["art"] || false
4552
4653 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
tests/qmltests/Dash/tst_Card.qml+3
@@ -298,6 +298,7 @@ Rectangle {
298298 }
299299
300300 function test_art_size(data) {
301+ wait(50) // Allow layout to settle.
301302 selector.selectedIndex = data.index;
302303
303304 if (data.hasOwnProperty("size")) {
@@ -361,6 +362,8 @@ Rectangle {
361362
362363 tryCompare(testCase.artImage, "source", "")
363364 compare(testCase.art.visible, false)
365+ compare(testCase.art.height, 0)
366+ compare(testCase.art.width, 0)
364367 }
365368 }
366369}