'update'
This commit is contained in:
@@ -94,8 +94,10 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
"QPushButton { border:none; color:#ffffff; padding:6px 22px; font-size:14px; font-weight:600; border-radius:22px; }"
|
||||
"QPushButton#export_btn { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #63a9ff, stop:1 #388bff); }"
|
||||
"QPushButton#config_btn { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #7ed957, stop:1 #4caf50); }"
|
||||
"QPushButton:hover { filter: brightness(1.08); }"
|
||||
"QPushButton:pressed { filter: brightness(0.92); }"
|
||||
"QPushButton#export_btn:hover { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #73b9ff, stop:1 #489bff); }"
|
||||
"QPushButton#config_btn:hover { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #8ef967, stop:1 #5cbf60); }"
|
||||
"QPushButton#export_btn:pressed { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #5399df, stop:1 #287bdf); }"
|
||||
"QPushButton#config_btn:pressed { background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #6ec937, stop:1 #3c9f40); }"
|
||||
"QPushButton:disabled { background:#888888; color:#dddddd; }"
|
||||
)
|
||||
# 仅作用于这两个按钮:分别附加 objectName 选择器
|
||||
@@ -594,7 +596,7 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
font = QFont(chosen, size)
|
||||
QApplication.instance().setFont(font)
|
||||
self.setFont(font)
|
||||
print(f'[字体] 应用 {chosen} {size}px')
|
||||
# print(f'[字体] 应用 {chosen} {size}px') # 字体应用成功
|
||||
except Exception as e:
|
||||
print('全局字体应用失败:', e)
|
||||
|
||||
@@ -623,7 +625,8 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
return "".join(parts)
|
||||
|
||||
def _init_charts(self):
|
||||
"""使用原生 Qt 组件渲染统计标签页四个图表(取代 matplotlib)。"""
|
||||
"""初始化原生图表组件,适配统计界面的相应区域"""
|
||||
print("📊 开始初始化图表组件...")
|
||||
try:
|
||||
from charts import BarChartWidget, BubbleMetricsWidget, ScatterChartWidget
|
||||
except Exception as e:
|
||||
@@ -637,20 +640,29 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
]
|
||||
for attr, layout_name in required:
|
||||
if not hasattr(self, attr) or not hasattr(self, layout_name):
|
||||
print('信息: 缺少统计容器', attr)
|
||||
print(f'信息: 缺少统计容器 {attr} 或 {layout_name}')
|
||||
return
|
||||
|
||||
print("📈 正在获取统计数据...")
|
||||
try:
|
||||
week_data = self.manager.get_total_readtime(days=7)
|
||||
month_data = self.manager.get_total_readtime(days=30)
|
||||
year_data = self.manager.get_total_readtime12m()
|
||||
year_total_minutes = self.manager.get_total_readtime_year()
|
||||
print(f" 7天总计: {sum(week_data)}分钟")
|
||||
print(f" 30天总计: {sum(month_data)}分钟")
|
||||
print(f" 年度总计: {sum(year_data)}分钟")
|
||||
except Exception as e:
|
||||
print('警告: 统计数据获取失败:', e)
|
||||
return
|
||||
|
||||
if all(v == 0 for v in week_data + month_data + year_data):
|
||||
print("⚠️ 所有数据为0,显示无数据提示")
|
||||
for _, layout_name in required:
|
||||
getattr(self, layout_name).addWidget(QLabel('暂无阅读数据'))
|
||||
return
|
||||
|
||||
print("✅ 数据正常,开始创建图表...")
|
||||
# 最近7天:weekday 英文缩写(索引0=今天)
|
||||
today = datetime.date.today()
|
||||
recent_days = [today - datetime.timedelta(days=i) for i in range(len(week_data))]
|
||||
@@ -677,9 +689,14 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
from PyQt6.QtWidgets import QSizePolicy
|
||||
for wdg in (week_chart, month_chart, year_chart):
|
||||
wdg.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
|
||||
print("🎯 正在添加图表到界面...")
|
||||
self.weekLayout.addWidget(week_chart)
|
||||
self.monthLayout.addWidget(month_chart)
|
||||
self.yearLayout.addWidget(year_chart)
|
||||
print(" - 7天图表已添加")
|
||||
print(" - 30天图表已添加")
|
||||
print(" - 年度图表已添加")
|
||||
year_hours_total = year_total_minutes / 60.0
|
||||
month_avg_hours = (sum(year_data)/12.0)/60.0 if year_data else 0
|
||||
week_hours = sum(week_data)/60.0
|
||||
@@ -700,6 +717,8 @@ class IBookExportApp(CoverMixin, FinishedBooksMixin, QWidget):
|
||||
bubble_widget = BubbleMetricsWidget(bubble_metrics)
|
||||
bubble_widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
self.bubbleLayout.addWidget(bubble_widget)
|
||||
print(" - 气泡图表已添加")
|
||||
print("🎉 所有图表初始化完成!")
|
||||
|
||||
# ---------------- 窗口尺寸持久化 ----------------
|
||||
def _restore_window_geometry(self):
|
||||
|
||||
Reference in New Issue
Block a user