mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
add empty card del hook, make sure we update templates on clayout close
This commit is contained in:
parent
1bcc8b9d27
commit
07ce5983f9
3 changed files with 13 additions and 14 deletions
|
@ -135,7 +135,7 @@ class AddCards(QDialog):
|
||||||
cards = self.mw.col.addNote(note)
|
cards = self.mw.col.addNote(note)
|
||||||
if not cards:
|
if not cards:
|
||||||
showWarning(_("""\
|
showWarning(_("""\
|
||||||
The input you have provided would make an empty
|
The input you have provided would make an empty \
|
||||||
question or answer on all cards."""), help="AddItems")
|
question or answer on all cards."""), help="AddItems")
|
||||||
return
|
return
|
||||||
self.addHistory(note)
|
self.addHistory(note)
|
||||||
|
|
|
@ -257,7 +257,7 @@ Enter deck to place new %s cards in, or leave blank:""") %
|
||||||
self.reject()
|
self.reject()
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
self.mm.save(self.model)
|
self.mm.save(self.model, templates=True)
|
||||||
self.mw.reset()
|
self.mw.reset()
|
||||||
saveGeom(self, "CardLayout")
|
saveGeom(self, "CardLayout")
|
||||||
return QDialog.reject(self)
|
return QDialog.reject(self)
|
||||||
|
|
23
aqt/main.py
23
aqt/main.py
|
@ -69,9 +69,9 @@ class AnkiQt(QMainWindow):
|
||||||
self.setupSystemSpecific()
|
self.setupSystemSpecific()
|
||||||
self.setupSignals()
|
self.setupSignals()
|
||||||
self.setupAutoUpdate()
|
self.setupAutoUpdate()
|
||||||
self.setupUpgrade()
|
|
||||||
self.setupCardStats()
|
self.setupCardStats()
|
||||||
self.setupSchema()
|
self.setupSchema()
|
||||||
|
self.setupEmptyCardDel()
|
||||||
self.updateTitleBar()
|
self.updateTitleBar()
|
||||||
# screens
|
# screens
|
||||||
self.setupDeckBrowser()
|
self.setupDeckBrowser()
|
||||||
|
@ -445,17 +445,6 @@ title="%s">%s</button>''' % (
|
||||||
from aqt.reviewer import Reviewer
|
from aqt.reviewer import Reviewer
|
||||||
self.reviewer = Reviewer(self)
|
self.reviewer = Reviewer(self)
|
||||||
|
|
||||||
# Upgrading from previous versions
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
def setupUpgrade(self):
|
|
||||||
addHook("1.x upgrade", self.onUpgrade)
|
|
||||||
|
|
||||||
def onUpgrade(self, db):
|
|
||||||
self.upgrading = True
|
|
||||||
self.progress.setupDB(db)
|
|
||||||
self.progress.start(label=_("Upgrading. Please be patient..."))
|
|
||||||
|
|
||||||
# Collection loading
|
# Collection loading
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
@ -818,6 +807,16 @@ This operation can't be merged when syncing, so if you have made \
|
||||||
changes on other devices that haven't been synced to this device yet, \
|
changes on other devices that haven't been synced to this device yet, \
|
||||||
they will be lost. Are you sure you want to continue?"""))
|
they will be lost. Are you sure you want to continue?"""))
|
||||||
|
|
||||||
|
# Empty card deletion
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def setupEmptyCardDel(self):
|
||||||
|
addHook("remEmptyCards", self.onEmptyCards)
|
||||||
|
|
||||||
|
def onEmptyCards(self, val, *args):
|
||||||
|
return askUser(_("""\
|
||||||
|
Your edits have left some cards empty. Do you want to delete them?"""))
|
||||||
|
|
||||||
# Advanced features
|
# Advanced features
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue