天气悬浮窗口优化

Maziang 3 months ago
parent 2415e09748
commit cd39d74ace

@ -203,44 +203,45 @@ class WeatherFloatingWidget(QDialog):
colors = theme_manager.get_current_theme_colors()
if is_dark:
# 深色主题样式
# 深色主题样式 - 与每日谏言悬浮窗口保持一致
self.main_frame.setStyleSheet(f"""
QFrame#mainFrame {{
background-color: {colors['surface']};
border: 1px solid {colors['border']};
border-radius: 8px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}}
QLabel {{
color: {colors['text']};
background-color: transparent;
padding: 3px 5px; // 适度增加padding使布局更舒适
margin: 1px;
padding: 4px 6px;
margin: 2px;
}}
QLabel#temperatureLabel {{
color: {colors['accent']};
font-size: 19px; // 适度增大字体大小
font-size: 20px;
font-weight: bold;
padding: 5px 7px; // 适度增加padding使布局更舒适
margin: 2px;
padding: 6px 8px;
margin: 3px;
}}
QLabel#cityLabel {{
color: {colors['text_secondary']};
font-size: 12px; // 适度增大字体大小
padding: 3px 5px; // 适度增加padding使布局更舒适
margin: 1px;
font-size: 12px;
padding: 4px 6px;
margin: 2px;
}}
QLabel#weatherDescLabel {{
color: {colors['text']};
font-size: 12px; // 适度增大字体大小
font-size: 12px;
font-weight: 500;
padding: 3px 5px; // 适度增加padding使布局更舒适
margin: 1px;
padding: 4px 6px;
margin: 2px;
}}
QLabel#detailLabel {{
color: {colors['text_secondary']};
font-size: 11px; // 适度增大字体大小
padding: 3px 5px; // 适度增加padding使布局更舒适
margin: 1px;
font-size: 11px;
padding: 4px 6px;
margin: 2px;
}}
QFrame#separator {{
background-color: {colors['border']};
@ -263,9 +264,9 @@ class WeatherFloatingWidget(QDialog):
background-color: {colors['accent']};
color: white;
border: none;
border-radius: 6px; // 适度增加圆角
padding: 5px 14px; // 适度增加padding使按钮更舒适
font-size: 11px; // 适度增大字体大小
border-radius: 6px;
padding: 6px 16px;
font-size: 11px;
font-weight: 500;
}}
QPushButton#refreshButton:hover, QPushButton#detailButton:hover {{
@ -275,28 +276,28 @@ class WeatherFloatingWidget(QDialog):
background-color: {colors['surface']};
color: {colors['text']};
border: 1px solid {colors['border']};
border-radius: 6px; // 适度增加圆角
padding: 4px 7px; // 适度增加padding使布局更舒适
font-size: 11px; // 适度增大字体大小
border-radius: 6px;
padding: 4px 7px;
font-size: 11px;
font-weight: 500;
min-height: 24px; // 适度增加最小高度使布局更舒适
min-height: 24px;
}}
QComboBox#cityCombo:hover {{
border-color: {colors['accent']};
}}
QComboBox#cityCombo::drop-down {{
border: none;
width: 14px; // 适度增加宽度
width: 14px;
}}
QComboBox#cityCombo::down-arrow {{
image: none;
border-left: 2px solid transparent;
border-right: 2px solid transparent;
border-top: 5px solid {colors['text']}; // 适度增加箭头大小
border-top: 5px solid {colors['text']};
}}
""")
else:
# 浅色主题样式
# 浅色主题样式 - 与每日谏言悬浮窗口保持一致
self.main_frame.setStyleSheet(f"""
QFrame#mainFrame {{
background-color: {colors['surface']};
@ -357,9 +358,9 @@ class WeatherFloatingWidget(QDialog):
background-color: {colors['accent']};
color: white;
border: none;
border-radius: 6px; // 适度增加圆角
padding: 5px 14px; // 适度增加padding使按钮更舒适
font-size: 11px; // 适度增大字体大小
border-radius: 6px;
padding: 6px 16px;
font-size: 11px;
font-weight: 500;
}}
QPushButton#refreshButton:hover, QPushButton#detailButton:hover {{
@ -369,24 +370,24 @@ class WeatherFloatingWidget(QDialog):
background-color: {colors['surface']};
color: {colors['text']};
border: 1px solid {colors['border']};
border-radius: 6px; // 适度增加圆角
padding: 4px 7px; // 适度增加padding使布局更舒适
font-size: 11px; // 适度增大字体大小
border-radius: 6px;
padding: 4px 7px;
font-size: 11px;
font-weight: 500;
min-height: 24px; // 适度增加最小高度使布局更舒适
min-height: 24px;
}}
QComboBox#cityCombo:hover {{
border-color: {colors['accent']};
}}
QComboBox#cityCombo::drop-down {{
border: none;
width: 14px; // 适度增加宽度
width: 14px;
}}
QComboBox#cityCombo::down-arrow {{
image: none;
border-left: 2px solid transparent;
border-right: 2px solid transparent;
border-top: 5px solid {colors['text']}; // 适度增加箭头大小
border-top: 5px solid {colors['text']};
}}
""")

@ -1655,7 +1655,18 @@ class WordStyleMainWindow(QMainWindow):
"""手动刷新天气信息"""
try:
# 获取当前选择的城市
current_city = self.ribbon.city_combo.currentText()
current_city = "自动定位" # 默认值
# 安全地获取当前城市选择
if hasattr(self, 'ribbon') and hasattr(self.ribbon, 'city_combo'):
current_city = self.ribbon.city_combo.currentText()
elif hasattr(self, 'weather_floating_widget') and hasattr(self.weather_floating_widget, 'city_combo'):
# 如果Ribbon中的city_combo不可用尝试从天气悬浮窗口获取
current_city = self.weather_floating_widget.city_combo.currentText()
else:
# 如果都没有,使用默认值
current_city = "自动定位"
print(f"刷新天气 - 当前选择的城市: {current_city}")
if current_city == '自动定位':

Loading…
Cancel
Save