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 ##########################################################################