File BMC13246_0001-New-MDeviceProfile-orientationFromAngle.patch of Package libmeegotouch
From c764ec102e26d4dc331a18d723512659149409f1 Mon Sep 17 00:00:00 2001
From: Daniel d'Andrada <daniel.dandrada@nokia.com>
Date: Fri, 18 Mar 2011 10:19:06 +0200
Subject: [PATCH 1/9] New: MDeviceProfile::orientationFromAngle()
RevBy: TrustMe
Details:
Part of fix for BMC#13264. Inspired by patches from Shane Bryan.
---
src/corelib/workspace/mdeviceprofile.cpp | 24 ++++++++++++++++++++++++
src/corelib/workspace/mdeviceprofile.h | 18 ++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/corelib/workspace/mdeviceprofile.cpp b/src/corelib/workspace/mdeviceprofile.cpp
index 3db9459..8617c13 100644
--- a/src/corelib/workspace/mdeviceprofile.cpp
+++ b/src/corelib/workspace/mdeviceprofile.cpp
@@ -225,6 +225,30 @@ bool MDeviceProfile::showStatusbar() const
return d->showStatusBar;
}
+M::Orientation MDeviceProfile::orientationFromAngle(M::OrientationAngle angle) const
+{
+ Q_D(const MDeviceProfile);
+ M::Orientation orientation;
+
+ if (d->resolution.width() >= d->resolution.height()) {
+ // native display orientation is landscape
+ if (angle == M::Angle0 || angle == M::Angle180) {
+ orientation = M::Landscape;
+ } else {
+ orientation = M::Portrait;
+ }
+ } else {
+ // native display orientation is portrait
+ if (angle == M::Angle0 || angle == M::Angle180) {
+ orientation = M::Portrait;
+ } else {
+ orientation = M::Landscape;
+ }
+ }
+
+ return orientation;
+}
+
bool MDeviceProfile::orientationAngleIsSupported(M::OrientationAngle angle, bool isKeyboardOpen) const
{
Q_D(const MDeviceProfile);
diff --git a/src/corelib/workspace/mdeviceprofile.h b/src/corelib/workspace/mdeviceprofile.h
index 8a13802..5a2dd7d 100644
--- a/src/corelib/workspace/mdeviceprofile.h
+++ b/src/corelib/workspace/mdeviceprofile.h
@@ -54,6 +54,24 @@ public:
//! Return whether the status bar should be shown on target device
bool showStatusbar() const;
+ /*!
+ \brief Returns the resulting orientation of a device for a given rotation angle.
+
+ The rotation is relative to the position where the device's display has its
+ top edge on top.
+
+ For devices whose display native resolution is landscape:
+ \li Angle0 and Angle180 are landscape angles.
+ \li Angle90 and Angle270 are portrait angles.
+
+ For devices whose display native resolution is portrait:
+ \li Angle0 and Angle180 are portrait angles.
+ \li Angle90 and Angle270 are landscape angles.
+
+ orientationFromAngle(M::Angle0) returns the display's native orientation.
+ */
+ M::Orientation orientationFromAngle(M::OrientationAngle angle) const;
+
//! Returns true if orientation angle is supported for given keyboard state.
bool orientationAngleIsSupported(M::OrientationAngle angle, bool isKeyboardOpen) const;
--
1.7.2.2