mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-08-02 06:09:36 +08:00
fix(theme): 主题系统交叉审查缺陷修复
启动恢复: - _initializeAppearance 自定义主题加载失败时调用 clearTheme 回退配色方案 列表校验: - listThemes 同时校验 info.json 和 theme.qss 完整性 - 损坏的主题文件记录 LogManager 警告并跳过 - 按 (名称, 作者) 去重,同一作者同名主题仅保留一个 导入保护: - importTheme 新增 (名称, 作者) 冲突检查 - applyTheme 缺少 theme.qss 时抛出明确 ValueError 状态一致性: - saveAndApply 在 syncRadioFromNeedTheme 后重新采集 THEME 再保存 - __original_theme / __original_custom_theme 随每次 Apply 同步更新 - Reset 按钮恢复组合框到原始位置并刷新状态标签 代码质量: - 提取 _colorSchemeFor 静态方法消除 applyTheme/clearTheme 中的重复映射 - 移除未使用的 _applyTheme 死代码 - _active_style_name 默认值从 '' 改为 'Fusion' - 日志调用统一使用 LogManager - _applyCustomTheme 异常时通过 LogManager 记录详细错误 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -12,15 +12,14 @@ import os
|
||||
from PySide6.QtCore import QStandardPaths, QDir
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from gui.ALSettingsWidget import (
|
||||
_setActiveStyleName,
|
||||
_applyTheme,
|
||||
)
|
||||
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
|
||||
from managers.theme.ThemeManager import(
|
||||
setActiveStyle,
|
||||
instance as themeInstance
|
||||
)
|
||||
|
||||
|
||||
def _initializeLogManager(
|
||||
@@ -82,14 +81,16 @@ def _initializeAppearance(
|
||||
saved_theme = cfg.get(CfgKey.GLOBAL.APPEARANCE.THEME, "system")
|
||||
saved_custom_theme = cfg.get(CfgKey.GLOBAL.APPEARANCE.CUSTOM_THEME, "")
|
||||
app.setStyle(saved_style)
|
||||
_setActiveStyleName(saved_style)
|
||||
setActiveStyle(saved_style)
|
||||
logger = logInstance().getLogger("AppInitializer")
|
||||
if saved_custom_theme:
|
||||
try:
|
||||
themeInstance().applyTheme(saved_custom_theme)
|
||||
except Exception:
|
||||
logger.warning("无法应用自定义主题 '%s',回退到默认外观", saved_custom_theme)
|
||||
_applyTheme(saved_theme)
|
||||
logger.warning("无法应用自定义主题 '%s',回退到默认外观", saved_custom_theme)
|
||||
themeInstance().clearTheme(saved_theme)
|
||||
return
|
||||
themeInstance().clearTheme(saved_theme)
|
||||
|
||||
def initializeApp(
|
||||
) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user