@@ -0,0 +1,163 @@
2+ * Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18+import Ubuntu.Components 0.1
20+import "../../Components"
25+ property bool ready: previewData ? true : false
26+ property bool playable: false
27+ property url url: ready ? previewData.image : ""
29+ title: root.ready ? previewData.title : ""
30+ previewWidthRatio: 0.6
32+ onPreviewImageClicked: {
34+ shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', root.fileUri);
38+ // TODO: replace this UbuntuShape with the Video component once that lands
40+ header: UbuntuShape {
42+ anchors.left: parent.left
43+ anchors.right: parent.right
49+ fillMode: Image.PreserveAspectCrop
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)
59+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
63+ id: previewImageMouseArea
65+ onClicked: root.previewImageClicked()
71+ objectName: "gridButtons"
72+ model: root.previewData.actions
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))
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)
84+ width: Math.max(units.gu(4), buttons.buttonWidth)
85+ height: buttons.buttonHeight
87+ text: modelData.displayName
88+ iconSource: modelData.iconHint
89+ iconPosition: "right"
92+ root.previewData.execute(modelData.id, { })
101+ maximumRating: 10 // FIXME: this should happen on the backend side
102+ rating: ready ? previewData.rating: 0
106+ text: ready ? previewData.description : ""
107+ color: Theme.palette.selected.backgroundText
111+ wrapMode: Text.WordWrap
118+ spacing: units.gu(1)
120+ property int firstColWidth: units.gu(9)
121+ property int secondColWidth: width - firstColWidth - spacing
123+ visible: directedLabel.visible
127+ horizontalAlignment: Text.AlignRight
128+ width: parent.firstColWidth
129+ text: i18n.tr("Directed by:")
139+ width: parent.secondColWidth
140+ text: ready ? previewData.subtitle : ""
143+ wrapMode: Text.WordWrap
154+ if (previewData.year) parts.push(previewData.year)
155+ //if (nfo.video.runtime) parts.push("%1 minutes".arg(nfo.video.runtime))
157+ return parts.join(", ");