对主题代码优化,使其尽量适配Win10

因为是Win10环境修改,需要Win11用户进行测试
This commit is contained in:
Nether-Dream
2025-04-09 10:33:34 +08:00
parent 273fbe2261
commit a78b7fdb29
2 changed files with 74 additions and 6 deletions

48
.gitignore vendored Normal file
View File

@@ -0,0 +1,48 @@
.idea/AUTO_MAA.iml
.idea/inspectionProfiles/profiles_settings.xml
.idea/misc.xml
.idea/vcs.xml
.idea/modules.xml
.idea/workspace.xml
app/__pycache__/__init__.cpython-312.pyc
app/core/__pycache__/__init__.cpython-312.pyc
app/core/__pycache__/main_info_bar.cpython-312.pyc
app/core/__pycache__/config.cpython-312.pyc
app/core/__pycache__/task_manager.cpython-312.pyc
app/core/__pycache__/timer.cpython-312.pyc
app/models/__pycache__/__init__.cpython-312.pyc
testPython/.idea/workspace.xml
testPython/.idea/testPython.iml
testPython/.idea/vcs.xml
testPython/.idea/misc.xml
testPython/.idea/modules.xml
testPython/.idea/inspectionProfiles/profiles_settings.xml
debug/AUTO_MAA.log
data/key/verifysalt.txt
resources/notice.json
data/key/private_key.bin
data/key/public_key.pem
data/key/PASSWORDsalt.txt
data/key/AES_password_verify.bin
data/gameid.txt
data/data.db
config/QueueConfig/调度队列_1.json
config/MaaConfig/脚本_1/user_data.db
config/MaaConfig/脚本_1/config.json
config/config.json
app/utils/__pycache__/downloader.cpython-312.pyc
app/utils/__pycache__/__init__.cpython-312.pyc
app/ui/__pycache__/Widget.cpython-312.pyc
app/ui/__pycache__/setting.cpython-312.pyc
app/ui/__pycache__/queue_manager.cpython-312.pyc
app/ui/__pycache__/member_manager.cpython-312.pyc
app/ui/__pycache__/main_window.cpython-312.pyc
app/ui/__pycache__/history.cpython-312.pyc
app/ui/__pycache__/home.cpython-312.pyc
app/ui/__pycache__/__init__.cpython-312.pyc
app/services/__pycache__/system.cpython-312.pyc
app/services/__pycache__/security.cpython-312.pyc
app/services/__pycache__/notification.cpython-312.pyc
app/services/__pycache__/__init__.cpython-312.pyc
app/models/__pycache__/MAA.cpython-312.pyc
app/ui/__pycache__/dispatch_center.cpython-312.pyc

View File

@@ -42,12 +42,14 @@ from qfluentwidgets import (
MSFluentWindow, MSFluentWindow,
NavigationItemPosition, NavigationItemPosition,
qconfig, qconfig,
FluentBackgroundTheme
) )
from PySide6.QtGui import QIcon, QCloseEvent from PySide6.QtGui import QIcon, QCloseEvent
from PySide6.QtCore import Qt, QTimer from PySide6.QtCore import Qt, QTimer
import json import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
import shutil import shutil
import sys
from app.core import Config, TaskManager, MainTimer, MainInfoBar from app.core import Config, TaskManager, MainTimer, MainInfoBar
from app.services import Notify, Crypto, System from app.services import Notify, Crypto, System
@@ -68,6 +70,13 @@ class AUTO_MAA(MSFluentWindow):
self.setWindowTitle("AUTO_MAA") self.setWindowTitle("AUTO_MAA")
setTheme(Theme.AUTO, lazy=True) 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.splashScreen = SplashScreen(self.windowIcon(), self)
self.show_ui("显示主窗口", if_quick=True) self.show_ui("显示主窗口", if_quick=True)
@@ -207,15 +216,26 @@ class AUTO_MAA(MSFluentWindow):
self.themeListener.start() self.themeListener.start()
def switch_theme(self): def switch_theme(self):
"""切换主题""" #切换主题
setTheme(Theme.AUTO, lazy=True) 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( QTimer.singleShot(
500, 300,
lambda: self.windowEffect.setMicaEffect(self.winId(), isDarkTheme()), lambda: self.windowEffect.setMicaEffect(self.winId(), isDarkTheme()),
) )