on xenial help sign in
more preview fixes
0c6a895Nick Dedekind
qml/Components/MediaServices/MediaServices.qml+16−11
@@ -36,11 +36,7 @@ FocusScope {
36 if (fullscreen && parent) {
36 if (fullscreen && parent) {
37 return parent.height;
37 return parent.height;
38 }
38 }
39− return contentLoader.height
40− }
41− Behavior on implicitHeight {
39+ return content ? content.implicitHeight : parent.height
42− enabled: fullscreen
43− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
44 }
40 }
45
41
46 onFullscreenChanged: {
42 onFullscreenChanged: {
@@ -90,11 +86,7 @@ FocusScope {
90 objectName: "videoPlayer"
86 objectName: "videoPlayer"
91
87
92 width: orientationHelper.width
88 width: orientationHelper.width
93− height: fullscreen ? orientationHelper.height : implicitHeight
89+ height: orientationHelper.height
94− Behavior on height {
95− enabled: !fullscreen
96− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
97− }
98
90
99 fixedHeight: fullscreen
91 fixedHeight: fullscreen
100 orientation: orientationHelper.state == "portrait" ? Qt.PortraitOrientation : Qt.LandscapeOrientation
92 orientation: orientationHelper.state == "portrait" ? Qt.PortraitOrientation : Qt.LandscapeOrientation
@@ -214,6 +206,8 @@ FocusScope {
214 userActions: root.actions
206 userActions: root.actions
215
207
216 mediaPlayer.source: {
208 mediaPlayer.source: {
209+ if (!root.sourceData) return "";
210+
217 var x = root.sourceData["source"];
211 var x = root.sourceData["source"];
218 if (x.toString().indexOf("video://") === 0) {
212 if (x.toString().indexOf("video://") === 0) {
219 return x.toString().substr(6);
213 return x.toString().substr(6);
@@ -308,13 +302,24 @@ FocusScope {
308
302
309 StateGroup {
303 StateGroup {
310 states: [
304 states: [
305+ State {
306+ name: "minimized"
307+ when: !priv.fullscreen
308+ },
311 State {
309 State {
312 name: "fullscreen"
310 name: "fullscreen"
313 when: priv.fullscreen
311 when: priv.fullscreen
314− PropertyChanges { target: root; parent: rootItem }
312+ ParentChange { target: root; parent: rootItem; x: 0; y: 0; width: parent.width; height: parent.height }
315 PropertyChanges { target: fullscreenAction; iconName: "view-restore" }
313 PropertyChanges { target: fullscreenAction; iconName: "view-restore" }
316 }
314 }
317 ]
315 ]
316+
317+ transitions: Transition {
318+ ParentAnimation {
319+ UbuntuNumberAnimation { properties: "x,y,width,height"; duration: UbuntuAnimation.FastDuration }
320+ }
321+ }
322+
318 }
323 }
319
324
320 QtObject {
325 QtObject {
qml/Components/MediaServices/VideoPlayerControls.qml+24−13
@@ -12,15 +12,26 @@ MediaServicesControls {
12 QtObject {
12 QtObject {
13 id: priv
13 id: priv
14
14
15− function formatTime(position) {
15+ function formatProgress(time) {
16− var pos = (position/1000).toFixed(0)
16+ time = Math.floor(time / 1000);
17−
17+
18+ var secs = time % 60;
18− var m = Math.floor(pos/60);
19+ time = Math.floor(time / 60);
19− var ss = pos % 60;
20+ var min = time % 60;
20− if (ss >= 10) {
21+ var hour = Math.floor(time / 60);
21− return m + ":" + ss;
22+
23+ if (secs < 10) secs = "0%1".arg(secs);
24+ if (min < 10) min = "0%1".arg(min);
25+ if (hour > 0) {
26+ // TRANSLATORS: this refers to a duration/remaining time of the video in hours, minutes and seconds,
27+ // of which you can change the order.
28+ // %1 refers to hours, %2 refers to minutes and %3 refers to seconds.
29+ return i18n.tr("%1:%2:%3").arg(hour).arg(min).arg(secs);
22 } else {
30 } else {
23− return m + ":0" + ss;
31+ // TRANSLATORS: this refers to a duration/remaining time of the video in minutes and seconds,
32+ // of which you can change the order.
33+ // %1 refers to minutes and %2 refers to seconds.
34+ return i18n.tr("%1:%2").arg(min).arg(secs);
24 }
35 }
25 }
36 }
26 }
37 }
@@ -35,7 +46,7 @@ MediaServicesControls {
35 slider.value = mediaPlayer.position;
46 slider.value = mediaPlayer.position;
36 slider.valueGuard = false;
47 slider.valueGuard = false;
37 if (!slider.pressed) {
48 if (!slider.pressed) {
38− positionLabel.text = priv.formatTime(mediaPlayer.position);
49+ positionLabel.text = priv.formatProgress(mediaPlayer.position);
39 }
50 }
40 }
51 }
41 }
52 }
@@ -57,7 +68,7 @@ MediaServicesControls {
57 fontSize: "x-small"
68 fontSize: "x-small"
58 color: "#F3F3E7"
69 color: "#F3F3E7"
59
70
60− text: priv.formatTime(mediaPlayer.position)
71+ text: priv.formatProgress(mediaPlayer.position)
61 }
72 }
62
73
63 Slider {
74 Slider {
@@ -96,7 +107,7 @@ MediaServicesControls {
96 mediaPlayer.pause();
107 mediaPlayer.pause();
97 } else {
108 } else {
98
109
99− positionLabel.text = priv.formatTime(mediaPlayer.position);
110+ positionLabel.text = priv.formatProgress(mediaPlayer.position);
100 if (wasPlaying) {
111 if (wasPlaying) {
101 mediaPlayer.play();
112 mediaPlayer.play();
102 }
113 }
@@ -104,7 +115,7 @@ MediaServicesControls {
104 }
115 }
105
116
106 function formatValue(value) {
117 function formatValue(value) {
107− return priv.formatTime(value);
118+ return priv.formatProgress(value);
108 }
119 }
109 }
120 }
110
121
@@ -118,7 +129,7 @@ MediaServicesControls {
118 fontSize: "x-small"
129 fontSize: "x-small"
119 color: "#F3F3E7"
130 color: "#F3F3E7"
120
131
121− text: priv.formatTime(mediaPlayer.duration)
132+ text: priv.formatProgress(mediaPlayer.duration)
122 }
133 }
123 }
134 }
124
135
qml/Dash/GenericScopeView.qml+1
@@ -755,6 +755,7 @@ FocusScope {
755 item.open = Qt.binding(function() { return subPageLoader.open; } )
755 item.open = Qt.binding(function() { return subPageLoader.open; } )
756 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
756 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
757 item.model = Qt.binding(function() { return subPageLoader.model; } )
757 item.model = Qt.binding(function() { return subPageLoader.model; } )
758+ item.currentIndex = subPageLoader.initialIndex;
758 }
759 }
759 open = true;
760 open = true;
760 }
761 }
qml/Dash/Previews/PreviewInlineVideo.qml+38−39
@@ -18,7 +18,7 @@ import QtQuick 2.0
18import QtMultimedia 5.0
18import QtMultimedia 5.0
19import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
20import Ubuntu.Thumbnailer 0.1
20import Ubuntu.Thumbnailer 0.1
21−import Ubuntu.Content 0.1
21+//import Ubuntu.Content 0.1
22import "../../Components/MediaServices"
22import "../../Components/MediaServices"
23
23
24/*! \brief Preview widget for video.
24/*! \brief Preview widget for video.
@@ -39,51 +39,50 @@ PreviewWidget {
39 width: parent.width
39 width: parent.width
40
40
41 context: "video"
41 context: "video"
42− sourceData: widgetData
42+ sourceData: root.isCurrentPreview ? widgetData : undefined
43 fullscreen: false
43 fullscreen: false
44
44
45 onClose: fullscreen = false
45 onClose: fullscreen = false
46
46
47− actions: [
47+// actions: [
48− Action {
48+// Action {
49− text: i18n.tr("Share")
49+// text: i18n.tr("Share")
50− iconSource: "image://theme/share"
50+// iconSource: "image://theme/share"
51− onTriggered: sharePicker.visible = true
51+// onTriggered: sharePicker.visible = true
52− }
52+// }
53− ]
53+// ]
54 }
54 }
55
55
56− Component {
56+// Component {
57− id: contentItemComp
57+// id: contentItemComp
58− ContentItem {
58+// ContentItem {
59− url: widgetData["source"]
59+// url: widgetData["source"]
60− }
60+// }
61− }
61+// }
62−
63− ContentPeerPicker {
62+// ContentPeerPicker {
64− id: sharePicker
63+// id: sharePicker
65− objectName: "sharePickerEvents"
64+// objectName: "sharePickerEvents"
66− anchors.fill: parent
65+// anchors.fill: parent
67− showTitle: false
66+// showTitle: false
68− visible: false
67+// visible: false
69− parent: rootItem
68+// parent: rootItem
70− z: 100
69+// z: 100
71
70
72− contentType: ContentType.Videos
71+// contentType: ContentType.Videos
73− handler: ContentHandler.Share
72+// handler: ContentHandler.Share
74
73
75− onPeerSelected: {
74+// onPeerSelected: {
76− visible = false;
75+// visible = false;
77
76
78− var curTransfer = peer.request();
77+// var curTransfer = peer.request();
79− if (curTransfer.state === ContentTransfer.InProgress)
78+// if (curTransfer.state === ContentTransfer.InProgress)
80− {
79+// {
81− var medias = [ contentItemComp.createObject(parent) ]
80+// var medias = [ contentItemComp.createObject(parent) ]
82− curTransfer.state = ContentTransfer.Charged;
81+// curTransfer.state = ContentTransfer.Charged;
83− }
82+// }
84− }
83+// }
85− onCancelPressed: {
84+// onCancelPressed: {
86− visible = false;
85+// visible = false;
87− }
86+// }
88− }
87+// }
89}
88}
tests/mocks/QtMultimedia/VideoSurface.qml+9−4
@@ -29,18 +29,23 @@ Rectangle {
29
29
30 GridView {
30 GridView {
31 anchors.fill: parent
31 anchors.fill: parent
32− model: (parent.width * parent.height) / units.gu(10)
32+ model: (parent.width / units.gu(5)) * ((parent.height / units.gu(5) + 1))
33 clip: true
33 clip: true
34
34
35+ cellHeight: units.gu(5)
36+ cellWidth: units.gu(5)
37+
38+ onModelChanged: console.log("COUNT", model)
39+
35 delegate: Item {
40 delegate: Item {
36− width: units.gu(10)
41+ width: units.gu(5)
37− height: units.gu(10)
42+ height: units.gu(5)
38
43
39 Rectangle {
44 Rectangle {
40 id: rect
45 id: rect
41 color: "red"
46 color: "red"
42 anchors.fill: parent
47 anchors.fill: parent
43− anchors.margins: units.gu(2)
48+ anchors.margins: units.gu(1)
44
49
45 Connections {
50 Connections {
46 target: root
51 target: root
tests/mocks/QtMultimedia/mediaplayer.cpp+1−1
@@ -34,7 +34,7 @@ public:
34 }
34 }
35
35
36 QVariant title() const { return getProperty("title"); }
36 QVariant title() const { return getProperty("title"); }
37− QVariant resolution() const { return getProperty("resolution", QSize(160, 90)); }
37+ QVariant resolution() const { return getProperty("resolution", QSize(640, 640)); }
38
38
39 QVariant getProperty(const QString& property, QVariant defaultValue = QVariant()) const {
39 QVariant getProperty(const QString& property, QVariant defaultValue = QVariant()) const {
40 MediaDataSource* sourceData = MediaPlayerDataController::instance()->dataForSource(m_source->source());
40 MediaDataSource* sourceData = MediaPlayerDataController::instance()->dataForSource(m_source->source());
tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+16−9
@@ -37,18 +37,19 @@ Rectangle {
37 }
37 }
38
38
39 MediaDataSource {
39 MediaDataSource {
40− source: "file:///home/nick/Videos/test-mpeg.ogv"
40+ source: "file:///test-video1"
41− duration: 60000
41+ duration: 6000000
42 metaData: {
42 metaData: {
43 "title" : "TEST MPEG",
43 "title" : "TEST MPEG",
44− "resolution" : { "width": 100, "height": 150 }
44+ "resolution" : { "width": 1920, "height": 1080 }
45 }
45 }
46 }
46 }
47
47
48 Item {
48 Item {
49 anchors.fill: parent
49 anchors.fill: parent
50
50
51− Rectangle {
51+ Item {
52+ id: inner
52 anchors {
53 anchors {
53 top: parent.top
54 top: parent.top
54 bottom: parent.bottom
55 bottom: parent.bottom
@@ -56,13 +57,19 @@ Rectangle {
56 right: controls.left
57 right: controls.left
57 }
58 }
58
59
60+ Rectangle {
61+ anchors.fill: parent
62+ anchors.margins: units.gu(2)
63+
59− PreviewInlineVideo {
64+ PreviewInlineVideo {
60− id: videoPlayback
65+ id: videoPlayback
61− width: parent.width
66+ width: parent.width
62− widgetData: widgetData0
67+ widgetData: widgetData0
63
68
64− rootItem: parent
69+ rootItem: inner
70+ }
65 }
71 }
72+
66 }
73 }
67
74
68 Rectangle {
75 Rectangle {