@@ -0,0 +1,175 @@
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 QtMultimedia 5.0
19+import Ubuntu.Components 0.1
20+import Ubuntu.Components.ListItems 0.1
21+import ".."
22+import "../Generic"
23+import "../../Components"
24+import "../Previews"
25+
26+GenericPreview {
27+ id: root
28+
29+ previewImages: previewImageComponent
30+ header: headerComponent
31+ description: descriptionComponent
32+
33+ Component {
34+ id: previewImageComponent
35+ LazyImage {
36+ height: units.gu(22)
37+ scaleTo: "height"
38+ source: previewData ? previewData.image : ""
39+ initialHeight: height
40+ initialWidth: height
41+ }
42+ }
43+
44+ Component {
45+ id: headerComponent
46+ Header {
47+ title: previewData.title
48+ subtitle: previewData.subtitle
49+ }
50+ }
51+
52+ Component {
53+ id: descriptionComponent
54+
55+ Column {
56+ height: childrenRect.height
57+
58+ Repeater {
59+ id: trackRepeater
60+
61+ model: previewData.tracks
62+
63+ signal stopPlayback()
64+
65+ delegate: Item {
66+ objectName: "trackItem" + index
67+ width: parent.width
68+ height: units.gu(5)
69+ Row {
70+ id: trackRow
71+ width: parent.width
72+ spacing: units.gu(1)
73+ property int column1Width: units.gu(3)
74+ property int column2Width: width - (2 * spacing) - column1Width - column3Width
75+ property int column3Width: units.gu(4)
76+ anchors.verticalCenter: parent.verticalCenter
77+
78+ UbuntuShape {
79+ id: playButtonShape
80+ width: trackRow.column1Width
81+ height: width
82+ Icon {
83+ width: units.gu(2)
84+ height: width
85+ anchors.centerIn: playButtonShape
86+ name: audioPlayer.playbackState == Audio.PlayingState ? "media-playback-pause" : "media-playback-start"
87+ color: "white"
88+ opacity: .9
89+ }
90+ MouseArea {
91+ anchors.fill: parent
92+ onClicked: {
93+ if (audioPlayer.playbackState == Audio.PlayingState) {
94+ audioPlayer.pause();
95+ } else if (audioPlayer.playbackState == Audio.PausedState){
96+ audioPlayer.play();
97+ } else {
98+ trackRepeater.stopPlayback();
99+ audioPlayer.play();
100+ }
101+ }
102+ }
103+ }
104+
105+ Label {
106+ objectName: "trackTitleLabel"
107+ fontSize: "small"
108+ opacity: 0.9
109+ color: "white"
110+ horizontalAlignment: Text.AlignLeft
111+ anchors.verticalCenter: parent.verticalCenter
112+ width: parent.column2Width
113+ text: title
114+ style: Text.Raised
115+ styleColor: "black"
116+ elide: Text.ElideRight
117+
118+ // FIXME: get color values from design
119+ UbuntuShape {
120+ color: "#66000000"
121+ anchors {
122+ left: parent.left
123+ top: parent.bottom
124+ right: parent.right
125+ topMargin: units.dp(3)
126+ }
127+ height: units.dp(2)
128+ visible: audioPlayer.playbackState != Audio.StoppedState
129+
130+ UbuntuShape {
131+ color: "#dd4814"
132+ anchors.fill: parent
133+ anchors.rightMargin: parent.width - (parent.width * audioPlayer.percent / 100)
134+ }
135+ }
136+ }
137+ Label {
138+ id: valueLabel
139+ objectName: "timeLabel"
140+ fontSize: "small"
141+ opacity: 0.9
142+ color: "white"
143+ anchors.verticalCenter: parent.verticalCenter
144+ horizontalAlignment: Text.AlignRight
145+ width: parent.column3Width
146+ text: length
147+ style: Text.Raised
148+ styleColor: "black"
149+ }
150+ }
151+
152+ ThinDivider {
153+ anchors {
154+ left: parent.left
155+ bottom: parent.bottom
156+ right: parent.right
157+ }
158+ }
159+
160+ Audio {
161+ id: audioPlayer
162+ source: uri
163+ property real percent: audioPlayer.position * 100 / audioPlayer.duration
164+ onPositionChanged: print("got percent", percent, position, duration)
165+
166+ }
167+ Connections {
168+ target: trackRepeater
169+ onStopPlayback: audioPlayer.stop();
170+ }
171+ }
172+ }
173+ }
174+ }
175+}