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 = """ sharedCSS = """
body { body {
background: #f3f3f3;
margin: 2em; margin: 2em;
} }
h1 { margin-bottom: 0.2em; } h1 { margin-bottom: 0.2em; }

View file

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

View file

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

View file

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