From 4bbd644e0a6ef5105c9661cc640808384a1b1e3e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 8 Apr 2012 13:29:55 +0900 Subject: [PATCH] use stdHtml in preview --- aqt/clayout.py | 17 ++++++++++++----- aqt/webview.py | 4 ++-- designer/preview.ui | 38 ++------------------------------------ 3 files changed, 16 insertions(+), 43 deletions(-) diff --git a/aqt/clayout.py b/aqt/clayout.py index 97b029b55..392bf12f7 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -11,6 +11,7 @@ from aqt.utils import saveGeom, restoreGeom, getBase, mungeQA, \ saveSplitter, restoreSplitter, showInfo, askUser, getOnlyText, \ showWarning, openHelp, openLink from anki.utils import isMac, isWin +from aqt.webview import AnkiWebView class CardLayout(QDialog): @@ -86,9 +87,13 @@ class CardLayout(QDialog): right = QWidget() pform = aqt.forms.preview.Ui_Form() pform.setupUi(right) + self.frontWeb = AnkiWebView() + pform.frontPrevBox.addWidget(self.frontWeb) + self.backWeb = AnkiWebView() + pform.backPrevBox.addWidget(self.backWeb) def linkClicked(url): openLink(url) - for wig in pform.front, pform.back: + for wig in self.frontWeb, self.backWeb: wig.page().setLinkDelegationPolicy( QWebPage.DelegateExternalLinks) c(wig, SIGNAL("linkClicked(QUrl)"), linkClicked) @@ -179,10 +184,12 @@ Please create a new card type first.""")) %s''' ti = self.maybeTextInput base = getBase(self.mw.col) - self.tab['pform'].front.setHtml( - html % (base, "", ti(mungeQA(c.q(reload=True))))) - self.tab['pform'].back.setHtml( - html % (base, "", ti(mungeQA(c.a()), 'a'))) + self.frontWeb.stdHtml( + ti(mungeQA(c.q(reload=True))), self.mw.reviewer._styles(), + bodyClass="card", head=base) + self.backWeb.stdHtml( + ti(mungeQA(c.a())), self.mw.reviewer._styles(), + bodyClass="card", head=base) clearAudioQueue() if c.id not in self.playedAudio: playFromText(c.q()) diff --git a/aqt/webview.py b/aqt/webview.py index aa236bc07..cc36a337b 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -102,8 +102,8 @@ button { %s""" % ( - fontForPlatform(), button, css, js or anki.js.jquery, head, - bodyClass, body), loadCB) + fontForPlatform(), button, css, js or anki.js.jquery+anki.js.browserSel, + head, bodyClass, body), loadCB) def setBridge(self, bridge): self._bridge.setBridge(bridge) def eval(self, js): diff --git a/designer/preview.ui b/designer/preview.ui index ba66fc64d..e8c774cb7 100644 --- a/designer/preview.ui +++ b/designer/preview.ui @@ -22,28 +22,10 @@ Front Preview - + 0 - - - - - 1 - 0 - - - - Qt::NoFocus - - - - about:blank - - - - @@ -52,31 +34,15 @@ Back Preview - + 0 - - - - - about:blank - - - - - - - QWebView - QWidget -
QtWebKit/QWebView
-
-