set bgcol in ankiwebview

This commit is contained in:
Damien Elmes 2017-06-23 13:07:59 +10:00
parent 7af591cfd7
commit a3bdd04d42
4 changed files with 5 additions and 9 deletions

View file

@ -485,7 +485,6 @@ the manual for information on how to restore from an automatic backup."))
sharedCSS = """
body {
background: #f3f3f3;
margin: 2em;
}
h1 { margin-bottom: 0.2em; }

View file

@ -533,8 +533,6 @@ min-width: 60px; white-space: nowrap;
.spacer2 { height: 16px; }
#outer {
border-top: 1px solid #aaa;
background: -webkit-gradient(linear, left top, left bottom,
from(#fff), to(#ddd));
}
#innertable {
padding: 3px;

View file

@ -29,13 +29,12 @@ class Toolbar:
def draw(self):
self.web.onBridgeCmd = self._linkHandler
self.web.onLoadFinished = self.onLoaded
bgcol = QApplication.instance().palette().window().color().name()
self.web.stdHtml(self._body % (
# may want a context menu here in the future
' '*20,
self._centerLinks(),
self._rightIcons()),
self._css % bgcol)
self._css)
# Available links
######################################################################
@ -164,7 +163,6 @@ margin-top: 0;
def draw(self, buf):
self.web.onBridgeCmd = self._linkHandler
self.web.onLoadFinished = self.onLoaded
bgcol = QApplication.instance().palette().window().color().name()
self.web.stdHtml(
self._centerBody % buf,
self._css % bgcol)
self._css)

View file

@ -141,7 +141,7 @@ class AnkiWebView(QWebEngineView):
dpi = screen.logicalDpiX()
return max(1, dpi / 96.0)
def stdHtml(self, body, css="", bodyClass="", js=None, head=""):
def stdHtml(self, body, css="", bodyClass="", js=None, head="", bgcol=None):
if isWin:
buttonspec = "button { font-size: 12px; font-family:'Segoe UI'; }"
fontspec = 'font-size:12px;font-family:"Segoe UI";'
@ -161,7 +161,7 @@ border-radius:5px; font-family: Helvetica }"""
html="""
<!doctype html>
<html><head><title>%s</title><style>
body { zoom: %f; %s }
body { zoom: %f; background: %s; %s }
%s
%s</style>
<script>
@ -190,6 +190,7 @@ document.addEventListener("keydown", function(evt) {
<body class="%s">%s</body></html>""" % (
self.title,
self.zoomFactor(),
bgcol or QApplication.instance().palette().window().color().name(),
fontspec,
buttonspec,
css, js or anki.js.jquery+anki.js.browserSel,