on xenial help sign in
Theme dash plugin differently
commitffff556118990ef3d441b7ce1488bcc52ea7b480 authorAndrea Cimitan <andrea.cimitan@canonical.com> dateThu 3 Oct 2013, 12:22 (13 years ago) parente0f5a68
6 files changed+233−65
Components/Tile.qml+6−63 Components/TileStyle.qml+87 Dash/Generic/GenericFilterGrid.qml−2 Dash/Generic/GenericFilterGridDashPlugin.qml+47 Dash/Generic/TileStyleDashPlugin.qml+87 Dash/GenericScopeView.qml+6
Components/Tile.qml+6−63
@@ -18,70 +18,13 @@ import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919
2020AbstractButton {
21− id: root
22− property alias source: image.source
23− property alias fillMode: image.fillMode
24− property alias horizontalAlignment: image.horizontalAlignment
25− property alias verticalAlignment: image.verticalAlignment
26− property alias text: label.text
21+ property url source
22+ property int fillMode
23+ property int horizontalAlignment
24+ property int verticalAlignment
25+ property string text
2726 property int imageWidth
2827 property int imageHeight
2928
30− UbuntuShape {
31− id: icon
32− anchors {
33− top: parent.top
34− horizontalCenter: parent.horizontalCenter
35− }
36− radius: "medium"
37− width: imageWidth
38− height: imageHeight
39− image: Image {
40− id: image
41− objectName: "image"
42− sourceSize { width: icon.width; height: icon.height }
43− asynchronous: true
44− cache: false
45− }
46− }
47−
48− UbuntuShape {
49− id: borderPressed
50− objectName: "borderPressed"
51−
52− anchors.fill: icon
53− radius: "medium"
54− borderSource: "radius_pressed.sci"
55− opacity: root.pressed ? 1.0 : 0.0
56− Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
57− }
58−
59− Item {
60− anchors {
61− left: parent.left
62− right: parent.right
63− top: icon.bottom
64− }
65− height: units.gu(2)
66−
67− Label {
68− id: label
69− objectName: "label"
70− anchors {
71− baseline: parent.bottom
72− left: parent.left
73− right: parent.right
74− leftMargin: units.gu(1)
75− rightMargin: units.gu(1)
76− }
77−
78− color: Theme.palette.selected.backgroundText
79− opacity: 0.9
80− style: Text.Raised
81− styleColor: "black"
82− fontSize: "small"
83− elide: Text.ElideMiddle
84− horizontalAlignment: Text.AlignHCenter
85− }
86− }
29+ style: TileStyle {}
8730}
Components/TileStyle.qmlnew file+87
@@ -0,0 +1,87 @@
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+Item {
21+ id: tile
22+
23+ anchors.fill: parent
24+
25+ UbuntuShape {
26+ id: icon
27+ anchors {
28+ top: parent.top
29+ horizontalCenter: parent.horizontalCenter
30+ }
31+ radius: "medium"
32+ width: styledItem.imageWidth
33+ height: styledItem.imageHeight
34+ image: Image {
35+ id: image
36+ objectName: "image"
37+ sourceSize { width: icon.width; height: icon.height }
38+ asynchronous: true
39+ cache: false
40+ source: styledItem.source
41+ fillMode: styledItem.fillMode
42+ horizontalAlignment: styledItem.horizontalAlignment
43+ verticalAlignment: styledItem.verticalAlignment
44+ }
45+ }
46+
47+ UbuntuShape {
48+ id: borderPressed
49+ objectName: "borderPressed"
50+
51+ anchors.fill: icon
52+ radius: "medium"
53+ borderSource: "radius_pressed.sci"
54+ opacity: styledItem.pressed ? 1.0 : 0.0
55+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
56+ }
57+
58+ Item {
59+ anchors {
60+ left: parent.left
61+ right: parent.right
62+ top: icon.bottom
63+ }
64+ height: units.gu(2)
65+
66+ Label {
67+ id: label
68+ objectName: "label"
69+ anchors {
70+ baseline: parent.bottom
71+ left: parent.left
72+ right: parent.right
73+ leftMargin: units.gu(1)
74+ rightMargin: units.gu(1)
75+ }
76+
77+ color: Theme.palette.selected.backgroundText
78+ opacity: 0.9
79+ style: Text.Raised
80+ styleColor: "black"
81+ fontSize: "small"
82+ elide: Text.ElideMiddle
83+ horizontalAlignment: Text.AlignHCenter
84+ text: styledItem.text
85+ }
86+ }
87+}
Dash/Generic/GenericFilterGrid.qml−2
@@ -39,9 +39,7 @@ FilterGrid {
3939 text: model.title
4040 imageWidth: filtergrid.iconWidth
4141 imageHeight: filtergrid.iconHeight
42−
4342 source: model.icon
44−
4543 fillMode: Image.PreserveAspectCrop
4644
4745 onClicked: {
Dash/Generic/GenericFilterGridDashPlugin.qmlnew file+47
@@ -0,0 +1,47 @@
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+
21+GenericFilterGrid {
22+ id: filtergrid
23+
24+ delegate: Tile {
25+ id: tile
26+ objectName: "delegate" + index
27+ width: filtergrid.cellWidth
28+ height: filtergrid.cellHeight
29+ text: "model.title"
30+ imageWidth: filtergrid.iconWidth
31+ imageHeight: filtergrid.iconHeight
32+ source: model.icon
33+ fillMode: Image.PreserveAspectCrop
34+
35+ style: TileStyleDashPlugin {}
36+
37+ onClicked: {
38+ var data = { model: model }
39+ filtergrid.clicked(index, data, tile.y)
40+ }
41+
42+ onPressAndHold: {
43+ var data = { model: model }
44+ filtergrid.pressAndHold(index, data, tile.y)
45+ }
46+ }
47+}
Dash/Generic/TileStyleDashPlugin.qmlnew file+87
@@ -0,0 +1,87 @@
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+Item {
21+ id: tile
22+
23+ anchors.fill: parent
24+
25+ Item {
26+ id: icon
27+ anchors {
28+ top: parent.top
29+ horizontalCenter: parent.horizontalCenter
30+ }
31+ width: styledItem.imageWidth
32+ height: styledItem.imageHeight
33+
34+ Image {
35+ id: image
36+ objectName: "image"
37+ sourceSize { width: icon.width; height: icon.height }
38+ asynchronous: true
39+ cache: false
40+ source: styledItem.source
41+ fillMode: styledItem.fillMode
42+ horizontalAlignment: styledItem.horizontalAlignment
43+ verticalAlignment: styledItem.verticalAlignment
44+ }
45+ }
46+
47+ UbuntuShape {
48+ id: borderPressed
49+ objectName: "borderPressed"
50+
51+ anchors.fill: icon
52+ radius: "medium"
53+ borderSource: "radius_pressed.sci"
54+ opacity: styledItem.pressed ? 1.0 : 0.0
55+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
56+ }
57+
58+ Item {
59+ anchors {
60+ left: parent.left
61+ right: parent.right
62+ top: icon.bottom
63+ }
64+ height: units.gu(2)
65+
66+ Label {
67+ id: label
68+ objectName: "label"
69+ anchors {
70+ baseline: parent.bottom
71+ left: parent.left
72+ right: parent.right
73+ leftMargin: units.gu(1)
74+ rightMargin: units.gu(1)
75+ }
76+
77+ color: Theme.palette.selected.backgroundText
78+ opacity: 0.9
79+ style: Text.Raised
80+ styleColor: "black"
81+ fontSize: "small"
82+ elide: Text.ElideMiddle
83+ horizontalAlignment: Text.AlignHCenter
84+ text: styledItem.text
85+ }
86+ }
87+}
Dash/GenericScopeView.qml+6
@@ -197,6 +197,12 @@ ScopeView {
197197 switch (contentType) {
198198 case "video": return "Generic/GenericFilterGridPotrait.qml";
199199 case "music": return "Music/MusicFilterGrid.qml";
200+ case "apps": {
201+ if (rendererHint == "toggled")
202+ return "Generic/GenericFilterGridDashPlugin.qml";
203+ else
204+ return "Generic/GenericFilterGrid.qml";
205+ }
200206 default: return "Generic/GenericFilterGrid.qml";
201207 }
202208 }