mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-08-02 06:09:36 +08:00
refactor(theme): 将重复的主题逻辑下沉至 ThemeManager
ThemeManager 新增: - clearTheme(theme) — 清除 QSS 并应用指定色调 - applyThemeOrClear(name, fallback) — 应用或回退的封装 - _applyColorScheme(theme) — Qt ColorScheme 设置的统一入口 - themeToReadable(need_theme) — 静态工具方法 ALSettingsWidget 移除: - _clearCustomTheme → 改用 themeInstance().clearTheme() - _applyCustomTheme → 改用 themeInstance().applyThemeOrClear() - _themeToReadable → 改用 ThemeManager.themeToReadable() ALSettingsWidget 仅保留 _applyTheme(含 setStyle 逻辑,供 AppInitializer 使用)
This commit is contained in:
@@ -20,6 +20,7 @@ from interfaces.ConfigProvider import CfgKey
|
||||
from managers.config.ConfigManager import instance as configInstance
|
||||
from managers.driver.WebDriverManager import instance as webdriverInstance
|
||||
from managers.log.LogManager import instance as logInstance
|
||||
from managers.theme.ThemeManager import instance as themeInstance
|
||||
|
||||
|
||||
def _initializeLogManager(
|
||||
@@ -82,12 +83,12 @@ def _initializeAppearance(
|
||||
saved_custom_theme = cfg.get(CfgKey.GLOBAL.APPEARANCE.CUSTOM_THEME, "")
|
||||
app.setStyle(saved_style)
|
||||
_setActiveStyleName(saved_style)
|
||||
logger = logInstance().getLogger("AppInitializer")
|
||||
if saved_custom_theme:
|
||||
try:
|
||||
from managers.theme.ThemeManager import instance as themeInstance
|
||||
themeInstance().applyTheme(saved_custom_theme)
|
||||
except Exception:
|
||||
pass
|
||||
logger.warning("无法应用自定义主题 '%s',回退到默认外观", saved_custom_theme)
|
||||
_applyTheme(saved_theme)
|
||||
|
||||
def initializeApp(
|
||||
|
||||
Reference in New Issue
Block a user