Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83055

Simplify orientation APIs in Qt 6

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • GUI: Window management
    • 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.apple.com/documentation/bundleresources/information_property_list/uisupportedinterfaceorientations?language=objc#

      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

          For Gerrit Dashboard: QTBUG-83055
          # Subject Branch Project Status CR V

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes