对主题代码优化,使其尽量适配Win10
因为是Win10环境修改,需要Win11用户进行测试
This commit is contained in:
@@ -42,12 +42,14 @@ from qfluentwidgets import (
|
||||
MSFluentWindow,
|
||||
NavigationItemPosition,
|
||||
qconfig,
|
||||
FluentBackgroundTheme
|
||||
)
|
||||
from PySide6.QtGui import QIcon, QCloseEvent
|
||||
from PySide6.QtCore import Qt, QTimer
|
||||
import json
|
||||
from datetime import datetime, timedelta
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from app.core import Config, TaskManager, MainTimer, MainInfoBar
|
||||
from app.services import Notify, Crypto, System
|
||||
@@ -68,6 +70,13 @@ class AUTO_MAA(MSFluentWindow):
|
||||
self.setWindowTitle("AUTO_MAA")
|
||||
|
||||
setTheme(Theme.AUTO, lazy=True)
|
||||
if isDarkTheme():
|
||||
self.setStyleSheet("""
|
||||
CardWidget {background-color: #313131;}
|
||||
FluentBackgroundTheme {background-color: #313131;}
|
||||
""")
|
||||
else:
|
||||
self.setStyleSheet("""background-color: #ffffff;""")
|
||||
|
||||
self.splashScreen = SplashScreen(self.windowIcon(), self)
|
||||
self.show_ui("显示主窗口", if_quick=True)
|
||||
@@ -207,15 +216,26 @@ class AUTO_MAA(MSFluentWindow):
|
||||
self.themeListener.start()
|
||||
|
||||
def switch_theme(self):
|
||||
"""切换主题"""
|
||||
|
||||
#切换主题
|
||||
setTheme(Theme.AUTO, lazy=True)
|
||||
QTimer.singleShot(500, lambda: setTheme(Theme.AUTO, lazy=True))
|
||||
|
||||
QTimer.singleShot(300, lambda: setTheme(Theme.AUTO, lazy=True))
|
||||
# 云母特效不兼容Win10,如果True则通过云母进行主题转换,False则根据当前主题设置背景颜色
|
||||
# 云母特效启用时需要增加重试机制
|
||||
if self.isMicaEffectEnabled():
|
||||
if sys.platform != 'win32' or sys.getwindowsversion().build < 22000:
|
||||
#根据当前主题设置背景颜色
|
||||
if isDarkTheme():
|
||||
self.setStyleSheet("""
|
||||
CardWidget {background-color: #313131;}
|
||||
HeaderCardWidget {background-color: #313131;}
|
||||
background-color: #313131;
|
||||
""")
|
||||
else:
|
||||
self.setStyleSheet("background-color: #ffffff;")
|
||||
|
||||
else:
|
||||
print(sys.platform)
|
||||
QTimer.singleShot(
|
||||
500,
|
||||
300,
|
||||
lambda: self.windowEffect.setMicaEffect(self.winId(), isDarkTheme()),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user