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