on xenial help sign in
Merged new-scopes.
commit7f068d967ba3d25b9734c41ac7c56cbc07abdd61 authorMichał Karnicki <michal.karnicki@canonical.com> dateThu 9 Jan 2014, 00:32 (13 years ago) parent08a6e43bee3fc9
4 files changed+49−48
qml/Dash/CardCarousel.qml+38 qml/Dash/CardFilterGrid.qml+1−6 qml/Dash/GenericScopeView.qml+9−42 tests/qmltests/Dash/tst_Card.qml+1
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 {
3131 objectName: "delegate" + index
3232 cardData: model
3333 template: genericFilterGrid.template
34− components: {
35− "art": {
36− "aspect-ratio": 1.0,
37− "fill-mode": "crop"
38− }
39− }
34+ components: genericFilterGrid.components
4035
4136 //onClicked: genericFilterGrid.clicked(index, tile.y)
4237 //onPressAndHold: genericFilterGrid.pressAndHold(index, tile.y)
qml/Dash/GenericScopeView.qml+9−42
@@ -141,7 +141,7 @@ FocusScope {
141141 right: parent.right
142142 }
143143
144− source: getRenderer(model.renderer, model.contentType, model.rendererHint, results)
144+ source: getRenderer(model.renderer, results)
145145
146146 onLoaded: {
147147 if (item.enableHeightBehavior !== undefined && item.enableHeightBehaviorOnNextCreation !== undefined) {
@@ -302,49 +302,16 @@ FocusScope {
302302 }
303303 }
304304
305− function getDefaultRendererId(contentType) {
306− switch (contentType) {
307− default: return "grid";
308− }
309− }
305+ function getRenderer(template, results) {
306+ var layout = template["category-layout"];
310307
311− function getRenderer(rendererId, contentType, rendererHint, results) {
312− if (rendererId == "default") {
313− rendererId = getDefaultRendererId(contentType);
314− }
315− if (rendererId == "carousel") {
316− // Selectively disable carousel, 6 is fixed for now, should change on the form factor
317− if (results.count <= 6)
318− rendererId = "grid"
308+ if (layout === "carousel") {
309+ // TODO: Selectively disable carousel, 6 is fixed for now, should change depending on form factor
310+ if (results.count <= 6) layout = "grid";
319311 }
320− switch (rendererId) {
321− case "carousel": {
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": {
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− }
312+ switch (layout) {
313+ case "carousel": return "CardCarousel.qml";
314+ case "grid":
348315 default: return "CardFilterGrid.qml";
349316 }
350317 }
tests/qmltests/Dash/tst_Card.qml+1
@@ -163,6 +163,7 @@ Rectangle {
163163
164164 UT.UnityTestCase {
165165 id: testCase
166+ name: "Card"
166167
167168 when: windowShown
168169