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] 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)