From 2003351fe2b03801535a7423e4f25aebb91a6a98 Mon Sep 17 00:00:00 2001 From: MCleinman <9295855+mcleinman@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:47:34 -0800 Subject: [PATCH] VPN-6064 - detect dark mode (#10131) * VPN-6064 - detect dark mode * make work on Linux running older Qt --- src/theme.cpp | 13 +++++++++++++ src/theme.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/theme.cpp b/src/theme.cpp index 7043ab9fc7..d87aa21f34 100644 --- a/src/theme.cpp +++ b/src/theme.cpp @@ -6,6 +6,10 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) +# include +# include +#endif #include "leakdetector.h" #include "logger.h" @@ -181,6 +185,15 @@ QVariant Theme::data(const QModelIndex& index, int role) const { } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) +Qt::ColorScheme Theme::currentSystemTheme() { + QStyleHints* styleHints = QGuiApplication::styleHints(); + Qt::ColorScheme currentColorScheme = styleHints->colorScheme(); + logger.debug() << "Current system theme: " << currentColorScheme; + return currentColorScheme; +} +#endif + void Theme::setStatusBarTextColor([[maybe_unused]] StatusBarTextColor color) { #ifdef MZ_IOS IOSCommons::setStatusBarTextColor(color); diff --git a/src/theme.h b/src/theme.h index 621dea5c2d..3ddabcd06b 100644 --- a/src/theme.h +++ b/src/theme.h @@ -46,6 +46,10 @@ class Theme final : public QAbstractListModel { QVariant data(const QModelIndex& index, int role) const override; +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + Qt::ColorScheme currentSystemTheme(); +#endif + enum StatusBarTextColor { StatusBarTextColorLight, StatusBarTextColorDark,