on xenial help sign in
Merged new-scopes.
7f068d9Michał Karnicki
qml/Dash/CardCarousel.qmlnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+import "../Components"
20+import ".."
21+
22+DashCarousel {
23+ id: cardCarousel
24+
25+ itemComponent: Card {
26+ id: card
27+ objectName: "delegate" + index
28+ cardData: model
29+ template: cardCarousel.template
30+ components: cardCarousel.components
31+
32+ property bool explicitlyScaled
33+ property var model
34+ }
35+
36+ // onClicked: cardCarousel.clicked(index, itemY)
37+ // onPressAndHold: cardCarousel.pressAndHold(index, itemY)
38+}
qml/Dash/CardFilterGrid.qml+1−6
@@ -31,12 +31,7 @@ DashFilterGrid {
31 objectName: "delegate" + index
31 objectName: "delegate" + index
32 cardData: model
32 cardData: model
33 template: genericFilterGrid.template
33 template: genericFilterGrid.template
34− components: {
34+ components: genericFilterGrid.components
35− "art": {
36− "aspect-ratio": 1.0,
37− "fill-mode": "crop"
38− }
39− }
40
35
41 //onClicked: genericFilterGrid.clicked(index, tile.y)
36 //onClicked: genericFilterGrid.clicked(index, tile.y)
42 //onPressAndHold: genericFilterGrid.pressAndHold(index, tile.y)
37 //onPressAndHold: genericFilterGrid.pressAndHold(index, tile.y)
qml/Dash/GenericScopeView.qml+9−42
@@ -141,7 +141,7 @@ FocusScope {
141 right: parent.right
141 right: parent.right
142 }
142 }
143
143
144− source: getRenderer(model.renderer, model.contentType, model.rendererHint, results)
144+ source: getRenderer(model.renderer, results)
145
145
146 onLoaded: {
146 onLoaded: {
147 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
147 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
@@ -302,49 +302,16 @@ FocusScope {
302 }
302 }
303 }
303 }
304
304
305− function getDefaultRendererId(contentType) {
305+ function getRenderer(template, results) {
306− switch (contentType) {
306+ var layout = template["category-layout"];
307− default: return "grid";
308− }
309− }
310
307
311− function getRenderer(rendererId, contentType, rendererHint, results) {
312− if (rendererId == "default") {
313− rendererId = getDefaultRendererId(contentType);
314− }
315− if (rendererId == "carousel") {
308+ if (layout === "carousel") {
316− // Selectively disable carousel, 6 is fixed for now, should change on the form factor
309+ // TODO: Selectively disable carousel, 6 is fixed for now, should change depending on form factor
317− if (results.count <= 6)
310+ if (results.count <= 6) layout = "grid";
318− rendererId = "grid"
319 }
311 }
320− switch (rendererId) {
312+ switch (layout) {
321− case "carousel": {
313+ case "carousel": return "CardCarousel.qml";
322− switch (contentType) {
323− case "music": return "Music/MusicCarousel.qml";
324− case "video": return "Video/VideoCarousel.qml";
325− default: return "Generic/GenericCarousel.qml";
326− }
327− }
328− case "grid": {
314+ case "grid":
329− switch (contentType) {
330− case "apps": {
331− if (rendererHint == "toggled")
332− return "Apps/DashPluginFilterGrid.qml";
333− else
334− return "Generic/GenericFilterGrid.qml";
335− }
336− case "music": return "Music/MusicFilterGrid.qml";
337− case "video": return "Video/VideoFilterGrid.qml";
338− case "weather": return "Generic/WeatherFilterGrid.qml";
339− default: return "Generic/GenericFilterGrid.qml";
340− }
341− }
342− case "special": {
343− switch (contentType) {
344− case "apps": return "Apps/RunningApplicationsGrid.qml";
345− default: return "Generic/GenericFilterGrid.qml";
346− }
347− }
348 default: return "CardFilterGrid.qml";
315 default: return "CardFilterGrid.qml";
349 }
316 }
350 }
317 }
tests/qmltests/Dash/tst_Card.qml+1
@@ -163,6 +163,7 @@ Rectangle {
163
163
164 UT.UnityTestCase {
164 UT.UnityTestCase {
165 id: testCase
165 id: testCase
166+ name: "Card"
166
167
167 when: windowShown
168 when: windowShown
168
169