Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPN-6064 - detect dark mode #10131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading