From aeaf9df32f440c94899c5742e304798b8d546e53 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 22 Jun 2017 16:49:53 +1000 Subject: [PATCH] ensure only one copy of stats shown, and close with collection --- aqt/__init__.py | 3 ++- aqt/main.py | 2 +- aqt/stats.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/aqt/__init__.py b/aqt/__init__.py index c93beed41..356d2e401 100644 --- a/aqt/__init__.py +++ b/aqt/__init__.py @@ -44,11 +44,12 @@ from anki.utils import checksum class DialogManager: def __init__(self): - from aqt import addcards, browser, editcurrent + from aqt import addcards, browser, editcurrent, stats self._dialogs = { "AddCards": [addcards.AddCards, None], "Browser": [browser.Browser, None], "EditCurrent": [editcurrent.EditCurrent, None], + "DeckStats": [stats.DeckStats, None] } def open(self, name, *args): diff --git a/aqt/main.py b/aqt/main.py index 416953449..dd77f53a6 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -734,7 +734,7 @@ title="%s" %s>%s''' % ( deck = self._selectedDeck() if not deck: return - aqt.stats.DeckStats(self) + aqt.dialogs.open("DeckStats", self) def onPrefs(self): import aqt.preferences diff --git a/aqt/stats.py b/aqt/stats.py index f11530fcd..036481793 100644 --- a/aqt/stats.py +++ b/aqt/stats.py @@ -42,8 +42,12 @@ class DeckStats(QDialog): self.show() self.activateWindow() + def canClose(self): + return True + def reject(self): saveGeom(self, self.name) + aqt.dialogs.close("DeckStats") QDialog.reject(self) def _imagePath(self):