diff --git a/src/app/utilsadapter.cpp b/src/app/utilsadapter.cpp index 1e34bd33d65d3717449c312e7496d3880a8eb6d8..cb1fdd83c791aa668658f7ce708df4cf22498475 100644 --- a/src/app/utilsadapter.cpp +++ b/src/app/utilsadapter.cpp @@ -697,6 +697,12 @@ UtilsAdapter::isSystemThemeDark() return false; #else #if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>) +#if WATCHSYSTEMTHEME + if (!settings) { + settings = UISettings(); + settings.ColorValuesChanged([this](auto&&...) { Q_EMIT appThemeChanged(); }); + } +#endif return readAppsUseLightThemeRegistry(true); #else qWarning("System theme detection is not implemented or is not supported"); diff --git a/src/app/utilsadapter.h b/src/app/utilsadapter.h index 89fad25139d8d2ce09d162cab3e775fead1fc4e3..c0a520e5cdaca0b03da0a2f45def82d29f5ffc5c 100644 --- a/src/app/utilsadapter.h +++ b/src/app/utilsadapter.h @@ -35,6 +35,15 @@ #if defined(WIN32) && __has_include(<winrt/Windows.Foundation.h>) #include <winrt/Windows.Foundation.h> + +#define WATCHSYSTEMTHEME \ + __has_include(<winrt/Windows.UI.ViewManagement.h>) + +#if WATCHSYSTEMTHEME +#include <winrt/Windows.UI.ViewManagement.h> +#endif + +using winrt::Windows::UI::ViewManagement::UISettings; #endif class QClipboard; @@ -151,5 +160,9 @@ private: GSettings* settings {nullptr}; GSettingsSchema* schema {nullptr}; #endif + +#if WATCHSYSTEMTHEME + UISettings settings = NULL; +#endif }; Q_DECLARE_METATYPE(UtilsAdapter*)