summaryrefslogtreecommitdiffstats
path: root/ui/qt/utils
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:15:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:15:53 +0000
commit41ee6846b4605bf50f1f5b12acffc71a76257e5d (patch)
tree78044e6ed77e26ebcdb14ac483f29d508d88a92d /ui/qt/utils
parentAdding debian version 4.2.5-2. (diff)
downloadwireshark-41ee6846b4605bf50f1f5b12acffc71a76257e5d.tar.xz
wireshark-41ee6846b4605bf50f1f5b12acffc71a76257e5d.zip
Merging upstream version 4.2.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ui/qt/utils')
-rw-r--r--ui/qt/utils/color_utils.cpp14
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();
}