mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
minor tweaks
This commit is contained in:
parent
d3a77c1c67
commit
7fcaa98fa8
3 changed files with 37 additions and 46 deletions
|
@ -102,8 +102,10 @@ class AnkiQt(QMainWindow):
|
||||||
|
|
||||||
def _deckLoadingState(self, oldState):
|
def _deckLoadingState(self, oldState):
|
||||||
"Run once, when deck is loaded."
|
"Run once, when deck is loaded."
|
||||||
runHook("deckLoading", self.deck)
|
|
||||||
self.enableDeckMenuItems()
|
self.enableDeckMenuItems()
|
||||||
|
# ensure cwd is set if media dir exists
|
||||||
|
self.deck.media.dir()
|
||||||
|
runHook("deckLoading", self.deck)
|
||||||
self.moveToState("overview")
|
self.moveToState("overview")
|
||||||
|
|
||||||
def _deckClosingState(self, oldState):
|
def _deckClosingState(self, oldState):
|
||||||
|
@ -153,7 +155,7 @@ class AnkiQt(QMainWindow):
|
||||||
sharedCSS = """
|
sharedCSS = """
|
||||||
body {
|
body {
|
||||||
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#bbb));
|
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#bbb));
|
||||||
margin: 1em; }
|
margin: 2em; }
|
||||||
a:hover { background-color: #aaa; }
|
a:hover { background-color: #aaa; }
|
||||||
.but { font-size: 80%; padding: 3; background-color: #ccc;
|
.but { font-size: 80%; padding: 3; background-color: #ccc;
|
||||||
border-radius: 5px; color: #000; margin: 0 5 0 5; text-decoration:
|
border-radius: 5px; color: #000; margin: 0 5 0 5; text-decoration:
|
||||||
|
|
|
@ -116,7 +116,7 @@ $(function () {
|
||||||
buf += "<tr><th></th><th align=right>%s</th>" % _("Due")
|
buf += "<tr><th></th><th align=right>%s</th>" % _("Due")
|
||||||
buf += "<th align=right>%s</th><th></th></tr>" % _("New")
|
buf += "<th align=right>%s</th><th></th></tr>" % _("New")
|
||||||
line = "<tr><td><b>%s</b></td><td class=due>%s</td>"
|
line = "<tr><td><b>%s</b></td><td class=due>%s</td>"
|
||||||
line += "<td class=new>%s</td><td align=right>%s</td></tr>"
|
line += "<td class=new>%s</td><td>%s</td></tr>"
|
||||||
buf += line % (
|
buf += line % (
|
||||||
"<a href=chgrp>%s</a>" % _("Selected Groups"),
|
"<a href=chgrp>%s</a>" % _("Selected Groups"),
|
||||||
counts[0], counts[1],
|
counts[0], counts[1],
|
||||||
|
|
|
@ -40,6 +40,7 @@ class Reviewer(object):
|
||||||
if c:
|
if c:
|
||||||
self.mw.enableCardMenuItems()
|
self.mw.enableCardMenuItems()
|
||||||
self._maybeEnableSound()
|
self._maybeEnableSound()
|
||||||
|
#self.updateMarkAction()
|
||||||
self._showQuestion()
|
self._showQuestion()
|
||||||
else:
|
else:
|
||||||
self.mw.disableCardMenuItems()
|
self.mw.disableCardMenuItems()
|
||||||
|
@ -62,7 +63,7 @@ class Reviewer(object):
|
||||||
_css = """
|
_css = """
|
||||||
a.ansbut {
|
a.ansbut {
|
||||||
display: block; position: fixed;
|
display: block; position: fixed;
|
||||||
bottom: 5px; width: 250px; left: 50%; margin-left: -125px;
|
bottom: 1em; width: 250px; left: 50%; margin-left: -125px;
|
||||||
height: 40px; background-color: #ccc;
|
height: 40px; background-color: #ccc;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -72,7 +73,7 @@ a.ansbut {
|
||||||
|
|
||||||
}
|
}
|
||||||
a.ansbut:focus {
|
a.ansbut:focus {
|
||||||
border: 1px solid #333; border-radius: 5px;
|
background: #c7c7c7;
|
||||||
}
|
}
|
||||||
div.ansbut {
|
div.ansbut {
|
||||||
position: relative; top: 25%;
|
position: relative; top: 25%;
|
||||||
|
@ -86,7 +87,7 @@ div#filler {
|
||||||
# we want to include enough space at the bottom to allow for the
|
# we want to include enough space at the bottom to allow for the
|
||||||
# answer buttons
|
# answer buttons
|
||||||
buf = "<div id=filler></div>"
|
buf = "<div id=filler></div>"
|
||||||
self.web.stdHtml(text+buf, self._styles(), bodyClass=card.bgClass())
|
self.web.stdHtml(text+buf, self._styles(), bodyClass=card.cssClass())
|
||||||
|
|
||||||
def _styles(self):
|
def _styles(self):
|
||||||
css = self.mw.sharedCSS
|
css = self.mw.sharedCSS
|
||||||
|
@ -117,6 +118,7 @@ div#filler {
|
||||||
q=mungeQA(q),
|
q=mungeQA(q),
|
||||||
but=self._questionButtons())
|
but=self._questionButtons())
|
||||||
self._renderQA(c, buf)
|
self._renderQA(c, buf)
|
||||||
|
runHook('showQuestion')
|
||||||
|
|
||||||
# Question buttons
|
# Question buttons
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
@ -129,50 +131,25 @@ div#filler {
|
||||||
""" % _("Show Answer")
|
""" % _("Show Answer")
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
# Q/A support
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
def _showQuestionState(self, oldState):
|
|
||||||
# ensure cwd set to media dir
|
|
||||||
self.deck.mediaDir()
|
|
||||||
self.showAnswerButton()
|
|
||||||
self.updateMarkAction()
|
|
||||||
runHook('showQuestion')
|
|
||||||
|
|
||||||
# Showing the answer
|
# Showing the answer
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# elif self.state == "showAnswer":
|
def _showAnswer(self):
|
||||||
# self.setBackground()
|
c = self.card
|
||||||
# if not self.card.cardModel.questionInAnswer:
|
# original question with sounds
|
||||||
# self.drawQuestion(nosound=True)
|
q = c.a()
|
||||||
# if self.drawRule:
|
if self.mw.config['autoplaySounds']:
|
||||||
# self.write("<hr>")
|
|
||||||
# self.drawAnswer()
|
|
||||||
|
|
||||||
|
|
||||||
def _showAnswerState(self, oldState):
|
|
||||||
self.showEaseButtons()
|
|
||||||
|
|
||||||
def drawAnswer(self):
|
|
||||||
"Show the answer."
|
|
||||||
a = self.card.htmlAnswer()
|
|
||||||
a = runFilter("drawAnswer", a, self.card)
|
|
||||||
if self.card.cardModel.typeAnswer:
|
|
||||||
try:
|
|
||||||
cor = stripMedia(stripHTML(self.card.fact[
|
|
||||||
self.card.cardModel.typeAnswer]))
|
|
||||||
except KeyError:
|
|
||||||
self.card.cardModel.typeAnswer = ""
|
|
||||||
cor = ""
|
|
||||||
if cor:
|
|
||||||
given = unicode(self.main.typeAnswerField.text())
|
|
||||||
res = self.correct(cor, given)
|
|
||||||
a = res + "<br>" + a
|
|
||||||
self.write(self.center('<span id=answer />'
|
|
||||||
+ mungeQA(a)))
|
|
||||||
if self.state != self.oldState and self.main.config['autoplaySounds']:
|
|
||||||
playFromText(a)
|
playFromText(a)
|
||||||
|
# render
|
||||||
|
buf = self._qHtml % dict(
|
||||||
|
q=mungeQA(a),
|
||||||
|
but=self._answerButtons())
|
||||||
|
self._renderQA(c, buf)
|
||||||
|
runHook('showQuestion')
|
||||||
|
|
||||||
|
# buf = self.typeAnsResult()
|
||||||
|
# self.write(self.center('<span id=answer />'
|
||||||
|
# + mungeQA(a)))
|
||||||
|
|
||||||
def onLoadFinished(self, bool):
|
def onLoadFinished(self, bool):
|
||||||
if self.state == "showAnswer":
|
if self.state == "showAnswer":
|
||||||
|
@ -270,6 +247,18 @@ div#filler {
|
||||||
passedCharColour = "#00FF00"
|
passedCharColour = "#00FF00"
|
||||||
futureWarningColour = "#FF0000"
|
futureWarningColour = "#FF0000"
|
||||||
|
|
||||||
|
# if self.card.cardModel.typeAnswer:
|
||||||
|
# try:
|
||||||
|
# cor = stripMedia(stripHTML(self.card.fact[
|
||||||
|
# self.card.cardModel.typeAnswer]))
|
||||||
|
# except KeyError:
|
||||||
|
# self.card.cardModel.typeAnswer = ""
|
||||||
|
# cor = ""
|
||||||
|
# if cor:
|
||||||
|
# given = unicode(self.main.typeAnswerField.text())
|
||||||
|
# res = self.correct(cor, given)
|
||||||
|
# a = res + "<br>" + a
|
||||||
|
|
||||||
# fixme: type answer undo area shouldn't trigger global shortcut
|
# fixme: type answer undo area shouldn't trigger global shortcut
|
||||||
# class QLineEditNoUndo(QLineEdit):
|
# class QLineEditNoUndo(QLineEdit):
|
||||||
# def __init__(self, parent):
|
# def __init__(self, parent):
|
||||||
|
|
Loading…
Reference in a new issue