summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-10-04 13:11:30 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-07 22:23:30 +0200
commitc66b7cf55b6913dcf33d49d4f6bf9db51ccf39a8 (patch)
tree430983856f993de5618aa5d8d0198b2db98eda97 /src/gui/kernel/qevent.cpp
parent090d825e1d853a2ed875329a8350b0a727c3527e (diff)
Added Orientation API to QScreen and QWindow.
QScreen now has a primary and current orientation, and a QWindow can set its orientation as well. The current screen orientation is just a hint to the application. Change-Id: I4635982cfac2d16634d4edd5c6ab78e9d0ac55a4 Reviewed-on: http://codereview.qt-project.org/5988 Reviewed-by: Paul Olav Tvete <paul.tvete@nokia.com> Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp61
1 files changed, 8 insertions, 53 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index bbca4efd0c..7acb5f7ce5 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -4328,58 +4328,15 @@ const QScrollEventPrivate *QScrollEvent::d_func() const
}
/*!
- \enum QScreenOrientationChangeEvent::Orientation
-
- This enum describes the orientations that a device can have.
-
- \value Portrait The device is in a position where its top edge is pointing up.
-
- \value Landscape The device is rotated clockwise 90 degrees, so that its left edge is pointing up.
-
- \value PortraitInverted The device is rotated 180 degrees, so that its bottom edge is pointing up.
-
- \value LandscapeInverted The device is counterclockwise 90 degrees, so that its right edge is pointing up.
-
- \sa QScreenOrientationChangeEvent::orientation()
- \sa QScreenOrientationChangeEvent::orientationInDegrees()
-*/
-
-/*!
- Creates a new QScreenOrientationChangeEvent
- \a screenOrientationInDegrees is the new screen orientation, expressed in degrees.
- The orientation must be expressed in steps of 90 degrees.
-*/
-QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(qint32 screenOrientationInDegrees)
- : QEvent(QEvent::OrientationChange)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScreenOrientationChangeEventPrivate());
- d_func()->orientationInDegrees = screenOrientationInDegrees;
-
- qint32 orientationIndex = (qAbs(screenOrientationInDegrees) % 360) / 90;
- // flip around the negative coords to correct order.
- if (screenOrientationInDegrees < 0) {
- if (orientationIndex == 1)
- orientationIndex = 3;
- else if (orientationIndex == 3)
- orientationIndex = 1;
- }
-
- orientationIndex = qPow(2, orientationIndex);
- d_func()->orientation = (QScreenOrientationChangeEvent::Orientation)(orientationIndex);
- d_func()->isValid = (screenOrientationInDegrees % 90 == 0);
-}
-
-/*!
Creates a new QScreenOrientationChangeEvent
\a orientation is the new orientation of the screen.
*/
-QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreenOrientationChangeEvent::Orientation screenOrientation)
+QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
: QEvent(QEvent::OrientationChange)
{
d = reinterpret_cast<QEventPrivate *>(new QScreenOrientationChangeEventPrivate());
+ d_func()->screen = screen;
d_func()->orientation = screenOrientation;
- d_func()->orientationInDegrees = 90 * ((uint)screenOrientation);
- d_func()->isValid = true;
}
/*!
@@ -4391,21 +4348,19 @@ QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
}
/*!
- Returns the orientation of the screen.
+ Returns the screen whose orientation changed.
*/
-QScreenOrientationChangeEvent::Orientation QScreenOrientationChangeEvent::orientation() const
+QScreen *QScreenOrientationChangeEvent::screen() const
{
- return d_func()->orientation;
+ return d_func()->screen;
}
/*!
- Returns the screen orientation in degrees.
- The orientation is expressed in steps of 90 degrees and depends on the previous value of the orientation.
- This is intended to allow for smooth animations from one orientation to the other.
+ Returns the orientation of the screen.
*/
-qint32 QScreenOrientationChangeEvent::orientationInDegrees() const
+Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
{
- return d_func()->orientationInDegrees;
+ return d_func()->orientation;
}
/*!