From ae776365b13ced20dea668228afccc7fc51c6fff Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 21 Nov 2008 16:47:26 +0900 Subject: [PATCH] scroll to answer --- ankiqt/ui/view.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index cf01738ad..552c02462 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -4,6 +4,7 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * +from PyQt4.QtWebKit import QWebPage import anki, anki.utils from anki.sound import playFromText, stripSounds from anki.latex import renderLatex, stripLatex @@ -21,6 +22,8 @@ class View(object): self.main = parent self.body = body self.frame = frame + self.main.connect(self.body, SIGNAL("loadFinished(bool)"), + self.onLoadFinished) # State control ########################################################################## @@ -119,10 +122,15 @@ class View(object): "Show the answer." a = self.main.currentCard.htmlAnswer() a = renderLatex(self.main.deck, a) - self.write(stripSounds(a)) + self.write('' + stripSounds(a)) if self.state != self.oldState: playFromText(a) + def onLoadFinished(self): + if self.state == "showAnswer": + mf = self.body.page().mainFrame() + mf.evaluateJavaScript("location.hash = 'answer'") + # Top section ##########################################################################