on xenial help sign in
Integrate Card with scopes-ng and introduce CardFilterGrid.qml.
commit967bf53871b769fb277dda05eddba854fb3dcf9a authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 5 Dec 2013, 17:08 (13 years ago) parent4b9f0c7
5 files changed+58−2
Dash/Card.qml+2−1 Dash/CardFilterGrid.qml+44 Dash/DashFilterGrid.qml+2 Dash/DashRenderer.qml+6 Dash/GenericScopeView.qml+4−1
Dash/Card.qml+2−1
@@ -31,7 +31,8 @@ Item {
3131 width: root.width
3232 height: width / artShape.aspect
3333 objectName: "artImage"
34− source: cardData && cardData["art"] || ""
34+ // FIXME should be no need for "icon"
35+ source: cardData && cardData["art"] || cardData["icon"] || ""
3536 //sourceSize.width: width > height ? width : 0
3637 //sourceSize.height: height > width ? height : -1
3738 fillMode: components["art"]["fill-mode"] == "fit" ? Image.PreserveAspectFit: Image.PreserveAspectCrop
Dash/CardFilterGrid.qmlnew file+44
@@ -0,0 +1,44 @@
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+
20+DashFilterGrid {
21+ id: genericFilterGrid
22+
23+ minimumHorizontalSpacing: units.gu(0.5)
24+ // FIXME calculate the size correctly
25+ delegateWidth: grid.currentItem.width
26+ delegateHeight: grid.currentItem.height
27+ verticalSpacing: units.gu(2)
28+
29+ delegate: Card {
30+ id: tile
31+ objectName: "delegate" + index
32+ cardData: model
33+ template: genericFilterGrid.template
34+ components: {
35+ "art": {
36+ "aspect-ratio": 1.0,
37+ "fill-mode": "crop"
38+ }
39+ }
40+
41+ //onClicked: genericFilterGrid.clicked(index, tile.y)
42+ //onPressAndHold: genericFilterGrid.pressAndHold(index, tile.y)
43+ }
44+}
Dash/DashFilterGrid.qml+2
@@ -29,6 +29,8 @@ DashRenderer {
2929 property alias maximumNumberOfColumns: filterGrid.maximumNumberOfColumns
3030 property alias minimumHorizontalSpacing: filterGrid.minimumHorizontalSpacing
3131
32+ property FilterGrid grid: filterGrid
33+
3234 collapsedHeight: filterGrid.collapsedHeight
3335 collapsedRowCount: filterGrid.collapsedRowCount
3436 columns: filterGrid.columns
Dash/DashRenderer.qml+6
@@ -62,4 +62,10 @@ Item {
6262
6363 function startFilterAnimation(filter) {
6464 }
65+
66+ /// Category template definition from the scope
67+ property var template
68+
69+ /// Component mapping and configuration from the scope
70+ property var components
6571}
Dash/GenericScopeView.qml+4−1
@@ -163,6 +163,9 @@ FocusScope {
163163 }
164164 }
165165 updateDelegateCreationRange();
166+ // FIXME: should be "template", not "renderer"
167+ item.template = Qt.binding(function() { return model.renderer });
168+ item.components = Qt.binding(function() { return model.components });
166169 }
167170
168171 Component.onDestruction: {
@@ -340,7 +343,7 @@ FocusScope {
340343 default: return "Generic/GenericFilterGrid.qml";
341344 }
342345 }
343− default: return "Generic/GenericFilterGrid.qml";
346+ default: return "CardFilterGrid.qml";
344347 }
345348 }
346349