From 688f45eb00cadd05a2834a389f0b9fce3ecddaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Thu, 18 Apr 2024 23:01:23 +0200 Subject: [PATCH 1/2] Windows: Set proper window title bar color Set proper window title bar color based on dark/light theme on Windows 10+ and Qt 5.15+ --- App/NatronApp_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/App/NatronApp_main.cpp b/App/NatronApp_main.cpp index 415c81924..cc0c23fb6 100644 --- a/App/NatronApp_main.cpp +++ b/App/NatronApp_main.cpp @@ -94,6 +94,14 @@ int main(int argc, char *argv[]) freopen("CONOUT$", "w", stderr); } } +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) + // Set proper window title bar color (https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5) + QSettings registry(QString::fromUtf8("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"), + QSettings::NativeFormat); + if (registry.value(QString::fromUtf8("AppsUseLightTheme"), 0).toInt() == 0) { + qputenv("QT_QPA_PLATFORM", "windows:darkmode=1"); + } +#endif #endif #if defined(Q_OS_UNIX) && defined(RLIMIT_NOFILE) From 3ced97f699b0253343cb6b06be4c8b81641e4d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 20 Apr 2024 19:08:43 +0200 Subject: [PATCH 2/2] Update NatronApp_main.cpp Update references for Windows dark/light theme detection. --- App/NatronApp_main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/App/NatronApp_main.cpp b/App/NatronApp_main.cpp index cc0c23fb6..229c934cc 100644 --- a/App/NatronApp_main.cpp +++ b/App/NatronApp_main.cpp @@ -95,7 +95,9 @@ int main(int argc, char *argv[]) } } #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) - // Set proper window title bar color (https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5) + // Set window title bar color based on dark/light theme + // https://www.qt.io/blog/dark-mode-on-windows-11-with-qt-6.5 + // https://learn.microsoft.com/en-us/answers/questions/1161597/how-to-detect-windows-application-dark-mode QSettings registry(QString::fromUtf8("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"), QSettings::NativeFormat); if (registry.value(QString::fromUtf8("AppsUseLightTheme"), 0).toInt() == 0) {