audit-e2w 1.11.2 → 1.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +152 -148
  2. package/dsh_plugins/audit-e2w/lib/index.js +9 -1
  3. package/dsh_plugins/audit-e2w/lib/skill.js +3 -2
  4. package/excel_word/README.md +45 -37
  5. package/excel_word/qoder_engine.py +10 -11
  6. package/excel_word/wesync/__init__.py +1 -1
  7. package/excel_word/wesync/ai/__init__.py +52 -0
  8. package/excel_word/wesync/ai/actions.py +369 -0
  9. package/excel_word/wesync/ai/client.py +340 -0
  10. package/excel_word/wesync/ai/config.py +291 -0
  11. package/excel_word/wesync/ai/docs.py +177 -0
  12. package/excel_word/wesync/ai/prompts.py +288 -0
  13. package/excel_word/wesync/ai/tasks/__init__.py +26 -0
  14. package/excel_word/wesync/ai/tasks/actions_task.py +97 -0
  15. package/excel_word/wesync/ai/tasks/combined.py +123 -0
  16. package/excel_word/wesync/ai/tasks/diff_note.py +61 -0
  17. package/excel_word/wesync/ai/tasks/headings.py +119 -0
  18. package/excel_word/wesync/ai/tasks/help_task.py +69 -0
  19. package/excel_word/wesync/ai/tasks/roles.py +128 -0
  20. package/excel_word/wesync/align.py +1 -0
  21. package/excel_word/wesync/api.py +544 -92
  22. package/excel_word/wesync/backup_history.py +44 -9
  23. package/excel_word/wesync/cli.py +19 -1
  24. package/excel_word/wesync/commands/blank_cmd.py +59 -30
  25. package/excel_word/wesync/commands/bookmark_cmd.py +41 -10
  26. package/excel_word/wesync/commands/clear_cmd.py +5 -3
  27. package/excel_word/wesync/commands/export_cmd.py +270 -220
  28. package/excel_word/wesync/commands/incremental_cmd.py +157 -0
  29. package/excel_word/wesync/commands/marks_cmd.py +24 -16
  30. package/excel_word/wesync/commands/placeholders_cmd.py +12 -7
  31. package/excel_word/wesync/commands/writeback_cmd.py +72 -116
  32. package/excel_word/wesync/config.py +3 -2
  33. package/excel_word/wesync/console.py +9 -2
  34. package/excel_word/wesync/docx_bookmarks.py +12 -5
  35. package/excel_word/wesync/docx_columns.py +1 -1
  36. package/excel_word/wesync/docx_marks.py +183 -75
  37. package/excel_word/wesync/docx_placeholders.py +65 -26
  38. package/excel_word/wesync/excel_blocks.py +144 -185
  39. package/excel_word/wesync/excel_export.py +15 -8
  40. package/excel_word/wesync/excel_marks.py +265 -193
  41. package/excel_word/wesync/fsops.py +11 -6
  42. package/excel_word/wesync/gui/__init__.py +21 -2
  43. package/excel_word/wesync/gui/app.py +243 -29
  44. package/excel_word/wesync/gui/manual.py +5 -3
  45. package/excel_word/wesync/gui/pages/__init__.py +53 -4
  46. package/excel_word/wesync/gui/pages/_page.py +129 -7
  47. package/excel_word/wesync/gui/pages/ai_page.py +854 -0
  48. package/excel_word/wesync/gui/pages/batch_page.py +64 -31
  49. package/excel_word/wesync/gui/pages/blank_page.py +529 -464
  50. package/excel_word/wesync/gui/pages/bookmark_page.py +97 -37
  51. package/excel_word/wesync/gui/pages/export_page.py +140 -87
  52. package/excel_word/wesync/gui/pages/feedback_page.py +196 -0
  53. package/excel_word/wesync/gui/pages/format_page.py +551 -429
  54. package/excel_word/wesync/gui/pages/help_page.py +73 -7
  55. package/excel_word/wesync/gui/pages/history_page.py +167 -144
  56. package/excel_word/wesync/gui/pages/marks_page.py +210 -177
  57. package/excel_word/wesync/gui/pages/settings_page.py +450 -0
  58. package/excel_word/wesync/gui/pages/writeback_page.py +167 -146
  59. package/excel_word/wesync/gui/runner.py +29 -13
  60. package/excel_word/wesync/gui/store.py +23 -7
  61. package/excel_word/wesync/gui/theme.py +220 -49
  62. package/excel_word/wesync/gui/widgets/ai_config.py +362 -0
  63. package/excel_word/wesync/gui/widgets/cards.py +124 -5
  64. package/excel_word/wesync/gui/widgets/chips.py +565 -0
  65. package/excel_word/wesync/gui/widgets/filebar.py +1 -1
  66. package/excel_word/wesync/gui/widgets/logpane.py +24 -8
  67. package/excel_word/wesync/gui/widgets/nav.py +267 -12
  68. package/excel_word/wesync/gui/widgets/theme_choice.py +93 -0
  69. package/excel_word/wesync/report_format.py +9 -1
  70. package/excel_word/wesync/settings.py +35 -0
  71. package/excel_word/wesync/sort_rules.py +75 -26
  72. package/excel_word/wesync/valuefmt.py +40 -17
  73. package/package.json +53 -51
  74. package/packaging//344/275/277/347/224/250/350/257/264/346/230/216.txt +247 -0
  75. package/qoder_plugins/audit-toolbox/README.md +159 -156
  76. package/qoder_plugins/audit-toolbox/catalog.mjs +13 -13
@@ -1,91 +1,261 @@
1
- """界面统一视觉:配色、字体与 Qt 样式表(沿用原 tkinter 版配色)。"""
1
+ """界面统一视觉:配色、字体与 Qt 样式表。"""
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
5
  FONT_CANDIDATES = ("Microsoft YaHei UI", "Microsoft YaHei", "微软雅黑", "SimHei", "SimSun")
6
+ APPEARANCE_MODES = ("system", "light", "dark")
7
+ APPEARANCE_LABELS = {"system": "系统", "light": "浅色", "dark": "深色"}
6
8
 
7
- COLORS = {
8
- "primary": "#1F4E79",
9
- "primary_hover": "#2A6399",
10
- "primary_soft": "#EAF1F8",
11
- "bg": "#F7F8FA",
12
- "card": "#FFFFFF",
13
- "border": "#E3E6EA",
14
- "text": "#1F2937",
15
- "muted": "#6B7280",
16
- "success": "#15803D",
17
- "warning": "#B45309",
18
- "error": "#B91C1C",
19
- "disabled": "#9AA3AF",
20
- "nav_hover": "#F2F6FA",
9
+ PALETTES = {
10
+ "light": {
11
+ "primary": "#0F6CBD",
12
+ "primary_hover": "#115EA3",
13
+ "primary_soft": "#EAF3FC",
14
+ "bg": "#F4F6F9",
15
+ "card": "#FFFFFF",
16
+ "surface": "#F8FAFC",
17
+ "border": "#E3E8EF",
18
+ "border_hover": "#C8D2DE",
19
+ "text": "#172033",
20
+ "muted": "#667085",
21
+ "success": "#15803D",
22
+ "success_soft": "#E9F7F1",
23
+ "warning": "#B45309",
24
+ "error": "#B91C1C",
25
+ "disabled": "#98A2B3",
26
+ "disabled_bg": "#CBD5E1",
27
+ "disabled_text": "#F2F5F8",
28
+ "nav": "#FFFFFF",
29
+ "nav_hover": "#F0F5FA",
30
+ "nav_pressed": "#E6EDF5",
31
+ "nav_group": "#8A94A3",
32
+ "nav_group_hover": "#4B5563",
33
+ "input": "#FFFFFF",
34
+ "log_bg": "#FBFCFD",
35
+ "scroll": "#CDD5DF",
36
+ "scroll_hover": "#AAB6C4",
37
+ "tooltip_bg": "#172033",
38
+ "tooltip_text": "#FFFFFF",
39
+ "on_primary": "#FFFFFF",
40
+ "adjust_bg": "#F7FBFF",
41
+ "adjust_border": "#CFE2F7",
42
+ "switch_off": "#CBD5E1",
43
+ "switch_off_hover": "#AEBCCD",
44
+ },
45
+ "dark": {
46
+ "primary": "#6EA8FE",
47
+ "primary_hover": "#8AB4FF",
48
+ "primary_soft": "#193554",
49
+ "bg": "#111827",
50
+ "card": "#1B2430",
51
+ "surface": "#202C3B",
52
+ "border": "#344256",
53
+ "border_hover": "#4A5B73",
54
+ "text": "#E5ECF5",
55
+ "muted": "#9AA9BC",
56
+ "success": "#5BC98C",
57
+ "success_soft": "#183B31",
58
+ "warning": "#F0B45D",
59
+ "error": "#FF8080",
60
+ "disabled": "#5F7087",
61
+ "disabled_bg": "#303E50",
62
+ "disabled_text": "#8190A5",
63
+ "nav": "#172130",
64
+ "nav_hover": "#233247",
65
+ "nav_pressed": "#2B3C54",
66
+ "nav_group": "#91A1B5",
67
+ "nav_group_hover": "#C3CFDD",
68
+ "input": "#111927",
69
+ "log_bg": "#101925",
70
+ "scroll": "#43536A",
71
+ "scroll_hover": "#62748D",
72
+ "tooltip_bg": "#2B3C54",
73
+ "tooltip_text": "#F7FAFC",
74
+ "on_primary": "#0E1B2B",
75
+ "adjust_bg": "#162C46",
76
+ "adjust_border": "#2C5278",
77
+ "switch_off": "#3D4C61",
78
+ "switch_off_hover": "#50617A",
79
+ },
21
80
  }
22
81
 
82
+ _effective = "light"
23
83
  _family = FONT_CANDIDATES[0]
24
84
 
25
85
 
86
+ def normalize_mode(value) -> str:
87
+ mode = value.lower() if isinstance(value, str) else ""
88
+ return mode if mode in APPEARANCE_MODES else "system"
89
+
90
+
91
+ def resolve_mode(app, mode: str) -> str:
92
+ mode = normalize_mode(mode)
93
+ if mode != "system":
94
+ return mode
95
+ scheme = app.styleHints().colorScheme()
96
+ return "dark" if getattr(scheme, "name", "").lower() == "dark" else "light"
97
+
98
+
99
+ def colors(mode: str | None = None) -> dict[str, str]:
100
+ return PALETTES[mode] if mode in PALETTES else PALETTES[_effective]
101
+
102
+
103
+ def effective_mode() -> str:
104
+ return _effective
105
+
106
+
26
107
  def font_family() -> str:
27
108
  return _family
28
109
 
29
110
 
30
- def _qss() -> str:
31
- c = COLORS
111
+ def _qss(c: dict[str, str]) -> str:
32
112
  return f"""
33
113
  QWidget {{ background: {c['bg']}; color: {c['text']}; }}
34
114
  QMainWindow, QStackedWidget, QScrollArea {{ background: {c['bg']}; }}
35
115
  QScrollArea {{ border: none; }}
36
116
  QLabel {{ background: transparent; }}
37
- QFrame#Card {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 6px; }}
117
+ QWidget#FileBar {{ background: {c['card']}; }}
118
+ QWidget#Nav {{ background: {c['nav']}; }}
119
+ QFrame#Card {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 12px; }}
38
120
  QFrame#Card QLabel, QFrame#Card QCheckBox {{ background: transparent; }}
39
- QLabel#PageTitle {{ font-size: 18px; font-weight: 600; }}
40
- QLabel#Desc, QLabel#CardDesc {{ color: {c['muted']}; }}
41
- QLabel#SectionTitle {{ font-size: 15px; font-weight: 600; }}
121
+ QFrame#AdjustBlock {{ background: {c['adjust_bg']}; border: 1px solid {c['adjust_border']}; border-radius: 10px; }}
122
+ QFrame#AdjustBlock QLabel, QFrame#AdjustBlock QCheckBox {{ background: transparent; }}
123
+ QLabel#PageTitle {{ font-size: 22px; font-weight: 600; color: {c['text']}; }}
124
+ QLabel#Desc {{ color: {c['muted']}; font-size: 13px; }}
125
+ QLabel#CardDesc {{ color: {c['muted']}; font-size: 12px; }}
126
+ QLabel#SectionTitle {{ font-size: 15px; font-weight: 600; color: {c['text']}; }}
127
+ QLabel#SettingTitle {{ font-size: 15px; font-weight: 600; }}
128
+ QLabel#SettingName {{ font-weight: 600; }}
129
+ QLabel#SettingTag {{ color: {c['primary']}; background: {c['primary_soft']}; border-radius: 10px; padding: 2px 9px; font-size: 11px; }}
130
+ QLabel#OptionHint {{ color: {c['muted']}; font-size: 12px; }}
131
+ QLabel#RiskHint {{ color: {c['warning']}; font-size: 12px; }}
42
132
  QLabel#Status {{ color: {c['muted']}; font-size: 12px; }}
133
+ QLabel#Version {{ color: {c['muted']}; font-size: 12px; }}
134
+ QLabel#Notice {{ color: {c['primary']}; }}
135
+ QLabel#ContactEmail {{ color: {c['primary']}; font-size: 18px; font-weight: 600; }}
136
+ QLabel#ContactTag {{ color: {c['success']}; background: {c['success_soft']}; border-radius: 10px; padding: 3px 9px; font-size: 11px; }}
43
137
  QLabel#NavTitle {{ color: {c['muted']}; font-size: 12px; font-weight: 600; }}
44
- QLabel#PathBox {{ background: #FFFFFF; border: 1px solid {c['border']}; border-radius: 4px; padding: 4px 6px; }}
45
- QPushButton {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 8px 18px; font-size: 14px; }}
46
- QPushButton:hover {{ background: {c['nav_hover']}; }}
47
- QPushButton:disabled {{ background: {c['bg']}; color: {c['disabled']}; }}
48
- QPushButton#Primary {{ background: {c['primary']}; color: #FFFFFF; border: none; font-size: 16px; font-weight: 600; padding: 10px 28px; }}
49
- QPushButton#Primary:hover {{ background: {c['primary_hover']}; }}
50
- QPushButton#Primary:disabled {{ background: #B7C4D1; color: #F2F5F8; }}
51
- QPushButton#Nav {{ text-align: left; border: none; background: {c['card']}; padding: 10px 14px; font-size: 15px; border-radius: 6px; }}
138
+ QFrame#ContactBanner {{ border-left: 4px solid {c['primary']}; }}
139
+ QFrame#DonationPlaceholder {{ background: {c['surface']}; border: 1px dashed {c['border_hover']}; border-radius: 8px; color: {c['muted']}; }}
140
+ QPushButton#NavBrand {{ background: transparent; border: none; color: {c['text']}; text-align: left; padding: 0; font-size: 15px; font-weight: 700; }}
141
+ QPushButton#NavBrand:hover {{ color: {c['primary']}; }}
142
+ QPushButton#NavGroup {{ background: transparent; border: none; color: {c['nav_group']}; font-size: 12px; font-weight: 600; padding: 6px 10px 2px; text-align: left; }}
143
+ QPushButton#NavGroup:hover {{ color: {c['nav_group_hover']}; }}
144
+ QWidget#NavGroupItems {{ background: transparent; }}
145
+ QWidget#NavIndicator {{ background: {c['primary']}; border-radius: 2px; }}
146
+ QLabel#PathBox {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 6px 8px; }}
147
+ QPushButton {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 7px; padding: 7px 16px; min-height: 18px; font-size: 13px; }}
148
+ QPushButton:hover {{ background: {c['nav_hover']}; border-color: {c['border_hover']}; }}
149
+ QPushButton:pressed {{ background: {c['nav_pressed']}; }}
150
+ QPushButton:disabled {{ background: {c['bg']}; color: {c['disabled']}; border-color: {c['border']}; }}
151
+ QPushButton#Primary {{ background: {c['primary']}; color: {c['on_primary']}; border: 1px solid {c['primary']}; font-size: 14px; font-weight: 600; padding: 8px 22px; }}
152
+ QPushButton#Primary:hover {{ background: {c['primary_hover']}; border-color: {c['primary_hover']}; }}
153
+ QPushButton#Primary:disabled {{ background: {c['disabled_bg']}; color: {c['disabled_text']}; border-color: {c['disabled_bg']}; }}
154
+ /* 首次启动的外观选择:整块可点的选项卡,选中态用主色描边 */
155
+ QLabel#DialogTitle {{ color: {c['text']}; font-size: 16px; font-weight: 700; }}
156
+ QPushButton#ThemeOption {{ background: {c['surface']}; color: {c['text']}; border: 1px solid {c['border']}; border-radius: 10px; padding: 10px 12px; font-size: 13px; text-align: center; }}
157
+ QPushButton#ThemeOption:hover {{ background: {c['nav_hover']}; border-color: {c['border_hover']}; }}
158
+ QPushButton#ThemeOption:checked {{ background: {c['primary_soft']}; color: {c['primary']}; border: 2px solid {c['primary']}; font-weight: 600; }}
159
+ /* 胶囊开关外观由 _Switch.paintEvent 自绘;这里只清掉按钮默认的边框与文字内边距,
160
+ 避免样式表与自绘叠加出方形底或文字残影。 */
161
+ QPushButton#SettingSwitch {{ border: none; background: transparent; padding: 0; min-width: 0; }}
162
+ QPushButton#SettingSwitch:focus {{ outline: none; }}
163
+ QWidget#ExportActions QPushButton {{ padding: 7px 10px; }}
164
+ QWidget#ExportActions QPushButton#Primary {{ padding: 7px 14px; }}
165
+ /* min-height 在 Qt 样式表里指内容区高度,不含 padding;这里同时压 max-height 才能真的矮下来 */
166
+ QPushButton#Nav {{ text-align: left; border: none; background: transparent; padding: 3px 12px; min-height: 26px; max-height: 26px; font-size: 13px; border-radius: 8px; }}
52
167
  QPushButton#Nav:hover {{ background: {c['nav_hover']}; }}
168
+ QPushButton#Nav:pressed {{ background: {c['nav_pressed']}; }}
53
169
  QPushButton#Nav:checked {{ background: {c['primary_soft']}; color: {c['primary']}; font-weight: 600; }}
170
+ QWidget#Nav[collapsed="true"] QPushButton#Nav {{ padding: 0; min-width: 46px; max-width: 46px; }}
54
171
  QPushButton#LogTool {{ padding: 4px 10px; font-size: 12px; }}
55
- QCheckBox {{ background: transparent; spacing: 6px; }}
172
+ QFrame#OptionTile {{ background: {c['surface']}; border: 1px solid {c['border']}; border-radius: 9px; }}
173
+ QFrame#OptionTile:hover {{ background: {c['nav_hover']}; border-color: {c['border_hover']}; }}
174
+ QFrame#OptionTile QCheckBox {{ font-weight: 500; }}
175
+ /* 胶囊勾选项:底色与描边由 Chip.paintEvent 自绘(QWidget 不支持样式表圆角),
176
+ 这里只管文字与图标的颜色。 */
177
+ QWidget#Chip QLabel#ChipText {{ color: {c['text']}; font-size: 13px; font-weight: 500; background: transparent; border: none; }}
178
+ QWidget#Chip[checked="true"] QLabel#ChipText {{ color: {c['primary']}; font-weight: 600; }}
179
+ QWidget#Chip QLabel#ChipIcon {{ background: transparent; border: none; }}
180
+ QCheckBox {{ background: transparent; spacing: 7px; }}
181
+ QCheckBox::indicator {{ width: 16px; height: 16px; }}
56
182
  QRadioButton {{ background: transparent; spacing: 8px; }}
57
183
  QRadioButton::indicator {{ width: 16px; height: 16px; border: 2px solid {c['disabled']}; border-radius: 9px; background: {c['card']}; }}
58
184
  QRadioButton::indicator:hover {{ border-color: {c['primary_hover']}; }}
59
185
  QRadioButton::indicator:checked {{ border: 5px solid {c['primary']}; border-radius: 13px; background: {c['card']}; }}
60
186
  QRadioButton:checked {{ color: {c['primary']}; font-weight: 600; }}
61
- QPlainTextEdit#LogText {{ background: #FBFCFD; border: 1px solid {c['border']}; border-radius: 4px; font-size: 13px; }}
62
- QLineEdit, QSpinBox, QComboBox {{ background: #FFFFFF; border: 1px solid {c['border']}; border-radius: 4px; padding: 4px 6px; }}
63
- QListWidget#ManualChapters {{ background: #FFFFFF; border: 1px solid {c['border']}; border-radius: 6px; padding: 4px; outline: 0; }}
64
- QListWidget#ManualChapters::item {{ padding: 8px 10px; border-radius: 4px; }}
187
+ QPlainTextEdit, QTextEdit {{ background: {c['input']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 6px; }}
188
+ QPlainTextEdit#LogText {{ background: {c['log_bg']}; border-radius: 7px; padding: 0; font-size: 13px; }}
189
+ QLineEdit, QSpinBox, QComboBox {{ background: {c['input']}; border: 1px solid {c['border']}; border-radius: 6px; padding: 6px 8px; min-height: 18px; }}
190
+ QLineEdit:focus, QSpinBox:focus, QComboBox:focus {{ border-color: {c['primary']}; }}
191
+ QComboBox QAbstractItemView {{ background: {c['card']}; color: {c['text']}; border: 1px solid {c['border']}; selection-background-color: {c['primary']}; selection-color: {c['on_primary']}; }}
192
+ QListWidget, QTableWidget {{ background: {c['card']}; alternate-background-color: {c['surface']}; color: {c['text']}; gridline-color: {c['border']}; }}
193
+ QListWidget#ManualChapters {{ border: 1px solid {c['border']}; border-radius: 8px; padding: 4px; outline: 0; }}
194
+ QListWidget#ManualChapters::item {{ padding: 8px 10px; border-radius: 5px; }}
65
195
  QListWidget#ManualChapters::item:selected {{ background: {c['primary_soft']}; color: {c['primary']}; font-weight: 600; }}
66
- QTextBrowser#ManualView {{ background: #FFFFFF; border: 1px solid {c['border']}; border-radius: 6px; }}
67
- QTabWidget::pane {{ border: 1px solid {c['border']}; border-radius: 6px; background: {c['card']}; top: -1px; }}
68
- QTabBar::tab {{ background: {c['bg']}; border: 1px solid {c['border']}; border-bottom: none; padding: 8px 20px; border-top-left-radius: 6px; border-top-right-radius: 6px; }}
69
- QTabBar::tab:selected {{ background: {c['card']}; color: {c['primary']}; font-weight: 600; }}
196
+ QHeaderView::section {{ background: {c['surface']}; color: {c['text']}; border: 1px solid {c['border']}; padding: 5px; }}
197
+ QTextBrowser#ManualView {{ background: {c['card']}; border: 1px solid {c['border']}; border-radius: 8px; }}
198
+ QTabWidget::pane {{ border: 1px solid {c['border']}; border-radius: 9px; background: {c['card']}; top: -1px; }}
199
+ QTabBar::tab {{ background: transparent; border: none; border-bottom: 2px solid transparent; padding: 9px 18px; color: {c['muted']}; }}
200
+ QTabBar::tab:selected {{ background: transparent; color: {c['primary']}; font-weight: 600; border-bottom-color: {c['primary']}; }}
201
+ QTabBar::tab:hover {{ color: {c['primary']}; }}
202
+ QMenu {{ background: {c['card']}; color: {c['text']}; border: 1px solid {c['border']}; padding: 4px; }}
203
+ QMenu::item {{ padding: 6px 20px; border-radius: 4px; }}
204
+ QMenu::item:selected {{ background: {c['primary_soft']}; color: {c['primary']}; }}
70
205
  QStatusBar {{ background: {c['bg']}; }}
71
206
  QStatusBar QLabel {{ background: transparent; }}
72
- QProgressBar {{ border: 1px solid {c['border']}; border-radius: 4px; background: {c['card']}; }}
73
- QProgressBar::chunk {{ background: {c['primary']}; border-radius: 3px; }}
207
+ QProgressBar {{ border: 1px solid {c['border']}; border-radius: 5px; background: {c['card']}; text-align: center; }}
208
+ QProgressBar::chunk {{ background: {c['primary']}; border-radius: 4px; }}
74
209
  QSplitter::handle {{ background: {c['border']}; }}
75
- QScrollBar:vertical {{ background: {c['bg']}; width: 10px; }}
76
- QScrollBar::handle:vertical {{ background: {c['border']}; border-radius: 5px; min-height: 30px; }}
210
+ QScrollBar:vertical {{ background: transparent; width: 10px; margin: 2px; }}
211
+ QScrollBar::handle:vertical {{ background: {c['scroll']}; border-radius: 5px; min-height: 30px; }}
212
+ QScrollBar::handle:vertical:hover {{ background: {c['scroll_hover']}; }}
77
213
  QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{ height: 0; }}
78
- QScrollBar:horizontal {{ background: {c['bg']}; height: 10px; }}
79
- QScrollBar::handle:horizontal {{ background: {c['border']}; border-radius: 5px; min-width: 30px; }}
214
+ QScrollBar:horizontal {{ background: transparent; height: 10px; margin: 2px; }}
215
+ QScrollBar::handle:horizontal {{ background: {c['scroll']}; border-radius: 5px; min-width: 30px; }}
80
216
  QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {{ width: 0; }}
217
+ QToolTip {{ background: {c['tooltip_bg']}; color: {c['tooltip_text']}; border: none; padding: 6px 8px; border-radius: 5px; }}
81
218
  """
82
219
 
83
220
 
84
- def apply(app) -> str:
85
- """应用字体与样式表,返回实际使用的字体名。"""
86
- global _family
221
+ def _palette(c: dict[str, str]):
222
+ from PySide6.QtGui import QColor, QPalette
223
+
224
+ palette = QPalette()
225
+ roles = {
226
+ QPalette.Window: "bg",
227
+ QPalette.WindowText: "text",
228
+ QPalette.Base: "input",
229
+ QPalette.AlternateBase: "surface",
230
+ QPalette.Text: "text",
231
+ QPalette.Button: "card",
232
+ QPalette.ButtonText: "text",
233
+ QPalette.BrightText: "on_primary",
234
+ QPalette.ToolTipBase: "tooltip_bg",
235
+ QPalette.ToolTipText: "tooltip_text",
236
+ QPalette.Highlight: "primary",
237
+ QPalette.HighlightedText: "on_primary",
238
+ QPalette.Link: "primary",
239
+ QPalette.LinkVisited: "primary",
240
+ QPalette.PlaceholderText: "muted",
241
+ }
242
+ for role, key in roles.items():
243
+ palette.setColor(role, QColor(c[key]))
244
+ for role in (QPalette.Text, QPalette.ButtonText, QPalette.WindowText):
245
+ palette.setColor(QPalette.Disabled, role, QColor(c["disabled"]))
246
+ for role in (QPalette.Base, QPalette.Button, QPalette.Window):
247
+ palette.setColor(QPalette.Disabled, role, QColor(c["disabled_bg"]))
248
+ return palette
249
+
250
+
251
+ def apply(app, mode: str = "system") -> str:
252
+ """应用外观、字体与样式表,返回实际使用的字体名。"""
253
+ global _family, _effective
87
254
  from PySide6.QtGui import QFont, QFontDatabase
88
255
 
256
+ mode = normalize_mode(mode)
257
+ _effective = resolve_mode(app, mode)
258
+ c = PALETTES[_effective]
89
259
  families = set(QFontDatabase.families())
90
260
  for name in FONT_CANDIDATES:
91
261
  if name in families:
@@ -96,5 +266,6 @@ def apply(app) -> str:
96
266
  font.setPixelSize(14)
97
267
  font.setHintingPreference(QFont.PreferFullHinting)
98
268
  app.setFont(font)
99
- app.setStyleSheet(_qss())
100
- return _family
269
+ app.setPalette(_palette(c))
270
+ app.setStyleSheet(_qss(c))
271
+ return _family