diff --git a/qt/aqt/stats.py b/qt/aqt/stats.py index 0ad23deeb..d1bdb93e5 100644 --- a/qt/aqt/stats.py +++ b/qt/aqt/stats.py @@ -2,12 +2,13 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html +from __future__ import annotations + import time import aqt from anki.lang import _ from aqt.qt import * -from aqt.theme import theme_manager from aqt.utils import ( addCloseShortcut, getSaveFile, @@ -22,7 +23,7 @@ from aqt.utils import ( class DeckStats(QDialog): - def __init__(self, mw): + def __init__(self, mw: aqt.main.AnkiQt): QDialog.__init__(self, mw, Qt.Window) mw.setupDialogGC(self) self.mw = mw @@ -33,23 +34,15 @@ class DeckStats(QDialog): self.wholeCollection = False self.setMinimumWidth(700) f = self.form - if theme_manager.night_mode and not theme_manager.macos_dark_mode(): - # the grouping box renders incorrectly in the fusion theme. 5.9+ - # 5.13 behave differently to 5.14, but it looks bad in either case, - # and adjusting the top margin makes the 'save PDF' button show in - # the wrong place, so for now we just disable the border instead - self.setStyleSheet("QGroupBox { border: 0; }") f.setupUi(self) + # no night mode support yet + f.web._page.setBackgroundColor(QColor("white")) + f.groupBox.setVisible(False) + f.groupBox_2.setVisible(False) restoreGeom(self, self.name) b = f.buttonBox.addButton(_("Save PDF"), QDialogButtonBox.ActionRole) qconnect(b.clicked, self.saveImage) b.setAutoDefault(False) - qconnect(f.groups.clicked, lambda: self.changeScope("deck")) - f.groups.setShortcut("g") - qconnect(f.all.clicked, lambda: self.changeScope("collection")) - qconnect(f.month.clicked, lambda: self.changePeriod(0)) - qconnect(f.year.clicked, lambda: self.changePeriod(1)) - qconnect(f.life.clicked, lambda: self.changePeriod(2)) maybeHideClose(self.form.buttonBox) addCloseShortcut(self) self.show() @@ -87,22 +80,11 @@ class DeckStats(QDialog): tooltip(_("Saved.")) def changePeriod(self, n): - self.period = n - self.refresh() + pass def changeScope(self, type): - self.wholeCollection = type == "collection" - self.refresh() + pass def refresh(self): - self.mw.progress.start(parent=self) - stats = self.mw.col.stats() - stats.wholeCollection = self.wholeCollection - self.report = stats.report(type=self.period) - self.form.web.title = "deck stats" - self.form.web.stdHtml( - "
" + self.report + "", - js=["jquery.js", "plot.js"], - context=self, - ) - self.mw.progress.finish() + self.form.web.set_open_links_externally(False) + self.form.web.load(QUrl(f"{self.mw.serverURL()}_anki/graphs.html")) diff --git a/qt/designer/stats.ui b/qt/designer/stats.ui index 86869fedf..7642c135d 100644 --- a/qt/designer/stats.ui +++ b/qt/designer/stats.ui @@ -135,8 +135,24 @@