mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
presets
This commit is contained in:
parent
63a31dc7bd
commit
eb491a7a55
2 changed files with 67 additions and 18 deletions
|
@ -13,6 +13,8 @@ class DeckConf(QDialog):
|
|||
QDialog.__init__(self, mw)
|
||||
self.mw = mw
|
||||
self.deck = self.mw.col.decks.current()
|
||||
# context-sensitive extras like deck:foo
|
||||
self.search = search
|
||||
self.form = aqt.forms.dyndconf.Ui_Dialog()
|
||||
self.form.setupUi(self)
|
||||
if first:
|
||||
|
@ -27,16 +29,57 @@ class DeckConf(QDialog):
|
|||
SIGNAL("helpRequested()"),
|
||||
lambda: openHelp("cramming"))
|
||||
self.setWindowTitle(_("Options for %s") % self.deck['name'])
|
||||
self.setupCombos()
|
||||
self.setupExamples()
|
||||
self.setupOrder()
|
||||
self.loadConf()
|
||||
if first and search:
|
||||
self.form.search.setText(search)
|
||||
self.exec_()
|
||||
|
||||
def setupCombos(self):
|
||||
def setupOrder(self):
|
||||
import anki.consts as cs
|
||||
self.form.order.addItems(cs.dynOrderLabels().values())
|
||||
|
||||
def setupExamples(self):
|
||||
import anki.consts as cs
|
||||
f = self.form
|
||||
f.order.addItems(cs.dynOrderLabels().values())
|
||||
d = self.dynExamples = cs.dynExamples()
|
||||
f.examples.addItems([x[0] for x in d])
|
||||
self.connect(f.examples, SIGNAL("activated(int)"),
|
||||
self.onExample)
|
||||
# we'll need to reset whenever something is changed
|
||||
self.ignoreChange = False
|
||||
def onChange(*args):
|
||||
if self.ignoreChange:
|
||||
return
|
||||
f.examples.setCurrentIndex(0)
|
||||
c = self.connect
|
||||
c(f.steps, SIGNAL("textEdited(QString)"), onChange)
|
||||
c(f.search, SIGNAL("textEdited(QString)"), onChange)
|
||||
c(f.order, SIGNAL("activated(int)"), onChange)
|
||||
c(f.limit, SIGNAL("valueChanged(int)"), onChange)
|
||||
c(f.stepsOn, SIGNAL("stateChanged(int)"), onChange)
|
||||
c(f.resched, SIGNAL("stateChanged(int)"), onChange)
|
||||
|
||||
def onExample(self, idx):
|
||||
if idx == 0:
|
||||
return
|
||||
p = self.dynExamples[idx][1]
|
||||
f = self.form
|
||||
self.ignoreChange = True
|
||||
search = [p['search']]
|
||||
if self.search:
|
||||
search.append(self.search)
|
||||
f.search.setText(" ".join(search))
|
||||
print "set order to", p['order']
|
||||
f.order.setCurrentIndex(p['order'])
|
||||
f.resched.setChecked(p.get("resched", True))
|
||||
if p.get("steps"):
|
||||
f.steps.setText(p['steps'])
|
||||
f.stepsOn.setChecked(True)
|
||||
else:
|
||||
f.steps.setText("1 10")
|
||||
f.stepsOn.setChecked(False)
|
||||
f.limit.setValue(1000)
|
||||
self.ignoreChange = False
|
||||
|
||||
def loadConf(self):
|
||||
f = self.form
|
||||
|
|
|
@ -6,38 +6,35 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>619</width>
|
||||
<height>300</height>
|
||||
<width>445</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="examples"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Create deck from search</string>
|
||||
<string>Filter</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Limit to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="limit">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
|
@ -53,19 +50,29 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>cards selected by</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="6">
|
||||
<item row="1" column="1" colspan="6">
|
||||
<widget class="QLineEdit" name="search"/>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="4">
|
||||
<item row="2" column="3" colspan="4">
|
||||
<widget class="QComboBox" name="order"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="6">
|
||||
<widget class="QComboBox" name="examples"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Preset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -138,7 +145,6 @@
|
|||
<tabstop>stepsOn</tabstop>
|
||||
<tabstop>steps</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
<tabstop>examples</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
Loading…
Reference in a new issue