on xenial help sign in
moved inline video to old files
commit3e0fd99531f722ca583b6c5c5799258ec1a1ff23 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 8 Jul 2015, 10:45 (11 years ago) parente9a3155
6 files changed+79−255
qml/Dash/Previews/PreviewInlineVideo.qml−89 qml/Dash/Previews/PreviewVideoPlayback.qml+15−41 qml/Dash/Previews/PreviewWidgetFactory.qml+1−1 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml−106 tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml+62−17
qml/Dash/Previews/PreviewInlineVideo.qmldeleted−89
@@ -1,89 +0,0 @@
1−/*
2− * Copyright (C) 2015 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 1.2
20−import Ubuntu.Thumbnailer 0.1
21−//import Ubuntu.Content 0.1
22−import "../../Components/MediaServices"
23−
24−/*! \brief Preview widget for video.
25−
26− This widget shows video contained in widgetData["source"],
27− with a placeholder screenshot specified by widgetData["screenshot"].
28− */
29−
30−PreviewWidget {
31− id: root
32− implicitWidth: units.gu(35)
33− implicitHeight: services.height
34−
35− property alias rootItem: services.rootItem
36−
37− MediaServices {
38− id: services
39− width: parent.width
40−
41− context: "video"
42− sourceData: root.isCurrentPreview ? widgetData : undefined
43− fullscreen: false
44− maximumEmbeddedHeight: rootItem.height / 2
45−
46− onClose: fullscreen = false
47−
48−// actions: [
49−// Action {
50−// text: i18n.tr("Share")
51−// iconSource: "image://theme/share"
52−// onTriggered: sharePicker.visible = true
53−// }
54−// ]
55− }
56−
57−// Component {
58−// id: contentItemComp
59−// ContentItem {
60−// url: widgetData["source"]
61−// }
62−// }
63−// ContentPeerPicker {
64−// id: sharePicker
65−// objectName: "sharePickerEvents"
66−// anchors.fill: parent
67−// showTitle: false
68−// visible: false
69−// parent: rootItem
70−// z: 100
71−
72−// contentType: ContentType.Videos
73−// handler: ContentHandler.Share
74−
75−// onPeerSelected: {
76−// visible = false;
77−
78−// var curTransfer = peer.request();
79−// if (curTransfer.state === ContentTransfer.InProgress)
80−// {
81−// var medias = [ contentItemComp.createObject(parent) ]
82−// curTransfer.state = ContentTransfer.Charged;
83−// }
84−// }
85−// onCancelPressed: {
86−// visible = false;
87−// }
88−// }
89−}
qml/Dash/Previews/PreviewVideoPlayback.qml+15−41
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -15,9 +15,11 @@
1515 */
1616
1717import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import QtMultimedia 5.0
19+import Ubuntu.Components 1.2
1920import Ubuntu.Thumbnailer 0.1
20−import "../../Components"
21+//import Ubuntu.Content 0.1
22+import "../../Components/MediaServices"
2123
2224/*! \brief Preview widget for video.
2325
@@ -28,47 +30,19 @@ import "../../Components"
2830PreviewWidget {
2931 id: root
3032 implicitWidth: units.gu(35)
31− implicitHeight: childrenRect.height
33+ implicitHeight: services.height
3234
33− LazyImage {
34− objectName: "screenshot"
35− anchors {
36− left: parent.left
37− right: parent.right
38− }
39− scaleTo: "width"
40− source: {
41− var screenshot = widgetData["screenshot"];
42− if (screenshot) return screenshot;
35+ property alias rootItem: services.rootItem
4336
44− var source = widgetData["source"];
45− if (source) {
46− if (source.toString().indexOf("file://") === 0) {
47− return "image://thumbnailer/" + source.toString().substr(7);
48− }
49− }
37+ MediaServices {
38+ id: services
39+ width: parent.width
5040
51− return "";
52− }
53− initialHeight: width * 10 / 16
41+ context: "video"
42+ sourceData: root.isCurrentPreview ? widgetData : undefined
43+ fullscreen: false
44+ maximumEmbeddedHeight: rootItem.height / 2
5445
55− Image {
56− objectName: "playButton"
57−
58− readonly property bool bigButton: parent.width > units.gu(40)
59−
60− anchors.centerIn: parent
61− width: bigButton ? units.gu(8) : units.gu(4.5)
62− height: width
63− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
64− visible: parent.state === "ready"
65− }
66−
67− MouseArea {
68− enabled: parent.state === "ready"
69− id: previewImageMouseArea
70− anchors.fill: parent
71− onClicked: Qt.openUrlExternally(widgetData["source"])
72− }
46+ onClose: fullscreen = false
7347 }
7448}
qml/Dash/Previews/PreviewWidgetFactory.qml+1−1
@@ -61,7 +61,7 @@ Loader {
6161 case "reviews": return "PreviewRatingDisplay.qml";
6262 case "table": return "PreviewTable.qml";
6363 case "text": return "PreviewTextSummary.qml";
64− case "video": return "PreviewInlineVideo.qml";
64+ case "video": return "PreviewVideoPlayback.qml";
6565 default: return "";
6666 }
6767 }
tests/qmltests/CMakeLists.txt+1−1
@@ -10,6 +10,7 @@ add_unity8_qmltest(Components Dialogs LIGHTDM)
1010add_unity8_qmltest(Components DraggingArea)
1111add_unity8_qmltest(Components LazyImage)
1212add_unity8_qmltest(Components Lockscreen)
13+add_unity8_qmltest(Components MediaServices)
1314add_unity8_qmlunittest(Components PhysicalKeysMapper)
1415add_unity8_qmltest(Components Rating)
1516add_unity8_qmltest(Components ResponsiveGridView)
@@ -30,7 +31,6 @@ add_unity8_qmltest(Dash/Previews PreviewAudioPlayback)
3031add_unity8_qmltest(Dash/Previews PreviewExpandable)
3132add_unity8_qmltest(Dash/Previews PreviewHeader)
3233add_unity8_qmltest(Dash/Previews PreviewImageGallery)
33−add_unity8_qmltest(Dash/Previews PreviewInlineVideo)
3434add_unity8_qmltest(Dash/Previews PreviewPayments)
3535add_unity8_qmltest(Dash/Previews PreviewProgress)
3636add_unity8_qmltest(Dash/Previews PreviewRatingDisplay)
tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qmldeleted−106
@@ -1,106 +0,0 @@
1−/*
2− * Copyright 2015 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 "../../../../qml/Dash/Previews"
20−import Unity.Test 0.1 as UT
21−import Ubuntu.Components 1.2
22−import QtMultimedia 5.0
23−
24−Rectangle {
25− width: units.gu(70)
26− height: units.gu(80)
27− color: "lightgrey"
28−
29− property var widgetData0: {
30− "source": "file:///test-video1",
31− "screenshot": Qt.resolvedUrl("../artwork/avatar.png")
32− }
33−
34− property var widgetData1: {
35− "source": "file:///test-video2",
36− "screenshot": "file:///test-video2-screenshot"
37− }
38−
39− MediaDataSource {
40− source: "file:///test-video1"
41− duration: 6000000
42− metaData: {
43− "title" : "TEST MPEG",
44− "resolution" : { "width": 1920, "height": 1080 }
45− }
46− }
47−
48− Item {
49− anchors.fill: parent
50−
51− Item {
52− id: inner
53− anchors {
54− top: parent.top
55− bottom: parent.bottom
56− left: parent.left
57− right: controls.left
58− }
59−
60− Item {
61− anchors.fill: parent
62− anchors.margins: units.gu(2)
63−
64− PreviewInlineVideo {
65− id: videoPlayback
66− width: parent.width
67− widgetData: widgetData0
68−
69− rootItem: inner
70− }
71− }
72−
73− }
74−
75− Rectangle {
76− id: controls
77− color: "darkgrey"
78− anchors {
79− top: parent.top
80− bottom: parent.bottom
81− right: parent.right
82− }
83− width: units.gu(30)
84−
85− Column {
86− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
87−
88− UT.MouseTouchEmulationCheckbox {}
89− }
90− }
91− }
92−
93− UT.UnityTestCase {
94− name: "PreviewInlineVideoTest"
95− when: windowShown
96−
97− function test_loadScreenshot() {
98− var screenshot = findChild(videoPlayback, "screenshot");
99− verify(screenshot !== null);
100−
101− videoPlayback.widgetData = widgetData1;
102− var screenshotSource = screenshot.source
103− compare(screenshotSource.toString(), "file:///test-video2-screenshot");
104− }
105− }
106−}
tests/qmltests/Dash/Previews/tst_PreviewVideoPlayback.qml+62−17
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2014 Canonical Ltd.
2+ * Copyright 2015 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -18,44 +18,89 @@ import QtQuick 2.0
1818import QtTest 1.0
1919import "../../../../qml/Dash/Previews"
2020import Unity.Test 0.1 as UT
21+import Ubuntu.Components 1.2
22+import QtMultimedia 5.0
2123
2224Rectangle {
23− id: root
24− width: units.gu(40)
25+ width: units.gu(70)
2526 height: units.gu(80)
2627 color: "lightgrey"
2728
2829 property var widgetData0: {
29− "source": "",
30− "screenshot": ""
30+ "source": "file:///test-video1",
31+ "screenshot": Qt.resolvedUrl("../artwork/avatar.png")
3132 }
3233
3334 property var widgetData1: {
34− "source": "",
35− "screenshot": "../../../tests/qmltests/Components/tst_LazyImage/square.png"
35+ "source": "file:///test-video2",
36+ "screenshot": "file:///test-video2-screenshot"
3637 }
3738
38− property var widgetData2: {
39− "source": "file:///path/to/local/file",
40− "screenshot": ""
39+ MediaDataSource {
40+ source: "file:///test-video1"
41+ duration: 6000000
42+ metaData: {
43+ "title" : "TEST MPEG",
44+ "resolution" : { "width": 1920, "height": 1080 }
45+ }
4146 }
4247
43− PreviewVideoPlayback {
44− id: videoPlayback
45− width: parent.width
46− widgetData: widgetData1
48+ Item {
49+ anchors.fill: parent
50+
51+ Item {
52+ id: inner
53+ anchors {
54+ top: parent.top
55+ bottom: parent.bottom
56+ left: parent.left
57+ right: controls.left
58+ }
59+
60+ Item {
61+ anchors.fill: parent
62+ anchors.margins: units.gu(2)
63+
64+ PreviewVideoPlayback {
65+ id: videoPlayback
66+ width: parent.width
67+ widgetData: widgetData0
68+
69+ rootItem: inner
70+ }
71+ }
72+
73+ }
74+
75+ Rectangle {
76+ id: controls
77+ color: "darkgrey"
78+ anchors {
79+ top: parent.top
80+ bottom: parent.bottom
81+ right: parent.right
82+ }
83+ width: units.gu(30)
84+
85+ Column {
86+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
87+
88+ UT.MouseTouchEmulationCheckbox {}
89+ }
90+ }
4791 }
4892
4993 UT.UnityTestCase {
50− name: "PreviewVideoPlaybackTest"
94+ name: "PreviewInlineVideoTest"
5195 when: windowShown
5296
5397 function test_loadScreenshot() {
5498 var screenshot = findChild(videoPlayback, "screenshot");
99+ verify(screenshot !== null);
55100
56− videoPlayback.widgetData = widgetData2;
101+ videoPlayback.widgetData = widgetData1;
57102 var screenshotSource = screenshot.source
58− verify(screenshotSource.toString().indexOf("image://thumbnailer/") === 0)
103+ compare(screenshotSource.toString(), "file:///test-video2-screenshot");
59104 }
60105 }
61106}