From 724037bc0f7e01760ee3f94927bd1526fa48f2d7 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 18 Jan 2025 01:06:45 +0100 Subject: [PATCH] Fix applying darkmode in Qt Quick GUI on platforms with "darkmode flag" So far only tested on Windows with Qt 6.8.1 but it will hopefully also fix the same problem under Android. --- tray/gui/quick/app.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tray/gui/quick/app.cpp b/tray/gui/quick/app.cpp index 1dd4ffea..fde7a20f 100644 --- a/tray/gui/quick/app.cpp +++ b/tray/gui/quick/app.cpp @@ -133,7 +133,16 @@ App::App(bool insecure, QObject *parent) deletePipelineCache(); loadSettings(); applySettings(); + + // react to color scheme changes (whether "dark mode" is enabled) + // note: Doing this is actually problematic since we would apply whether dark mode is enabled before the application + // palette changes not taking any palette changes into account yet. Then, when the palette changes, we would also + // not take it into account anymore because the dark mode setting was already applied. So it make sense to only + // rely on reacting to palette changes by default. This may still be useful on platforms where Qt is not providing + // a palette matching the darkmode setting but where it can detect whether darkmode is enabled. +#ifdef SYNCTHING_APP_HANDLE_DARK_MODE_CHANGED_EXPLICITLY QtUtilities::onDarkModeChanged([this](bool darkColorScheme) { applyDarkmodeChange(darkColorScheme, m_darkPalette); }, this); +#endif auto &iconManager = Data::IconManager::instance(); auto statusIconSettings = StatusIconSettings();