mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
split empty card removal into separate diag
This commit is contained in:
parent
fd2851ac1e
commit
c60a6560c1
3 changed files with 42 additions and 18 deletions
35
aqt/main.py
35
aqt/main.py
|
@ -65,7 +65,6 @@ class AnkiQt(QMainWindow):
|
|||
self.setupAutoUpdate()
|
||||
self.setupCardStats()
|
||||
self.setupSchema()
|
||||
self.setupEmptyCardDel()
|
||||
self.updateTitleBar()
|
||||
# screens
|
||||
self.setupDeckBrowser()
|
||||
|
@ -768,6 +767,7 @@ upload, overwriting any changes either here or on AnkiWeb. Proceed?""")):
|
|||
self.connect(m.actionDonate, s, self.onDonate)
|
||||
self.connect(m.actionFullSync, s, self.onFullSync)
|
||||
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
||||
self.connect(m.actionEmptyCards, s, self.onEmptyCards)
|
||||
|
||||
def updateTitleBar(self):
|
||||
self.setWindowTitle("Anki")
|
||||
|
@ -825,18 +825,6 @@ you next synchronize your collection. If you have reviews or other changes \
|
|||
waiting on another device that haven't been synchronized here yet, they \
|
||||
will be lost. Continue?"""))
|
||||
|
||||
# Empty card deletion
|
||||
##########################################################################
|
||||
|
||||
def setupEmptyCardDel(self):
|
||||
addHook("remEmptyCards", self.onEmptyCards)
|
||||
|
||||
def onEmptyCards(self, flag, cnt):
|
||||
if flag and askUser(_("""\
|
||||
Your edits have left %d cards empty. Do you want to delete them?""" % cnt)):
|
||||
return flag
|
||||
return False
|
||||
|
||||
# Advanced features
|
||||
##########################################################################
|
||||
|
||||
|
@ -906,6 +894,27 @@ Your edits have left %d cards empty. Do you want to delete them?""" % cnt)):
|
|||
from aqt.studydeck import StudyDeck
|
||||
StudyDeck(self)
|
||||
|
||||
def onEmptyCards(self):
|
||||
self.progress.start(immediate=True)
|
||||
cids = self.col.emptyCids()
|
||||
if not cids:
|
||||
self.progress.finish()
|
||||
tooltip(_("No empty cards."))
|
||||
return
|
||||
report = self.col.emptyCardReport(cids)
|
||||
self.progress.finish()
|
||||
diag, box = showText(
|
||||
_("%d cards to delete:\n\n%s") % (len(cids), report), run=False)
|
||||
box.addButton(_("Delete Cards"), QDialogButtonBox.AcceptRole)
|
||||
box.button(QDialogButtonBox.Close).setDefault(True)
|
||||
def onDelete():
|
||||
QDialog.accept(diag)
|
||||
self.checkpoint(_("Delete Empty"))
|
||||
self.col.remCards(cids)
|
||||
tooltip(_("%d cards deleted.") % len(cids))
|
||||
diag.connect(box, SIGNAL("accepted()"), onDelete)
|
||||
diag.exec_()
|
||||
|
||||
# System specific code
|
||||
##########################################################################
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def showInfo(text, parent=None, help="", type="info"):
|
|||
b.setAutoDefault(False)
|
||||
return mb.exec_()
|
||||
|
||||
def showText(txt, parent=None, type="text"):
|
||||
def showText(txt, parent=None, type="text", run=True):
|
||||
if not parent:
|
||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||
diag = QDialog(parent)
|
||||
|
@ -66,7 +66,10 @@ def showText(txt, parent=None, type="text"):
|
|||
diag.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
|
||||
diag.setMinimumHeight(400)
|
||||
diag.setMinimumWidth(500)
|
||||
if run:
|
||||
diag.exec_()
|
||||
else:
|
||||
return diag, box
|
||||
|
||||
def askUser(text, parent=None, help="", defaultno=False):
|
||||
"Show a yes/no question. Return true if yes."
|
||||
|
|
|
@ -101,13 +101,20 @@
|
|||
<addaction name="menuStartup"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuMaintenance">
|
||||
<property name="title">
|
||||
<string>Maintenance</string>
|
||||
</property>
|
||||
<addaction name="actionFullDatabaseCheck"/>
|
||||
<addaction name="actionCheckMediaDatabase"/>
|
||||
<addaction name="actionEmptyCards"/>
|
||||
<addaction name="actionFullSync"/>
|
||||
</widget>
|
||||
<addaction name="actionStudyDeck"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCstats"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFullDatabaseCheck"/>
|
||||
<addaction name="actionCheckMediaDatabase"/>
|
||||
<addaction name="actionFullSync"/>
|
||||
<addaction name="menuMaintenance"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuPlugins"/>
|
||||
<addaction name="separator"/>
|
||||
|
@ -259,6 +266,11 @@
|
|||
<string>/</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEmptyCards">
|
||||
<property name="text">
|
||||
<string>Empty Cards...</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
|
Loading…
Reference in a new issue