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

Dark mode is not getting inherited visually but QStyleHints::colorScheme returns Dark

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8
    • GUI: Look'n'Feel
    • None
    • Linux/Wayland, Linux/X11

    Description

      https://imgur.com/a/yVjMQeZ

      It gets told through portal. Before 6.8 portal wasn't inherited at all and was always returning Dark based on theme name (even though it's not really dark unless I enable dark theme switch as you could see). It seems it's because Qt asks portal but doesn't synchronize gtk state to the value. This should make it to still inherit portal by force applying dark colors to gtk theme when portal says so but always return the value based on actual colors so colorScheme is always synchronized to the visual state (what should also fix QTBUG-123031):

      diff --git a/src/plugins/platformthemes/gtk3/qgtk3storage.cpp b/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
      index 2991212d03..7356bae278 100644
      --- a/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
      +++ b/src/plugins/platformthemes/gtk3/qgtk3storage.cpp
      @@ -364,14 +364,14 @@ void QGtk3Storage::populateMap()
       #if QT_CONFIG(dbus)
           // Prefer color scheme we get from xdg-desktop-portal as this is what GNOME
           // relies on these days
      -    newColorScheme = m_portalInterface->colorScheme();
      +    g_object_set(
      +        gtk_settings_get_default(),
      +        "gtk-application-prefer-dark-theme",
      +        gboolean(m_portalInterface->colorScheme() == Qt::ColorScheme::Dark),
      +        nullptr);
       #endif
       
      -    if (newColorScheme == Qt::ColorScheme::Unknown) {
      -        // Derive color scheme from theme name
      -        newColorScheme = newThemeName.contains("dark"_L1, Qt::CaseInsensitive)
      -                    ? Qt::ColorScheme::Dark : m_interface->colorSchemeByColors();
      -    }
      +    newColorScheme = m_interface->colorSchemeByColors();
       
           if (m_themeName == newThemeName && m_colorScheme == newColorScheme)
               return;
      
       

      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
              ilya-fedin Ilya Fedin
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes