Details
-
Task
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
We have several APIs, which is a bit confusing.
QScreen::orientation
QScreen::orientationUpdateMask
QScreen::primaryOrientation
QScreen::nativeOrientation
QWindow::contentOrientation
QOrientationSensor
orientationUpdateMask was an old Nokia way for an application to control which orientations it's prepared to respond to; but that intention overlaps a bit with QWindow::contentOrientation. The implementation is such that orientationUpdateMask provides a way of ignoring orientation changes by filtering: you have to set the mask to the orientations that you want to be able to detect. If you don't do that, QScreen::orientation is constant by default. (One reason was it was believed to conserve battery life if the accelerometer can be turned off unless an application explicitly requests that the user be able to rotate content by holding the device in a different orientation.) But the current mobile platforms have other ways for an application to specify which orientations it supports:
https://developer.android.com/guide/topics/resources/runtime-changes
https://stackoverflow.com/questions/582185/how-to-disable-landscape-mode-in-android
So the mask is mostly an obstacle: you have to change the default, and then QScreen::orientation normally tells you the orientation from the window system perspective (how is the whole screen currently rotated), while we have a few bugs indicating that users expect QScreen::orientation to work by default. So the mask seems like an obvious candidate for removal.
QScreen::primaryOrientation can only return portrait or landscape, whereas QScreen::orientation can return any of the 4 possible orientations. So as long as QScreen::orientation works, primaryOrientation seems less useful. We could consider removing it if nobody has serious objections. It's roughly equivalent to check QScreen::height() > QScreen::width() for portrait orientation, otherwise it's landscape; that's easy in both QML and C++.
QScreen::nativeOrientation is newer, and mainly relevant to mobile and embedded devices, it seems. We can debate whether we still need it.
As long as the screen or window gets rotated automatically, most applications don't need QOrientationSensor; but it's useful at the system level (writing the window system). We should ensure that it's clear enough in the docs which API to use for what.
Attachments
Issue Links
- relates to
-
QTBUG-102194 Enable locking screen orientation programmatically
- Open
Gerrit Reviews
For Gerrit Dashboard: QTBUG-83055 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
295026,4 | Remove QScreen::orientationUpdateMask | dev | qt/qtbase | Status: MERGED | +2 | 0 |
295029,3 | Remove Screen.orientationUpdateMask | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
299769,2 | Remove uses of QScreen::orientationUpdateMask | dev | qt/qtwayland | Status: MERGED | +2 | 0 |
299778,1 | Remove uses of QScreen::orientationUpdateMask | dev | qt/qttools | Status: ABANDONED | +2 | 0 |