Enhance calendar widget and theme manager with optimized Apple design styles

- Updated the `CalendarFloatingWidget` and `CalendarWidget` classes to improve dark and light theme styles, aligning with an optimized Apple design aesthetic.
- Adjusted font sizes, button styles, and color schemes for better visual consistency and usability.
- Enhanced the `ThemeManager` to provide refined styles for various UI components, including menus, buttons, and toolbars.
- Implemented responsive styles for button states (hover, pressed) and improved accessibility with disabled text colors.
- Ensured that theme changes propagate correctly across the application, particularly in the `WordStyleMainWindow`.
Maziang 3 months ago
parent f05a9a6d92
commit 75dbeb24e9

@ -187,134 +187,109 @@ class DeepSeekDialogWindow(QDialog):
self.streaming_finished.connect(self.on_streaming_finished)
def toggle_theme(self):
"""切换黑白主题"""
if hasattr(self, 'current_theme') and self.current_theme == "dark":
self.apply_theme("light")
else:
self.apply_theme("dark")
"""切换黑白主题 - 使用主题管理器"""
try:
from .ui.theme_manager import theme_manager
except ImportError:
# 处理直接运行的情况
from ui.theme_manager import theme_manager
current_is_dark = theme_manager.is_dark_theme()
theme_manager.set_dark_theme(not current_is_dark)
# 更新对话显示
self.rebuild_conversation_display()
def apply_theme(self, theme):
"""应用主题样式"""
self.current_theme = theme
if theme == "dark":
# 深色主题样式
self.setStyleSheet("""
QDialog {
background-color: #1e1e1e;
color: #ffffff;
}
QLabel {
color: #ffffff;
}
QTextEdit {
background-color: #2d2d2d;
color: #ffffff;
border: 1px solid #444;
border-radius: 4px;
padding: 10px;
font-family: 'Microsoft YaHei', sans-serif;
font-size: 12px;
}
QLineEdit {
background-color: #2d2d2d;
color: #ffffff;
border: 1px solid #444;
border-radius: 4px;
padding: 8px;
font-size: 12px;
}
QPushButton {
background-color: #0078d7;
color: white;
border: none;
border-radius: 4px;
padding: 8px 16px;
font-size: 12px;
}
QPushButton:hover {
background-color: #106ebe;
}
QPushButton:pressed {
background-color: #005a9e;
}
QScrollArea {
background-color: #1e1e1e;
border: none;
}
QScrollBar:vertical {
background-color: #2d2d2d;
width: 15px;
margin: 0px;
}
QScrollBar::handle:vertical {
background-color: #555;
border-radius: 7px;
min-height: 20px;
}
QScrollBar::handle:vertical:hover {
background-color: #666;
}
""")
else:
# 浅色主题样式
self.setStyleSheet("""
QDialog {
background-color: #ffffff;
color: #000000;
}
QLabel {
color: #000000;
}
QTextEdit {
background-color: #ffffff;
color: #000000;
border: 1px solid #ddd;
border-radius: 4px;
padding: 10px;
font-family: 'Microsoft YaHei', sans-serif;
font-size: 12px;
}
QLineEdit {
background-color: #ffffff;
color: #000000;
border: 1px solid #ddd;
border-radius: 4px;
padding: 8px;
font-size: 12px;
}
QPushButton {
background-color: #0078d7;
color: white;
border: none;
border-radius: 4px;
padding: 8px 16px;
font-size: 12px;
}
QPushButton:hover {
background-color: #106ebe;
}
QPushButton:pressed {
background-color: #005a9e;
}
QScrollArea {
background-color: #ffffff;
border: none;
}
QScrollBar:vertical {
background-color: #f0f0f0;
width: 15px;
margin: 0px;
}
QScrollBar::handle:vertical {
background-color: #c0c0c0;
border-radius: 7px;
min-height: 20px;
}
QScrollBar::handle:vertical:hover {
background-color: #a0a0a0;
}
""")
def apply_theme(self, is_dark=None):
"""应用主题样式 - 与主题管理器同步"""
try:
from .ui.theme_manager import theme_manager
except ImportError:
# 处理直接运行的情况
from ui.theme_manager import theme_manager
if is_dark is None:
is_dark = theme_manager.is_dark_theme()
# 获取主题管理器的样式表
base_stylesheet = theme_manager.get_theme_stylesheet(is_dark)
# 添加对话框特定的样式优化
dialog_stylesheet = base_stylesheet + f"""
/* DeepSeek对话框特定样式 */
QDialog {{
background-color: {'#1c1c1e' if is_dark else '#ffffff'};
}}
/* 对话区域优化 */
QTextEdit#conversation_text {{
background-color: {'#121212' if is_dark else '#ffffff'};
border: 1px solid {'#3a3a3c' if is_dark else '#e0e0e0'};
border-radius: 8px;
padding: 16px;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
font-size: 14px;
line-height: 1.6;
color: {'#e8e8ed' if is_dark else '#333333'};
}}
/* 输入框优化 */
QTextEdit#input_edit {{
background-color: {'#2c2c2e' if is_dark else '#f8f8f8'};
border: 1px solid {'#3a3a3c' if is_dark else '#e0e0e0'};
border-radius: 8px;
padding: 12px;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
font-size: 14px;
color: {'#e8e8ed' if is_dark else '#333333'};
}}
QTextEdit#input_edit:focus {{
border: 2px solid {'#0a84ff' if is_dark else '#0078d7'};
}}
/* 按钮优化 */
QPushButton {{
border-radius: 8px;
padding: 8px 16px;
font-weight: 500;
min-width: 80px;
}}
QPushButton:default {{
background-color: #0a84ff;
color: #ffffff;
}}
/* 滚动区域优化 */
QScrollArea {{
border: none;
background-color: transparent;
}}
/* 消息气泡样式 */
.user-message {{
background-color: {'#0a84ff' if is_dark else '#0078d7'};
color: #ffffff;
border-radius: 12px;
padding: 12px 16px;
margin: 4px 0;
max-width: 80%;
align-self: flex-end;
}}
.ai-message {{
background-color: {'#3a3a3c' if is_dark else '#f0f0f0'};
color: {'#e8e8ed' if is_dark else '#333333'};
border-radius: 12px;
padding: 12px 16px;
margin: 4px 0;
max-width: 80%;
align-self: flex-start;
}}
"""
self.setStyleSheet(dialog_stylesheet)
def create_conversation_area(self, parent):
"""创建对话显示区域"""
@ -413,7 +388,6 @@ class DeepSeekDialogWindow(QDialog):
self.add_streaming_message_start()
# 在新线程中执行流式请求
import threading
self.streaming_thread = threading.Thread(target=self.call_deepseek_api_stream, args=(message,))
self.streaming_thread.daemon = True
self.streaming_thread.start()
@ -455,7 +429,14 @@ class DeepSeekDialogWindow(QDialog):
self.conversation_text.ensureCursorVisible()
def rebuild_conversation_display(self):
"""重新构建对话显示"""
"""重新构建对话显示 - 优化主题适配"""
try:
from .ui.theme_manager import theme_manager
except ImportError:
# 处理直接运行的情况
from ui.theme_manager import theme_manager
is_dark = theme_manager.is_dark_theme()
html_content = ""
for msg in self.conversation_history:
@ -463,29 +444,66 @@ class DeepSeekDialogWindow(QDialog):
message = msg["message"]
is_streaming = msg.get("streaming", False)
# 根据发送者设置不同的样式
# 根据发送者和主题设置不同的样式 - 优化颜色对比度
if sender == "用户":
bg_color = "#e3f2fd" if self.current_theme == "light" else "#2d3e50"
text_color = "#000" if self.current_theme == "light" else "#fff"
bg_color = "#0a84ff" # 统一的用户消息颜色
text_color = "#ffffff"
align_style = "margin-left: auto; margin-right: 0;"
elif sender == "AI助手":
bg_color = "#f5f5f5" if self.current_theme == "light" else "#3d3d3d"
text_color = "#000" if self.current_theme == "light" else "#fff"
bg_color = "#3a3a3c" if is_dark else "#f0f0f0"
text_color = "#e8e8ed" if is_dark else "#333333"
align_style = "margin-left: 0; margin-right: auto;"
else: # 系统消息
bg_color = "#fff3cd" if self.current_theme == "light" else "#5d4e00"
text_color = "#856404" if self.current_theme == "light" else "#ffd700"
bg_color = "#5d4e00" if is_dark else "#fff3cd"
text_color = "#ffd700" if is_dark else "#856404"
align_style = "margin: 0 auto;"
# 格式化消息内容
formatted_message = message.replace('\n', '<br>') if message else "正在思考..."
# 优化消息气泡样式
html_content += f'''
<div style="background-color: {bg_color}; color: {text_color}; padding: 10px; margin: 5px; border-radius: 10px;">
<b>{sender}:</b><br>
{formatted_message}
<div style="
background-color: {bg_color};
color: {text_color};
padding: 12px 16px;
margin: 8px 0;
border-radius: 12px;
max-width: 80%;
{align_style}
word-wrap: break-word;
line-height: 1.5;
">
<div style="font-weight: 600; margin-bottom: 4px; opacity: 0.8;">{sender}:</div>
<div>{formatted_message}</div>
</div>
'''
# 添加现代滚动条样式
scrollbar_style = f"""
<style>
::-webkit-scrollbar {{
width: 8px;
}}
::-webkit-scrollbar-track {{
background: {'#1c1c1e' if is_dark else '#f8f8f8'};
border-radius: 4px;
}}
::-webkit-scrollbar-thumb {{
background: {'#5a5a5c' if is_dark else '#c0c0c0'};
border-radius: 4px;
}}
::-webkit-scrollbar-thumb:hover {{
background: {'#6a6a6c' if is_dark else '#a0a0a0'};
}}
</style>
"""
# 设置HTML内容
self.conversation_text.setHtml(html_content)
self.conversation_text.setHtml(scrollbar_style + html_content)
def call_deepseek_api_stream(self, message):
"""调用DeepSeek API流式版本"""

@ -133,12 +133,12 @@ class CalendarFloatingWidget(QWidget):
self.apply_theme()
def apply_theme(self):
"""应用主题样式"""
"""应用主题样式 - 优化Apple设计风格"""
is_dark = theme_manager.is_dark_theme()
colors = theme_manager.get_current_theme_colors()
if is_dark:
# 深色主题样式
# 深色主题样式 - 优化版Apple设计风格
self.main_frame.setStyleSheet(f"""
QFrame#mainFrame {{
background-color: {colors['surface']};
@ -153,7 +153,7 @@ class CalendarFloatingWidget(QWidget):
}}
QLabel#dateLabel {{
color: {colors['text_secondary']};
font-size: 11px;
font-size: 12px;
padding: 4px 6px;
margin: 2px;
}}
@ -174,40 +174,49 @@ class CalendarFloatingWidget(QWidget):
color: white;
border-radius: 6px;
}}
QPushButton#closeButton:pressed {{
background-color: #c50e1f;
}}
QPushButton#todayButton, QPushButton#clearButton, QPushButton#insertButton {{
background-color: {colors['accent']};
color: white;
border: none;
border-radius: 6px;
padding: 6px 16px;
font-size: 11px;
font-size: 12px;
font-weight: 500;
}}
QPushButton#todayButton:hover, QPushButton#clearButton:hover, QPushButton#insertButton:hover {{
background-color: {colors['accent_hover']};
}}
QPushButton#todayButton:pressed, QPushButton#clearButton:pressed, QPushButton#insertButton:pressed {{
background-color: {colors['accent_pressed']};
}}
""")
# 更新日历控件样式
# 更新日历控件样式 - 深色主题优化版Apple设计风格
self.calendar.setStyleSheet(f"""
QCalendarWidget {{
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 8px;
}}
QCalendarWidget QToolButton {{
height: 30px;
width: 80px;
height: 32px;
width: 85px;
color: {colors['text']};
font-size: 12px;
font-weight: bold;
font-size: 13px;
font-weight: 500;
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 6px;
}}
QCalendarWidget QToolButton:hover {{
background-color: {colors['surface_hover']};
}}
QCalendarWidget QToolButton:pressed {{
background-color: {colors['surface_pressed']};
}}
QCalendarWidget QMenu {{
width: 150px;
left: 20px;
@ -215,15 +224,16 @@ class CalendarFloatingWidget(QWidget):
font-size: 12px;
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 6px;
}}
QCalendarWidget QSpinBox {{
width: 80px;
width: 85px;
font-size: 12px;
background-color: {colors['surface']};
selection-background-color: {colors['accent']};
selection-color: white;
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 6px;
color: {colors['text']};
}}
QCalendarWidget QSpinBox::up-button {{
@ -254,12 +264,15 @@ class CalendarFloatingWidget(QWidget):
background-color: {colors['surface']};
color: {colors['text']};
}}
QCalendarWidget QAbstractItemView:disabled {{
color: {colors['text_disabled']};
}}
QCalendarWidget QWidget#qt_calendar_navigationbar {{
background-color: {colors['surface']};
}}
""")
else:
# 浅色主题样式
# 浅色主题样式 - 优化版Apple设计风格
self.main_frame.setStyleSheet(f"""
QFrame#mainFrame {{
background-color: {colors['surface']};
@ -275,7 +288,7 @@ class CalendarFloatingWidget(QWidget):
}}
QLabel#dateLabel {{
color: {colors['text_secondary']};
font-size: 11px;
font-size: 12px;
padding: 4px 6px;
margin: 2px;
}}
@ -296,40 +309,49 @@ class CalendarFloatingWidget(QWidget):
color: white;
border-radius: 6px;
}}
QPushButton#closeButton:pressed {{
background-color: #c50e1f;
}}
QPushButton#todayButton, QPushButton#clearButton, QPushButton#insertButton {{
background-color: {colors['accent']};
color: white;
border: none;
border-radius: 6px;
padding: 6px 16px;
font-size: 11px;
font-size: 12px;
font-weight: 500;
}}
QPushButton#todayButton:hover, QPushButton#clearButton:hover, QPushButton#insertButton:hover {{
background-color: {colors['accent_hover']};
}}
QPushButton#todayButton:pressed, QPushButton#clearButton:pressed, QPushButton#insertButton:pressed {{
background-color: {colors['accent_pressed']};
}}
""")
# 更新日历控件样式
# 更新日历控件样式 - 浅色主题优化版Apple设计风格
self.calendar.setStyleSheet(f"""
QCalendarWidget {{
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 8px;
}}
QCalendarWidget QToolButton {{
height: 30px;
width: 80px;
height: 32px;
width: 85px;
color: {colors['text']};
font-size: 12px;
font-weight: bold;
font-size: 13px;
font-weight: 500;
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 6px;
}}
QCalendarWidget QToolButton:hover {{
background-color: {colors['surface_hover']};
}}
QCalendarWidget QToolButton:pressed {{
background-color: {colors['surface_pressed']};
}}
QCalendarWidget QMenu {{
width: 150px;
left: 20px;
@ -337,15 +359,16 @@ class CalendarFloatingWidget(QWidget):
font-size: 12px;
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 6px;
}}
QCalendarWidget QSpinBox {{
width: 80px;
width: 85px;
font-size: 12px;
background-color: {colors['surface']};
selection-background-color: {colors['accent']};
selection-color: white;
border: 1px solid {colors['border']};
border-radius: 4px;
border-radius: 6px;
color: {colors['text']};
}}
QCalendarWidget QSpinBox::up-button {{
@ -376,6 +399,9 @@ class CalendarFloatingWidget(QWidget):
background-color: {colors['surface']};
color: {colors['text']};
}}
QCalendarWidget QAbstractItemView:disabled {{
color: {colors['text_disabled']};
}}
QCalendarWidget QWidget#qt_calendar_navigationbar {{
background-color: {colors['surface']};
}}

@ -277,153 +277,205 @@ class CalendarWidget(QWidget):
theme_manager.theme_changed.connect(self.on_theme_changed)
# 应用当前主题
self.apply_theme()
current_theme = theme_manager.is_dark_theme()
self.apply_theme(current_theme)
def apply_theme(self):
"""应用主题样式"""
def apply_theme(self, is_dark_theme):
"""应用主题样式 - 优化Apple设计风格"""
is_dark = theme_manager.is_dark_theme()
if is_dark:
# 深色主题样式
# 深色主题样式 - 优化版Apple设计风格
self.setStyleSheet("""
QWidget {
background-color: #2c2c2e;
color: #f0f0f0;
background-color: #1c1c1e;
color: #e8e8ed;
}
""")
# 更新日历控件样式
self.calendar.setStyleSheet("""
QCalendarWidget {
background-color: #2c2c2e;
border: 1px solid #404040;
border-radius: 4px;
background-color: #1c1c1e;
border: 1px solid #3a3a3c;
border-radius: 8px;
}
QCalendarWidget QToolButton {
height: 30px;
width: 80px;
color: #f0f0f0;
font-size: 12px;
font-weight: bold;
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
border-radius: 4px;
height: 32px;
width: 85px;
color: #e8e8ed;
font-size: 13px;
font-weight: 500;
background-color: #2c2c2e;
border: 1px solid #3a3a3c;
border-radius: 6px;
}
QCalendarWidget QToolButton:hover {
QCalendarWidget QToolButton:pressed {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
}
QCalendarWidget QMenu {
width: 150px;
left: 20px;
color: #f0f0f0;
font-size: 12px;
QCalendarWidget QToolButton:hover {
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
}
QCalendarWidget QMenu {
width: 160px;
left: 20px;
color: #e8e8ed;
font-size: 13px;
background-color: #2c2c2e;
border: 1px solid #3a3a3c;
border-radius: 6px;
}
QCalendarWidget QMenu::item:selected {
background-color: #0a84ff;
color: #ffffff;
}
QCalendarWidget QSpinBox {
width: 80px;
font-size: 12px;
background-color: #3a3a3c;
width: 85px;
font-size: 13px;
background-color: #2c2c2e;
selection-background-color: #0a84ff;
selection-color: #ffffff;
border: 1px solid #4a4a4c;
border-radius: 4px;
color: #f0f0f0;
border: 1px solid #3a3a3c;
border-radius: 6px;
color: #e8e8ed;
padding: 2px;
}
QCalendarWidget QSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 20px;
width: 22px;
border: 1px solid #3a3a3c;
background-color: #2c2c2e;
border-radius: 0 6px 0 0;
}
QCalendarWidget QSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 20px;
width: 22px;
border: 1px solid #3a3a3c;
background-color: #2c2c2e;
border-radius: 0 0 6px 0;
}
QCalendarWidget QSpinBox::up-button:hover,
QCalendarWidget QSpinBox::down-button:hover {
background-color: #3a3a3c;
}
QCalendarWidget QSpinBox::up-button:pressed,
QCalendarWidget QSpinBox::down-button:pressed {
background-color: #4a4a4c;
}
QCalendarWidget QSpinBox::up-arrow {
width: 10px;
height: 10px;
width: 12px;
height: 12px;
}
QCalendarWidget QSpinBox::down-arrow {
width: 10px;
height: 10px;
width: 12px;
height: 12px;
}
QCalendarWidget QWidget {
alternate-background-color: #3a3a3c;
alternate-background-color: #2c2c2e;
}
QCalendarWidget QAbstractItemView:enabled {
font-size: 12px;
font-size: 13px;
selection-background-color: #0a84ff;
selection-color: #ffffff;
background-color: #2c2c2e;
color: #f0f0f0;
background-color: #121212;
color: #e8e8ed;
}
QCalendarWidget QAbstractItemView:disabled {
color: #8a8a8d;
}
QCalendarWidget QWidget#qt_calendar_navigationbar {
background-color: #3a3a3c;
background-color: #2c2c2e;
}
""")
# 更新标签样式
self.date_label.setStyleSheet("QLabel { color: #a0a0a0; }")
self.date_label.setStyleSheet("QLabel { color: #8a8a8d; font-size: 12px; font-weight: 500; }")
# 更新按钮样式
self.close_btn.setStyleSheet("""
QPushButton {
background-color: #2c2c2e;
border: 1px solid #3a3a3c;
border-radius: 14px;
font-size: 18px;
font-weight: 600;
color: #e8e8ed;
padding: 6px;
}
QPushButton:hover {
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
border-radius: 12px;
font-size: 16px;
font-weight: bold;
color: #f0f0f0;
}
QPushButton:hover {
QPushButton:pressed {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
}
""")
self.today_btn.setStyleSheet("""
QPushButton {
background-color: #0a84ff;
color: white;
color: #ffffff;
border: none;
border-radius: 4px;
padding: 5px 10px;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #0066cc;
background-color: #0071e3;
}
QPushButton:pressed {
background-color: #0051d5;
}
""")
self.clear_btn.setStyleSheet("""
QPushButton {
background-color: #2c2c2e;
color: #e8e8ed;
border: 1px solid #3a3a3c;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #3a3a3c;
color: #f0f0f0;
border: 1px solid #4a4a4c;
border-radius: 4px;
padding: 5px 10px;
}
QPushButton:hover {
QPushButton:pressed {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
}
""")
self.insert_btn.setStyleSheet("""
QPushButton {
background-color: #32d74b;
color: #000000;
background-color: #34c759;
color: #ffffff;
border: none;
border-radius: 4px;
padding: 5px 10px;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #24b334;
background-color: #30d158;
}
QPushButton:pressed {
background-color: #2eb750;
}
""")
else:
# 浅色主题样式
# 浅色主题样式 - 优化版Apple设计风格
self.setStyleSheet("""
QWidget {
background-color: white;
background-color: #f8f8f8;
color: #333333;
}
""")
@ -431,68 +483,96 @@ class CalendarWidget(QWidget):
# 更新日历控件样式
self.calendar.setStyleSheet("""
QCalendarWidget {
background-color: white;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 6px;
}
QCalendarWidget QToolButton {
height: 30px;
width: 80px;
color: #333;
font-size: 12px;
font-weight: bold;
height: 32px;
width: 85px;
color: #333333;
font-size: 13px;
font-weight: 500;
background-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 6px;
}
QCalendarWidget QToolButton:pressed {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 4px;
border: 1px solid #c0c0c0;
}
QCalendarWidget QToolButton:hover {
background-color: #e0e0e0;
background-color: #f0f0f0;
border: 1px solid #d0d0d0;
}
QCalendarWidget QMenu {
width: 150px;
width: 160px;
left: 20px;
color: #333;
font-size: 12px;
background-color: white;
border: 1px solid #ccc;
color: #333333;
font-size: 13px;
background-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 6px;
}
QCalendarWidget QMenu::item:selected {
background-color: #007aff;
color: #ffffff;
}
QCalendarWidget QSpinBox {
width: 80px;
font-size: 12px;
background-color: #f0f0f0;
selection-background-color: #0078d7;
selection-color: white;
border: 1px solid #ccc;
border-radius: 4px;
color: #333;
width: 85px;
font-size: 13px;
background-color: #ffffff;
selection-background-color: #007aff;
selection-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 6px;
color: #333333;
padding: 2px;
}
QCalendarWidget QSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 20px;
width: 22px;
border: 1px solid #e0e0e0;
background-color: #ffffff;
border-radius: 0 6px 0 0;
}
QCalendarWidget QSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 20px;
width: 22px;
border: 1px solid #e0e0e0;
background-color: #ffffff;
border-radius: 0 0 6px 0;
}
QCalendarWidget QSpinBox::up-button:hover,
QCalendarWidget QSpinBox::down-button:hover {
background-color: #f0f0f0;
}
QCalendarWidget QSpinBox::up-button:pressed,
QCalendarWidget QSpinBox::down-button:pressed {
background-color: #e0e0e0;
}
QCalendarWidget QSpinBox::up-arrow {
width: 10px;
height: 10px;
width: 12px;
height: 12px;
}
QCalendarWidget QSpinBox::down-arrow {
width: 10px;
height: 10px;
width: 12px;
height: 12px;
}
QCalendarWidget QWidget {
alternate-background-color: #f0f0f0;
alternate-background-color: #f8f8f8;
}
QCalendarWidget QAbstractItemView:enabled {
font-size: 12px;
selection-background-color: #0078d7;
selection-color: white;
background-color: white;
color: #333;
font-size: 13px;
selection-background-color: #007aff;
selection-color: #ffffff;
background-color: #ffffff;
color: #333333;
}
QCalendarWidget QAbstractItemView:disabled {
color: #999999;
}
QCalendarWidget QWidget#qt_calendar_navigationbar {
background-color: #f8f8f8;
@ -500,65 +580,88 @@ class CalendarWidget(QWidget):
""")
# 更新标签样式
self.date_label.setStyleSheet("QLabel { color: #666; }")
self.date_label.setStyleSheet("QLabel { color: #666666; font-size: 12px; font-weight: 500; }")
# 更新按钮样式
self.close_btn.setStyleSheet("""
QPushButton {
background-color: #f0f0f0;
border: 1px solid #ccc;
border-radius: 12px;
font-size: 16px;
font-weight: bold;
color: #333;
background-color: #ffffff;
border: 1px solid #e0e0e0;
border-radius: 14px;
font-size: 18px;
font-weight: 600;
color: #333333;
padding: 6px;
}
QPushButton:hover {
background-color: #f0f0f0;
border: 1px solid #d0d0d0;
}
QPushButton:pressed {
background-color: #e0e0e0;
border: 1px solid #c0c0c0;
}
""")
self.today_btn.setStyleSheet("""
QPushButton {
background-color: #0078d7;
color: white;
background-color: #007aff;
color: #ffffff;
border: none;
border-radius: 4px;
padding: 5px 10px;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #005a9e;
background-color: #0056b3;
}
QPushButton:pressed {
background-color: #004494;
}
""")
self.clear_btn.setStyleSheet("""
QPushButton {
background-color: #f0f0f0;
color: #333;
border: 1px solid #ccc;
border-radius: 4px;
padding: 5px 10px;
background-color: #ffffff;
color: #333333;
border: 1px solid #e0e0e0;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #f0f0f0;
border: 1px solid #d0d0d0;
}
QPushButton:pressed {
background-color: #e0e0e0;
border: 1px solid #c0c0c0;
}
""")
self.insert_btn.setStyleSheet("""
QPushButton {
background-color: #4CAF50;
color: white;
background-color: #34c759;
color: #ffffff;
border: none;
border-radius: 4px;
padding: 5px 10px;
border-radius: 6px;
padding: 6px 12px;
font-weight: 500;
font-size: 12px;
}
QPushButton:hover {
background-color: #45a049;
background-color: #2e8b57;
}
QPushButton:pressed {
background-color: #267349;
}
""")
def on_theme_changed(self, is_dark):
"""主题切换槽函数"""
self.apply_theme()
self.apply_theme(is_dark)
if __name__ == "__main__":

@ -153,67 +153,67 @@ class ThemeManager(QObject):
return self._get_light_stylesheet()
def _get_dark_stylesheet(self):
"""深色主题样式表 - Apple设计风格"""
"""深色主题样式表 - 优化版Apple设计风格"""
return """
/* Apple设计风格深色主题样式 */
/* 优化版Apple设计风格深色主题样式 */
/* 全局文字颜色和字体 - 使用Apple系统字体 */
QWidget {
color: #f0f0f0;
color: #e8e8ed;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
font-size: 13px;
}
/* 主窗口 - Apple深色背景 */
/* 主窗口 - 优化后的深色背景 */
QMainWindow {
background-color: #2c2c2e;
background-color: #1c1c1e;
}
/* 菜单栏 - Apple深色风格 */
/* 菜单栏 - 优化版Apple深色风格 */
QMenuBar {
background-color: #2c2c2e;
border: none;
border-bottom: 1px solid #404040;
border-bottom: 1px solid #3a3a3c;
font-size: 13px;
color: #f0f0f0;
color: #e8e8ed;
padding: 4px 0;
}
QMenuBar::item {
background-color: transparent;
padding: 6px 12px;
color: #f0f0f0;
border-radius: 4px;
margin: 0 1px;
color: #e8e8ed;
border-radius: 6px;
margin: 0 2px;
}
QMenuBar::item:selected {
background-color: #404040;
color: #f0f0f0;
background-color: #3a3a3c;
color: #e8e8ed;
}
QMenuBar::item:pressed {
background-color: #505050;
color: #f0f0f0;
background-color: #4a4a4c;
color: #e8e8ed;
}
/* 菜单 - Apple深色风格 */
/* 菜单 - 优化版Apple深色风格 */
QMenu {
background-color: #2c2c2e;
border: 1px solid #404040;
border: 1px solid #3a3a3c;
border-radius: 8px;
font-size: 13px;
color: #f0f0f0;
color: #e8e8ed;
padding: 4px 0;
margin: 2px;
}
QMenu::item {
color: #f0f0f0;
color: #e8e8ed;
background-color: transparent;
border-radius: 4px;
border-radius: 6px;
margin: 0 4px;
padding: 4px 20px;
padding: 6px 20px;
}
QMenu::item:selected {
@ -228,22 +228,22 @@ class ThemeManager(QObject):
QMenu::separator {
height: 1px;
background-color: #404040;
background-color: #3a3a3c;
margin: 4px 8px;
}
/* 功能区 */
/* 功能区 - 优化背景色 */
QFrame {
background-color: #2c2c2e;
background-color: #1c1c1e;
border: none;
}
/* 组框 */
/* 组框 - 优化标题颜色 */
QGroupBox {
font-size: 12px;
font-weight: normal;
color: #f0f0f0;
background-color: #2c2c2e;
color: #e8e8ed;
background-color: #1c1c1e;
border: none;
border-radius: 8px;
margin-top: 5px;
@ -254,27 +254,27 @@ class ThemeManager(QObject):
subcontrol-origin: margin;
left: 10px;
padding: 0 5px 0 5px;
color: #a0a0a0;
color: #8a8a8d;
}
/* 工具按钮 - Apple深色风格 */
/* 工具按钮 - 优化版Apple深色风格 */
QToolButton {
border: 1px solid transparent;
border-radius: 6px;
background-color: #3a3a3c;
background-color: #2c2c2e;
font-size: 13px;
color: #f0f0f0;
color: #e8e8ed;
padding: 6px 12px;
}
QToolButton:hover {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
}
QToolButton:pressed {
background-color: #5a5a5c;
border: 1px solid #6a6a6c;
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
}
QToolButton:checked {
@ -283,18 +283,18 @@ class ThemeManager(QObject):
color: #ffffff;
}
/* 切换按钮 */
/* 切换按钮 - 优化样式 */
QToolButton[checkable="true"] {
border: 1px solid #4a4a4c;
border: 1px solid #3a3a3c;
border-radius: 6px;
background-color: #3a3a3c;
background-color: #2c2c2e;
font-size: 12px;
color: #f0f0f0;
color: #e8e8ed;
padding: 6px 12px;
}
QToolButton[checkable="true"]:hover {
background-color: #4a4a4c;
background-color: #3a3a3c;
}
QToolButton[checkable="true"]:checked {
@ -303,26 +303,26 @@ class ThemeManager(QObject):
color: #ffffff;
}
/* 下拉框 - Apple深色风格 */
/* 下拉框 - 优化版Apple深色风格 */
QComboBox {
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
background-color: #2c2c2e;
border: 1px solid #3a3a3c;
border-radius: 6px;
color: #f0f0f0;
color: #e8e8ed;
padding: 4px 8px;
selection-background-color: #0a84ff;
selection-color: #ffffff;
}
QComboBox:hover {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
}
QComboBox::drop-down {
border: none;
width: 20px;
border-left: 1px solid #4a4a4c;
border-left: 1px solid #3a3a3c;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
@ -331,44 +331,44 @@ class ThemeManager(QObject):
image: none;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 6px solid #a0a0a0;
border-top: 6px solid #8a8a8d;
margin: 6px;
}
QComboBox QAbstractItemView {
background-color: #2c2c2e;
border: 1px solid #4a4a4c;
color: #f0f0f0;
background-color: #1c1c1e;
border: 1px solid #3a3a3c;
color: #e8e8ed;
selection-background-color: #0a84ff;
selection-color: #ffffff;
}
/* 文本编辑区域 - Apple深色风格 */
/* 文本编辑区域 - 优化版Apple深色风格 */
QTextEdit {
background-color: #1c1c1e;
background-color: #121212;
border: none;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
font-size: 15px;
color: #f0f0f0;
color: #e8e8ed;
padding: 32px;
line-height: 1.5;
selection-background-color: #0066cc;
line-height: 1.6;
selection-background-color: #0a84ff;
selection-color: #ffffff;
}
/* 状态栏 - Apple深色风格 */
/* 状态栏 - 优化版Apple深色风格 */
QStatusBar {
background-color: #3a3a3c;
border-top: 1px solid #4a4a4c;
background-color: #2c2c2e;
border-top: 1px solid #3a3a3c;
font-size: 12px;
color: #a0a0a0;
color: #8a8a8d;
font-family: '-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Helvetica Neue', 'Helvetica', 'Arial', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
padding: 6px 12px;
}
/* 标签 */
/* 标签 - 优化颜色 */
QLabel {
color: #f0f0f0;
color: #e8e8ed;
background-color: transparent;
}
@ -436,24 +436,24 @@ class ThemeManager(QObject):
background: none;
}
/* 按钮 - Apple深色风格 */
/* 按钮 - 优化版Apple深色风格 */
QPushButton {
background-color: #3a3a3c;
color: #f0f0f0;
border: 1px solid #4a4a4c;
background-color: #2c2c2e;
color: #e8e8ed;
border: 1px solid #3a3a3c;
border-radius: 6px;
padding: 6px 16px;
font-size: 13px;
}
QPushButton:hover {
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
background-color: #3a3a3c;
border: 1px solid #4a4a4c;
}
QPushButton:pressed {
background-color: #5a5a5c;
border: 1px solid #6a6a6c;
background-color: #4a4a4c;
border: 1px solid #5a5a5c;
}
QPushButton:default {
@ -815,22 +815,28 @@ class ThemeManager(QObject):
'background': '#1e1e1e',
'surface': '#2d2d2d',
'surface_hover': '#3c3c3c',
'surface_pressed': '#4a4a4c',
'text': '#e0e0e0',
'text_secondary': '#b0b0b0',
'text_disabled': '#8a8a8d',
'border': '#3c3c3c',
'accent': '#0078d4',
'accent_hover': '#106ebe'
'accent_hover': '#106ebe',
'accent_pressed': '#005a9e'
}
else:
return {
'background': '#f3f2f1',
'surface': '#ffffff',
'surface_hover': '#f0f0f0',
'surface_pressed': '#e0e0e0',
'text': '#333333',
'text_secondary': '#666666',
'text_disabled': '#999999',
'border': '#d0d0d0',
'accent': '#0078d7',
'accent_hover': '#005a9e'
'accent_hover': '#005a9e',
'accent_pressed': '#004a99'
}

@ -359,7 +359,7 @@ class WordStyleMainWindow(QMainWindow):
# 更新日历组件样式
if hasattr(self, 'calendar_widget') and self.calendar_widget is not None:
# 日历组件有自己的主题管理机制,只需触发其主题更新
self.calendar_widget.apply_theme()
self.calendar_widget.apply_theme(is_dark)
def update_ribbon_styles(self, is_dark):
"""更新功能区样式"""

Loading…
Cancel
Save