ensure only one copy of stats shown, and close with collection

This commit is contained in:
Damien Elmes 2017-06-22 16:49:53 +10:00
parent 34dcf64d76
commit aeaf9df32f
3 changed files with 7 additions and 2 deletions

View File

@ -44,11 +44,12 @@ from anki.utils import checksum
class DialogManager: class DialogManager:
def __init__(self): def __init__(self):
from aqt import addcards, browser, editcurrent from aqt import addcards, browser, editcurrent, stats
self._dialogs = { self._dialogs = {
"AddCards": [addcards.AddCards, None], "AddCards": [addcards.AddCards, None],
"Browser": [browser.Browser, None], "Browser": [browser.Browser, None],
"EditCurrent": [editcurrent.EditCurrent, None], "EditCurrent": [editcurrent.EditCurrent, None],
"DeckStats": [stats.DeckStats, None]
} }
def open(self, name, *args): def open(self, name, *args):

View File

@ -734,7 +734,7 @@ title="%s" %s>%s</button>''' % (
deck = self._selectedDeck() deck = self._selectedDeck()
if not deck: if not deck:
return return
aqt.stats.DeckStats(self) aqt.dialogs.open("DeckStats", self)
def onPrefs(self): def onPrefs(self):
import aqt.preferences import aqt.preferences

View File

@ -42,8 +42,12 @@ class DeckStats(QDialog):
self.show() self.show()
self.activateWindow() self.activateWindow()
def canClose(self):
return True
def reject(self): def reject(self):
saveGeom(self, self.name) saveGeom(self, self.name)
aqt.dialogs.close("DeckStats")
QDialog.reject(self) QDialog.reject(self)
def _imagePath(self): def _imagePath(self):