on xenial help sign in
Shrink artShape when artImage not set.
bf51e08Michał Karnicki
qml/Dash/Card.qml+9−2
@@ -38,9 +38,16 @@ Item {
38 UbuntuShape {
38 UbuntuShape {
39 id: artShape
39 id: artShape
40 objectName: "artShape"
40 objectName: "artShape"
41+ width: {
42+ if (!visible) return 0
41− width: image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
43+ return image.fillMode === Image.PreserveAspectCrop || aspect < image.aspect ? image.width : height * image.aspect
44+ }
45+ height: {
46+ if (!visible) return 0
42− height: image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
47+ return image.fillMode === Image.PreserveAspectCrop || aspect > image.aspect ? image.height : width / image.aspect
48+ }
43 anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
49 anchors.horizontalCenter: template && template["card-layout"] === "horizontal" ? undefined : parent.horizontalCenter
50+ anchors.left: template && template["card-layout"] === "horizontal" ? parent.left : undefined
44 visible: cardData && cardData["art"] || false
51 visible: cardData && cardData["art"] || false
45
52
46 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
53 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
tests/qmltests/Dash/tst_Card.qml+3
@@ -298,6 +298,7 @@ Rectangle {
298 }
298 }
299
299
300 function test_art_size(data) {
300 function test_art_size(data) {
301+ wait(50) // Allow layout to settle.
301 selector.selectedIndex = data.index;
302 selector.selectedIndex = data.index;
302
303
303 if (data.hasOwnProperty("size")) {
304 if (data.hasOwnProperty("size")) {
@@ -361,6 +362,8 @@ Rectangle {
361
362
362 tryCompare(testCase.artImage, "source", "")
363 tryCompare(testCase.artImage, "source", "")
363 compare(testCase.art.visible, false)
364 compare(testCase.art.visible, false)
365+ compare(testCase.art.height, 0)
366+ compare(testCase.art.width, 0)
364 }
367 }
365 }
368 }
366}
369}