|
|
|
|
@ -302,6 +302,32 @@ class WordRibbon(QFrame):
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 更新天气组件样式
|
|
|
|
|
if hasattr(self, 'weather_icon_label') and self.weather_icon_label is not None:
|
|
|
|
|
self.weather_icon_label.setStyleSheet(f"""
|
|
|
|
|
QLabel {{
|
|
|
|
|
font-size: 32px;
|
|
|
|
|
padding: 0px;
|
|
|
|
|
margin: 0px;
|
|
|
|
|
border: none;
|
|
|
|
|
background: transparent;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
if hasattr(self, 'weather_temp_label') and self.weather_temp_label is not None:
|
|
|
|
|
self.weather_temp_label.setStyleSheet(f"""
|
|
|
|
|
QLabel {{
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
padding: 0px;
|
|
|
|
|
margin: 0px;
|
|
|
|
|
border: none;
|
|
|
|
|
background: transparent;
|
|
|
|
|
min-height: 30px;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 更新下拉框样式
|
|
|
|
|
self.update_combo_styles(is_dark)
|
|
|
|
|
|
|
|
|
|
@ -595,7 +621,7 @@ class WordRibbon(QFrame):
|
|
|
|
|
if self.weather_group is not None:
|
|
|
|
|
return self.weather_group
|
|
|
|
|
|
|
|
|
|
weather_group = self.create_ribbon_group("天气")
|
|
|
|
|
weather_group = self.create_ribbon_group("天气", is_special_group=True)
|
|
|
|
|
weather_group.setFixedWidth(200) # 增加整体宽度
|
|
|
|
|
weather_layout = QVBoxLayout()
|
|
|
|
|
weather_layout.setSpacing(8) # 增加行间距
|
|
|
|
|
@ -624,11 +650,11 @@ class WordRibbon(QFrame):
|
|
|
|
|
# 温度标签 - 优化垂直居中对齐
|
|
|
|
|
self.weather_temp_label = QLabel("--°C")
|
|
|
|
|
self.weather_temp_label.setAlignment(Qt.AlignVCenter | Qt.AlignLeft) # 使用Qt对齐方式
|
|
|
|
|
# 初始化时使用默认颜色,主题切换时会更新
|
|
|
|
|
self.weather_temp_label.setStyleSheet("""
|
|
|
|
|
QLabel {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: #333333;
|
|
|
|
|
padding: 0px;
|
|
|
|
|
margin: 0px;
|
|
|
|
|
border: none;
|
|
|
|
|
@ -709,7 +735,7 @@ class WordRibbon(QFrame):
|
|
|
|
|
if self.quote_group is not None:
|
|
|
|
|
return self.quote_group
|
|
|
|
|
|
|
|
|
|
quote_group = self.create_ribbon_group("每日一言")
|
|
|
|
|
quote_group = self.create_ribbon_group("每日一言", is_special_group=True)
|
|
|
|
|
quote_layout = QVBoxLayout()
|
|
|
|
|
|
|
|
|
|
# 创建第一行:类型选择下拉框和刷新按钮
|
|
|
|
|
@ -772,27 +798,76 @@ class WordRibbon(QFrame):
|
|
|
|
|
self.quote_group = None
|
|
|
|
|
self.quote_visible = False
|
|
|
|
|
|
|
|
|
|
def create_ribbon_group(self, title):
|
|
|
|
|
def create_ribbon_group(self, title, is_special_group=False):
|
|
|
|
|
"""创建功能区组"""
|
|
|
|
|
group = QGroupBox(title)
|
|
|
|
|
group.setStyleSheet("""
|
|
|
|
|
QGroupBox {
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
color: #333333;
|
|
|
|
|
border: 1px solid #e1e1e1;
|
|
|
|
|
border-radius: 0px;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
padding-top: 5px;
|
|
|
|
|
}
|
|
|
|
|
QGroupBox::title {
|
|
|
|
|
subcontrol-origin: margin;
|
|
|
|
|
left: 10px;
|
|
|
|
|
padding: 0 5px 0 5px;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 为非特殊组设置最小宽度以确保标题完整显示
|
|
|
|
|
if not is_special_group:
|
|
|
|
|
# 根据标题长度计算合适的最小宽度
|
|
|
|
|
min_width = max(100, len(title) * 12 + 40) # 基础宽度+每个字符约12px
|
|
|
|
|
group.setMinimumWidth(min_width)
|
|
|
|
|
|
|
|
|
|
# 连接主题切换信号以动态更新样式
|
|
|
|
|
theme_manager.theme_changed.connect(lambda: self._update_group_style(group))
|
|
|
|
|
|
|
|
|
|
# 立即应用当前主题样式
|
|
|
|
|
self._update_group_style(group)
|
|
|
|
|
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
|
|
def _update_group_style(self, group):
|
|
|
|
|
"""更新组样式以适配当前主题"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
group.setStyleSheet(f"""
|
|
|
|
|
QGroupBox {{
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
background-color: {colors['surface']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
border-radius: 0px;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
padding-top: 5px;
|
|
|
|
|
}}
|
|
|
|
|
QGroupBox::title {{
|
|
|
|
|
subcontrol-origin: margin;
|
|
|
|
|
left: 10px;
|
|
|
|
|
padding: 0 5px 0 5px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
/* 确保标题不会被截断 */
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: clip; /* 不显示省略号 */
|
|
|
|
|
overflow: visible; /* 允许内容溢出 */
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
group.setStyleSheet(f"""
|
|
|
|
|
QGroupBox {{
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
background-color: {colors['surface']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
border-radius: 0px;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
padding-top: 5px;
|
|
|
|
|
}}
|
|
|
|
|
QGroupBox::title {{
|
|
|
|
|
subcontrol-origin: margin;
|
|
|
|
|
left: 10px;
|
|
|
|
|
padding: 0 5px 0 5px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
/* 确保标题不会被截断 */
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: clip; /* 不显示省略号 */
|
|
|
|
|
overflow: visible; /* 允许内容溢出 */
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
def on_refresh_weather(self):
|
|
|
|
|
"""刷新天气按钮点击处理"""
|
|
|
|
|
pass
|
|
|
|
|
@ -873,25 +948,57 @@ class WordRibbon(QFrame):
|
|
|
|
|
btn.setText(text)
|
|
|
|
|
btn.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
|
|
|
|
|
btn.setFixedSize(60, 60)
|
|
|
|
|
btn.setStyleSheet("""
|
|
|
|
|
QToolButton {
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: #333333;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:hover {
|
|
|
|
|
background-color: #f0f0f0;
|
|
|
|
|
border: 1px solid #d0d0d0;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:pressed {
|
|
|
|
|
background-color: #e1e1e1;
|
|
|
|
|
border: 1px solid #c0c0c0;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 连接主题切换信号以动态更新样式
|
|
|
|
|
theme_manager.theme_changed.connect(lambda: self._update_button_style(btn))
|
|
|
|
|
|
|
|
|
|
# 立即应用当前主题样式
|
|
|
|
|
self._update_button_style(btn)
|
|
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
def _update_button_style(self, btn):
|
|
|
|
|
"""更新按钮样式以适配当前主题"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #5a5a5c;
|
|
|
|
|
border: 1px solid #6a6a6c;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: #f0f0f0;
|
|
|
|
|
border: 1px solid #d0d0d0;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #e1e1e1;
|
|
|
|
|
border: 1px solid #c0c0c0;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
def create_toggle_button(self, text, icon_name):
|
|
|
|
|
"""创建切换按钮 - 现代极简主义风格"""
|
|
|
|
|
btn = QToolButton()
|
|
|
|
|
@ -905,111 +1012,204 @@ class WordRibbon(QFrame):
|
|
|
|
|
btn.setFixedSize(48, 28) # 两个字符(如"居中")
|
|
|
|
|
else:
|
|
|
|
|
btn.setFixedSize(64, 28) # 三个字符及以上(如"左对齐"、"两端对齐")
|
|
|
|
|
btn.setStyleSheet("""
|
|
|
|
|
QToolButton {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:hover {
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:pressed {
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:checked {
|
|
|
|
|
background-color: #ebf8ff;
|
|
|
|
|
border: 1px solid #bee3f8;
|
|
|
|
|
color: #3182ce;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 连接主题切换信号以动态更新样式
|
|
|
|
|
theme_manager.theme_changed.connect(lambda: self._update_toggle_button_style(btn))
|
|
|
|
|
|
|
|
|
|
# 立即应用当前主题样式
|
|
|
|
|
self._update_toggle_button_style(btn)
|
|
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
def _update_toggle_button_style(self, btn):
|
|
|
|
|
"""更新切换按钮样式以适配当前主题"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #5a5a5c;
|
|
|
|
|
border: 1px solid #6a6a6c;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:checked {{
|
|
|
|
|
background-color: {colors['accent']};
|
|
|
|
|
border: 1px solid {colors['accent']};
|
|
|
|
|
color: {colors['surface']};
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:checked {{
|
|
|
|
|
background-color: #ebf8ff;
|
|
|
|
|
border: 1px solid #bee3f8;
|
|
|
|
|
color: #3182ce;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
def create_color_button(self, text, icon_name):
|
|
|
|
|
"""创建颜色选择按钮 - 现代极简主义风格"""
|
|
|
|
|
btn = QToolButton()
|
|
|
|
|
btn.setText(text)
|
|
|
|
|
btn.setToolButtonStyle(Qt.ToolButtonTextOnly)
|
|
|
|
|
btn.setFixedSize(32, 28)
|
|
|
|
|
btn.setStyleSheet("""
|
|
|
|
|
QToolButton {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:hover {
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}
|
|
|
|
|
QToolButton:pressed {
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 连接主题切换信号以动态更新样式
|
|
|
|
|
theme_manager.theme_changed.connect(lambda: self._update_color_button_style(btn))
|
|
|
|
|
|
|
|
|
|
# 立即应用当前主题样式
|
|
|
|
|
self._update_color_button_style(btn)
|
|
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
def _update_color_button_style(self, btn):
|
|
|
|
|
"""更新颜色按钮样式以适配当前主题"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #5a5a5c;
|
|
|
|
|
border: 1px solid #6a6a6c;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QToolButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:hover {{
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}}
|
|
|
|
|
QToolButton:pressed {{
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
def create_style_button(self, text):
|
|
|
|
|
"""创建样式按钮 - 现代极简主义风格"""
|
|
|
|
|
btn = QPushButton(text)
|
|
|
|
|
btn.setFixedSize(60, 28)
|
|
|
|
|
btn.setStyleSheet("""
|
|
|
|
|
QPushButton {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
QPushButton:hover {
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}
|
|
|
|
|
QPushButton:pressed {
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 连接主题切换信号以动态更新样式
|
|
|
|
|
theme_manager.theme_changed.connect(lambda: self._update_style_button_style(btn))
|
|
|
|
|
|
|
|
|
|
# 立即应用当前主题样式
|
|
|
|
|
self._update_style_button_style(btn)
|
|
|
|
|
|
|
|
|
|
return btn
|
|
|
|
|
|
|
|
|
|
def _update_style_button_style(self, btn):
|
|
|
|
|
"""更新样式按钮样式以适配当前主题"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QPushButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:hover {{
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
border: 1px solid {colors['border']};
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:pressed {{
|
|
|
|
|
background-color: #5a5a5c;
|
|
|
|
|
border: 1px solid #6a6a6c;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
btn.setStyleSheet(f"""
|
|
|
|
|
QPushButton {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 6px 10px;
|
|
|
|
|
color: #4a5568;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:hover {{
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
border: 1px solid #e2e8f0;
|
|
|
|
|
}}
|
|
|
|
|
QPushButton:pressed {{
|
|
|
|
|
background-color: #edf2f7;
|
|
|
|
|
border: 1px solid #cbd5e0;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
class WordStatusBar(QStatusBar):
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super().__init__(parent)
|
|
|
|
|
self.setup_ui()
|
|
|
|
|
# 连接主题切换信号
|
|
|
|
|
theme_manager.theme_changed.connect(self.apply_theme)
|
|
|
|
|
# 应用初始主题
|
|
|
|
|
self.apply_theme()
|
|
|
|
|
|
|
|
|
|
def setup_ui(self):
|
|
|
|
|
"""设置状态栏 - 现代极简主义风格"""
|
|
|
|
|
self.setStyleSheet("""
|
|
|
|
|
QStatusBar {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border-top: 1px solid #e2e8f0;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #718096;
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
}
|
|
|
|
|
QStatusBar QLabel {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
QStatusBar QLabel:hover {
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 添加状态栏项目
|
|
|
|
|
self.page_label = QLabel("第 1 页,共 1 页")
|
|
|
|
|
self.words_label = QLabel("字数: 0")
|
|
|
|
|
@ -1020,12 +1220,61 @@ class WordStatusBar(QStatusBar):
|
|
|
|
|
self.addPermanentWidget(self.words_label)
|
|
|
|
|
self.addPermanentWidget(self.language_label)
|
|
|
|
|
self.addPermanentWidget(self.input_mode_label)
|
|
|
|
|
|
|
|
|
|
def apply_theme(self):
|
|
|
|
|
"""应用当前主题到状态栏"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
self.setStyleSheet(f"""
|
|
|
|
|
QStatusBar {{
|
|
|
|
|
background-color: {colors['surface']};
|
|
|
|
|
border-top: 1px solid {colors['border']};
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: {colors['text_secondary']};
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
}}
|
|
|
|
|
QStatusBar QLabel {{
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
color: {colors['text_secondary']};
|
|
|
|
|
}}
|
|
|
|
|
QStatusBar QLabel:hover {{
|
|
|
|
|
background-color: {colors['surface_hover']};
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
self.setStyleSheet("""
|
|
|
|
|
QStatusBar {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border-top: 1px solid #e2e8f0;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #718096;
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
}
|
|
|
|
|
QStatusBar QLabel {
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
padding: 4px 8px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
QStatusBar QLabel:hover {
|
|
|
|
|
background-color: #f7fafc;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
class WordTextEdit(QTextEdit):
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super().__init__(parent)
|
|
|
|
|
self.setup_ui()
|
|
|
|
|
self.input_processor = None # 输入处理器引用
|
|
|
|
|
# 连接主题切换信号
|
|
|
|
|
theme_manager.theme_changed.connect(self.apply_theme)
|
|
|
|
|
# 应用初始主题
|
|
|
|
|
self.apply_theme()
|
|
|
|
|
|
|
|
|
|
def set_input_processor(self, processor):
|
|
|
|
|
"""设置输入处理器"""
|
|
|
|
|
@ -1106,23 +1355,6 @@ class WordTextEdit(QTextEdit):
|
|
|
|
|
|
|
|
|
|
def setup_ui(self):
|
|
|
|
|
"""设置文本编辑区域样式 - 现代极简主义风格"""
|
|
|
|
|
self.setStyleSheet("""
|
|
|
|
|
QTextEdit {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border: none;
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
color: #2d3748;
|
|
|
|
|
padding: 40px;
|
|
|
|
|
line-height: 1.7;
|
|
|
|
|
selection-background-color: rgba(66, 153, 225, 0.2);
|
|
|
|
|
selection-color: #2d3748;
|
|
|
|
|
}
|
|
|
|
|
QTextEdit:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 设置页面边距和背景
|
|
|
|
|
self.setViewportMargins(50, 50, 50, 50)
|
|
|
|
|
|
|
|
|
|
@ -1136,6 +1368,46 @@ class WordTextEdit(QTextEdit):
|
|
|
|
|
|
|
|
|
|
# 设置光标宽度
|
|
|
|
|
self.setCursorWidth(2)
|
|
|
|
|
|
|
|
|
|
def apply_theme(self):
|
|
|
|
|
"""应用当前主题到文本编辑区域"""
|
|
|
|
|
is_dark = theme_manager.is_dark_theme()
|
|
|
|
|
colors = theme_manager.get_current_theme_colors()
|
|
|
|
|
|
|
|
|
|
if is_dark:
|
|
|
|
|
self.setStyleSheet(f"""
|
|
|
|
|
QTextEdit {{
|
|
|
|
|
background-color: {colors['surface']};
|
|
|
|
|
border: none;
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
color: {colors['text']};
|
|
|
|
|
padding: 40px;
|
|
|
|
|
line-height: 1.7;
|
|
|
|
|
selection-background-color: rgba(66, 153, 225, 0.3);
|
|
|
|
|
selection-color: {colors['text']};
|
|
|
|
|
}}
|
|
|
|
|
QTextEdit:focus {{
|
|
|
|
|
outline: none;
|
|
|
|
|
}}
|
|
|
|
|
""")
|
|
|
|
|
else:
|
|
|
|
|
self.setStyleSheet("""
|
|
|
|
|
QTextEdit {
|
|
|
|
|
background-color: #ffffff;
|
|
|
|
|
border: none;
|
|
|
|
|
font-family: 'Inter', 'SF Pro Display', 'Microsoft YaHei', '微软雅黑', sans-serif;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
color: #2d3748;
|
|
|
|
|
padding: 40px;
|
|
|
|
|
line-height: 1.7;
|
|
|
|
|
selection-background-color: rgba(66, 153, 225, 0.2);
|
|
|
|
|
selection-color: #2d3748;
|
|
|
|
|
}
|
|
|
|
|
QTextEdit:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
class WeatherAPI:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|