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
=== modified file 'debian/control'
--- debian/control 2013-02-27 14:39:24 +0000
+++ debian/control 2013-02-27 14:39:24 +0000
@@ -24,13 +24,10 @@
24 mediaplayerplugin-aal[armel],24 mediaplayerplugin-aal[armel],
25 mediaplayerplugin-aal[armhf],25 mediaplayerplugin-aal[armhf],
26 libqt5declarative5-qtmultimedia-plugin,26 libqt5declarative5-qtmultimedia-plugin,
27 libqt5sensors5,
28 qtdeclarative5-window-plugin,27 qtdeclarative5-window-plugin,
29 qtdeclarative5-xmllistmodel-plugin,28 qtdeclarative5-xmllistmodel-plugin,
30 qt-components-ubuntu,29 qt-components-ubuntu,
31 libhud-qt-qml,30 libhud-qt-qml,
32 qtubuntu-sensors[armel],
33 qtubuntu-sensors[armhf],
34 gstreamer0.10-ffmpeg,31 gstreamer0.10-ffmpeg,
35 gstreamer0.10-plugins-base,32 gstreamer0.10-plugins-base,
36 gstreamer0.10-plugins-good,33 gstreamer0.10-plugins-good,
3734
=== modified file 'src/mediaplayer.cpp'
--- src/mediaplayer.cpp 2013-02-12 21:35:22 +0000
+++ src/mediaplayer.cpp 2013-02-27 14:39:24 +0000
@@ -30,6 +30,7 @@
30#include <QtDBus/QDBusInterface>30#include <QtDBus/QDBusInterface>
31#include <QtDBus/QDBusReply>31#include <QtDBus/QDBusReply>
32#include <QtDBus/QDBusConnectionInterface>32#include <QtDBus/QDBusConnectionInterface>
33#include <QScreen>
33#include "config.h"34#include "config.h"
3435
35static void printUsage(const QStringList& arguments)36static void printUsage(const QStringList& arguments)
@@ -94,6 +95,12 @@
94 connect(m_view, SIGNAL(heightChanged(int)), SLOT(onHeightChanged(int)));95 connect(m_view, SIGNAL(heightChanged(int)), SLOT(onHeightChanged(int)));
95 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));96 connect(m_view->engine(), SIGNAL(quit()), SLOT(quit()));
9697
98 // Set the orientation changes that this app is interested in being signaled about
99 QGuiApplication::primaryScreen()->setOrientationUpdateMask(Qt::PortraitOrientation |
100 Qt::LandscapeOrientation |
101 Qt::InvertedPortraitOrientation |
102 Qt::InvertedLandscapeOrientation);
103
97 QUrl source(mediaPlayerDirectory() + "/qml/player.qml");104 QUrl source(mediaPlayerDirectory() + "/qml/player.qml");
98 m_view->setSource(source);105 m_view->setSource(source);
99 m_view->setWidth(1200);106 m_view->setWidth(1200);
100107
=== modified file 'src/qml/player.qml'
--- src/qml/player.qml 2013-02-20 23:47:09 +0000
+++ src/qml/player.qml 2013-02-27 14:39:24 +0000
@@ -22,7 +22,6 @@
22import QtQuick 2.022import QtQuick 2.0
23import QtQuick.Window 2.023import QtQuick.Window 2.0
24import QtMultimedia 5.024import QtMultimedia 5.0
25import QtSensors 5.0
26import Ubuntu.HUD 0.1 as HUD25import Ubuntu.HUD 0.1 as HUD
2726
28Rectangle {27Rectangle {
@@ -43,6 +42,11 @@
43 }42 }
44 }43 }
4544
45 Screen.onOrientationChanged: {
46 // Rotate the UI when the device orientation changes
47 mediaPlayer.orientation = Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
48 }
49
46 Loader {50 Loader {
47 id: playerLoader51 id: playerLoader
48 source: "player/VideoPlayer.qml"52 source: "player/VideoPlayer.qml"
@@ -127,73 +131,6 @@
127 }131 }
128 }132 }
129 ]133 ]
130
131 OrientationSensor {
132 id: orientationSensor
133 active: true
134
135 // Causes the media player UI to rotate when the target device is rotated
136 onReadingChanged: {
137 setOrientation("sensor", reading.orientation)
138 }
139 }
140 }
141
142 onNativeOrientationChanged: {
143 // Discover the device based on native orientation
144 // This is necessary because the Screen.currentOrientation does not notify
145 // about orientation changes and we need translate the sensors information
146 // TODO: remove it when "Screen.currentOrientation" get fixed
147 if (nativeOrientation == Qt.LandscapeOrientation)
148 formFactor = "tablet"
149 else
150 formFactor = "phone"
151
152 setOrientation("qpa", nativeOrientation)
153 }
154
155 function setOrientation(type, orient) {
156 var newOrientation = null
157 if (type === "sensor") {
158 // translate sensors information based on formFactor
159 switch (orient)
160 {
161 case OrientationReading.LeftUp:
162 if (formFactor == "tablet") {
163 newOrientation = Qt.InvertedPortraitOrientation
164 } else {
165 newOrientation = Qt.LandscapeOrientation
166 }
167 break;
168 case OrientationReading.RightUp:
169 if (formFactor == "tablet") {
170 newOrientation = Qt.PortraitOrientation
171 } else {
172 newOrientation = Qt.InvertedLandscapeOrientation
173 }
174 break;
175 case OrientationReading.TopUp:
176 if (formFactor == "tablet") {
177 newOrientation = Qt.LandscapeOrientation
178 } else {
179 newOrientation = Qt.PortraitOrientation
180 }
181 break;
182 case OrientationReading.TopDown:
183 if (formFactor == "tablet") {
184 newOrientation = Qt.InvertedLandscapeOrientation
185 } else {
186 newOrientation = Qt.InvertedPortraitOrientation
187 }
188 break;
189 }
190 } else {
191 newOrientation = orient
192 }
193
194 if (newOrientation) {
195 mediaPlayer.orientation = Screen.angleBetween(Screen.primaryOrientation, newOrientation)
196 }
197 }134 }
198135
199 HUD.HUD {136 HUD.HUD {

Subscribers

People subscribed via source and target branches