work on reviewer

This commit is contained in:
Damien Elmes 2011-12-01 15:15:20 +09:00
parent c2176edd07
commit cecec92934
28 changed files with 118 additions and 115 deletions

View file

@ -19,7 +19,7 @@ system. It's free and open source.")
abouttext += '<p>' + _("Written by Damien Elmes, with patches, translation,\
testing and design from:<p>%(cont)s") % {'cont': u"""
Andreas Klauer, Andrew Wright, Bernhard Ibertsberger, Charlene
Alex Fraser, Andreas Klauer, Andrew Wright, Bernhard Ibertsberger, Charlene
Barina, Christian Rusche, David Smith, Dave Druelinger, Dotan Cohen, Emilio
Wuerges, Emmanuel Jarri, Frank Harper, H. Mijail, Ian Lewis, Iroiro, Jin
Eun-Deok, Jarvik7, Jo Nakashima, Christian Krause, LaC, Laurent Steffan, Marco
@ -30,12 +30,8 @@ Petr Michalec, Piotr Kubowicz, Richard Colley, Samson Melamed, Stefaan
De Pooter, Susanna Björverud, Tacutu, Timm Preetz, Timo Paulssen, Ursus, Victor
Suba, and Xtru.
<p>
Anki icon by Alex Fraser (CC GNU GPL)<br>
Deck icon: Be Box Icons (free for non-commercial use)<br>
Deck browser icons from:<br>
http://led24.de/iconset<br>
http://p.yusukekamiyamane.com/<br>
Other icons under LGPL or public domain.<br>
The icons were obtained from various sources; please see the Anki source
for credits.
"""
}

View file

@ -1447,7 +1447,7 @@ class BrowserToolbar(Toolbar):
self.web.stdHtml(self._body % (
"<span style='display:inline-block; width: 100px;'></span>",
self._centerLinks(),
right), self._css, focus=False)
right), self._css)
# Link handling
######################################################################

View file

@ -292,7 +292,7 @@ background: #f3f3f3;
margin: 2em;
}
h1 { margin-bottom: 0.2em; }
hr { margin:5 0 5 0; border:0; height:1px; background-color:#ccc; }
hr { background-color:#ccc; margin: 1em; }
"""
def button(self, link, name, key=None, class_="", id=""):

View file

@ -43,7 +43,6 @@ class Overview(object):
def _linkHandler(self, url):
print "link", url
if url == "study":
self.mw.col.reset()
self.mw.moveToState("review")
elif url == "anki":
print "anki menu"

View file

@ -33,7 +33,7 @@ class Reviewer(object):
else:
self.nextCard()
self.keep = False
self.bottom.web.setFixedHeight(60)
self.bottom.web.setFixedHeight(46)
self.bottom.web.setLinkHandler(self._linkHandler)
def lastCard(self):
@ -82,12 +82,17 @@ var ankiPlatform = "desktop";
var hideq;
var ans;
var typeans;
function _updateQA (q) {
function _updateQA (q, answerMode) {
$("#qa").html(q);
typeans = document.getElementById("typeans");
if (typeans) {
typeans.focus();
}
if (answerMode) {
window.location = "#answerStart";
} else {
window.location = "";
}
};
function _showans (a) {
$("#qa").html(a);
@ -117,15 +122,14 @@ function _typeAnsPress() {
_showans();
}
}
$(document).ready(function () {
$(".ansbut").focus();
});
</script>
"""
def _initWeb(self):
base = getBase(self.mw.col)
self.web.stdHtml(self._revHtml, self._styles(),
bodyID="card", loadCB=lambda x: self._showQuestion())
bodyID="card", loadCB=lambda x: self._showQuestion(),
head=base)
# Showing the question
##########################################################################
@ -143,12 +147,12 @@ $(".ansbut").focus();
q = c.q()
if self.mw.pm.profile['autoplay']:
playFromText(q)
# render
# render & update bottom
q = self._mungeQA(q)
self.web.eval("_updateQA(%s);" % simplejson.dumps(q))
runHook('showQuestion')
# and refresh bottom bar
self._showAnswerButton()
# user hook
runHook('showQuestion')
# Showing the answer
##########################################################################
@ -157,54 +161,16 @@ $(".ansbut").focus();
self.state = "answer"
c = self.card
a = c.a()
# play audio?
if self.mw.pm.profile['autoplay']:
playFromText(a)
# render
# render and update bottom
a = self._mungeQA(a)
self.web.eval("_updateQA(%s, true);" % simplejson.dumps(a))
self._showEaseButtons()
# user hook
runHook('showAnswer')
# Ease buttons
##########################################################################
def _defaultEase(self):
if self.mw.col.sched.answerButtons(self.card) == 4:
return 3
else:
return 2
def _answerButtons(self):
if self.mw.col.sched.answerButtons(self.card) == 4:
labels = (_("Again"), _("Hard"), _("Good"), _("Easy"))
else:
labels = (_("Again"), _("Good"), _("Easy"))
times = []
buttons = []
default = self._defaultEase()
def but(label, i):
if i == default:
extra=" id=defease"
else:
extra = ""
return '''
<a %s class="ansbut easebut" href=ease%d>%s</a>''' % (extra, i, label)
for i in range(0, len(labels)):
l = labels[i]
l += "<br><small>%s</small>" % self._buttonTime(i, default-1)
buttons.append(but(l, i+1))
buf = ("<table><tr><td>" +
"</td><td>".join(buttons) + "</td></tr></table>")
return "<center>" + buf + "</center>"
return buf
def _buttonTime(self, i, green):
if self.mw.pm.profile['showDueTimes']:
return ""
txt = self.mw.col.sched.nextIvlStr(self.card, i+1, True)
if i == 0:
txt = '<span style="color: #700">%s</span>' % txt
elif i == green:
txt = '<span style="color: #070">%s</span>' % txt
return txt
# Answering a card
############################################################
@ -445,39 +411,90 @@ from(#fff), to(#ddd));
border-bottom: 0;
border-top: 1px solid #aaa;
margin: 0;
padding: 5px;
padding: 0px;
padding-left: 5px; padding-right: 5px;
}
td { font-weight: bold; font-size: 12px; }
.hitem { padding: 0; }
"""
_bottomQuestion = """
<table width=100%% cellspacing=0 cellpadding=0>
<tr>
<td width=100>0 + 0 + 0</td>
<td align=center>
<button onclick='py.link(\"ans\");'>%s</button>
</td>
<td width=100 align=right>0:00</td>
</tr>
</table>
<center>
<table width=100%% cellspacing=0 cellpadding=0>
<tr>
<td align=left>
<a class=hitem href="foo">Actions &#9662;</a>&nbsp;&nbsp;&nbsp;
</td>
<td align=right>
<a class=hitem><img src="qrc:/icons/star16.png"></a>
<a class=hitem><img src="qrc:/icons/star16.png"></a>
</td>
</tr></table>
.hitem { margin-top: 2px; }
.stat { padding-top: 5px; }
.stattxt { padding-left: 5px; padding-right: 5px; }
.nobold { font-weight: normal; display: inline-block; padding-top: 3px; }
.spacer { height: 18px; }
.spacer2 { height: 16px; }
button { font-weight: normal; }
"""
def _bottomHTML(self, middle):
return """
<table width=100%% cellspacing=0 cellpadding=0>
<tr>
<td align=left width=50 valign=top class=stat><span class=stattxt>1 + 7 + 3</span><br>
<button>Edit Note</button></td>
<td align=center valign=top>
%(middle)s
</td>
<td width=50 align=right valign=top class=stat><span class=stattxt>0:53</span><br>
<button>More &#9662;</button>
</td>
</tr>
</table>
<script>$(function () { $("#ansbut").focus(); });</script>
""" % dict(middle=middle)
def _showAnswerButton(self):
self.bottom.web.setFocus()
middle = '''
<div class=spacer2></div>
<button id=ansbut onclick='py.link(\"ans\");'>%s</button>''' % _("Show Answer")
# wrap it in a table so it has the same top margin as the ease buttons
middle = "<table cellpadding=0><tr><td>%s</td></tr></table>" % middle
self.bottom.web.stdHtml(
self._bottomQuestion % _("Show Answer"),
self._bottomHTML(middle),
self.bottom._css + self._bottomCSS)
def _showEaseButtons(self):
print self._answerButtons()
self.bottom.web.stdHtml(
self._bottomHTML(self._answerButtons()),
self.bottom._css + self._bottomCSS)
def _defaultEase(self):
if self.mw.col.sched.answerButtons(self.card) == 4:
return 3
else:
return 2
def _answerButtons(self):
if self.mw.col.sched.answerButtons(self.card) == 4:
labels = (_("Again"), _("Hard"), _("Good"), _("Easy"))
else:
labels = (_("Again"), _("Good"), _("Easy"))
times = []
buttons = []
default = self._defaultEase()
def but(label, i):
if i == default:
extra = "id=defease"
else:
extra = ""
due = self._buttonTime(i-1, default-1)
return '''
<td align=center>%s<button %s onclick='py.link("ease%d");'>\
%s</button></td>''' % (due, extra, i, label)
buf = "<center><table cellpading=0 cellspacing=0><tr>"
for i in range(0, len(labels)):
buf += but(labels[i], i+1)
buf += "</tr></table>"
script = """
<script>$(function () { $("#defease").focus(); });</script>"""
return buf + script
def _buttonTime(self, i, green):
if not self.mw.pm.profile['showDueTimes']:
return "<div class=spacer></div>"
txt = self.mw.col.sched.nextIvlStr(self.card, i+1, True)
return '<span class=nobold>%s</span><br>' % txt
# Status bar
##########################################################################

View file

@ -20,7 +20,7 @@ class Toolbar(object):
'&nbsp;'*20,
self._centerLinks(),
self._rightIcons()),
self._css, focus=False)
self._css)
# Available links
######################################################################
@ -62,6 +62,10 @@ class Toolbar(object):
elif l == "decks":
self.mw.moveToState("deckBrowser")
elif l == "study":
# if overview already shown, switch to review
if self.mw.state == "overview":
self.mw.moveToState("review")
else:
self.mw.onOverview()
elif l == "add":
self.mw.onAddCard()

View file

@ -83,16 +83,14 @@ class AnkiWebView(QWebView):
if loadCB:
self._loadFinishedCB = loadCB
QWebView.setHtml(self, html)
def stdHtml(self, body, css="", bodyID="", loadCB=None, focus=True):
def stdHtml(self, body, css="", bodyID="", loadCB=None, head=""):
self.setHtml("""
<html><head><style>%s</style>
<script>%s</script>
%s
</head>
<body id="%s">%s</body></html>""" % (
css, anki.js.all, bodyID, body), loadCB)
# ensure we're focused
if focus:
self.setFocus()
css, anki.js.all, head, bodyID, body), loadCB)
def setBridge(self, bridge):
self._bridge.setBridge(bridge)
def eval(self, js):

View file

@ -2,26 +2,21 @@
<qresource prefix="/">
<file>icons/arrow-up.png</file>
<file>icons/arrow-down.png</file>
<file>icons/blue.png</file>
<file>icons/gears.png</file>
<file>icons/both.png</file>
<file>icons/green.png</file>
<file>icons/clock-icon.png</file>
<file>icons/plus-circle.png</file>
<file>icons/none.png</file>
<file>icons/edit-find 2.png</file>
<file>icons/edit-find-replace.png</file>
<file>icons/graphite_smooth_folder_noncommercial.png</file>
<file>icons/user-identity.png</file>
<file>icons/layout.png</file>
<file>icons/generate_07.png</file>
<file>icons/view-sort-descending.png</file>
<file>icons/view-refresh.png</file>
<file>icons/emblem-important.png</file>
<file>icons/view-sort-ascending.png</file>
<file>icons/media-playback-start2.png</file>
<file>icons/anki-logo-thin.png</file>
<file>icons/anki-logo.png</file>
<file>icons/download.png</file>
<file>icons/preferences-plugin.png</file>
<file>icons/system-software-update.png</file>
@ -43,34 +38,22 @@
<file>icons/anki-tag.png</file>
<file>icons/edit-redo.png</file>
<file>icons/text-xml.png</file>
<file>icons/document-preview.png</file>
<file>icons/media-record.png</file>
<file>icons/edit-rename.png</file>
<file>icons/kblogger.png</file>
<file>icons/chronometer.png</file>
<file>icons/Anki_Card.png</file>
<file>icons/document-open-remote.png</file>
<file>icons/document-open-recent.png</file>
<file>icons/khtml_kget.png</file>
<file>icons/edit-find.png</file>
<file>icons/colors.png</file>
<file>icons/anki.png</file>
<file>icons/Anki_Add_Tag.png</file>
<file>icons/Anki_Card.png</file>
<file>icons/Anki_Del_Tag.png</file>
<file>icons/Anki_Fact.png</file>
<file>icons/application-exit.png</file>
<file>icons/colorscm.png</file>
<file>icons/configure.png</file>
<file>icons/contents.png</file>
<file>icons/contents2.png</file>
<file>icons/document-export.png</file>
<file>icons/document-import.png</file>
<file>icons/document-new.png</file>
<file>icons/document-open-recent.png</file>
<file>icons/document-open.png</file>
<file>icons/document-save-as.png</file>
<file>icons/document-save.png</file>
<file>icons/edit-undo.png</file>
<file>icons/edit.png</file>
<file>icons/editdelete.png</file>
@ -79,11 +62,9 @@
<file>icons/folder_sound.png</file>
<file>icons/format-stroke-color.png</file>
<file>icons/games-solve.png</file>
<file>icons/go-home.png</file>
<file>icons/help-contents.png</file>
<file>icons/help.png</file>
<file>icons/image.png</file>
<file>icons/kanji.png</file>
<file>icons/kbugbuster.png</file>
<file>icons/kexi.png</file>
<file>icons/kpersonalizer.png</file>
@ -93,7 +74,6 @@
<file>icons/media-playback-pause.png</file>
<file>icons/media-playback-start.png</file>
<file>icons/media-playback-stop.png</file>
<file>icons/multisynk.png</file>
<file>icons/package_games_card.png</file>
<file>icons/preferences-desktop-font.png</file>
<file>icons/rating.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1,9 @@
-Anki icon by Alex Fraser (CC GNU GPL)
-Deck icon: Be Box Icons (non-commercial use)
-Deck due/new icons from:
http://led24.de/iconset
http://p.yusukekamiyamane.com/
-Other icons obtained from KDE themes (GPL/LGPL)
Note that some of the icons have been modified to fit in with Anki better
(grayscaled, cropped, etc).