on xenial help sign in
Don't display artShape when artImage source not set.
commit604e7843f8efd916fedbf0a3a80ecc44678a17ff authorMichał Karnicki <michal.karnicki@canonical.com> dateWed 29 Jan 2014, 16:10 (13 years ago) parente065d707a31376
2 files changed+24−2
qml/Dash/Card.qml+10−2 tests/qmltests/Dash/tst_Card.qml+14
qml/Dash/Card.qml+10−2
@@ -38,9 +38,17 @@ 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
51+ visible: cardData && cardData["art"] || false
4452
4553 property real aspect: components !== undefined ? components["art"]["aspect-ratio"] : 1
4654
tests/qmltests/Dash/tst_Card.qml+14
@@ -110,6 +110,11 @@ Rectangle {
110110 "name": "Art, header - vertical",
111111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
112112 },
113+ {
114+ "name": "Header title only - horizontal",
115+ "layout": { "template": { "card-layout": "horizontal" },
116+ "components": { "title": "title" } }
117+ },
113118 ]
114119
115120 Card {
@@ -350,5 +355,14 @@ Rectangle {
350355 tryCompareFunction(function() { return testCase.header.y === data.top() }, true);
351356 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
352357 }
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+ }
353367 }
354368}