From cd4cad75513b3397870bbc135684329cdf808686 Mon Sep 17 00:00:00 2001 From: Doug Massay Date: Fri, 3 May 2024 18:03:05 -0400 Subject: [PATCH] Further refine IsDarkMode test --- src/Misc/Utility.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Misc/Utility.cpp b/src/Misc/Utility.cpp index 3d7ec175ed..610c8a1beb 100644 --- a/src/Misc/Utility.cpp +++ b/src/Misc/Utility.cpp @@ -137,21 +137,16 @@ QString Utility::DefinePrefsDir() bool Utility::IsDarkMode() { -#ifdef Q_OS_MAC +#if defined(Q_OS_MAC) MainApplication *mainApplication = qobject_cast(qApp); return mainApplication->isDarkMode(); -#else // Windows, Linux and Other platforms -#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) - if (qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark) { - return true; - } - return false; -#else // less than Qt6.5.0 +#elif defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + return qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark; +#else // Windows less than Qt6.5.0 and ALL Linux QPalette app_palette = qApp->palette(); bool isdark = app_palette.color(QPalette::Active,QPalette::WindowText).lightness() > 128; return isdark; #endif -#endif } bool Utility::IsWindowsSysDarkMode()