From 284c41feb7c4ed8e352ea5c78985c04715323b2a Mon Sep 17 00:00:00 2001 From: DLmaster Date: Sat, 15 Feb 2025 17:28:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E9=80=82=E9=85=8D=E6=B7=B1=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ui/main_window.py | 27 +++++++++++++++++++++++++-- resources/version.json | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/ui/main_window.py b/app/ui/main_window.py index 21cf592..ee6e82d 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -36,13 +36,15 @@ from qfluentwidgets import ( InfoBar, InfoBarPosition, setTheme, + isDarkTheme, + SystemThemeListener, Theme, MSFluentWindow, NavigationItemPosition, qconfig, ) from PySide6.QtGui import QIcon, QCloseEvent -from PySide6.QtCore import Qt +from PySide6.QtCore import Qt, QTimer from app.core import Config, TaskManager, MainTimer, MainInfoBar from app.services import Notify, Crypto, System @@ -60,7 +62,7 @@ class AUTO_MAA(MSFluentWindow): self.setWindowIcon(QIcon(str(Config.app_path / "resources/icons/AUTO_MAA.ico"))) self.setWindowTitle("AUTO_MAA") - setTheme(Theme.AUTO) + setTheme(Theme.AUTO, lazy=True) self.splashScreen = SplashScreen(self.windowIcon(), self) self.show_ui("显示主窗口", if_quick=True) @@ -175,6 +177,23 @@ class AUTO_MAA(MSFluentWindow): self.splashScreen.finish() + self.themeListener = SystemThemeListener(self) + self.themeListener.systemThemeChanged.connect(self.switch_theme) + self.themeListener.start() + + def switch_theme(self): + """切换主题""" + + setTheme(Theme.AUTO, lazy=True) + QTimer.singleShot(100, lambda: setTheme(Theme.AUTO, lazy=True)) + + # 云母特效启用时需要增加重试机制 + if self.isMicaEffectEnabled(): + QTimer.singleShot( + 100, + lambda: self.windowEffect.setMicaEffect(self.winId(), isDarkTheme()), + ) + def start_up_task(self) -> None: """启动时任务""" @@ -334,6 +353,10 @@ class AUTO_MAA(MSFluentWindow): # 关闭数据库连接 Config.close_database() + # 关闭主题监听 + self.themeListener.terminate() + self.themeListener.deleteLater() + logger.info("AUTO_MAA主程序关闭") logger.info("----------------END----------------") diff --git a/resources/version.json b/resources/version.json index abfbd46..c869e39 100644 --- a/resources/version.json +++ b/resources/version.json @@ -1,7 +1,7 @@ { "main_version": "4.2.3.1", "updater_version": "1.1.1.3", - "announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n## 修复BUG\n- 修复静默代理标记移除异常情况\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项", + "announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n## 修复BUG\n- 修复静默代理标记移除异常情况\n- 适配深色模式 #18\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项", "proxy_list": [ "", "https://gitproxy.click/",