on xenial help sign in
more preview fixes
commit0c6a895e5b06351682db93056ecbe7599d2e3290 authorNick Dedekind <nick.dedekind@canonical.com> dateTue 26 May 2015, 14:17 (11 years ago) parent148f507
7 files changed+105−77
qml/Components/MediaServices/MediaServices.qml+16−11 qml/Components/MediaServices/VideoPlayerControls.qml+24−13 qml/Dash/GenericScopeView.qml+1 qml/Dash/Previews/PreviewInlineVideo.qml+38−39 tests/mocks/QtMultimedia/VideoSurface.qml+9−4 tests/mocks/QtMultimedia/mediaplayer.cpp+1−1 tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+16−9
qml/Components/MediaServices/MediaServices.qml+16−11
@@ -36,11 +36,7 @@ FocusScope {
3636 if (fullscreen && parent) {
3737 return parent.height;
3838 }
39− return contentLoader.height
40− }
41− Behavior on implicitHeight {
42− enabled: fullscreen
43− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
39+ return content ? content.implicitHeight : parent.height
4440 }
4541
4642 onFullscreenChanged: {
@@ -90,11 +86,7 @@ FocusScope {
9086 objectName: "videoPlayer"
9187
9288 width: orientationHelper.width
93− height: fullscreen ? orientationHelper.height : implicitHeight
94− Behavior on height {
95− enabled: !fullscreen
96− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
97− }
89+ height: orientationHelper.height
9890
9991 fixedHeight: fullscreen
10092 orientation: orientationHelper.state == "portrait" ? Qt.PortraitOrientation : Qt.LandscapeOrientation
@@ -214,6 +206,8 @@ FocusScope {
214206 userActions: root.actions
215207
216208 mediaPlayer.source: {
209+ if (!root.sourceData) return "";
210+
217211 var x = root.sourceData["source"];
218212 if (x.toString().indexOf("video://") === 0) {
219213 return x.toString().substr(6);
@@ -308,13 +302,24 @@ FocusScope {
308302
309303 StateGroup {
310304 states: [
305+ State {
306+ name: "minimized"
307+ when: !priv.fullscreen
308+ },
311309 State {
312310 name: "fullscreen"
313311 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 }
315313 PropertyChanges { target: fullscreenAction; iconName: "view-restore" }
316314 }
317315 ]
316+
317+ transitions: Transition {
318+ ParentAnimation {
319+ UbuntuNumberAnimation { properties: "x,y,width,height"; duration: UbuntuAnimation.FastDuration }
320+ }
321+ }
322+
318323 }
319324
320325 QtObject {
qml/Components/MediaServices/VideoPlayerControls.qml+24−13
@@ -12,15 +12,26 @@ MediaServicesControls {
1212 QtObject {
1313 id: priv
1414
15− function formatTime(position) {
16− var pos = (position/1000).toFixed(0)
17−
18− var m = Math.floor(pos/60);
19− var ss = pos % 60;
20− if (ss >= 10) {
21− return m + ":" + ss;
15+ function formatProgress(time) {
16+ time = Math.floor(time / 1000);
17+
18+ var secs = time % 60;
19+ time = Math.floor(time / 60);
20+ var min = time % 60;
21+ var hour = Math.floor(time / 60);
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);
2230 } 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);
2435 }
2536 }
2637 }
@@ -35,7 +46,7 @@ MediaServicesControls {
3546 slider.value = mediaPlayer.position;
3647 slider.valueGuard = false;
3748 if (!slider.pressed) {
38− positionLabel.text = priv.formatTime(mediaPlayer.position);
49+ positionLabel.text = priv.formatProgress(mediaPlayer.position);
3950 }
4051 }
4152 }
@@ -57,7 +68,7 @@ MediaServicesControls {
5768 fontSize: "x-small"
5869 color: "#F3F3E7"
5970
60− text: priv.formatTime(mediaPlayer.position)
71+ text: priv.formatProgress(mediaPlayer.position)
6172 }
6273
6374 Slider {
@@ -96,7 +107,7 @@ MediaServicesControls {
96107 mediaPlayer.pause();
97108 } else {
98109
99− positionLabel.text = priv.formatTime(mediaPlayer.position);
110+ positionLabel.text = priv.formatProgress(mediaPlayer.position);
100111 if (wasPlaying) {
101112 mediaPlayer.play();
102113 }
@@ -104,7 +115,7 @@ MediaServicesControls {
104115 }
105116
106117 function formatValue(value) {
107− return priv.formatTime(value);
118+ return priv.formatProgress(value);
108119 }
109120 }
110121
@@ -118,7 +129,7 @@ MediaServicesControls {
118129 fontSize: "x-small"
119130 color: "#F3F3E7"
120131
121− text: priv.formatTime(mediaPlayer.duration)
132+ text: priv.formatProgress(mediaPlayer.duration)
122133 }
123134 }
124135
qml/Dash/GenericScopeView.qml+1
@@ -755,6 +755,7 @@ FocusScope {
755755 item.open = Qt.binding(function() { return subPageLoader.open; } )
756756 item.initialIndex = Qt.binding(function() { return subPageLoader.initialIndex; } )
757757 item.model = Qt.binding(function() { return subPageLoader.model; } )
758+ item.currentIndex = subPageLoader.initialIndex;
758759 }
759760 open = true;
760761 }
qml/Dash/Previews/PreviewInlineVideo.qml+38−39
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import QtMultimedia 5.0
1919import Ubuntu.Components 0.1
2020import Ubuntu.Thumbnailer 0.1
21−import Ubuntu.Content 0.1
21+//import Ubuntu.Content 0.1
2222import "../../Components/MediaServices"
2323
2424/*! \brief Preview widget for video.
@@ -39,51 +39,50 @@ PreviewWidget {
3939 width: parent.width
4040
4141 context: "video"
42− sourceData: widgetData
42+ sourceData: root.isCurrentPreview ? widgetData : undefined
4343 fullscreen: false
4444
4545 onClose: fullscreen = false
4646
47− actions: [
48− Action {
49− text: i18n.tr("Share")
50− iconSource: "image://theme/share"
51− onTriggered: sharePicker.visible = true
52− }
53− ]
47+// actions: [
48+// Action {
49+// text: i18n.tr("Share")
50+// iconSource: "image://theme/share"
51+// onTriggered: sharePicker.visible = true
52+// }
53+// ]
5454 }
5555
56− Component {
57− id: contentItemComp
58− ContentItem {
59− url: widgetData["source"]
60− }
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
56+// Component {
57+// id: contentItemComp
58+// ContentItem {
59+// url: widgetData["source"]
60+// }
61+// }
62+// ContentPeerPicker {
63+// id: sharePicker
64+// objectName: "sharePickerEvents"
65+// anchors.fill: parent
66+// showTitle: false
67+// visible: false
68+// parent: rootItem
69+// z: 100
7170
72− contentType: ContentType.Videos
73− handler: ContentHandler.Share
71+// contentType: ContentType.Videos
72+// handler: ContentHandler.Share
7473
75− onPeerSelected: {
76− visible = false;
74+// onPeerSelected: {
75+// visible = false;
7776
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− }
77+// var curTransfer = peer.request();
78+// if (curTransfer.state === ContentTransfer.InProgress)
79+// {
80+// var medias = [ contentItemComp.createObject(parent) ]
81+// curTransfer.state = ContentTransfer.Charged;
82+// }
83+// }
84+// onCancelPressed: {
85+// visible = false;
86+// }
87+// }
8988}
tests/mocks/QtMultimedia/VideoSurface.qml+9−4
@@ -29,18 +29,23 @@ Rectangle {
2929
3030 GridView {
3131 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))
3333 clip: true
3434
35+ cellHeight: units.gu(5)
36+ cellWidth: units.gu(5)
37+
38+ onModelChanged: console.log("COUNT", model)
39+
3540 delegate: Item {
36− width: units.gu(10)
37− height: units.gu(10)
41+ width: units.gu(5)
42+ height: units.gu(5)
3843
3944 Rectangle {
4045 id: rect
4146 color: "red"
4247 anchors.fill: parent
43− anchors.margins: units.gu(2)
48+ anchors.margins: units.gu(1)
4449
4550 Connections {
4651 target: root
tests/mocks/QtMultimedia/mediaplayer.cpp+1−1
@@ -34,7 +34,7 @@ public:
3434 }
3535
3636 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)); }
3838
3939 QVariant getProperty(const QString& property, QVariant defaultValue = QVariant()) const {
4040 MediaDataSource* sourceData = MediaPlayerDataController::instance()->dataForSource(m_source->source());
tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+16−9
@@ -37,18 +37,19 @@ Rectangle {
3737 }
3838
3939 MediaDataSource {
40− source: "file:///home/nick/Videos/test-mpeg.ogv"
41− duration: 60000
40+ source: "file:///test-video1"
41+ duration: 6000000
4242 metaData: {
4343 "title" : "TEST MPEG",
44− "resolution" : { "width": 100, "height": 150 }
44+ "resolution" : { "width": 1920, "height": 1080 }
4545 }
4646 }
4747
4848 Item {
4949 anchors.fill: parent
5050
51− Rectangle {
51+ Item {
52+ id: inner
5253 anchors {
5354 top: parent.top
5455 bottom: parent.bottom
@@ -56,13 +57,19 @@ Rectangle {
5657 right: controls.left
5758 }
5859
59− PreviewInlineVideo {
60− id: videoPlayback
61− width: parent.width
62− widgetData: widgetData0
60+ Rectangle {
61+ anchors.fill: parent
62+ anchors.margins: units.gu(2)
63+
64+ PreviewInlineVideo {
65+ id: videoPlayback
66+ width: parent.width
67+ widgetData: widgetData0
6368
64− rootItem: parent
69+ rootItem: inner
70+ }
6571 }
72+
6673 }
6774
6875 Rectangle {