mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
use stdHtml in preview
This commit is contained in:
parent
cd4b1e894e
commit
4bbd644e0a
3 changed files with 16 additions and 43 deletions
|
@ -11,6 +11,7 @@ from aqt.utils import saveGeom, restoreGeom, getBase, mungeQA, \
|
||||||
saveSplitter, restoreSplitter, showInfo, askUser, getOnlyText, \
|
saveSplitter, restoreSplitter, showInfo, askUser, getOnlyText, \
|
||||||
showWarning, openHelp, openLink
|
showWarning, openHelp, openLink
|
||||||
from anki.utils import isMac, isWin
|
from anki.utils import isMac, isWin
|
||||||
|
from aqt.webview import AnkiWebView
|
||||||
|
|
||||||
class CardLayout(QDialog):
|
class CardLayout(QDialog):
|
||||||
|
|
||||||
|
@ -86,9 +87,13 @@ class CardLayout(QDialog):
|
||||||
right = QWidget()
|
right = QWidget()
|
||||||
pform = aqt.forms.preview.Ui_Form()
|
pform = aqt.forms.preview.Ui_Form()
|
||||||
pform.setupUi(right)
|
pform.setupUi(right)
|
||||||
|
self.frontWeb = AnkiWebView()
|
||||||
|
pform.frontPrevBox.addWidget(self.frontWeb)
|
||||||
|
self.backWeb = AnkiWebView()
|
||||||
|
pform.backPrevBox.addWidget(self.backWeb)
|
||||||
def linkClicked(url):
|
def linkClicked(url):
|
||||||
openLink(url)
|
openLink(url)
|
||||||
for wig in pform.front, pform.back:
|
for wig in self.frontWeb, self.backWeb:
|
||||||
wig.page().setLinkDelegationPolicy(
|
wig.page().setLinkDelegationPolicy(
|
||||||
QWebPage.DelegateExternalLinks)
|
QWebPage.DelegateExternalLinks)
|
||||||
c(wig, SIGNAL("linkClicked(QUrl)"), linkClicked)
|
c(wig, SIGNAL("linkClicked(QUrl)"), linkClicked)
|
||||||
|
@ -179,10 +184,12 @@ Please create a new card type first."""))
|
||||||
<style>%s</style>%s</body></html>'''
|
<style>%s</style>%s</body></html>'''
|
||||||
ti = self.maybeTextInput
|
ti = self.maybeTextInput
|
||||||
base = getBase(self.mw.col)
|
base = getBase(self.mw.col)
|
||||||
self.tab['pform'].front.setHtml(
|
self.frontWeb.stdHtml(
|
||||||
html % (base, "", ti(mungeQA(c.q(reload=True)))))
|
ti(mungeQA(c.q(reload=True))), self.mw.reviewer._styles(),
|
||||||
self.tab['pform'].back.setHtml(
|
bodyClass="card", head=base)
|
||||||
html % (base, "", ti(mungeQA(c.a()), 'a')))
|
self.backWeb.stdHtml(
|
||||||
|
ti(mungeQA(c.a())), self.mw.reviewer._styles(),
|
||||||
|
bodyClass="card", head=base)
|
||||||
clearAudioQueue()
|
clearAudioQueue()
|
||||||
if c.id not in self.playedAudio:
|
if c.id not in self.playedAudio:
|
||||||
playFromText(c.q())
|
playFromText(c.q())
|
||||||
|
|
|
@ -102,8 +102,8 @@ button {
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="%s">%s</body></html>""" % (
|
<body class="%s">%s</body></html>""" % (
|
||||||
fontForPlatform(), button, css, js or anki.js.jquery, head,
|
fontForPlatform(), button, css, js or anki.js.jquery+anki.js.browserSel,
|
||||||
bodyClass, body), loadCB)
|
head, bodyClass, body), loadCB)
|
||||||
def setBridge(self, bridge):
|
def setBridge(self, bridge):
|
||||||
self._bridge.setBridge(bridge)
|
self._bridge.setBridge(bridge)
|
||||||
def eval(self, js):
|
def eval(self, js):
|
||||||
|
|
|
@ -22,28 +22,10 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Front Preview</string>
|
<string>Front Preview</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="frontPrevBox">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QWebView" name="front">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="url">
|
|
||||||
<url>
|
|
||||||
<string>about:blank</string>
|
|
||||||
</url>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -52,31 +34,15 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Back Preview</string>
|
<string>Back Preview</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="backPrevBox">
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QWebView" name="back">
|
|
||||||
<property name="url">
|
|
||||||
<url>
|
|
||||||
<string>about:blank</string>
|
|
||||||
</url>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>QWebView</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>QtWebKit/QWebView</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in a new issue