Merge lp:~saviq/unity8/fix-empty-attributes into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 1166
Merged at revision: 1207
Proposed branch: lp:~saviq/unity8/fix-empty-attributes
Merge into: lp:unity8
Prerequisite: lp:~saviq/unity8/header-customizations
Diff against target: 84 lines (+12/-4)
4 files modified
plugins/Dash/CardAttributes.qml (+6/-3)
plugins/Dash/CardCreator.js (+1/-0)
tests/plugins/Dash/cardcreator/7.res (+1/-0)
tests/plugins/Dash/tst_CardAttributes.qml (+4/-1)
To merge this branch: bzr merge lp:~saviq/unity8/fix-empty-attributes
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+231076@code.launchpad.net

This proposal supersedes a proposal from 2014-08-16.

Commit message

Don't ignore empty attributes in CardAttributes.qml and improve its encapsulation

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
N
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y
 * Did you make sure that your branch does not contain spurious tags?
Y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
1164. By Michał Sawicz

Merge lp:~saviq/unity8/header-customizations

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1165. By Michał Sawicz

Merge lp:~saviq/unity8/header-customizations

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1166. By Michał Sawicz

Fix cardcreator test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

if you test cardAttributes with model: testData[4] you see the text omitted, something is not right there...

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

Right, that's a caveat: the first row determines column widths for the rest of the rows. So if you have an empty attribute in the first row, any below that one in the same column will not render properly.

It's a limitation resulting from a desire for this all to be somewhat dynamic. We should probably revisit the rules for laying them out soon. We might, for example, put them in a Column of RowLayouts instead of a GridLayout, knowing that this will cause uneven horizontal centering of the middle column. But maybe that'd be a better case than what we have now. We'll need to weigh this out with design.

Revision history for this message
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y
 * Did CI run pass? If not, please explain why.
y

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Dash/CardAttributes.qml'
2--- plugins/Dash/CardAttributes.qml 2014-08-18 08:22:56 +0000
3+++ plugins/Dash/CardAttributes.qml 2014-08-18 08:22:57 +0000
4@@ -26,8 +26,10 @@
5 right: parent.right;
6 }
7 columns: 2 + repeater.count % 2
8+ rowSpacing: units.gu(.5)
9 property alias model: repeater.model
10- property var color
11+ property color color: Theme.palette.normal.baseText
12+ property real fontScale: 1.0
13
14 Repeater {
15 id: repeater
16@@ -42,18 +44,19 @@
17 Layout.columnSpan: index == repeater.count - 1 && grid.columns == 3 && column == 1 ? 2 : 1
18 Layout.maximumWidth: Math.max(icon.width, label.x + label.implicitWidth)
19 Layout.fillWidth: true
20+ height: units.gu(2)
21 StatusIcon {
22 id: icon
23 height: units.gu(2)
24 sets: ["actions", "status", "apps"]
25- source: "icon" in modelData ? modelData["icon"] : ""
26+ source: "icon" in modelData && modelData["icon"] || ""
27 color: grid.color
28 }
29 Label {
30 id: label
31 width: parent.width - x
32 anchors.verticalCenter: parent.verticalCenter
33- text: "value" in modelData ? modelData["value"] : "";
34+ text: "value" in modelData && modelData["value"] || "";
35 elide: Text.ElideRight
36 maximumLineCount: 1
37 font.weight: "style" in modelData && modelData["style"] == "highlighted" ? Font.DemiBold : Font.Light
38
39=== modified file 'plugins/Dash/CardCreator.js'
40--- plugins/Dash/CardCreator.js 2014-08-18 08:22:56 +0000
41+++ plugins/Dash/CardCreator.js 2014-08-18 08:22:57 +0000
42@@ -274,6 +274,7 @@
43 objectName: "attributesRow"; \n\
44 anchors { %1 } \n\
45 color: %2; \n\
46+ fontScale: root.fontScale; \n\
47 model: cardData && cardData["attributes"]; \n\
48 }\n';
49
50
51=== modified file 'tests/plugins/Dash/cardcreator/7.res'
52--- tests/plugins/Dash/cardcreator/7.res 2014-08-18 08:22:56 +0000
53+++ tests/plugins/Dash/cardcreator/7.res 2014-08-18 08:22:57 +0000
54@@ -128,6 +128,7 @@
55 top: subtitleLabel.bottom;
56 }
57 color: backgroundLoader.active && backgroundLoader.item && root.scopeStyle ? root.scopeStyle.getTextColor(backgroundLoader.item.luminance) : (backgroundLoader.item.luminance > 0.7 ? Theme.palette.normal.baseText : "white");
58+ fontScale: root.fontScale;
59 model: cardData && cardData["attributes"];
60 }
61
62
63=== modified file 'tests/plugins/Dash/tst_CardAttributes.qml'
64--- tests/plugins/Dash/tst_CardAttributes.qml 2014-07-25 08:46:29 +0000
65+++ tests/plugins/Dash/tst_CardAttributes.qml 2014-08-18 08:22:57 +0000
66@@ -26,7 +26,8 @@
67 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"}],
68 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"}],
69 [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3"},{"value":"text4"}],
70- [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3","style":"highlighted"},{"value":"text4","icon":"image://theme/close","style":"highlighted"},{"value":"text5"}]
71+ [{"value":"text1","icon":"image://theme/ok"},{"value":"text2","icon":"image://theme/cancel"},{"value":"text3","style":"highlighted"},{"value":"text4","icon":"image://theme/close","style":"highlighted"},{"value":"text5"}],
72+ [{"value":"text1","icon":"image://theme/ok"},{},{},{},{"value":"text5", "icon": "image://theme/search"}],
73 ]
74
75 CardAttributes {
76@@ -49,6 +50,8 @@
77 function test_columns(data) {
78 cardAttributes.model = data;
79 compare(cardAttributes.columns, 2 + data.length % 2);
80+ var rows = Math.ceil(data.length / 3);
81+ tryCompare(cardAttributes, "height", rows * units.gu(2) + (rows - 1) * cardAttributes.rowSpacing);
82 }
83 }
84 }

Subscribers

People subscribed via source and target branches