Merge lp:~aacid/unity8/readonly_properties_to_cardtool into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 2599
Merged at revision: 2676
Proposed branch: lp:~aacid/unity8/readonly_properties_to_cardtool
Merge into: lp:unity8
Diff against target: 251 lines (+65/-62)
3 files modified
qml/Dash/CardGrid.qml (+3/-4)
qml/Dash/CardTool.qml (+60/-16)
qml/Dash/GenericScopeView.qml (+2/-42)
To merge this branch: bzr merge lp:~aacid/unity8/readonly_properties_to_cardtool
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
Unity8 CI Bot continuous-integration Approve
Review via email: mp+303431@code.launchpad.net

Commit message

Make more CardTool properties readonly

This removes "hacks" from GenericScopeView and moves them to either CardTool or CardGrid in a less "this is a hack" way

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * 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.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2598
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1992/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/2611/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2639
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2518
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2518
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2518
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2512/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2512/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2512/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2512
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2512/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1992/rebuild

review: Needs Fixing (continuous-integration)
2599. By Albert Astals Cid

Merge

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2599
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2257/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2971
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1637
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1637
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/1637
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2999
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2857/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2857
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2857/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2257/rebuild

review: Approve (continuous-integration)
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?
yes in a silo
 * 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 'qml/Dash/CardGrid.qml'
2--- qml/Dash/CardGrid.qml 2016-05-09 08:34:38 +0000
3+++ qml/Dash/CardGrid.qml 2016-09-27 13:36:54 +0000
4@@ -20,13 +20,12 @@
5 DashRenderer {
6 id: root
7
8- readonly property real defaultMinimumHorizontalSpacing: units.gu(1)
9 readonly property int collapsedRows: {
10 if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
11 return cardTool.template["collapsed-rows"];
12 }
13- property string backgroundShapeStyle: "inset";
14- property alias minimumHorizontalSpacing: grid.minimumHorizontalSpacing
15+ // ↓ This is the ubuntu store icon
16+ readonly property string backgroundShapeStyle: cardTool.isAppLikeScope && !cardTool.isAppLikeScopeAppCategory ? "shadow" : "inset"
17
18 expandedHeight: grid.totalContentHeight
19 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
20@@ -46,7 +45,7 @@
21 ResponsiveGridView {
22 id: grid
23 anchors.fill: parent
24- minimumHorizontalSpacing: root.defaultMinimumHorizontalSpacing
25+ minimumHorizontalSpacing: (cardTool.isAppLikeScopeAppCategory && cardTool.isWideView) ? units.gu(5) : units.gu(1)
26 delegateWidth: cardTool.cardWidth
27 delegateHeight: cardTool.cardHeight
28 verticalSpacing: units.gu(1)
29
30=== modified file 'qml/Dash/CardTool.qml'
31--- qml/Dash/CardTool.qml 2016-08-23 12:48:23 +0000
32+++ qml/Dash/CardTool.qml 2016-09-27 13:36:54 +0000
33@@ -42,11 +42,6 @@
34 property real viewWidth
35
36 /*!
37- \brief Scaling factor of selected Carousel item.
38- */
39- readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
40-
41- /*!
42 \brief Template supplied for the category.
43 */
44 property var template
45@@ -57,9 +52,24 @@
46 property var components
47
48 /*!
49+ \brief The Scope this cardTool is representing
50+ */
51+ property string scopeId
52+
53+ /*!
54+ \brief The Scope category this cardTool is representing
55+ */
56+ property string categoryId
57+
58+ /*!
59+ \brief Scaling factor of selected Carousel item.
60+ */
61+ readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
62+
63+ /*!
64 \brief The category layout for this card tool.
65 */
66- property string categoryLayout: {
67+ readonly property string categoryLayout: {
68 var layout = template["category-layout"];
69
70 // carousel fallback mode to grid
71@@ -67,9 +77,17 @@
72 return layout;
73 }
74
75+ readonly property bool isAppLikeScope: scopeId === "clickscope" || scopeId === "libertine-scope.ubuntu_libertine-scope"
76+ readonly property bool isAppLikeScopeAppCategory: ((scopeId === "clickscope" && (categoryId === "predefined" || categoryId === "local"))
77+ || (scopeId === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint"))
78
79- // Not readonly because gets overwritten from GenericScopeView in some cases
80- property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
81+ readonly property string artShapeStyle: {
82+ if (isAppLikeScope) {
83+ return isAppLikeScopeAppCategory ? "icon" : "flat";
84+ } else {
85+ return categoryLayout === "carousel" ? "shadow" : "inset"
86+ }
87+ }
88
89 // FIXME ? This seems like it should not be needed, but on Qt 5.4 + phone
90 // we are doing unneeded calls to getCardComponent with artShapeStyle and categoryLayout being empty
91@@ -90,12 +108,31 @@
92 height: 0
93 clip: true
94
95+ // We have 3 view "widths"
96+ // narrow <= 45gu
97+ // normal
98+ // wide >= 70gu
99+ readonly property bool isWideView: viewWidth >= units.gu(70)
100+ readonly property bool isNarrowView: viewWidth <= units.gu(45)
101+
102 /*!
103 type:real \brief Width to be enforced on the card in this configuration.
104
105 If -1, should use implicit width of the actual card.
106 */
107- property real cardWidth: {
108+ readonly property real cardWidth: {
109+ if (isAppLikeScopeAppCategory) {
110+ if (!isNarrowView) {
111+ if (isWideView) {
112+ return units.gu(11);
113+ } else {
114+ return units.gu(10);
115+ }
116+ } else {
117+ return units.gu(12);
118+ }
119+ }
120+
121 switch (categoryLayout) {
122 case "grid":
123 case "vertical-journal":
124@@ -103,16 +140,16 @@
125 if (template["card-layout"] === "horizontal") size = "large";
126 switch (size) {
127 case "small": {
128- if (viewWidth <= units.gu(45)) return units.gu(12);
129+ if (isNarrowView) return units.gu(12);
130 else return units.gu(14);
131 }
132 case "large": {
133- if (viewWidth >= units.gu(70)) return units.gu(42);
134+ if (isWideView) return units.gu(42);
135 else return viewWidth - units.gu(2);
136 }
137 }
138- if (viewWidth <= units.gu(45)) return units.gu(18);
139- else if (viewWidth >= units.gu(70)) return units.gu(20);
140+ if (isNarrowView) return units.gu(18);
141+ else if (isWideView) return units.gu(20);
142 else return units.gu(23);
143 case "carousel":
144 case "horizontal-list":
145@@ -152,12 +189,19 @@
146 type:real \brief Height of the card's header.
147 */
148 readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0
149- property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0)
150+
151+ readonly property size artShapeSize: {
152+ if (isAppLikeScopeAppCategory) {
153+ return Qt.size(units.gu(8), units.gu(7.5));
154+ } else {
155+ return cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0)
156+ }
157+ }
158
159 QtObject {
160 id: carouselTool
161
162- property real minimumTileWidth: {
163+ readonly property real minimumTileWidth: {
164 if (cardTool.viewWidth === undefined) return undefined;
165 if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
166 if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
167@@ -166,7 +210,7 @@
168
169 readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
170
171- property real realPathItemCount: {
172+ readonly property real realPathItemCount: {
173 var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
174 var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
175 return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
176
177=== modified file 'qml/Dash/GenericScopeView.qml'
178--- qml/Dash/GenericScopeView.qml 2016-09-22 07:37:21 +0000
179+++ qml/Dash/GenericScopeView.qml 2016-09-27 13:36:54 +0000
180@@ -267,6 +267,8 @@
181 template: model.renderer
182 components: model.components
183 viewWidth: parent.width
184+ scopeId: scope ? scope.id : ""
185+ categoryId: baseItem.category
186 }
187
188 onExpandableChanged: {
189@@ -342,17 +344,6 @@
190 baseItem.expand(shouldExpand, false /*animate*/);
191 }
192 updateRanges();
193- clickScopeSizingHacks();
194- if (scope && (scope.id === "clickscope" || scope.id === "libertine-scope.ubuntu_libertine-scope")) {
195- if (isLibertineContainerCategory() || categoryId === "predefined" || categoryId === "local") {
196- cardTool.artShapeSize = Qt.binding(function() { return Qt.size(units.gu(8), units.gu(7.5)) });
197- cardTool.artShapeStyle = "icon";
198- } else {
199- // Should be ubuntu store icon
200- cardTool.artShapeStyle = "flat";
201- item.backgroundShapeStyle = "shadow";
202- }
203- }
204 item.cardTool = cardTool;
205 }
206
207@@ -361,36 +352,6 @@
208 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
209 }
210 }
211- // FIXME: directly connecting to onUnitsChanged cause a compile error:
212- // Cannot assign to non-existent property "onUnitsChanged"
213- // Until the units object is reworked to properly do all we need, let's go through a intermediate property
214- property int pxpgu: units.gu(1);
215- onPxpguChanged: clickScopeSizingHacks();
216-
217- // Returns true if the current category pertains to a Libertine container
218- function isLibertineContainerCategory() {
219- return scope && scope.id === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint";
220- }
221-
222- function clickScopeSizingHacks() {
223- if (scope &&
224- ((scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) ||
225- isLibertineContainerCategory())) {
226- // Yeah, hackish :/
227- if (scopeView.width > units.gu(45)) {
228- if (scopeView.width >= units.gu(70)) {
229- cardTool.cardWidth = units.gu(11);
230- item.minimumHorizontalSpacing = units.gu(5);
231- return;
232- } else {
233- cardTool.cardWidth = units.gu(10);
234- }
235- } else {
236- cardTool.cardWidth = units.gu(12);
237- }
238- item.minimumHorizontalSpacing = item.defaultMinimumHorizontalSpacing;
239- }
240- }
241
242 Connections {
243 target: rendererLoader.item
244@@ -425,7 +386,6 @@
245 target: scopeView
246 onIsCurrentChanged: rendererLoader.updateRanges();
247 onVisibleToParentChanged: rendererLoader.updateRanges();
248- onWidthChanged: rendererLoader.clickScopeSizingHacks();
249 }
250 Connections {
251 target: holdingList

Subscribers

People subscribed via source and target branches