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

More properties to handle Light/Dark/System mode

    XMLWordPrintable

Details

    Description

      It'd be nice to have a property to read and write the following "requested mode"
      a) Fixed Light (regardless of system setting)
      b) Fixed Dark (regardless of system setting)
      c) Follow the system setting.

      e.g.

      ApplicationWindow.theme = ApplicationWindow.Dark // Light // System
      
      RadioButton {
      text: "Light"
      checked: ApplicationWindow.theme === ApplicationWindow.Light
      onClicked: ApplicationWindow.theme = ApplicationWindow.Light
      }
      
      RadioButton {
      text: "Dark"
      checked: ApplicationWindow.theme === ApplicationWindow.Dark
      onClicked: ApplicationWindow.theme = ApplicationWindow.Dark
      }
      
      RadioButton {
      text: "System"
      checked: ApplicationWindow.theme === ApplicationWindow.System
      onClicked: ApplicationWindow.theme = ApplicationWindow.System
      }
      

      It'd also like to have a READ only property that tells the "effective mode"
      In case a) it would give Light. In case b) it would give dark. In case c) it would give Light or Dark, depending on the system.

      e.g.

      Label {
      text: ApplicationWindow.effectTheme === ApplicationWindow.Light ? "Light" : "Dark"
      // effectiveTheme has only two possible values
      }
      

      For color bindings and theme mappings, we would naturally use the second property because it is binary in nature and we don't really need to know HOW
      the value was derived, just what it is. This property would appear most likely in numerous places as styles are designed.
      The three-way property would be seldom used, but is vital in being able to create a popup with three radio buttons with the three options in it to show
      and set the desired mode.
      The usage example can be seen in e.g. Gmail app Settings > General Settings > Theme

      It'd be nice to have these two properties somewhere e.g. in
      QQuickWindow or ApplicationWindow or in its attached property for QML use (or pushed further back in QWindow so it can be used with widgets too). Or, if it
      suits, a completely new public helper class with c++ and QML bindings.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              nagrohn Nahomi Gröhn (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes