diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2012-06-05 14:17:24 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-06 07:41:17 +0200 |
commit | 80653bf4ce8d03f4af2fe8cc2f3751d32bd31d75 (patch) | |
tree | 92c8f2d94a8348e61651391f1aec0fdf2950c359 /src/gui/kernel/qscreen.cpp | |
parent | 09001e72dc527cb50d84c15d7afdfb4b4116c883 (diff) |
Added QScreen::setOrientationUpdateMask().
It might be too expensive to always have an accelerometer sensor
running, so introduce API so that the application has to explictly ask
to get the orientation updates it's interested in.
Change-Id: Ib7dc5ad8807718409f744ebef53f4476aa05175d
Reviewed-by: Ian Monroe <ian.monroe@nokia.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Reviewed-by: Kevin Ottens <kevin.ottens.qnx@kdab.com>
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 2e0df43e66..fe8b15e9a0 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -345,6 +345,35 @@ QRect QScreen::availableVirtualGeometry() const } /*! + Sets the orientations that the application is interested in receiving + updates for in conjunction with this screen. + + For example, to receive orientation() updates and thus have + orientationChanged() signals being emitted for LandscapeOrientation and + InvertedLandscapeOrientation, call setOrientationUpdateMask() with the + argument Qt::LandscapeOrientation | Qt::InvertedLandscapeOrientation. + + The default, 0, means no orientationChanged() signals are fired. +*/ +void QScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask) +{ + Q_D(QScreen); + d->orientationUpdateMask = mask; + d->platformScreen->setOrientationUpdateMask(mask); +} + +/*! + Returns the currently set orientation update mask. + + \sa setOrientationUpdateMask() +*/ +Qt::ScreenOrientations QScreen::orientationUpdateMask() const +{ + Q_D(const QScreen); + return d->orientationUpdateMask; +} + +/*! \property QScreen::orientation \brief the screen orientation @@ -353,6 +382,11 @@ QRect QScreen::availableVirtualGeometry() const will change based on the device is being held, and a desktop display might be rotated so that it's in portrait mode. + Changes to this property will be filtered by orientationUpdateMask(), + so in order to receive orientation updates the application must first + call setOrientationUpdateMask() with a mask of the orientations it wants + to receive. + Qt::PrimaryOrientation is never returned. \sa primaryOrientation(), orientationChanged() @@ -360,7 +394,7 @@ QRect QScreen::availableVirtualGeometry() const Qt::ScreenOrientation QScreen::orientation() const { Q_D(const QScreen); - return d->orientation == Qt::PrimaryOrientation ? primaryOrientation() : d->orientation; + return d->filteredOrientation; } /*! |