mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
add timer flag, limit timer to maxTaken
This commit is contained in:
parent
494b7310f0
commit
34b56b5003
3 changed files with 21 additions and 2 deletions
|
@ -146,6 +146,7 @@ class DeckConf(QDialog):
|
||||||
# general
|
# general
|
||||||
c = self.conf
|
c = self.conf
|
||||||
f.maxTaken.setValue(c['maxTaken'])
|
f.maxTaken.setValue(c['maxTaken'])
|
||||||
|
f.showTimer.setChecked(c.get('timer', 0))
|
||||||
f.autoplaySounds.setChecked(c['autoplay'])
|
f.autoplaySounds.setChecked(c['autoplay'])
|
||||||
# description
|
# description
|
||||||
f.desc.setPlainText(self.deck['desc'])
|
f.desc.setPlainText(self.deck['desc'])
|
||||||
|
@ -216,6 +217,7 @@ class DeckConf(QDialog):
|
||||||
# general
|
# general
|
||||||
c = self.conf
|
c = self.conf
|
||||||
c['maxTaken'] = f.maxTaken.value()
|
c['maxTaken'] = f.maxTaken.value()
|
||||||
|
c['timer'] = f.showTimer.isChecked() and 1 or 0
|
||||||
c['autoplay'] = f.autoplaySounds.isChecked()
|
c['autoplay'] = f.autoplaySounds.isChecked()
|
||||||
# description
|
# description
|
||||||
self.deck['desc'] = f.desc.toPlainText()
|
self.deck['desc'] = f.desc.toPlainText()
|
||||||
|
|
|
@ -352,6 +352,10 @@ td { font-weight: bold; font-size: 12px; }
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _bottomHTML(self, middle):
|
def _bottomHTML(self, middle):
|
||||||
|
if not self.card.deckConf().get('timer'):
|
||||||
|
maxTime = 0
|
||||||
|
else:
|
||||||
|
maxTime = self.card.deckConf()['maxTaken']
|
||||||
return """
|
return """
|
||||||
<table width=100%% cellspacing=0 cellpadding=0>
|
<table width=100%% cellspacing=0 cellpadding=0>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -376,7 +380,10 @@ setInterval(function () { time += 1; updateTime() }, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
var updateTime = function () {
|
var updateTime = function () {
|
||||||
|
if (!%(maxTime)s) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
time = Math.min(%(maxTime)s, time);
|
||||||
var m = Math.floor(time / 60);
|
var m = Math.floor(time / 60);
|
||||||
var s = time %% 60;
|
var s = time %% 60;
|
||||||
if (s < 10) {
|
if (s < 10) {
|
||||||
|
@ -387,7 +394,8 @@ var updateTime = function () {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
""" % dict(middle=middle, rem=self._remaining(), edit=_("Edit"),
|
""" % dict(middle=middle, rem=self._remaining(), edit=_("Edit"),
|
||||||
more=_("More"), time=self.card.timeTaken()/1000)
|
more=_("More"), time=self.card.timeTaken()/1000,
|
||||||
|
maxTime=maxTime)
|
||||||
|
|
||||||
def _showAnswerButton(self):
|
def _showAnswerButton(self):
|
||||||
self.bottom.web.setFocus()
|
self.bottom.web.setFocus()
|
||||||
|
|
|
@ -554,6 +554,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showTimer">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show answer timer</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoplaySounds">
|
<widget class="QCheckBox" name="autoplaySounds">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -631,8 +638,10 @@
|
||||||
<tabstop>leechThreshold</tabstop>
|
<tabstop>leechThreshold</tabstop>
|
||||||
<tabstop>leechAction</tabstop>
|
<tabstop>leechAction</tabstop>
|
||||||
<tabstop>maxTaken</tabstop>
|
<tabstop>maxTaken</tabstop>
|
||||||
|
<tabstop>showTimer</tabstop>
|
||||||
<tabstop>autoplaySounds</tabstop>
|
<tabstop>autoplaySounds</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
|
<tabstop>desc</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
Loading…
Reference in a new issue