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

GnomeTheme colorScheme not being initialized

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.0
    • GUI: Look'n'Feel
    • None
    • Ubuntu 22.04.2 LTS
      Gnome Version 42.5
      X11
    • Linux/X11

    Description

      In qtbase/src/gui/platform/unix/qgenericunixthemes.cpp

      GnomeTheme colorScheme is not initalised.

      The value is set to Qt::ColorScheme::Unknown in the constructor, however, there is no initial read on this value before a GUI application is launch.

      A dbus connection is set up for watching the "SettingChanged" but not an initial read of the gtk theme.

       

      Apply the following patch to WidgetGallery example:

      --- a/./qtbase/examples/widgets/gallery/widgetgallery.cpp
      +++ b/./qtbase/examples/widgets/gallery/widgetgallery.cpp
      @@ -45,6 +45,8 @@
       #include <QTextStream>
       #include <QTimer>
       
      +#include <QStyleHints>
      +
       static inline QString className(const QObject *o)
       {
            return QString::fromUtf8(o->metaObject()->className());
      @@ -132,6 +134,14 @@ WidgetGallery::WidgetGallery(QWidget *parent)
           }
           styleComboBox->addItems(styleNames);
       
      +    QStyleHints *hints = QApplication::styleHints();
      +    connect(hints, &QStyleHints::colorSchemeChanged,
      +            this, [this](Qt::ColorScheme colorScheme) {
      +            qDebug() << colorScheme;
      +            setPalette(qApp->style()->standardPalette());
      +            } );
      +
      +
           auto styleLabel = createWidget1<QLabel>(tr("&Style:"), "styleLabel");
           styleLabel->setBuddy(styleComboBox);
      
      

       

      Example scenario: 

      1. Set Ubuntu to Dark-Mode via GUI.
      2. Build widget_gallery with Qt 6.5 with above patch
      3. Launch widget_gallery.

      Widget_gallery will open in "light" mode with color-scheme set to Qt::ColorScheme::Unknown.

       

      Opening "Appearance" in Ubuntu Settings will trigger "Setting Changed" and the widgets gallery will switch to Dark Mode.

      Switching to "light-mode" in Ubuntu Settings will toggle the widgets gallery back.

       

      But the initial system Settings for Dark Mode are ignored until the settings GUI is opened and "Appearance" is selected.

       

      The colorScheme value in GnomeTheme is missing an initial value being checked, unlike in the "refresh" function in the KdeTheme constructor.

       

      Attachments

        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
            louspe-linaro Louise Spellacy
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes