on xenial help sign in
Added code for music and video tiles, but video tiles waiting asset
commit015f5f0b6e5156b02777316015de021fc0cf3673 authorAndrea Cimitan <andrea.cimitan@canonical.com> dateWed 9 Oct 2013, 16:28 (13 years ago) parent217e85a
8 files changed+245−47
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+103 Dash/Video/VideosFilterGrid.qml → Dash/Video/VideoFilterGrid.qml+13−16 Dash/Video/VideoTileStyle.qml+98
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.WordWrap
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.WordWrap
7677 maximumLineCount: styledItem.maximumLineCount
7778 }
7879}
Dash/GenericScopeView.qml+1−1
@@ -207,7 +207,7 @@ ScopeView {
207207 switch (rendererId) {
208208 case "grid": {
209209 switch (contentType) {
210− case "video": return "Generic/GenericFilterGridPotrait.qml";
210+ case "video": return "Video/VideoFilterGrid.qml";
211211 case "music": return "Music/MusicFilterGrid.qml";
212212 case "apps": {
213213 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+103
@@ -0,0 +1,103 @@
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: parent.left
67+ right: parent.right
68+ leftMargin: units.gu(1)
69+ rightMargin: units.gu(1)
70+ }
71+
72+ color: Theme.palette.selected.backgroundText
73+ opacity: 0.9
74+ style: Text.Raised
75+ styleColor: "black"
76+ fontSize: "small"
77+ font.weight: Font.Bold
78+ elide: Text.ElideRight
79+ horizontalAlignment: styledItem.horizontalAlignment
80+ text: styledItem.text
81+ wrapMode: Text.WordWrap
82+ maximumLineCount: styledItem.maximumLineCount
83+ }
84+
85+ Label {
86+ id: artistLabel
87+ anchors {
88+ top: label.bottom
89+ left: parent.left
90+ right: parent.right
91+ leftMargin: units.gu(1)
92+ rightMargin: units.gu(1)
93+ }
94+
95+ color: Theme.palette.selected.backgroundText
96+ opacity: 0.9
97+ style: Text.Raised
98+ styleColor: "black"
99+ fontSize: "x-small"
100+ elide: Text.ElideMiddle
101+ horizontalAlignment: styledItem.horizontalAlignment
102+ }
103+}
Dash/Video/VideosFilterGrid.qml → Dash/Video/VideoFilterGrid.qmlrenamed+13−16
@@ -16,21 +16,11 @@
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
25− delegateWidth: units.gu(11)
26− delegateHeight: iconHeight + units.gu(2.5)
27− verticalSpacing: units.gu(2)
28−
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)
33−
3424 delegate: Tile {
3525 id: tile
3626 objectName: "delegate" + index
@@ -40,11 +30,18 @@ FilterGrid {
4030 imageWidth: filtergrid.iconWidth
4131 imageHeight: filtergrid.iconHeight
4232 source: model.icon
43− fillMode: Image.PreserveAspectCrop
33+ fillMode: Image.PreserveAspectFit
34+
35+ style: VideoTileStyle {}
36+
4437 onClicked: {
45− var fileUri = model.uri.replace(/^[^:]+:/, "")
46− var data = {fileUri: fileUri, nfoUri: model.comment}
47− filtergrid.clicked(index, data, tile.y);
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)
4845 }
4946 }
5047}
Dash/Video/VideoTileStyle.qmlnew file+98
@@ -0,0 +1,98 @@
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: Image.AlignHCenter
43+ verticalAlignment: Image.AlignVCenter
44+ }
45+
46+ /*Image {
47+ source: "background.png";
48+ width: foo
49+ height: bar
50+
51+ Image {
52+ source: the_source
53+ anchors {
54+ fill: parent;
55+ topMargin: units.gu(5);
56+ bottomMargin: units.gu(5)
57+ }
58+ fillMode: Image.PreserveAspectCrop
59+ sourceSize.height: height
60+ }
61+ }*/
62+ }
63+
64+ UbuntuShape {
65+ id: borderPressed
66+ objectName: "borderPressed"
67+
68+ anchors.fill: icon
69+ radius: "medium"
70+ borderSource: "radius_pressed.sci"
71+ opacity: styledItem.pressed ? 1.0 : 0.0
72+ Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
73+ }
74+
75+ Label {
76+ id: label
77+ objectName: "label"
78+ anchors {
79+ baseline: icon.bottom
80+ baselineOffset: units.gu(2)
81+ left: parent.left
82+ right: parent.right
83+ leftMargin: units.gu(1)
84+ rightMargin: units.gu(1)
85+ }
86+
87+ color: Theme.palette.selected.backgroundText
88+ opacity: 0.9
89+ style: Text.Raised
90+ styleColor: "black"
91+ fontSize: "small"
92+ elide: Text.ElideMiddle
93+ horizontalAlignment: styledItem.horizontalAlignment
94+ text: styledItem.text
95+ wrapMode: Text.WordWrap
96+ maximumLineCount: styledItem.maximumLineCount
97+ }
98+}