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.setupAutoUpdate()
|
||||||
self.setupCardStats()
|
self.setupCardStats()
|
||||||
self.setupSchema()
|
self.setupSchema()
|
||||||
self.setupEmptyCardDel()
|
|
||||||
self.updateTitleBar()
|
self.updateTitleBar()
|
||||||
# screens
|
# screens
|
||||||
self.setupDeckBrowser()
|
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.actionDonate, s, self.onDonate)
|
||||||
self.connect(m.actionFullSync, s, self.onFullSync)
|
self.connect(m.actionFullSync, s, self.onFullSync)
|
||||||
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
||||||
|
self.connect(m.actionEmptyCards, s, self.onEmptyCards)
|
||||||
|
|
||||||
def updateTitleBar(self):
|
def updateTitleBar(self):
|
||||||
self.setWindowTitle("Anki")
|
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 \
|
waiting on another device that haven't been synchronized here yet, they \
|
||||||
will be lost. Continue?"""))
|
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
|
# 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
|
from aqt.studydeck import StudyDeck
|
||||||
StudyDeck(self)
|
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
|
# System specific code
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ def showInfo(text, parent=None, help="", type="info"):
|
||||||
b.setAutoDefault(False)
|
b.setAutoDefault(False)
|
||||||
return mb.exec_()
|
return mb.exec_()
|
||||||
|
|
||||||
def showText(txt, parent=None, type="text"):
|
def showText(txt, parent=None, type="text", run=True):
|
||||||
if not parent:
|
if not parent:
|
||||||
parent = aqt.mw.app.activeWindow() or aqt.mw
|
parent = aqt.mw.app.activeWindow() or aqt.mw
|
||||||
diag = QDialog(parent)
|
diag = QDialog(parent)
|
||||||
|
@ -66,7 +66,10 @@ def showText(txt, parent=None, type="text"):
|
||||||
diag.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
|
diag.connect(box, SIGNAL("rejected()"), diag, SLOT("reject()"))
|
||||||
diag.setMinimumHeight(400)
|
diag.setMinimumHeight(400)
|
||||||
diag.setMinimumWidth(500)
|
diag.setMinimumWidth(500)
|
||||||
diag.exec_()
|
if run:
|
||||||
|
diag.exec_()
|
||||||
|
else:
|
||||||
|
return diag, box
|
||||||
|
|
||||||
def askUser(text, parent=None, help="", defaultno=False):
|
def askUser(text, parent=None, help="", defaultno=False):
|
||||||
"Show a yes/no question. Return true if yes."
|
"Show a yes/no question. Return true if yes."
|
||||||
|
|
|
@ -101,13 +101,20 @@
|
||||||
<addaction name="menuStartup"/>
|
<addaction name="menuStartup"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
</widget>
|
</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="actionStudyDeck"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionCstats"/>
|
<addaction name="actionCstats"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionFullDatabaseCheck"/>
|
<addaction name="menuMaintenance"/>
|
||||||
<addaction name="actionCheckMediaDatabase"/>
|
|
||||||
<addaction name="actionFullSync"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="menuPlugins"/>
|
<addaction name="menuPlugins"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -259,6 +266,11 @@
|
||||||
<string>/</string>
|
<string>/</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionEmptyCards">
|
||||||
|
<property name="text">
|
||||||
|
<string>Empty Cards...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
Loading…
Reference in a new issue