Use old palette change detection method on Windows 10 and under
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 5 Nov 2024 08:02:32 +0000 (17:02 +0900)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 19 Nov 2024 13:09:05 +0000 (14:09 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/theme.cpp

index 2f9944b929fe8f79901f1c1847c275efc8dec910..e69c34922e14b56a80914772161073390049d8fb 100644 (file)
@@ -969,8 +969,15 @@ void Theme::connectToPaletteSignal()
 {
     if (!_paletteSignalsConnected) {
         if (const auto ptr = qobject_cast<QGuiApplication *>(QGuiApplication::instance())) {
-            connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged);
-            connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
+#ifdef Q_OS_WIN
+            // Windows 10 does not have proper dark mode support via Qt 6 so hack detection
+            if (!IsWindows11OrGreater()) {
+                connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::darkModeChanged);
+            } else
+#endif
+            {
+                connect(ptr->styleHints(), &QStyleHints::colorSchemeChanged, this, &Theme::darkModeChanged);
+            }
             _paletteSignalsConnected = true;
         }
     }