diff options
Diffstat (limited to 'ui/qt/utils')
-rw-r--r-- | ui/qt/utils/color_utils.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ui/qt/utils/color_utils.cpp b/ui/qt/utils/color_utils.cpp index e7d7c6c5..e7e396d0 100644 --- a/ui/qt/utils/color_utils.cpp +++ b/ui/qt/utils/color_utils.cpp @@ -148,10 +148,16 @@ QRgb ColorUtils::sequenceColor(int item) bool ColorUtils::themeIsDark() { #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) - return qApp->styleHints()->colorScheme() == Qt::ColorScheme::Dark; -#else - return qApp->palette().windowText().color().lightness() > qApp->palette().window().color().lightness(); + switch (qApp->styleHints()->colorScheme()) { + case Qt::ColorScheme::Dark: + return true; + case Qt::ColorScheme::Light: + return false; + case Qt::ColorScheme::Unknown: + break; + } #endif + return qApp->palette().windowText().color().lightness() > qApp->palette().window().color().lightness(); } // Qt < 5.12.6 on macOS always uses Qt::blue for the link color, which is @@ -191,8 +197,10 @@ const QColor ColorUtils::contrastingTextColor(const QColor color) { bool background_is_light = color.lightness() > 127; if ( (background_is_light && !ColorUtils::themeIsDark()) || (!background_is_light && ColorUtils::themeIsDark()) ) { + // usually black/darker color in light mode and white/lighter color in dark mode return QApplication::palette().text().color(); } + // usually white/lighter color in light mode and black/darker color in dark mode return QApplication::palette().base().color(); } |