@@ -0,0 +1,163 @@
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 ".."
20+import "../../Components"
21+
22+DashPreview {
23+ id: root
24+
25+ property bool ready: previewData ? true : false
26+ property bool playable: false
27+ property url url: ready ? previewData.image : ""
28+
29+ title: root.ready ? previewData.title : ""
30+ previewWidthRatio: 0.6
31+
32+ onPreviewImageClicked: {
33+ if (playable) {
34+ shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', root.fileUri);
35+ }
36+ }
37+
38+ // TODO: replace this UbuntuShape with the Video component once that lands
39+ // with the player.
40+ header: UbuntuShape {
41+ id: urlLoader
42+ anchors.left: parent.left
43+ anchors.right: parent.right
44+ radius: "medium"
45+ image: Image {
46+ id: previewImage
47+ asynchronous: true
48+ source: root.url
49+ fillMode: Image.PreserveAspectCrop
50+ }
51+
52+ Image {
53+ objectName: "playButton"
54+ anchors.centerIn: parent
55+ visible: root.playable
56+ readonly property bool bigButton: parent.width > units.gu(40)
57+ width: bigButton ? units.gu(8) : units.gu(4.5)
58+ height: width
59+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
60+ }
61+
62+ MouseArea {
63+ id: previewImageMouseArea
64+ anchors.fill: parent
65+ onClicked: root.previewImageClicked()
66+ }
67+ }
68+
69+ buttons: GridView {
70+ id: buttons
71+ objectName: "gridButtons"
72+ model: root.previewData.actions
73+
74+ property int numOfRows: (count + 1) / 2
75+ property int spacing: units.gu(1)
76+ height: Math.max(units.gu(4), units.gu(4)*numOfRows + spacing*(numOfRows - 1))
77+
78+ cellWidth: Math.max(units.gu(9), width / 2)
79+ cellHeight: buttonHeight + spacing
80+ property int buttonWidth: Math.max(0, width / 2 - spacing)
81+ property int buttonHeight: units.gu(4)
82+
83+ delegate: Button {
84+ width: Math.max(units.gu(4), buttons.buttonWidth)
85+ height: buttons.buttonHeight
86+ color: "#dd4814"
87+ text: modelData.displayName
88+ iconSource: modelData.iconHint
89+ iconPosition: "right"
90+ visible: true
91+ onClicked: {
92+ root.previewData.execute(modelData.id, { })
93+ }
94+ }
95+ focus: false
96+ }
97+
98+ body: Column {
99+ spacing: units.gu(2)
100+ RatingStars {
101+ maximumRating: 10 // FIXME: this should happen on the backend side
102+ rating: ready ? previewData.rating: 0
103+ }
104+
105+ Label {
106+ text: ready ? previewData.description : ""
107+ color: Theme.palette.selected.backgroundText
108+ opacity: .6
109+ fontSize: "medium"
110+ width: parent.width
111+ wrapMode: Text.WordWrap
112+ style: Text.Raised
113+ styleColor: "black"
114+ }
115+
116+ Grid {
117+ columns: 2
118+ spacing: units.gu(1)
119+ width: parent.width
120+ property int firstColWidth: units.gu(9)
121+ property int secondColWidth: width - firstColWidth - spacing
122+ Label {
123+ visible: directedLabel.visible
124+ fontSize: "small"
125+ opacity: 0.9
126+ color: "white"
127+ horizontalAlignment: Text.AlignRight
128+ width: parent.firstColWidth
129+ text: i18n.tr("Directed by:")
130+ style: Text.Raised
131+ styleColor: "black"
132+ }
133+ Label {
134+ id: directedLabel
135+ visible: text != ""
136+ fontSize: "small"
137+ opacity: 0.6
138+ color: "white"
139+ width: parent.secondColWidth
140+ text: ready ? previewData.subtitle : ""
141+ style: Text.Raised
142+ styleColor: "black"
143+ wrapMode: Text.WordWrap
144+ }
145+ }
146+
147+ Label {
148+ fontSize: "small"
149+ opacity: 0.6
150+ color: "white"
151+ text: {
152+ var parts = []
153+ if (ready) {
154+ if (previewData.year) parts.push(previewData.year)
155+ //if (nfo.video.runtime) parts.push("%1 minutes".arg(nfo.video.runtime))
156+ }
157+ return parts.join(", ");
158+ }
159+ style: Text.Raised
160+ styleColor: "black"
161+ }
162+ }
163+}