on xenial help sign in
Don't display artShape when artImage source not set.
604e784Michał Karnicki
qml/Dash/Card.qml+10−2
@@ -38,9 +38,17 @@ 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
51+ visible: cardData && cardData["art"] || false
44
52
45 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
53 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
46
54
tests/qmltests/Dash/tst_Card.qml+14
@@ -110,6 +110,11 @@ Rectangle {
110 "name": "Art, header - vertical",
110 "name": "Art, header - vertical",
111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
112 },
112 },
113+ {
114+ "name": "Header title only - horizontal",
115+ "layout": { "template": { "card-layout": "horizontal" },
116+ "components": { "title": "title" } }
117+ },
113 ]
118 ]
114
119
115 Card {
120 Card {
@@ -350,5 +355,14 @@ Rectangle {
350 tryCompareFunction(function() { return testCase.header.y === data.top() }, true);
355 tryCompareFunction(function() { return testCase.header.y === data.top() }, true);
351 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
356 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
352 }
357 }
358+
359+ function test_art_visibility() {
360+ selector.selectedIndex = 7
361+
362+ tryCompare(testCase.artImage, "source", "")
363+ compare(testCase.art.visible, false)
364+ compare(testCase.art.height, 0)
365+ compare(testCase.art.width, 0)
366+ }
353 }
367 }
354}
368}