mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
timer, global shortcuts
This commit is contained in:
parent
9c5eb98114
commit
5e97a285a1
3 changed files with 50 additions and 5 deletions
22
aqt/main.py
22
aqt/main.py
|
@ -477,6 +477,28 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
print "applystyles"
|
print "applystyles"
|
||||||
#applyStyles(self)
|
#applyStyles(self)
|
||||||
|
|
||||||
|
# Key handling
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def setupKeys(self):
|
||||||
|
self.keyDelegate = None
|
||||||
|
|
||||||
|
def keyPressEvent(self, evt):
|
||||||
|
QMainWindow.keyPressEvent(self, evt)
|
||||||
|
# check global keys
|
||||||
|
key = unicode(evt.text())
|
||||||
|
if key == "d":
|
||||||
|
self.moveToState("deckBrowser")
|
||||||
|
elif key == "s":
|
||||||
|
if self.state == "overview":
|
||||||
|
self.moveToState("review")
|
||||||
|
else:
|
||||||
|
self.moveToState("overview")
|
||||||
|
elif key == "a":
|
||||||
|
self.onAddCard()
|
||||||
|
elif key == "b":
|
||||||
|
self.onBrowse()
|
||||||
|
|
||||||
# App exit
|
# App exit
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -364,18 +364,38 @@ button { font-weight: normal; }
|
||||||
return """
|
return """
|
||||||
<table width=100%% cellspacing=0 cellpadding=0>
|
<table width=100%% cellspacing=0 cellpadding=0>
|
||||||
<tr>
|
<tr>
|
||||||
<td align=left width=50 valign=top class=stat><span class=stattxt>%(rem)s</span><br>
|
<td align=left width=50 valign=top class=stat>
|
||||||
|
<span class=stattxt>%(rem)s</span><br>
|
||||||
<button onclick="py.link('edit');">%(edit)s</button></td>
|
<button onclick="py.link('edit');">%(edit)s</button></td>
|
||||||
<td align=center valign=top>
|
<td align=center valign=top>
|
||||||
%(middle)s
|
%(middle)s
|
||||||
</td>
|
</td>
|
||||||
<td width=75 align=right valign=top class=stat><span class=stattxt>0:53</span><br>
|
<td width=75 align=right valign=top class=stat><span id=time class=stattxt>
|
||||||
|
</span><br>
|
||||||
<button onclick="py.link('more');">%(more)s ▾</button>
|
<button onclick="py.link('more');">%(more)s ▾</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<script>$(function () { $("#ansbut").focus(); });</script>
|
<script>
|
||||||
""" % dict(middle=middle, rem=self._remaining(), edit=_("Edit"), more=_("More"))
|
var time = %(time)d;
|
||||||
|
$(function () {
|
||||||
|
$("#ansbut").focus();
|
||||||
|
updateTime();
|
||||||
|
setInterval(function () { time += 1; updateTime() }, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
|
var updateTime = function () {
|
||||||
|
var m = Math.floor(time / 60);
|
||||||
|
var s = time %% 60;
|
||||||
|
if (s < 10) {
|
||||||
|
s = "0" + s;
|
||||||
|
}
|
||||||
|
var e = $("#time").text(time);
|
||||||
|
e.text(m + ":" + s);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
""" % dict(middle=middle, rem=self._remaining(), edit=_("Edit"),
|
||||||
|
more=_("More"), time=self.card.timeTaken()/1000)
|
||||||
|
|
||||||
def _showAnswerButton(self):
|
def _showAnswerButton(self):
|
||||||
self.bottom.web.setFocus()
|
self.bottom.web.setFocus()
|
||||||
|
@ -389,7 +409,6 @@ button { font-weight: normal; }
|
||||||
self.bottom._css + self._bottomCSS)
|
self.bottom._css + self._bottomCSS)
|
||||||
|
|
||||||
def _showEaseButtons(self):
|
def _showEaseButtons(self):
|
||||||
print self._answerButtons()
|
|
||||||
self.bottom.web.stdHtml(
|
self.bottom.web.stdHtml(
|
||||||
self._bottomHTML(self._answerButtons()),
|
self._bottomHTML(self._answerButtons()),
|
||||||
self.bottom._css + self._bottomCSS)
|
self.bottom._css + self._bottomCSS)
|
||||||
|
|
|
@ -115,6 +115,10 @@ color: #000;
|
||||||
.hitem:hover {
|
.hitem:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class BottomBar(Toolbar):
|
class BottomBar(Toolbar):
|
||||||
|
|
Loading…
Reference in a new issue