on xenial help sign in
Add music and video renderers
commit2c4d7749500103f2327d5a6235d3104fbc409f1c authorAndrea Cimitan <andrea.cimitan@canonical.com> dateThu 10 Oct 2013, 13:23 (13 years ago) parent1660c3251c4af9
10 files changed+236−45
Components/Tile.qml+1−2 Components/TileStyle.qml+4−3 Dash/Generic/FlatTileStyle.qml+4−3 Dash/GenericScopeView.qml+1−1 Dash/Music/MusicFilterGrid.qml+21−22 Dash/Music/MusicTileStyle.qml+101 Dash/Video/VideosFilterGrid.qml → Dash/Video/VideoFilterGrid.qml+17−13 Dash/Video/VideoTileStyle.qml+86 Dash/Video/graphics/movie_icon_holder@27.png tests/qmltests/Dash/tst_FilterGrids.qml+1−1
Components/Tile.qml+1−2
@@ -20,8 +20,7 @@ import Ubuntu.Components 0.1
2020AbstractButton {
2121 property url source
2222 property int fillMode: Image.PreserveAspectCrop
23− property int horizontalAlignment: Image.AlignHCenter
24− property int verticalAlignment: Image.AlignVCenter
23+ property int horizontalAlignment: Text.AlignHCenter
2524 property string text
2625 property int imageWidth
2726 property int imageHeight
Components/TileStyle.qml+4−3
@@ -39,8 +39,8 @@ Item {
3939 cache: false
4040 source: styledItem.source
4141 fillMode: styledItem.fillMode
42− horizontalAlignment: styledItem.horizontalAlignment
43− verticalAlignment: styledItem.verticalAlignment
42+ horizontalAlignment: Image.AlignHCenter
43+ verticalAlignment: Image.AlignVCenter
4444 }
4545 }
4646
@@ -73,8 +73,9 @@ Item {
7373 styleColor: "black"
7474 fontSize: "small"
7575 elide: Text.ElideMiddle
76− horizontalAlignment: Text.AlignHCenter
76+ horizontalAlignment: styledItem.horizontalAlignment
7777 text: styledItem.text
78+ wrapMode: Text.Wrap
7879 maximumLineCount: styledItem.maximumLineCount
7980 }
8081}
Dash/Generic/FlatTileStyle.qml+4−3
@@ -38,8 +38,8 @@ Item {
3838 source: styledItem.source
3939 fillMode: styledItem.fillMode
4040 opacity: tile.disabled ? 0.3 : 1.0
41− horizontalAlignment: styledItem.horizontalAlignment
42− verticalAlignment: styledItem.verticalAlignment
41+ horizontalAlignment: Image.AlignHCenter
42+ verticalAlignment: Image.AlignVCenter
4343 }
4444
4545 UbuntuShape {
@@ -71,8 +71,9 @@ Item {
7171 styleColor: "black"
7272 fontSize: "small"
7373 elide: Text.ElideMiddle
74− horizontalAlignment: Text.AlignHCenter
74+ horizontalAlignment: styledItem.horizontalAlignment
7575 text: styledItem.text
76+ wrapMode: Text.Wrap
7677 maximumLineCount: styledItem.maximumLineCount
7778 }
7879}
Dash/GenericScopeView.qml+1−1
@@ -208,7 +208,7 @@ ScopeView {
208208 switch (rendererId) {
209209 case "grid": {
210210 switch (contentType) {
211− case "video": return "Generic/GenericFilterGridPotrait.qml";
211+ case "video": return "Video/VideoFilterGrid.qml";
212212 case "music": return "Music/MusicFilterGrid.qml";
213213 case "apps": {
214214 if (rendererHint == "toggled")
Dash/Music/MusicFilterGrid.qml+21−22
@@ -16,42 +16,41 @@
1616
1717import QtQuick 2.0
1818import "../../Components"
19+import "../Generic"
1920
20−FilterGrid {
21− id: filterGrid
21+GenericFilterGrid {
22+ id: filtergrid
2223
23− minimumHorizontalSpacing: units.gu(2)
24− maximumNumberOfColumns: 5
25− delegateWidth: units.gu(17)
26− delegateHeight: iconHeight + units.gu(3.5)
27− verticalSpacing: units.gu(2)
24+ delegateWidth: units.gu(11)
25+ delegateHeight: units.gu(16)
2826
29− readonly property int iconWidth: (width / columns) * 0.8
30− readonly property int iconHeight: iconWidth
27+ iconWidth: units.gu(11)
28+ iconHeight: units.gu(11)
3129
32− signal clicked(int index, var delegateItem, real itemY)
33− signal pressAndHold(int index, var delegateItem, real itemY)
34−
35− delegate: AlbumTile {
30+ delegate: Tile {
3631 id: tile
3732 objectName: "delegate" + index
38− width: filterGrid.cellWidth
39− height: filterGrid.cellHeight
40− iconWidth: filterGrid.iconWidth
41− iconHeight: filterGrid.iconHeight
42−
43− artist: model.title
44− album: model.comment
33+ width: filtergrid.cellWidth
34+ height: filtergrid.cellHeight
35+ text: model.comment
36+ imageWidth: filtergrid.iconWidth
37+ imageHeight: filtergrid.iconHeight
4538 source: model.icon
39+ maximumLineCount: 2
40+ horizontalAlignment: Text.AlignLeft
41+
42+ style: MusicTileStyle {
43+ artist: model.title
44+ }
4645
4746 onClicked: {
4847 var data = { model: model }
49− filterGrid.clicked(index, data, tile.y)
48+ filtergrid.clicked(index, data, tile.y)
5049 }
5150
5251 onPressAndHold: {
5352 var data = { model: model }
54− filterGrid.pressAndHold(index, data, tile.y)
53+ filtergrid.pressAndHold(index, data, tile.y)
5554 }
5655 }
5756}
Dash/Music/MusicTileStyle.qmlnew file+101
@@ -0,0 +1,101 @@
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+ property alias artist: artistLabel.text
24+
25+ anchors.fill: parent
26+
27+ UbuntuShape {
28+ id: icon
29+ anchors {
30+ top: parent.top
31+ horizontalCenter: parent.horizontalCenter
32+ }
33+ radius: "medium"
34+ width: styledItem.imageWidth
35+ height: styledItem.imageHeight
36+ image: Image {
37+ id: image
38+ objectName: "image"
39+ sourceSize { width: icon.width; height: icon.height }
40+ asynchronous: true
41+ cache: false
42+ source: styledItem.source
43+ fillMode: styledItem.fillMode
44+ horizontalAlignment: Image.AlignHCenter
45+ verticalAlignment: Image.AlignVCenter
46+ }
47+ }
48+
49+ UbuntuShape {
50+ id: borderPressed
51+ objectName: "borderPressed"
52+
53+ anchors.fill: icon
54+ radius: "medium"
55+ borderSource: "radius_pressed.sci"
56+ opacity: styledItem.pressed ? 1.0 : 0.0
57+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
58+ }
59+
60+ Label {
61+ id: label
62+ objectName: "label"
63+ anchors {
64+ baseline: icon.bottom
65+ baselineOffset: units.gu(2)
66+ left: icon.left
67+ right: parent.right
68+ rightMargin: units.gu(1)
69+ }
70+
71+ color: Theme.palette.selected.backgroundText
72+ opacity: 0.9
73+ style: Text.Raised
74+ styleColor: "black"
75+ fontSize: "small"
76+ font.weight: Font.Bold
77+ elide: Text.ElideRight
78+ horizontalAlignment: styledItem.horizontalAlignment
79+ text: styledItem.text
80+ wrapMode: Text.Wrap
81+ maximumLineCount: styledItem.maximumLineCount
82+ }
83+
84+ Label {
85+ id: artistLabel
86+ anchors {
87+ top: label.bottom
88+ left: label.left
89+ right: label.right
90+ rightMargin: units.gu(1)
91+ }
92+
93+ color: Theme.palette.selected.backgroundText
94+ opacity: 0.9
95+ style: Text.Raised
96+ styleColor: "black"
97+ fontSize: "x-small"
98+ elide: Text.ElideMiddle
99+ horizontalAlignment: styledItem.horizontalAlignment
100+ }
101+}
Dash/Video/VideosFilterGrid.qml → Dash/Video/VideoFilterGrid.qmlrenamed+17−13
@@ -16,20 +16,16 @@
1616
1717import QtQuick 2.0
1818import "../../Components"
19+import "../Generic"
1920
20−FilterGrid {
21+GenericFilterGrid {
2122 id: filtergrid
2223
23− minimumHorizontalSpacing: units.gu(0.5)
24− maximumNumberOfColumns: 5
2524 delegateWidth: units.gu(11)
26− delegateHeight: iconHeight + units.gu(2.5)
27− verticalSpacing: units.gu(2)
25+ delegateHeight: units.gu(15)
2826
29− readonly property int iconWidth: (width / columns) * 0.8
30− readonly property int iconHeight: iconWidth * 16 / 11
31−
32− signal clicked(int index, var data, real itemY)
27+ iconWidth: units.gu(11)
28+ iconHeight: units.gu(11)
3329
3430 delegate: Tile {
3531 id: tile
@@ -40,11 +36,19 @@ FilterGrid {
4036 imageWidth: filtergrid.iconWidth
4137 imageHeight: filtergrid.iconHeight
4238 source: model.icon
43− fillMode: Image.PreserveAspectCrop
39+ maximumLineCount: 2
40+ horizontalAlignment: Text.AlignLeft
41+
42+ style: VideoTileStyle {}
43+
4444 onClicked: {
45− var fileUri = model.uri.replace(/^[^:]+:/, "")
46− var data = {fileUri: fileUri, nfoUri: model.comment}
47− filtergrid.clicked(index, data, tile.y);
45+ var data = { model: model }
46+ filtergrid.clicked(index, data, tile.y)
47+ }
48+
49+ onPressAndHold: {
50+ var data = { model: model }
51+ filtergrid.pressAndHold(index, data, tile.y)
4852 }
4953 }
5054}
Dash/Video/VideoTileStyle.qmlnew file+86
@@ -0,0 +1,86 @@
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+ Image {
26+ id: icon
27+ anchors {
28+ top: parent.top
29+ horizontalCenter: parent.horizontalCenter
30+ }
31+ width: styledItem.imageWidth
32+ height: styledItem.imageHeight
33+ source: "graphics/movie_icon_holder.png"
34+
35+ Image {
36+ id: image
37+ objectName: "image"
38+ anchors {
39+ fill: parent;
40+ topMargin: units.gu(2);
41+ bottomMargin: units.gu(2)
42+ }
43+ sourceSize { width: icon.width; height: icon.height }
44+ asynchronous: true
45+ cache: false
46+ source: styledItem.source
47+ fillMode: styledItem.fillMode
48+ horizontalAlignment: Image.AlignHCenter
49+ verticalAlignment: Image.AlignVCenter
50+ }
51+ }
52+
53+ UbuntuShape {
54+ id: borderPressed
55+ objectName: "borderPressed"
56+
57+ anchors.fill: icon
58+ radius: "medium"
59+ borderSource: "radius_pressed.sci"
60+ opacity: styledItem.pressed ? 1.0 : 0.0
61+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
62+ }
63+
64+ Label {
65+ id: label
66+ objectName: "label"
67+ anchors {
68+ baseline: icon.bottom
69+ baselineOffset: units.gu(2)
70+ left: icon.left
71+ right: parent.right
72+ rightMargin: units.gu(1)
73+ }
74+
75+ color: Theme.palette.selected.backgroundText
76+ opacity: 0.9
77+ style: Text.Raised
78+ styleColor: "black"
79+ fontSize: "small"
80+ elide: Text.ElideRight
81+ horizontalAlignment: styledItem.horizontalAlignment
82+ text: styledItem.text
83+ wrapMode: Text.Wrap
84+ maximumLineCount: styledItem.maximumLineCount
85+ }
86+}
Dash/Video/graphics/movie_icon_holder@27.pngnew file

Binary file not shown.

tests/qmltests/Dash/tst_FilterGrids.qml+1−1
@@ -107,7 +107,7 @@ Rectangle {
107107
108108 function test_clicked_signal_data() {
109109 return [
110− {tag: "VideosFilterGrid", component: "Video/VideosFilterGrid.qml"},
110+ {tag: "VideoFilterGrid", component: "Video/VideoFilterGrid.qml"},
111111 {tag: "MusicFilterGrid", component: "Music/MusicFilterGrid.qml"},
112112 {tag: "ApplicationsFilterGrid", component: "Apps/ApplicationsFilterGrid.qml"}
113113 ]