on xenial help sign in
drop video preview, replaced by movie preview
commitdb80e66299a42bb4a61c1663f8e4a2538a062990 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 1 Oct 2013, 10:06 (13 years ago) parent13e6008
3 files changed−291
Dash/Video/VideoPreview.qml−227 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Dash/Video/tst_VideoPreview.qml−63
Dash/Video/VideoPreview.qmldeleted−227
@@ -1,227 +0,0 @@
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 var item
26− property alias ready: nfo.ready
27− property bool playable: fileUri != ""
28− readonly property url fileUri: item ? item.fileUri : ""
29− property url url: item ? item.nfoUri.replace(/\.nfo$/, "-fanart.jpg") : ""
30−
31− VideoInfo {
32− id: nfo
33− source: item ? item.nfoUri : ""
34− }
35−
36− previewWidthRatio: 0.6
37−
38− onPreviewImageClicked: {
39− if (playable) {
40− shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', root.fileUri);
41− }
42− }
43−
44− // TODO: replace this UbuntuShape with the Video component once that lands
45− // with the player.
46− header: UbuntuShape {
47− id: urlLoader
48− anchors.left: parent.left
49− anchors.right: parent.right
50− height: width * previewImage.sourceSize.height / previewImage.sourceSize.width
51− radius: "medium"
52− image: Image {
53− id: previewImage
54− asynchronous: true
55− source: root.url
56− fillMode: Image.PreserveAspectCrop
57− }
58−
59− Image {
60− objectName: "playButton"
61− anchors.centerIn: parent
62− visible: root.playable
63− readonly property bool bigButton: parent.width > units.gu(40)
64− width: bigButton ? units.gu(8) : units.gu(4.5)
65− height: width
66− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
67− }
68−
69− MouseArea {
70− id: previewImageMouseArea
71− anchors.fill: parent
72− onClicked: root.previewImageClicked()
73− }
74− }
75−
76− title: Label {
77− id: title
78− objectName: "titleLabel"
79− anchors {
80− left: parent.left
81− right: parent.right
82− }
83−
84− elide: Text.ElideRight
85− fontSize: "x-large"
86− font.weight: Font.Light
87− color: Theme.palette.selected.backgroundText
88− opacity: 0.9
89− text: nfo.ready ? nfo.video.title : ""
90− style: Text.Raised
91− styleColor: "black"
92− }
93−
94− buttons: Row {
95− spacing: units.gu(2)
96−
97− property int buttonWidth: Math.min(units.gu(22), (width - spacing) / 2)
98− Button {
99− width: parent.buttonWidth
100− color: Theme.palette.selected.foreground
101− text: nfo.ready && nfo.video.buyPrice != "" ? "Buy for " + nfo.video.buyPrice : ""
102− visible: text != ""
103− iconSource: "graphics/icon_button_amazon.png"
104− iconPosition: "right"
105− }
106− Button {
107− width: parent.buttonWidth
108− color: Theme.palette.selected.foreground
109− text: nfo.ready && nfo.video.buyPrice != "" ? "Rent for " + nfo.video.rentPrice : ""
110− visible: text != ""
111− iconSource: "graphics/icon_button_u1.png"
112− iconPosition: "right"
113− }
114− }
115−
116− body: Column {
117− spacing: units.gu(2)
118− RatingStars {
119− maximumRating: 10 // FIXME: this should happen on the backend side
120− rating: nfo.ready ? nfo.video.rating: 0
121− }
122−
123− Label {
124− text: nfo.ready ? nfo.video.plot : ""
125− color: Theme.palette.selected.backgroundText
126− opacity: .6
127− fontSize: "medium"
128− width: parent.width
129− wrapMode: Text.WordWrap
130− style: Text.Raised
131− styleColor: "black"
132− }
133−
134− Grid {
135− columns: 2
136− spacing: units.gu(1)
137− width: parent.width
138− property int firstColWidth: units.gu(9)
139− property int secondColWidth: width - firstColWidth - spacing
140− Label {
141− visible: directedLabel.visible
142− fontSize: "small"
143− opacity: 0.9
144− color: "white"
145− horizontalAlignment: Text.AlignRight
146− width: parent.firstColWidth
147− text: i18n.tr("Directed by:")
148− style: Text.Raised
149− styleColor: "black"
150− }
151− Label {
152− id: directedLabel
153− visible: text != ""
154− fontSize: "small"
155− opacity: 0.6
156− color: "white"
157− width: parent.secondColWidth
158− text: nfo.ready ? nfo.video.director : ""
159− style: Text.Raised
160− styleColor: "black"
161− wrapMode: Text.WordWrap
162− }
163− Label {
164− visible: starringLabel.visible
165− fontSize: "small"
166− opacity: 0.9
167− horizontalAlignment: Text.AlignRight
168− color: "white"
169− width: parent.firstColWidth
170− text: i18n.tr("Starring:")
171− style: Text.Raised
172− styleColor: "black"
173− }
174− Label {
175− id: starringLabel
176− visible: text != ""
177− fontSize: "small"
178− opacity: 0.6
179− color: "white"
180− width: parent.secondColWidth
181− text: nfo.ready ? nfo.getActors().join(", ") : ""
182− wrapMode: Text.WordWrap
183− style: Text.Raised
184− styleColor: "black"
185− }
186− Label {
187− visible: authorLabel.visible
188− fontSize: "small"
189− opacity: 0.9
190− horizontalAlignment: Text.AlignRight
191− color: "white"
192− width: parent.firstColWidth
193− text: i18n.tr("Author:")
194− style: Text.Raised
195− styleColor: "black"
196− }
197− Label {
198− id: authorLabel
199− visible: text != ""
200− fontSize: "small"
201− opacity: 0.6
202− color: "white"
203− width: parent.secondColWidth
204− text: nfo.ready ? nfo.video.author : ""
205− wrapMode: Text.WordWrap
206− style: Text.Raised
207− styleColor: "black"
208− }
209− }
210−
211− Label {
212− fontSize: "small"
213− opacity: 0.6
214− color: "white"
215− text: {
216− var parts = []
217− if (nfo.ready) {
218− if (nfo.video.year) parts.push(nfo.video.year)
219− if (nfo.video.runtime) parts.push("%1 minutes".arg(nfo.video.runtime))
220− }
221− return parts.join(", ");
222− }
223− style: Text.Raised
224− styleColor: "black"
225− }
226− }
227−}
tests/qmltests/CMakeLists.txt−1
@@ -51,7 +51,6 @@ add_qml_test(Dash FilterGrids IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMA
5151 ${CMAKE_BINARY_DIR}/tests/mocks)
5252add_qml_test(Dash/Apps RunningApplicationsGrid IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5353add_qml_test(Dash/Apps AppPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
54−add_qml_test(Dash/Video VideoPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5554add_qml_test(Dash/Movie MoviePreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5655add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
5756 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
tests/qmltests/Dash/Video/tst_VideoPreview.qmldeleted−63
@@ -1,63 +0,0 @@
1−/*
2− * Copyright 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 QtTest 1.0
19−import "../../../../Dash/Video"
20−import Unity.Test 0.1 as UT
21−
22−Item {
23− id: root
24− width: units.gu(60)
25− height: units.gu(80)
26−
27− SignalSpy {
28− id: previewClickedSpy
29− target: preview
30− signalName: "previewImageClicked"
31− }
32−
33− // The component under test
34− VideoPreview {
35− id: preview
36− anchors.fill: parent
37− }
38−
39− UT.UnityTestCase {
40− name: "VideoPreview"
41− when: windowShown
42−
43− function test_play_button_data() {
44− return [
45− {tag: "playable", playable: true},
46− {tag: "not playable", playable: false}
47− ]
48− }
49−
50− function test_play_button(data) {
51− var playButton = findChild(preview, "playButton")
52− preview.playable = data.playable
53− compare(playButton.visible, data.playable)
54− }
55−
56− function test_play_button_click() {
57− preview.playable = true
58− var playButton = findChild(preview, "playButton")
59− mouseClick(playButton, 1, 1)
60− tryCompare(previewClickedSpy, "count", 1)
61− }
62− }
63−}