on xenial help sign in
Improve Card layout: anchor summary to art when no header.
commit7a5e8cef618f25655e6194ca84bc36f53be5c0f2 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 30 Jan 2014, 21:05 (13 years ago) parent119a21d
2 files changed+23−6
qml/Dash/Card.qml+1−1 tests/qmltests/Dash/tst_Card.qml+22−5
qml/Dash/Card.qml+1−1
@@ -82,7 +82,7 @@ Item {
8282
8383 Label {
8484 objectName: "summaryLabel"
85− anchors { top: header.bottom; left: parent.left; right: parent.right }
85+ anchors { top: header.visible ? header.bottom : artShape.bottom; left: parent.left; right: parent.right }
8686 wrapMode: Text.Wrap
8787 maximumLineCount: 5
8888 elide: Text.ElideRight
tests/qmltests/Dash/tst_Card.qml+22−5
@@ -110,6 +110,10 @@ Rectangle {
110110 "name": "Art, header - vertical",
111111 "layout": { "components": Helpers.update(JSON.parse(root.fullMapping), { "summary": undefined }) }
112112 },
113+ {
114+ "name": "Art, summary - vertical",
115+ "layout": { "components": { "art": "art", "summary": "summary" } }
116+ },
113117 {
114118 "name": "Header title only - horizontal",
115119 "layout": { "template": { "card-layout": "horizontal" },
@@ -356,13 +360,26 @@ Rectangle {
356360 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
357361 }
358362
363+ function test_summary_layout_data() {
364+ return [
365+ { tag: "With header", top: function() { return header.y + header.height }, index: 0 },
366+ { tag: "Without header", top: function() { return art.y + art.height }, index: 7 },
367+ ]
368+ }
369+
370+ function test_summary_layout(data) {
371+ selector.selectedIndex = data.index;
372+
373+ tryCompareFunction(function() { return testCase.summary.y === data.top() }, true);
374+ }
375+
359376 function test_art_visibility() {
360− selector.selectedIndex = 7
377+ selector.selectedIndex = 8;
361378
362− tryCompare(testCase.artImage, "source", "")
363− compare(testCase.art.visible, false)
364− compare(testCase.art.height, 0)
365− compare(testCase.art.width, 0)
379+ tryCompare(testCase.artImage, "source", "");
380+ compare(testCase.art.visible, false);
381+ compare(testCase.art.height, 0);
382+ compare(testCase.art.width, 0);
366383 }
367384 }
368385}