mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 06:07:11 -05:00
add option to cram current deck
This commit is contained in:
parent
56b89fdc91
commit
a1ef0c2d73
3 changed files with 10 additions and 3 deletions
|
|
@ -9,7 +9,7 @@ from aqt.utils import showInfo, showWarning, openHelp, getOnlyText
|
|||
from operator import itemgetter
|
||||
|
||||
class DeckConf(QDialog):
|
||||
def __init__(self, mw, first=False):
|
||||
def __init__(self, mw, first=False, search=""):
|
||||
QDialog.__init__(self, mw)
|
||||
self.mw = mw
|
||||
self.deck = self.mw.col.decks.current()
|
||||
|
|
@ -29,6 +29,8 @@ class DeckConf(QDialog):
|
|||
self.setWindowTitle(_("Options for %s") % self.deck['name'])
|
||||
self.setupCombos()
|
||||
self.loadConf()
|
||||
if first and search:
|
||||
self.form.search.setText(search)
|
||||
self.exec_()
|
||||
|
||||
def setupCombos(self):
|
||||
|
|
|
|||
|
|
@ -718,7 +718,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
# Cramming
|
||||
##########################################################################
|
||||
|
||||
def onCram(self):
|
||||
def onCram(self, search=""):
|
||||
import aqt.dyndeckconf
|
||||
n = 1
|
||||
decks = self.col.decks.allNames()
|
||||
|
|
@ -732,7 +732,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
|||
showWarning(_("The provided name was already in use."))
|
||||
return
|
||||
did = self.col.decks.newDyn(name)
|
||||
diag = aqt.dyndeckconf.DeckConf(self, first=True)
|
||||
diag = aqt.dyndeckconf.DeckConf(self, first=True, search=search)
|
||||
if not diag.ok:
|
||||
# user cancelled first config
|
||||
self.col.decks.rem(did)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class Overview(object):
|
|||
print "anki menu"
|
||||
elif url == "opts":
|
||||
self.mw.onDeckConf()
|
||||
elif url == "cram":
|
||||
deck = self.mw.col.decks.current()
|
||||
self.mw.onCram("'deck:%s'" % deck['name'])
|
||||
elif url == "refresh":
|
||||
self.mw.col.sched.rebuildDyn()
|
||||
self.mw.reset()
|
||||
|
|
@ -161,6 +164,8 @@ text-align: center;
|
|||
]
|
||||
if self.mw.col.decks.current()['dyn']:
|
||||
links.append(["refresh", _("Rebuild")])
|
||||
else:
|
||||
links.append(["cram", _("Cram")])
|
||||
buf = ""
|
||||
for b in links:
|
||||
buf += "<button onclick='py.link(\"%s\");'>%s</button>" % tuple(b)
|
||||
|
|
|
|||
Loading…
Reference in a new issue