From ec93740bd7e2f42ea1fa1e5280f179bbdbae5044 Mon Sep 17 00:00:00 2001 From: Dylan Liu <312902918@qq.com> Date: Fri, 19 May 2023 13:12:25 +0800 Subject: [PATCH] Add manual control of darkmode for Quick. (#220) Add the function of manual control of dark mode in Quick module. --- include/FramelessHelper/Quick/framelessquickutils.h | 3 ++- src/quick/framelessquickutils.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/FramelessHelper/Quick/framelessquickutils.h b/include/FramelessHelper/Quick/framelessquickutils.h index ee01e50..8222543 100644 --- a/include/FramelessHelper/Quick/framelessquickutils.h +++ b/include/FramelessHelper/Quick/framelessquickutils.h @@ -47,7 +47,7 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickUtils : public QObject, public QQm Q_PROPERTY(qreal titleBarHeight READ titleBarHeight CONSTANT FINAL) Q_PROPERTY(bool frameBorderVisible READ frameBorderVisible CONSTANT FINAL) Q_PROPERTY(qreal frameBorderThickness READ frameBorderThickness CONSTANT FINAL) - Q_PROPERTY(QuickGlobal::SystemTheme systemTheme READ systemTheme NOTIFY systemThemeChanged FINAL) + Q_PROPERTY(QuickGlobal::SystemTheme systemTheme READ systemTheme WRITE setOverrideTheme NOTIFY systemThemeChanged FINAL) Q_PROPERTY(QColor systemAccentColor READ systemAccentColor NOTIFY systemAccentColorChanged FINAL) Q_PROPERTY(bool titleBarColorized READ titleBarColorized NOTIFY titleBarColorizedChanged FINAL) Q_PROPERTY(QColor defaultSystemLightColor READ defaultSystemLightColor CONSTANT FINAL) @@ -65,6 +65,7 @@ public: Q_NODISCARD bool frameBorderVisible() const; Q_NODISCARD qreal frameBorderThickness() const; Q_NODISCARD QuickGlobal::SystemTheme systemTheme() const; + void setOverrideTheme(const QuickGlobal::SystemTheme theme); Q_NODISCARD QColor systemAccentColor() const; Q_NODISCARD bool titleBarColorized() const; Q_NODISCARD QColor defaultSystemLightColor() const; diff --git a/src/quick/framelessquickutils.cpp b/src/quick/framelessquickutils.cpp index f3bc371..7cee918 100644 --- a/src/quick/framelessquickutils.cpp +++ b/src/quick/framelessquickutils.cpp @@ -84,7 +84,12 @@ qreal FramelessQuickUtils::frameBorderThickness() const QuickGlobal::SystemTheme FramelessQuickUtils::systemTheme() const { - return FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemTheme, Utils::getSystemTheme()); + return FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemTheme, FramelessManager::instance()->systemTheme()); +} + +void FramelessQuickUtils::setOverrideTheme(const QuickGlobal::SystemTheme theme) +{ + FramelessManager::instance()->setOverrideTheme(FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemTheme, theme)); } QColor FramelessQuickUtils::systemAccentColor() const