@ -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 : # 2c2c2 e;
color : # f0f0f0 ;
background - color : # 1c1c1 e;
color : # e8e8ed ;
}
""" )
# 更新日历控件样式
self . calendar . setStyleSheet ( """
QCalendarWidget {
background - color : # 2c2c2 e;
border : 1 px solid # 404040 ;
border - radius : 4 px ;
background - color : # 1c1c1 e;
border : 1 px solid # 3a3a3c ;
border - radius : 8 px ;
}
QCalendarWidget QToolButton {
height : 3 0 px ;
width : 8 0 px ;
color : # f0f0f0 ;
font - size : 1 2 px ;
font - weight : bold ;
background - color : # 3a3a3c ;
border : 1 px solid # 4a4a4 c;
border - radius : 4 px ;
height : 3 2 px ;
width : 8 5 px ;
color : # e8e8ed ;
font - size : 1 3 px ;
font - weight : 500 ;
background - color : # 2c2c2e ;
border : 1 px solid # 3a3a3 c;
border - radius : 6 px ;
}
QCalendarWidget QToolButton : hover {
QCalendarWidget QToolButton : pressed {
background - color : #4a4a4c;
border : 1 px solid #5a5a5c;
}
QCalendarWidget QMenu {
width : 150 px ;
left : 20 px ;
color : #f0f0f0;
font - size : 12 px ;
QCalendarWidget QToolButton : hover {
background - color : #3a3a3c;
border : 1 px solid #4a4a4c;
}
QCalendarWidget QMenu {
width : 160 px ;
left : 20 px ;
color : #e8e8ed;
font - size : 13 px ;
background - color : #2c2c2e;
border : 1 px solid #3a3a3c;
border - radius : 6 px ;
}
QCalendarWidget QMenu : : item : selected {
background - color : #0a84ff;
color : #ffffff;
}
QCalendarWidget QSpinBox {
width : 80 px ;
font - size : 12 px ;
background - color : #3a3a3c;
width : 8 5 px ;
font - size : 1 3 px ;
background - color : # 2c2c2e ;
selection - background - color : #0a84ff;
selection - color : #ffffff;
border : 1 px solid #4a4a4c;
border - radius : 4 px ;
color : #f0f0f0;
border : 1 px solid #3a3a3c;
border - radius : 6 px ;
color : #e8e8ed;
padding : 2 px ;
}
QCalendarWidget QSpinBox : : up - button {
subcontrol - origin : border ;
subcontrol - position : top right ;
width : 20 px ;
width : 22 px ;
border : 1 px solid #3a3a3c;
background - color : #2c2c2e;
border - radius : 0 6 px 0 0 ;
}
QCalendarWidget QSpinBox : : down - button {
subcontrol - origin : border ;
subcontrol - position : bottom right ;
width : 20 px ;
width : 22 px ;
border : 1 px solid #3a3a3c;
background - color : #2c2c2e;
border - radius : 0 0 6 px 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 : 10 px ;
height : 10 px ;
width : 1 2 px ;
height : 1 2 px ;
}
QCalendarWidget QSpinBox : : down - arrow {
width : 10 px ;
height : 10 px ;
width : 1 2 px ;
height : 1 2 px ;
}
QCalendarWidget QWidget {
alternate - background - color : #3a3a3c;
alternate - background - color : # 2c2c2e ;
}
QCalendarWidget QAbstractItemView : enabled {
font - size : 1 2 px ;
font - size : 1 3 px ;
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: # a0a0a 0; }" )
self . date_label . setStyleSheet ( " QLabel { color: # 8a8a8d; font-size: 12px; font-weight: 50 0; }" )
# 更新按钮样式
self . close_btn . setStyleSheet ( """
QPushButton {
background - color : #2c2c2e;
border : 1 px solid #3a3a3c;
border - radius : 14 px ;
font - size : 18 px ;
font - weight : 600 ;
color : #e8e8ed;
padding : 6 px ;
}
QPushButton : hover {
background - color : #3a3a3c;
border : 1 px solid #4a4a4c;
border - radius : 12 px ;
font - size : 16 px ;
font - weight : bold ;
color : #f0f0f0;
}
QPushButton : hover {
QPushButton : pressed {
background - color : #4a4a4c;
border : 1 px solid #5a5a5c;
}
""" )
self . today_btn . setStyleSheet ( """
QPushButton {
background - color : #0a84ff;
color : white ;
color : #ffffff ;
border : none ;
border - radius : 4 px ;
padding : 5 px 10 px ;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
QPushButton : hover {
background - color : #0066cc;
background - color : #0071e3;
}
QPushButton : pressed {
background - color : #0051d5;
}
""" )
self . clear_btn . setStyleSheet ( """
QPushButton {
background - color : #2c2c2e;
color : #e8e8ed;
border : 1 px solid #3a3a3c;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
QPushButton : hover {
background - color : #3a3a3c;
color : #f0f0f0;
border : 1 px solid #4a4a4c;
border - radius : 4 px ;
padding : 5 px 10 px ;
}
QPushButton : hover {
QPushButton : pressed {
background - color : #4a4a4c;
border : 1 px solid #5a5a5c;
}
""" )
self . insert_btn . setStyleSheet ( """
QPushButton {
background - color : #3 2d74b ;
color : # 000000 ;
background - color : #3 4c759 ;
color : # ffffff ;
border : none ;
border - radius : 4 px ;
padding : 5 px 10 px ;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
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 : 1 px solid # ccc ;
border - radius : 4 px ;
background - color : #ffffff ;
border : 1 px solid # e0e0e0 ;
border - radius : 6 px ;
}
QCalendarWidget QToolButton {
height : 30 px ;
width : 80 px ;
color : #333;
font - size : 12 px ;
font - weight : bold ;
height : 32 px ;
width : 85 px ;
color : #333333;
font - size : 13 px ;
font - weight : 500 ;
background - color : #ffffff;
border : 1 px solid #e0e0e0;
border - radius : 6 px ;
}
QCalendarWidget QToolButton : pressed {
background - color : #f0f0f0;
border : 1 px solid #ccc;
border - radius : 4 px ;
border : 1 px solid #c0c0c0;
}
QCalendarWidget QToolButton : hover {
background - color : #e0e0e0;
background - color : #f0f0f0;
border : 1 px solid #d0d0d0;
}
QCalendarWidget QMenu {
width : 1 5 0px ;
width : 1 6 0px ;
left : 20 px ;
color : #333;
font - size : 12 px ;
background - color : white ;
border : 1 px solid #ccc;
color : #333333;
font - size : 13 px ;
background - color : #ffffff;
border : 1 px solid #e0e0e0;
border - radius : 6 px ;
}
QCalendarWidget QMenu : : item : selected {
background - color : #007aff;
color : #ffffff;
}
QCalendarWidget QSpinBox {
width : 80 px ;
font - size : 12 px ;
background - color : #f0f0f0;
selection - background - color : #0078d7;
selection - color : white ;
border : 1 px solid #ccc;
border - radius : 4 px ;
color : #333;
width : 85 px ;
font - size : 13 px ;
background - color : #ffffff;
selection - background - color : #007aff;
selection - color : #ffffff;
border : 1 px solid #e0e0e0;
border - radius : 6 px ;
color : #333333;
padding : 2 px ;
}
QCalendarWidget QSpinBox : : up - button {
subcontrol - origin : border ;
subcontrol - position : top right ;
width : 20 px ;
width : 22 px ;
border : 1 px solid #e0e0e0;
background - color : #ffffff;
border - radius : 0 6 px 0 0 ;
}
QCalendarWidget QSpinBox : : down - button {
subcontrol - origin : border ;
subcontrol - position : bottom right ;
width : 20 px ;
width : 22 px ;
border : 1 px solid #e0e0e0;
background - color : #ffffff;
border - radius : 0 0 6 px 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 : 10 px ;
height : 10 px ;
width : 1 2 px ;
height : 1 2 px ;
}
QCalendarWidget QSpinBox : : down - arrow {
width : 10 px ;
height : 10 px ;
width : 1 2 px ;
height : 1 2 px ;
}
QCalendarWidget QWidget {
alternate - background - color : #f0f0f0;
alternate - background - color : #f 8f8f8 ;
}
QCalendarWidget QAbstractItemView : enabled {
font - size : 12 px ;
selection - background - color : #0078d7;
selection - color : white ;
background - color : white ;
color : #333;
font - size : 13 px ;
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: #666 666; font-size: 12px; font-weight: 500 ; }" )
# 更新按钮样式
self . close_btn . setStyleSheet ( """
QPushButton {
background - color : #f0f0f0;
border : 1 px solid #ccc;
border - radius : 12 px ;
font - size : 16 px ;
font - weight : bold ;
color : #333;
background - color : #ffffff;
border : 1 px solid #e0e0e0;
border - radius : 14 px ;
font - size : 18 px ;
font - weight : 600 ;
color : #333333;
padding : 6 px ;
}
QPushButton : hover {
background - color : #f0f0f0;
border : 1 px solid #d0d0d0;
}
QPushButton : pressed {
background - color : #e0e0e0;
border : 1 px solid #c0c0c0;
}
""" )
self . today_btn . setStyleSheet ( """
QPushButton {
background - color : #007 8d7 ;
color : white ;
background - color : #007 aff ;
color : #ffffff ;
border : none ;
border - radius : 4 px ;
padding : 5 px 10 px ;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
QPushButton : hover {
background - color : #005a9e;
background - color : #0056b3;
}
QPushButton : pressed {
background - color : #004494;
}
""" )
self . clear_btn . setStyleSheet ( """
QPushButton {
background - color : #f0f0f0;
color : #333;
border : 1 px solid #ccc;
border - radius : 4 px ;
padding : 5 px 10 px ;
background - color : #ffffff;
color : #333333;
border : 1 px solid #e0e0e0;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
QPushButton : hover {
background - color : #f0f0f0;
border : 1 px solid #d0d0d0;
}
QPushButton : pressed {
background - color : #e0e0e0;
border : 1 px solid #c0c0c0;
}
""" )
self . insert_btn . setStyleSheet ( """
QPushButton {
background - color : # 4CAF50 ;
color : white ;
background - color : # 34c759 ;
color : #ffffff ;
border : none ;
border - radius : 4 px ;
padding : 5 px 10 px ;
border - radius : 6 px ;
padding : 6 px 12 px ;
font - weight : 500 ;
font - size : 12 px ;
}
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__ " :