cloze deletion tweaks (#601)

- allow creation of cloze deletion when note type not selected; warn with
tooltip. prevents selection from getting lost
- warn before adding cloze note type with no deletions
This commit is contained in:
Damien Elmes 2013-05-17 15:57:22 +09:00
parent 205c6d4c38
commit ebba215a9a
2 changed files with 10 additions and 5 deletions

View file

@ -131,6 +131,12 @@ class AddCards(QDialog):
"The first field is empty."),
help="AddItems#AddError")
return
if '{{cloze:' in note.model()['tmpls'][0]['qfmt']:
if not self.mw.col.models._availClozeOrds(
note.model(), note.joinedFields(), False):
if not askUser(_("You have a cloze deletion note type "
"but have not made any cloze deletions. Proceed?")):
return
cards = self.mw.col.addNote(note)
if not cards:
showWarning(_("""\

View file

@ -10,7 +10,7 @@ from anki.hooks import runHook, runFilter
from aqt.sound import getAudio
from aqt.webview import AnkiWebView
from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile, \
openHelp
openHelp, tooltip
import aqt
import anki.js
from BeautifulSoup import BeautifulSoup
@ -754,9 +754,8 @@ class Editor(object):
# check that the model is set up for cloze deletion
if '{{cloze:' not in self.note.model()['tmpls'][0]['qfmt']:
if self.addMode:
showInfo(_("""\
To use this button, please select the Cloze note type. To learn more, \
please click the help button."""), help="cloze")
tooltip(_("Warning, cloze deletions will not work until "
"you switch the type at the top to Cloze."))
else:
showInfo(_("""\
To make a cloze deletion on an existing note, you need to change it \