on xenial help sign in
Remove "hacks" from GenericScopeView
1f0f2c9Albert Astals Cid
qml/Dash/CardGrid.qml+3−4
@@ -20,13 +20,12 @@ import "../Components"
20DashRenderer {
20DashRenderer {
21 id: root
21 id: root
22
22
23− readonly property real defaultMinimumHorizontalSpacing: units.gu(1)
24 readonly property int collapsedRows: {
23 readonly property int collapsedRows: {
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;
26 return cardTool.template["collapsed-rows"];
25 return cardTool.template["collapsed-rows"];
27 }
26 }
27+ // ↓ This is the ubuntu store icon
28− property string backgroundShapeStyle: "inset";
28+ readonly property string backgroundShapeStyle: cardTool.isAppLikeScope && !cardTool.isAppLikeScopeAppCategory ? "shadow" : "inset"
29− property alias minimumHorizontalSpacing: grid.minimumHorizontalSpacing
30
29
31 expandedHeight: grid.totalContentHeight
30 expandedHeight: grid.totalContentHeight
32 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
31 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
@@ -46,7 +45,7 @@ DashRenderer {
46 ResponsiveGridView {
45 ResponsiveGridView {
47 id: grid
46 id: grid
48 anchors.fill: parent
47 anchors.fill: parent
49− minimumHorizontalSpacing: root.defaultMinimumHorizontalSpacing
48+ minimumHorizontalSpacing: (cardTool.isAppLikeScopeAppCategory && cardTool.viewWidth >= units.gu(70)) ? units.gu(5) : units.gu(1)
50 delegateWidth: cardTool.cardWidth
49 delegateWidth: cardTool.cardWidth
51 delegateHeight: cardTool.cardHeight
50 delegateHeight: cardTool.cardHeight
52 verticalSpacing: units.gu(1)
51 verticalSpacing: units.gu(1)
qml/Dash/CardTool.qml+50−13
@@ -41,11 +41,6 @@ Item {
41 */
41 */
42 property real viewWidth
42 property real viewWidth
43
43
44− /*!
45− \brief Scaling factor of selected Carousel item.
46− */
47− readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
48−
49 /*!
44 /*!
50 \brief Template supplied for the category.
45 \brief Template supplied for the category.
51 */
46 */
@@ -56,10 +51,25 @@ Item {
56 */
51 */
57 property var components
52 property var components
58
53
54+ /*!
55+ \brief The Scope this cardTool is representing
56+ */
57+ property string scopeId
58+
59+ /*!
60+ \brief The Scope category this cardTool is representing
61+ */
62+ property string categoryId
63+
64+ /*!
65+ \brief Scaling factor of selected Carousel item.
66+ */
67+ readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
68+
59 /*!
69 /*!
60 \brief The category layout for this card tool.
70 \brief The category layout for this card tool.
61 */
71 */
62− property string categoryLayout: {
72+ readonly property string categoryLayout: {
63 var layout = template["category-layout"];
73 var layout = template["category-layout"];
64
74
65 // carousel fallback mode to grid
75 // carousel fallback mode to grid
@@ -67,11 +77,19 @@ Item {
67 return layout;
77 return layout;
68 }
78 }
69
79
80+ readonly property bool isAppLikeScope: scopeId === "clickscope" || scopeId === "libertine-scope.ubuntu_libertine-scope"
81+ readonly property bool isAppLikeScopeAppCategory: ((scopeId === "clickscope" && (categoryId === "predefined" || categoryId === "local"))
82+ || (scopeId === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint"))
70
83
71− // Not readonly because gets overwritten from GenericScopeView in some cases
84+ readonly property string artShapeStyle: {
85+ if (isAppLikeScope) {
86+ return isAppLikeScopeAppCategory ? "icon" : "flat";
87+ } else {
72− property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
88+ return categoryLayout === "carousel" ? "shadow" : "inset"
89+ }
90+ }
73
91
74− property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout);
92+ readonly property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout);
75
93
76 // FIXME: Saviq
94 // FIXME: Saviq
77 // Only way for the card below to actually be laid out completely.
95 // Only way for the card below to actually be laid out completely.
@@ -85,7 +103,19 @@ Item {
85
103
86 If -1, should use implicit width of the actual card.
104 If -1, should use implicit width of the actual card.
87 */
105 */
88− property real cardWidth: {
106+ readonly property real cardWidth: {
107+ if (isAppLikeScopeAppCategory) {
108+ if (viewWidth > units.gu(45)) {
109+ if (viewWidth >= units.gu(70)) {
110+ return units.gu(11);
111+ } else {
112+ return units.gu(10);
113+ }
114+ } else {
115+ return units.gu(12);
116+ }
117+ }
118+
89 switch (categoryLayout) {
119 switch (categoryLayout) {
90 case "grid":
120 case "grid":
91 case "vertical-journal":
121 case "vertical-journal":
@@ -142,12 +172,19 @@ Item {
142 type:real \brief Height of the card's header.
172 type:real \brief Height of the card's header.
143 */
173 */
144 readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0
174 readonly property int headerHeight: cardLoader.item ? cardLoader.item.headerHeight : 0
175+
176+ readonly property size artShapeSize: {
177+ if (isAppLikeScopeAppCategory) {
178+ return Qt.size(units.gu(8), units.gu(7.5));
179+ } else {
145− property size artShapeSize: cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0)
180+ return cardLoader.item ? cardLoader.item.artShapeSize : Qt.size(0, 0)
181+ }
182+ }
146
183
147 QtObject {
184 QtObject {
148 id: carouselTool
185 id: carouselTool
149
186
150− property real minimumTileWidth: {
187+ readonly property real minimumTileWidth: {
151 if (cardTool.viewWidth === undefined) return undefined;
188 if (cardTool.viewWidth === undefined) return undefined;
152 if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
189 if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
153 if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
190 if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
@@ -156,7 +193,7 @@ Item {
156
193
157 readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
194 readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
158
195
159− property real realPathItemCount: {
196+ readonly property real realPathItemCount: {
160 var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
197 var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
161 var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
198 var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
162 return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
199 return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
qml/Dash/GenericScopeView.qml+2−42
@@ -266,6 +266,8 @@ FocusScope {
266 template: model.renderer
266 template: model.renderer
267 components: model.components
267 components: model.components
268 viewWidth: parent.width
268 viewWidth: parent.width
269+ scopeId: scope ? scope.id : ""
270+ categoryId: baseItem.category
269 }
271 }
270
272
271 onExpandableChanged: {
273 onExpandableChanged: {
@@ -341,17 +343,6 @@ FocusScope {
341 baseItem.expand(shouldExpand, false /*animate*/);
343 baseItem.expand(shouldExpand, false /*animate*/);
342 }
344 }
343 updateRanges();
345 updateRanges();
344− clickScopeSizingHacks();
345− if (scope && (scope.id === "clickscope" || scope.id === "libertine-scope.ubuntu_libertine-scope")) {
346− if (isLibertineContainerCategory() || categoryId === "predefined" || categoryId === "local") {
347− cardTool.artShapeSize = Qt.binding(function() { return Qt.size(units.gu(8), units.gu(7.5)) });
348− cardTool.artShapeStyle = "icon";
349− } else {
350− // Should be ubuntu store icon
351− cardTool.artShapeStyle = "flat";
352− item.backgroundShapeStyle = "shadow";
353− }
354− }
355 item.cardTool = cardTool;
346 item.cardTool = cardTool;
356 }
347 }
357
348
@@ -360,36 +351,6 @@ FocusScope {
360 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
351 scopeView.enableHeightBehaviorOnNextCreation = item.enableHeightBehaviorOnNextCreation;
361 }
352 }
362 }
353 }
363− // FIXME: directly connecting to onUnitsChanged cause a compile error:
364− // Cannot assign to non-existent property "onUnitsChanged"
365− // Until the units object is reworked to properly do all we need, let's go through a intermediate property
366− property int pxpgu: units.gu(1);
367− onPxpguChanged: clickScopeSizingHacks();
368−
369− // Returns true if the current category pertains to a Libertine container
370− function isLibertineContainerCategory() {
371− return scope && scope.id === "libertine-scope.ubuntu_libertine-scope" && categoryId !== "hint";
372− }
373−
374− function clickScopeSizingHacks() {
375− if (scope &&
376− ((scope.id === "clickscope" && (categoryId === "predefined" || categoryId === "local")) ||
377− isLibertineContainerCategory())) {
378− // Yeah, hackish :/
379− if (scopeView.width > units.gu(45)) {
380− if (scopeView.width >= units.gu(70)) {
381− cardTool.cardWidth = units.gu(11);
382− item.minimumHorizontalSpacing = units.gu(5);
383− return;
384− } else {
385− cardTool.cardWidth = units.gu(10);
386− }
387− } else {
388− cardTool.cardWidth = units.gu(12);
389− }
390− item.minimumHorizontalSpacing = item.defaultMinimumHorizontalSpacing;
391− }
392− }
393
354
394 Connections {
355 Connections {
395 target: rendererLoader.item
356 target: rendererLoader.item
@@ -424,7 +385,6 @@ FocusScope {
424 target: scopeView
385 target: scopeView
425 onIsCurrentChanged: rendererLoader.updateRanges();
386 onIsCurrentChanged: rendererLoader.updateRanges();
426 onVisibleToParentChanged: rendererLoader.updateRanges();
387 onVisibleToParentChanged: rendererLoader.updateRanges();
427− onWidthChanged: rendererLoader.clickScopeSizingHacks();
428 }
388 }
429 Connections {
389 Connections {
430 target: holdingList
390 target: holdingList