mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
add help to cram mode, fail if no cards matched
This commit is contained in:
parent
9c67a69b65
commit
c2a8302a26
2 changed files with 42 additions and 6 deletions
|
@ -1049,7 +1049,7 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
|
|||
ui.utils.showInfo(
|
||||
_("Already cramming. Please close this deck first."))
|
||||
return
|
||||
(s, ret) = QInputDialog.getText(self, _("Anki"), _("Tags to cram:"))
|
||||
(s, ret) = ui.utils.getText(_("Tags to cram:"), help="CramMode")
|
||||
if not ret:
|
||||
return
|
||||
s = unicode(s)
|
||||
|
@ -1063,6 +1063,9 @@ To upgrade an old deck, download Anki 0.9.8.7."""))
|
|||
if s:
|
||||
e.limitTags = parseTags(s)
|
||||
e.exportInto(path)
|
||||
if not e.exportedCards:
|
||||
ui.utils.showInfo(_("No cards matched the provided tags."))
|
||||
return
|
||||
self.deck.close()
|
||||
self.deck = None
|
||||
self.loadDeck(path)
|
||||
|
|
|
@ -44,13 +44,46 @@ def askUser(text, parent=None):
|
|||
QMessageBox.Yes | QMessageBox.No)
|
||||
return r == QMessageBox.Yes
|
||||
|
||||
def getText(prompt, parent=None):
|
||||
class GetTextDialog(QDialog):
|
||||
|
||||
def __init__(self, parent, question, help=None):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setWindowTitle("Anki")
|
||||
self.question = question
|
||||
self.help = help
|
||||
v = QVBoxLayout()
|
||||
v.addWidget(QLabel(question))
|
||||
self.l = QLineEdit()
|
||||
v.addWidget(self.l)
|
||||
buts = QDialogButtonBox.Ok | QDialogButtonBox.Cancel
|
||||
if help:
|
||||
buts |= QDialogButtonBox.Help
|
||||
b = QDialogButtonBox(buts)
|
||||
v.addWidget(b)
|
||||
self.setLayout(v)
|
||||
self.connect(b.button(QDialogButtonBox.Ok),
|
||||
SIGNAL("clicked()"), self.accept)
|
||||
self.connect(b.button(QDialogButtonBox.Cancel),
|
||||
SIGNAL("clicked()"), self.reject)
|
||||
if help:
|
||||
self.connect(b.button(QDialogButtonBox.Help),
|
||||
SIGNAL("clicked()"), self.helpRequested)
|
||||
|
||||
def accept(self):
|
||||
return QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
return QDialog.reject(self)
|
||||
|
||||
def helpRequested(self):
|
||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + self.help))
|
||||
|
||||
def getText(prompt, parent=None, help=None):
|
||||
if not parent:
|
||||
parent = ankiqt.mw
|
||||
(text, ok) = QInputDialog.getText(parent, "Anki", prompt)
|
||||
if not ok:
|
||||
return None
|
||||
return unicode(text)
|
||||
d = GetTextDialog(parent, prompt, help=help)
|
||||
ret = d.exec_()
|
||||
return (unicode(d.l.text()), ret)
|
||||
|
||||
def getFile(parent, title, dir, key):
|
||||
"Ask the user for a file. Use DIR as config variable."
|
||||
|
|
Loading…
Reference in a new issue