|
|
|
|
@ -238,18 +238,19 @@ class WordRibbon(QFrame):
|
|
|
|
|
preview_layout.setSpacing(8)
|
|
|
|
|
|
|
|
|
|
style_items = [
|
|
|
|
|
("正文", "font-size:14px;"),
|
|
|
|
|
("无间隔", "font-size:14px;"),
|
|
|
|
|
("标题 1", "font-size:22px; font-weight:bold; color:#2E75B6;"),
|
|
|
|
|
("标题 2", "font-size:18px; color:#2E75B6;"),
|
|
|
|
|
("标题 3", "font-size:16px; font-weight:bold;"),
|
|
|
|
|
("副标题", "font-size:14px; font-style:italic; color:#555;"),
|
|
|
|
|
("强调", "font-size:14px; color:#C0504D;"),
|
|
|
|
|
("正文", "font-size:14px;", "body_text_preview_btn"),
|
|
|
|
|
("无间隔", "font-size:14px;", "no_spacing_preview_btn"),
|
|
|
|
|
("标题 1", "font-size:22px; font-weight:bold; color:#2E75B6;", "heading1_preview_btn"),
|
|
|
|
|
("标题 2", "font-size:18px; color:#2E75B6;", "heading2_preview_btn"),
|
|
|
|
|
("标题 3", "font-size:16px; font-weight:bold;", "heading3_preview_btn"),
|
|
|
|
|
("副标题", "font-size:14px; font-style:italic; color:#555;", "subtitle_preview_btn"),
|
|
|
|
|
("强调", "font-size:14px; color:#C0504D;", "emphasis_preview_btn"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for text, style in style_items:
|
|
|
|
|
for text, style, obj_name in style_items:
|
|
|
|
|
btn = QPushButton(text)
|
|
|
|
|
btn.setFixedSize(95, 60)
|
|
|
|
|
btn.setObjectName(obj_name)
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QPushButton {{
|
|
|
|
|
background: white;
|
|
|
|
|
@ -264,6 +265,9 @@ class WordRibbon(QFrame):
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
preview_layout.addWidget(btn)
|
|
|
|
|
|
|
|
|
|
# 将按钮保存为实例属性,以便主窗口可以连接信号
|
|
|
|
|
setattr(self, obj_name, btn)
|
|
|
|
|
|
|
|
|
|
preview_layout.addStretch()
|
|
|
|
|
|
|
|
|
|
@ -300,6 +304,9 @@ class WordRibbon(QFrame):
|
|
|
|
|
self.update_combo_styles(is_dark)
|
|
|
|
|
self.update_font_button_styles(is_dark)
|
|
|
|
|
|
|
|
|
|
# 更新样式预览按钮样式
|
|
|
|
|
self.update_style_preview_buttons(is_dark)
|
|
|
|
|
|
|
|
|
|
# 更新天气组件样式
|
|
|
|
|
if hasattr(self, 'weather_icon_label') and self.weather_icon_label is not None:
|
|
|
|
|
self.weather_icon_label.setStyleSheet(f"""
|
|
|
|
|
@ -397,6 +404,50 @@ class WordRibbon(QFrame):
|
|
|
|
|
# 更新字体工具栏按钮样式
|
|
|
|
|
self.update_font_button_styles(is_dark)
|
|
|
|
|
|
|
|
|
|
def update_style_preview_buttons(self, is_dark):
|
|
|
|
|
"""更新样式预览按钮样式"""
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
# 样式预览按钮配置
|
|
|
|
|
style_items = [
|
|
|
|
|
("正文", "font-size:14px;", "body_text_preview_btn"),
|
|
|
|
|
("无间隔", "font-size:14px;", "no_spacing_preview_btn"),
|
|
|
|
|
("标题 1", "font-size:22px; font-weight:bold; color:#2E75B6;", "heading1_preview_btn"),
|
|
|
|
|
("标题 2", "font-size:18px; color:#2E75B6;", "heading2_preview_btn"),
|
|
|
|
|
("标题 3", "font-size:16px; font-weight:bold;", "heading3_preview_btn"),
|
|
|
|
|
("副标题", "font-size:14px; font-style:italic; color:#555;", "subtitle_preview_btn"),
|
|
|
|
|
("强调", "font-size:14px; color:#C0504D;", "emphasis_preview_btn"),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for text, style, obj_name in style_items:
|
|
|
|
|
if hasattr(self, obj_name):
|
|
|
|
|
btn = getattr(self, obj_name)
|
|
|
|
|
# 根据主题调整颜色
|
|
|
|
|
if is_dark:
|
|
|
|
|
# 黑色模式下的颜色调整
|
|
|
|
|
if "color:#2E75B6" in style:
|
|
|
|
|
style = style.replace("color:#2E75B6", "color:#5B9BD5")
|
|
|
|
|
elif "color:#555" in style:
|
|
|
|
|
style = style.replace("color:#555", "color:#999")
|
|
|
|
|
elif "color:#C0504D" in style:
|
|
|
|
|
style = style.replace("color:#C0504D", "color:#E74C3C")
|
|
|
|
|
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QPushButton {{
|
|
|
|
|
background-color: {colors['surface']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
text-align: left;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
{style}
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:hover {{
|
|
|
|
|
border: 1px solid {colors['accent']};
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
def update_font_button_styles(self, is_dark):
|
|
|
|
|
"""更新字体工具栏按钮样式"""
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|