Merge lp:~jhodapp/mediaplayer-app/mediaplayer_new-orientation into lp:mediaplayer-app

Proposed by Jim Hodapp
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 58
Merged at revision: 57
Proposed branch: lp:~jhodapp/mediaplayer-app/mediaplayer_new-orientation
Merge into: lp:mediaplayer-app
Prerequisite: lp:~jhodapp/mediaplayer-app/mediaplayer_fix-launchpad-project-name
Diff against target: 140 lines (+12/-71)
3 files modified
debian/control (+0/-3)
src/mediaplayer.cpp (+7/-0)
src/qml/player.qml (+5/-68)
To merge this branch: bzr merge lp:~jhodapp/mediaplayer-app/mediaplayer_new-orientation
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+150811@code.launchpad.net

Commit message

* Greatly simplified UI orientation/rotation support based on Screen.orientation instead of directly using QtSensors.
* Removed the sensor related package dependencies since they're no longer required due to this functionality being moved into qtubuntu.
* Got rid of an unecessary debug statement and added useful comment to new orientation implementation.

Description of the change

* Greatly simplified UI orientation/rotation support based on Screen.orientation instead of directly using QtSensors.
* Removed the sensor related package dependencies since they're no longer required due to this functionality being moved into qtubuntu.
* Got rid of an unecessary debug statement and added useful comment to new orientation implementation.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

works nice, great job

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-02-27 14:39:24 +0000
3+++ debian/control 2013-02-27 14:39:24 +0000
4@@ -24,13 +24,10 @@
5 mediaplayerplugin-aal[armel],
6 mediaplayerplugin-aal[armhf],
7 libqt5declarative5-qtmultimedia-plugin,
8- libqt5sensors5,
9 qtdeclarative5-window-plugin,
10 qtdeclarative5-xmllistmodel-plugin,
11 qt-components-ubuntu,
12 libhud-qt-qml,
13- qtubuntu-sensors[armel],
14- qtubuntu-sensors[armhf],
15 gstreamer0.10-ffmpeg,
16 gstreamer0.10-plugins-base,
17 gstreamer0.10-plugins-good,
18
19=== modified file 'src/mediaplayer.cpp'
20--- src/mediaplayer.cpp 2013-02-12 21:35:22 +0000
21+++ src/mediaplayer.cpp 2013-02-27 14:39:24 +0000
22@@ -30,6 +30,7 @@
23 #include <QtDBus/QDBusInterface>
24 #include <QtDBus/QDBusReply>
25 #include <QtDBus/QDBusConnectionInterface>
26+#include <QScreen>
27 #include "config.h"
28
29 static void printUsage(const QStringList& arguments)
30@@ -94,6 +95,12 @@
31 connect(m_view, SIGNAL(heightChanged(int)), SLOT(onHeightChanged(int)));
32 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));
33
34+ // Set the orientation changes that this app is interested in being signaled about
35+ QGuiApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |
36+ Qt::LandscapeOrientation |
37+ Qt::InvertedPortraitOrientation |
38+ Qt::InvertedLandscapeOrientation);
39+
40 QUrl source(mediaPlayerDirectory() + "/qml/player.qml");
41 m_view->setSource(source);
42 m_view->setWidth(1200);
43
44=== modified file 'src/qml/player.qml'
45--- src/qml/player.qml 2013-02-20 23:47:09 +0000
46+++ src/qml/player.qml 2013-02-27 14:39:24 +0000
47@@ -22,7 +22,6 @@
48 import QtQuick 2.0
49 import QtQuick.Window 2.0
50 import QtMultimedia 5.0
51-import QtSensors 5.0
52 import Ubuntu.HUD 0.1 as HUD
53
54 Rectangle {
55@@ -43,6 +42,11 @@
56 }
57 }
58
59+ Screen.onOrientationChanged: {
60+ // Rotate the UI when the device orientation changes
61+ mediaPlayer.orientation = Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
62+ }
63+
64 Loader {
65 id: playerLoader
66 source: "player/VideoPlayer.qml"
67@@ -127,73 +131,6 @@
68 }
69 }
70 ]
71-
72- OrientationSensor {
73- id: orientationSensor
74- active: true
75-
76- // Causes the media player UI to rotate when the target device is rotated
77- onReadingChanged: {
78- setOrientation("sensor", reading.orientation)
79- }
80- }
81- }
82-
83- onNativeOrientationChanged: {
84- // Discover the device based on native orientation
85- // This is necessary because the Screen.currentOrientation does not notify
86- // about orientation changes and we need translate the sensors information
87- // TODO: remove it when "Screen.currentOrientation" get fixed
88- if (nativeOrientation == Qt.LandscapeOrientation)
89- formFactor = "tablet"
90- else
91- formFactor = "phone"
92-
93- setOrientation("qpa", nativeOrientation)
94- }
95-
96- function setOrientation(type, orient) {
97- var newOrientation = null
98- if (type === "sensor") {
99- // translate sensors information based on formFactor
100- switch (orient)
101- {
102- case OrientationReading.LeftUp:
103- if (formFactor == "tablet") {
104- newOrientation = Qt.InvertedPortraitOrientation
105- } else {
106- newOrientation = Qt.LandscapeOrientation
107- }
108- break;
109- case OrientationReading.RightUp:
110- if (formFactor == "tablet") {
111- newOrientation = Qt.PortraitOrientation
112- } else {
113- newOrientation = Qt.InvertedLandscapeOrientation
114- }
115- break;
116- case OrientationReading.TopUp:
117- if (formFactor == "tablet") {
118- newOrientation = Qt.LandscapeOrientation
119- } else {
120- newOrientation = Qt.PortraitOrientation
121- }
122- break;
123- case OrientationReading.TopDown:
124- if (formFactor == "tablet") {
125- newOrientation = Qt.InvertedLandscapeOrientation
126- } else {
127- newOrientation = Qt.InvertedPortraitOrientation
128- }
129- break;
130- }
131- } else {
132- newOrientation = orient
133- }
134-
135- if (newOrientation) {
136- mediaPlayer.orientation = Screen.angleBetween(Screen.primaryOrientation, newOrientation)
137- }
138 }
139
140 HUD.HUD {

Subscribers

People subscribed via source and target branches