Skip to content

Commit

Permalink
VPN-6064 - detect dark mode (#10131)
Browse files Browse the repository at this point in the history
* VPN-6064 - detect dark mode

* make work on Linux running older Qt
  • Loading branch information
mcleinman authored Jan 6, 2025
1 parent 8701d63 commit 2003351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include <QDir>
#include <QJSEngine>
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
# include <QGuiApplication>
# include <QStyleHints>
#endif

#include "leakdetector.h"
#include "logger.h"
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2003351

Please sign in to comment.