on xenial help sign in
Improve Card layout: anchor summary to art when no header.
7a5e8ceMichał Sawicz
qml/Dash/Card.qml+1−1
@@ -82,7 +82,7 @@ Item {
82
82
83 Label {
83 Label {
84 objectName: "summaryLabel"
84 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 }
86 wrapMode: Text.Wrap
86 wrapMode: Text.Wrap
87 maximumLineCount: 5
87 maximumLineCount: 5
88 elide: Text.ElideRight
88 elide: Text.ElideRight
tests/qmltests/Dash/tst_Card.qml+22−5
@@ -110,6 +110,10 @@ 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": "Art, summary - vertical",
115+ "layout": { "components": { "art": "art", "summary": "summary" } }
116+ },
113 {
117 {
114 "name": "Header title only - horizontal",
118 "name": "Header title only - horizontal",
115 "layout": { "template": { "card-layout": "horizontal" },
119 "layout": { "template": { "card-layout": "horizontal" },
@@ -356,13 +360,26 @@ Rectangle {
356 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
360 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
357 }
361 }
358
362
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+
359 function test_art_visibility() {
376 function test_art_visibility() {
360− selector.selectedIndex = 7
377+ selector.selectedIndex = 8;
361
378
362− tryCompare(testCase.artImage, "source", "")
379+ tryCompare(testCase.artImage, "source", "");
363− compare(testCase.art.visible, false)
380+ compare(testCase.art.visible, false);
364− compare(testCase.art.height, 0)
381+ compare(testCase.art.height, 0);
365− compare(testCase.art.width, 0)
382+ compare(testCase.art.width, 0);
366 }
383 }
367 }
384 }
368}
385}