Allow to choose color scheme on Windows

PR #21615.
This commit is contained in:
Vladimir Golovnev
2024-10-19 13:37:51 +03:00
committed by GitHub
parent 4805afc1a2
commit a47e1cdb48
8 changed files with 163 additions and 4 deletions

View File

@@ -31,6 +31,7 @@
#pragma once
#include <QtSystemDetection>
#include <QtVersionChecks>
#include <QColor>
#include <QHash>
#include <QIcon>
@@ -40,6 +41,15 @@
#include "uithemesource.h"
#if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)) && defined(Q_OS_WIN)
#define QBT_HAS_COLORSCHEME_OPTION
#endif
#ifdef QBT_HAS_COLORSCHEME_OPTION
#include "base/settingvalue.h"
#include "colorscheme.h"
#endif
class UIThemeManager final : public QObject
{
Q_OBJECT
@@ -50,6 +60,11 @@ public:
static void freeInstance();
static UIThemeManager *instance();
#ifdef QBT_HAS_COLORSCHEME_OPTION
ColorScheme colorScheme() const;
void setColorScheme(ColorScheme value);
#endif
QIcon getIcon(const QString &iconId, const QString &fallback = {}) const;
QIcon getFlagIcon(const QString &countryIsoCode) const;
QPixmap getScaledPixmap(const QString &iconId, int height) const;
@@ -66,8 +81,15 @@ private:
void applyStyleSheet() const;
void onColorSchemeChanged();
#ifdef QBT_HAS_COLORSCHEME_OPTION
void applyColorScheme() const;
#endif
static UIThemeManager *m_instance;
const bool m_useCustomTheme;
#ifdef QBT_HAS_COLORSCHEME_OPTION
SettingValue<ColorScheme> m_colorSchemeSetting;
#endif
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
const bool m_useSystemIcons;
#endif