on e97365d help sign in
unity8/Dash/Video/VideoPreview.qml
178 lines 5.7 kB history raw
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 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import ".."
20import "../../Components"
22DashPreview {
23 id: root
25 property var item
26 property alias ready: nfo.ready
27 readonly property url fileUri: item ? item.fileUri : ""
29 VideoInfo {
30 id: nfo
31 source: item ? item.nfoUri : ""
32 }
34 title: nfo.ready ? nfo.video.title : ""
35 url: item ? item.nfoUri.replace(/\.nfo$/, "-fanart.jpg") : ""
36 previewWidthRatio: 0.6
37 playable: fileUri != ""
39 onPreviewImageClicked: {
40 if (playable) {
41 shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', root.fileUri);
42 }
43 }
45 buttons: Row {
46 spacing: units.gu(2)
48 property int buttonWidth: Math.min(units.gu(22), (width - spacing) / 2)
49 Button {
50 width: parent.buttonWidth
51 color: "#dd4814"
52 text: nfo.ready && nfo.video.buyPrice != "" ? "Buy for " + nfo.video.buyPrice : ""
53 visible: text != ""
54 iconSource: "graphics/icon_button_amazon.png"
55 iconPosition: "right"
56 }
57 Button {
58 width: parent.buttonWidth
59 color: "#dd4814"
60 text: nfo.ready && nfo.video.buyPrice != "" ? "Rent for " + nfo.video.rentPrice : ""
61 visible: text != ""
62 iconSource: "graphics/icon_button_u1.png"
63 iconPosition: "right"
64 }
65 }
67 description: Column {
68 spacing: units.gu(2)
69 RatingStars {
70 maximumRating: 10 // FIXME: this should happen on the backend side
71 rating: nfo.ready ? nfo.video.rating: 0
72 }
74 Label {
75 text: nfo.ready ? nfo.video.plot : ""
76 color: "#f3f3e7"
77 opacity: .6
78 fontSize: "medium"
79 width: parent.width
80 wrapMode: Text.WordWrap
81 style: Text.Raised
82 styleColor: "black"
83 }
85 Grid {
86 columns: 2
87 spacing: units.gu(1)
88 width: parent.width
89 property int firstColWidth: units.gu(9)
90 property int secondColWidth: width - firstColWidth - spacing
91 Label {
92 visible: directedLabel.visible
93 fontSize: "small"
94 opacity: 0.9
95 color: "white"
96 horizontalAlignment: Text.AlignRight
97 width: parent.firstColWidth
98 text: i18n.tr("Directed by:")
99 style: Text.Raised
100 styleColor: "black"
101 }
102 Label {
103 id: directedLabel
104 visible: text != ""
105 fontSize: "small"
106 opacity: 0.6
107 color: "white"
108 width: parent.secondColWidth
109 text: nfo.ready ? nfo.video.director : ""
110 style: Text.Raised
111 styleColor: "black"
112 wrapMode: Text.WordWrap
113 }
114 Label {
115 visible: starringLabel.visible
116 fontSize: "small"
117 opacity: 0.9
118 horizontalAlignment: Text.AlignRight
119 color: "white"
120 width: parent.firstColWidth
121 text: i18n.tr("Starring:")
122 style: Text.Raised
123 styleColor: "black"
124 }
125 Label {
126 id: starringLabel
127 visible: text != ""
128 fontSize: "small"
129 opacity: 0.6
130 color: "white"
131 width: parent.secondColWidth
132 text: nfo.ready ? nfo.getActors().join(", ") : ""
133 wrapMode: Text.WordWrap
134 style: Text.Raised
135 styleColor: "black"
136 }
137 Label {
138 visible: authorLabel.visible
139 fontSize: "small"
140 opacity: 0.9
141 horizontalAlignment: Text.AlignRight
142 color: "white"
143 width: parent.firstColWidth
144 text: i18n.tr("Author:")
145 style: Text.Raised
146 styleColor: "black"
147 }
148 Label {
149 id: authorLabel
150 visible: text != ""
151 fontSize: "small"
152 opacity: 0.6
153 color: "white"
154 width: parent.secondColWidth
155 text: nfo.ready ? nfo.video.author : ""
156 wrapMode: Text.WordWrap
157 style: Text.Raised
158 styleColor: "black"
159 }
160 }
162 Label {
163 fontSize: "small"
164 opacity: 0.6
165 color: "white"
166 text: {
167 var parts = []
168 if (nfo.ready) {
169 if (nfo.video.year) parts.push(nfo.video.year)
170 if (nfo.video.runtime) parts.push("%1 minutes".arg(nfo.video.runtime))
171 }
172 return parts.join(", ");
173 }
174 style: Text.Raised
175 styleColor: "black"
176 }
177 }