Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0
-
None
-
Ubuntu 22.04.2 LTS
Gnome Version 42.5
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:
- Set Ubuntu to Dark-Mode via GUI.
- Build widget_gallery with Qt 6.5 with above patch
- 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.