Merge lp:~aacid/unity8/readonly_properties_to_cardtool into lp:unity8
- readonly_properties_to_cardtool
- Merge into trunk
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 |
Related bugs: |
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
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
- 2599. By Albert Astals Cid
-
Merge
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:2599
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
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
Preview Diff
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 | 20 | DashRenderer { | 20 | DashRenderer { |
6 | 21 | id: root | 21 | id: root |
7 | 22 | 22 | ||
8 | 23 | readonly property real defaultMinimumHorizontalSpacing: units.gu(1) | ||
9 | 24 | readonly property int collapsedRows: { | 23 | readonly property int collapsedRows: { |
10 | 25 | if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2; | 24 | if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2; |
11 | 26 | return cardTool.template["collapsed-rows"]; | 25 | return cardTool.template["collapsed-rows"]; |
12 | 27 | } | 26 | } |
15 | 28 | property string backgroundShapeStyle: "inset"; | 27 | // ↓ This is the ubuntu store icon |
16 | 29 | property alias minimumHorizontalSpacing: grid.minimumHorizontalSpacing | 28 | readonly property string backgroundShapeStyle: cardTool.isAppLikeScope && !cardTool.isAppLikeScopeAppCategory ? "shadow" : "inset" |
17 | 30 | 29 | ||
18 | 31 | expandedHeight: grid.totalContentHeight | 30 | expandedHeight: grid.totalContentHeight |
19 | 32 | collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight) | 31 | collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight) |
20 | @@ -46,7 +45,7 @@ | |||
21 | 46 | ResponsiveGridView { | 45 | ResponsiveGridView { |
22 | 47 | id: grid | 46 | id: grid |
23 | 48 | anchors.fill: parent | 47 | anchors.fill: parent |
25 | 49 | minimumHorizontalSpacing: root.defaultMinimumHorizontalSpacing | 48 | minimumHorizontalSpacing: (cardTool.isAppLikeScopeAppCategory && cardTool.isWideView) ? units.gu(5) : units.gu(1) |
26 | 50 | delegateWidth: cardTool.cardWidth | 49 | delegateWidth: cardTool.cardWidth |
27 | 51 | delegateHeight: cardTool.cardHeight | 50 | delegateHeight: cardTool.cardHeight |
28 | 52 | verticalSpacing: units.gu(1) | 51 | verticalSpacing: units.gu(1) |
29 | 53 | 52 | ||
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 | 42 | property real viewWidth | 42 | property real viewWidth |
35 | 43 | 43 | ||
36 | 44 | /*! | 44 | /*! |
37 | 45 | \brief Scaling factor of selected Carousel item. | ||
38 | 46 | */ | ||
39 | 47 | readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards | ||
40 | 48 | |||
41 | 49 | /*! | ||
42 | 50 | \brief Template supplied for the category. | 45 | \brief Template supplied for the category. |
43 | 51 | */ | 46 | */ |
44 | 52 | property var template | 47 | property var template |
45 | @@ -57,9 +52,24 @@ | |||
46 | 57 | property var components | 52 | property var components |
47 | 58 | 53 | ||
48 | 59 | /*! | 54 | /*! |
49 | 55 | \brief The Scope this cardTool is representing | ||
50 | 56 | */ | ||
51 | 57 | property string scopeId | ||
52 | 58 | |||
53 | 59 | /*! | ||
54 | 60 | \brief The Scope category this cardTool is representing | ||
55 | 61 | */ | ||
56 | 62 | property string categoryId | ||
57 | 63 | |||
58 | 64 | /*! | ||
59 | 65 | \brief Scaling factor of selected Carousel item. | ||
60 | 66 | */ | ||
61 | 67 | readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards | ||
62 | 68 | |||
63 | 69 | /*! | ||
64 | 60 | \brief The category layout for this card tool. | 70 | \brief The category layout for this card tool. |
65 | 61 | */ | 71 | */ |
67 | 62 | property string categoryLayout: { | 72 | readonly property string categoryLayout: { |
68 | 63 | var layout = template["category-layout"]; | 73 | var layout = template["category-layout"]; |
69 | 64 | 74 | ||
70 | 65 | // carousel fallback mode to grid | 75 | // carousel fallback mode to grid |
71 | @@ -67,9 +77,17 @@ | |||
72 | 67 | return layout; | 77 | return layout; |
73 | 68 | } | 78 | } |
74 | 69 | 79 | ||
75 | 80 | readonly property bool isAppLikeScope: scopeId === "clickscope" || scopeId === "libertine-scope.ubuntu_libertine-scope" | ||
76 | 81 | readonly property bool isAppLikeScopeAppCategory: ((scopeId === "clickscope" && (categoryId === "predefined" || categoryId === "local")) | ||
77 | 82 | || (scopeId === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint")) | ||
78 | 70 | 83 | ||
81 | 71 | // Not readonly because gets overwritten from GenericScopeView in some cases | 84 | readonly property string artShapeStyle: { |
82 | 72 | property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset" | 85 | if (isAppLikeScope) { |
83 | 86 | return isAppLikeScopeAppCategory ? "icon" : "flat"; | ||
84 | 87 | } else { | ||
85 | 88 | return categoryLayout === "carousel" ? "shadow" : "inset" | ||
86 | 89 | } | ||
87 | 90 | } | ||
88 | 73 | 91 | ||
89 | 74 | // FIXME ? This seems like it should not be needed, but on Qt 5.4 + phone | 92 | // FIXME ? This seems like it should not be needed, but on Qt 5.4 + phone |
90 | 75 | // we are doing unneeded calls to getCardComponent with artShapeStyle and categoryLayout being empty | 93 | // we are doing unneeded calls to getCardComponent with artShapeStyle and categoryLayout being empty |
91 | @@ -90,12 +108,31 @@ | |||
92 | 90 | height: 0 | 108 | height: 0 |
93 | 91 | clip: true | 109 | clip: true |
94 | 92 | 110 | ||
95 | 111 | // We have 3 view "widths" | ||
96 | 112 | // narrow <= 45gu | ||
97 | 113 | // normal | ||
98 | 114 | // wide >= 70gu | ||
99 | 115 | readonly property bool isWideView: viewWidth >= units.gu(70) | ||
100 | 116 | readonly property bool isNarrowView: viewWidth <= units.gu(45) | ||
101 | 117 | |||
102 | 93 | /*! | 118 | /*! |
103 | 94 | type:real \brief Width to be enforced on the card in this configuration. | 119 | type:real \brief Width to be enforced on the card in this configuration. |
104 | 95 | 120 | ||
105 | 96 | If -1, should use implicit width of the actual card. | 121 | If -1, should use implicit width of the actual card. |
106 | 97 | */ | 122 | */ |
108 | 98 | property real cardWidth: { | 123 | readonly property real cardWidth: { |
109 | 124 | if (isAppLikeScopeAppCategory) { | ||
110 | 125 | if (!isNarrowView) { | ||
111 | 126 | if (isWideView) { | ||
112 | 127 | return units.gu(11); | ||
113 | 128 | } else { | ||
114 | 129 | return units.gu(10); | ||
115 | 130 | } | ||
116 | 131 | } else { | ||
117 | 132 | return units.gu(12); | ||
118 | 133 | } | ||
119 | 134 | } | ||
120 | 135 | |||
121 | 99 | switch (categoryLayout) { | 136 | switch (categoryLayout) { |
122 | 100 | case "grid": | 137 | case "grid": |
123 | 101 | case "vertical-journal": | 138 | case "vertical-journal": |
124 | @@ -103,16 +140,16 @@ | |||
125 | 103 | if (template["card-layout"] === "horizontal") size = "large"; | 140 | if (template["card-layout"] === "horizontal") size = "large"; |
126 | 104 | switch (size) { | 141 | switch (size) { |
127 | 105 | case "small": { | 142 | case "small": { |
129 | 106 | if (viewWidth <= units.gu(45)) return units.gu(12); | 143 | if (isNarrowView) return units.gu(12); |
130 | 107 | else return units.gu(14); | 144 | else return units.gu(14); |
131 | 108 | } | 145 | } |
132 | 109 | case "large": { | 146 | case "large": { |
134 | 110 | if (viewWidth >= units.gu(70)) return units.gu(42); | 147 | if (isWideView) return units.gu(42); |
135 | 111 | else return viewWidth - units.gu(2); | 148 | else return viewWidth - units.gu(2); |
136 | 112 | } | 149 | } |
137 | 113 | } | 150 | } |
140 | 114 | if (viewWidth <= units.gu(45)) return units.gu(18); | 151 | if (isNarrowView) return units.gu(18); |
141 | 115 | else if (viewWidth >= units.gu(70)) return units.gu(20); | 152 | else if (isWideView) return units.gu(20); |
142 | 116 | else return units.gu(23); | 153 | else return units.gu(23); |
143 | 117 | case "carousel": | 154 | case "carousel": |
144 | 118 | case "horizontal-list": | 155 | case "horizontal-list": |
145 | @@ -152,12 +189,19 @@ | |||
146 | 152 | type:real \brief Height of the card's header. | 189 | type:real \brief Height of the card's header. |
147 | 153 | */ | 190 | */ |
148 | 154 | readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0 | 191 | readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0 |
150 | 155 | property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0) | 192 | |
151 | 193 | readonly property size artShapeSize: { | ||
152 | 194 | if (isAppLikeScopeAppCategory) { | ||
153 | 195 | return Qt.size(units.gu(8), units.gu(7.5)); | ||
154 | 196 | } else { | ||
155 | 197 | return cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0) | ||
156 | 198 | } | ||
157 | 199 | } | ||
158 | 156 | 200 | ||
159 | 157 | QtObject { | 201 | QtObject { |
160 | 158 | id: carouselTool | 202 | id: carouselTool |
161 | 159 | 203 | ||
163 | 160 | property real minimumTileWidth: { | 204 | readonly property real minimumTileWidth: { |
164 | 161 | if (cardTool.viewWidth === undefined) return undefined; | 205 | if (cardTool.viewWidth === undefined) return undefined; |
165 | 162 | if (cardTool.viewWidth <= units.gu(40)) return units.gu(18); | 206 | if (cardTool.viewWidth <= units.gu(40)) return units.gu(18); |
166 | 163 | if (cardTool.viewWidth >= units.gu(128)) return units.gu(26); | 207 | if (cardTool.viewWidth >= units.gu(128)) return units.gu(26); |
167 | @@ -166,7 +210,7 @@ | |||
168 | 166 | 210 | ||
169 | 167 | readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values | 211 | readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values |
170 | 168 | 212 | ||
172 | 169 | property real realPathItemCount: { | 213 | readonly property real realPathItemCount: { |
173 | 170 | var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor; | 214 | var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor; |
174 | 171 | var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth); | 215 | var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth); |
175 | 172 | return Math.min(cardTool.viewWidth / tileWidth, pathItemCount); | 216 | return Math.min(cardTool.viewWidth / tileWidth, pathItemCount); |
176 | 173 | 217 | ||
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 | 267 | template: model.renderer | 267 | template: model.renderer |
182 | 268 | components: model.components | 268 | components: model.components |
183 | 269 | viewWidth: parent.width | 269 | viewWidth: parent.width |
184 | 270 | scopeId: scope ? scope.id : "" | ||
185 | 271 | categoryId: baseItem.category | ||
186 | 270 | } | 272 | } |
187 | 271 | 273 | ||
188 | 272 | onExpandableChanged: { | 274 | onExpandableChanged: { |
189 | @@ -342,17 +344,6 @@ | |||
190 | 342 | baseItem.expand(shouldExpand, false /*animate*/); | 344 | baseItem.expand(shouldExpand, false /*animate*/); |
191 | 343 | } | 345 | } |
192 | 344 | updateRanges(); | 346 | updateRanges(); |
193 | 345 | clickScopeSizingHacks(); | ||
194 | 346 | if (scope && (scope.id === "clickscope" || scope.id === "libertine-scope.ubuntu_libertine-scope")) { | ||
195 | 347 | if (isLibertineContainerCategory() || categoryId === "predefined" || categoryId === "local") { | ||
196 | 348 | cardTool.artShapeSize = Qt.binding(function() { return Qt.size(units.gu(8), units.gu(7.5)) }); | ||
197 | 349 | cardTool.artShapeStyle = "icon"; | ||
198 | 350 | } else { | ||
199 | 351 | // Should be ubuntu store icon | ||
200 | 352 | cardTool.artShapeStyle = "flat"; | ||
201 | 353 | item.backgroundShapeStyle = "shadow"; | ||
202 | 354 | } | ||
203 | 355 | } | ||
204 | 356 | item.cardTool = cardTool; | 347 | item.cardTool = cardTool; |
205 | 357 | } | 348 | } |
206 | 358 | 349 | ||
207 | @@ -361,36 +352,6 @@ | |||
208 | 361 | scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation; | 352 | scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation; |
209 | 362 | } | 353 | } |
210 | 363 | } | 354 | } |
211 | 364 | // FIXME: directly connecting to onUnitsChanged cause a compile error: | ||
212 | 365 | // Cannot assign to non-existent property "onUnitsChanged" | ||
213 | 366 | // Until the units object is reworked to properly do all we need, let's go through a intermediate property | ||
214 | 367 | property int pxpgu: units.gu(1); | ||
215 | 368 | onPxpguChanged: clickScopeSizingHacks(); | ||
216 | 369 | |||
217 | 370 | // Returns true if the current category pertains to a Libertine container | ||
218 | 371 | function isLibertineContainerCategory() { | ||
219 | 372 | return scope && scope.id === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint"; | ||
220 | 373 | } | ||
221 | 374 | |||
222 | 375 | function clickScopeSizingHacks() { | ||
223 | 376 | if (scope && | ||
224 | 377 | ((scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) || | ||
225 | 378 | isLibertineContainerCategory())) { | ||
226 | 379 | // Yeah, hackish :/ | ||
227 | 380 | if (scopeView.width > units.gu(45)) { | ||
228 | 381 | if (scopeView.width >= units.gu(70)) { | ||
229 | 382 | cardTool.cardWidth = units.gu(11); | ||
230 | 383 | item.minimumHorizontalSpacing = units.gu(5); | ||
231 | 384 | return; | ||
232 | 385 | } else { | ||
233 | 386 | cardTool.cardWidth = units.gu(10); | ||
234 | 387 | } | ||
235 | 388 | } else { | ||
236 | 389 | cardTool.cardWidth = units.gu(12); | ||
237 | 390 | } | ||
238 | 391 | item.minimumHorizontalSpacing = item.defaultMinimumHorizontalSpacing; | ||
239 | 392 | } | ||
240 | 393 | } | ||
241 | 394 | 355 | ||
242 | 395 | Connections { | 356 | Connections { |
243 | 396 | target: rendererLoader.item | 357 | target: rendererLoader.item |
244 | @@ -425,7 +386,6 @@ | |||
245 | 425 | target: scopeView | 386 | target: scopeView |
246 | 426 | onIsCurrentChanged: rendererLoader.updateRanges(); | 387 | onIsCurrentChanged: rendererLoader.updateRanges(); |
247 | 427 | onVisibleToParentChanged: rendererLoader.updateRanges(); | 388 | onVisibleToParentChanged: rendererLoader.updateRanges(); |
248 | 428 | onWidthChanged: rendererLoader.clickScopeSizingHacks(); | ||
249 | 429 | } | 389 | } |
250 | 430 | Connections { | 390 | Connections { |
251 | 431 | target: holdingList | 391 | target: holdingList |
FAILED: Continuous integration, rev:2598 /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/1992/ /unity8- jenkins. ubuntu. com/job/ build/2611/ console /unity8- jenkins. ubuntu. com/job/ build-0- fetch/2639 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 2518 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 2518 /unity8- jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 2518 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 2512/console /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 2512/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 2512 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= yakkety/ 2512/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/1992/ rebuild
https:/