on xenial help sign in
Merge improve-header-layout.
commit076e19882a3df6d86250abd3c0f6891b9a59dea9 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 30 Jan 2014, 21:31 (13 years ago) parent2dc83251905c1a
4 files changed+41−12
qml/Dash/Card.qml+2−1 qml/Dash/CardHeader.qml+14−3 tests/qmltests/Dash/tst_Card.qml+22−5 tests/qmltests/Dash/tst_CardHeader.qml+3−3
qml/Dash/Card.qml+2−1
@@ -28,6 +28,7 @@ Item {
2828
2929 UbuntuShape {
3030 id: artShape
31+ radius: "medium"
3132 objectName: "artShape"
3233 width: {
3334 if (!visible) return 0
@@ -73,7 +74,7 @@ Item {
7374
7475 Label {
7576 objectName: "summaryLabel"
76− anchors { top: header.bottom; left: parent.left; right: parent.right }
77+ anchors { top: header.visible ? header.bottom : artShape.bottom; left: parent.left; right: parent.right }
7778 wrapMode: Text.Wrap
7879 maximumLineCount: 5
7980 elide: Text.ElideRight
qml/Dash/CardHeader.qml+14−3
@@ -27,14 +27,21 @@ Item {
2727 property alias altPrice: altPriceLabel.text
2828
2929 visible: mascotImage.status === Image.Ready || title || price
30− height: row.height > 0 ? row.height + row.spacing * 2 : 0
30+ height: row.height > 0 ? row.height + row.margins * 2 : 0
3131
3232 Row {
3333 id: row
3434 objectName: "outerRow"
3535
36− anchors { top: parent.top; left: parent.left; right: parent.right; margins: spacing }
37− spacing: units.gu(1)
36+ property real margins: units.gu(1)
37+
38+ anchors {
39+ top: parent.top; left: parent.left; right: parent.right
40+ margins: margins
41+ leftMargin: spacing
42+ rightMargin: spacing
43+ }
44+ spacing: mascotShape.visible ? margins : 0
3845
3946 UbuntuShape {
4047 id: mascotShape
@@ -53,6 +60,7 @@ Item {
5360 Column {
5461 objectName: "column"
5562 width: parent.width - x
63+ spacing: units.gu(0.5)
5664
5765 Label {
5866 id: titleLabel
@@ -62,6 +70,7 @@ Item {
6270 font.weight: Font.DemiBold
6371 wrapMode: Text.Wrap
6472 maximumLineCount: 2
73+ fontSize: "small"
6574 }
6675
6776 Label {
@@ -69,7 +78,9 @@ Item {
6978 objectName: "subtitleLabel"
7079 anchors { left: parent.left; right: parent.right }
7180 elide: Text.ElideRight
81+ font.weight: Font.Light
7282 visible: titleLabel.text && text
83+ fontSize: "x-small"
7384 }
7485
7586 Row {
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" },
@@ -365,13 +369,26 @@ Rectangle {
365369 tryCompareFunction(function() { return testCase.header.x === data.left() }, true);
366370 }
367371
372+ function test_summary_layout_data() {
373+ return [
374+ { tag: "With header", top: function() { return header.y + header.height }, index: 0 },
375+ { tag: "Without header", top: function() { return art.y + art.height }, index: 7 },
376+ ]
377+ }
378+
379+ function test_summary_layout(data) {
380+ selector.selectedIndex = data.index;
381+
382+ tryCompareFunction(function() { return testCase.summary.y === data.top() }, true);
383+ }
384+
368385 function test_art_visibility() {
369− selector.selectedIndex = 7
386+ selector.selectedIndex = 8;
370387
371− tryCompare(testCase.artImage, "source", "")
372− compare(testCase.art.visible, false)
373− compare(testCase.art.height, 0)
374− compare(testCase.art.width, 0)
388+ tryCompare(testCase.artImage, "source", "");
389+ compare(testCase.art.visible, false);
390+ compare(testCase.art.height, 0);
391+ compare(testCase.art.width, 0);
375392 }
376393 }
377394}
tests/qmltests/Dash/tst_CardHeader.qml+3−3
@@ -120,9 +120,9 @@ Rectangle {
120120
121121 function test_dimensions_data() {
122122 return [
123− { tag: "Column width", object: column, width: cardHeader.width - testCase.outerRow.spacing * 2 },
124− { tag: "Column width", object: column, width: cardHeader.width - mascot.width - testCase.outerRow.spacing * 3, mascot: "artwork/avatar.png" },
125− { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.spacing * 2 } },
123+ { tag: "Column width", object: column, width: cardHeader.width },
124+ { tag: "Column width with mascot", object: column, width: cardHeader.width - mascot.width - outerRow.margins * 3, mascot: "artwork/avatar.png" },
125+ { tag: "Header height", object: cardHeader, height: function() { return subtitleLabel.y + subtitleLabel.height + outerRow.margins * 2 } },
126126 ]
127127 }
128128