mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 23:12:21 -04:00
apply standard zoom and background to graphs; prevent FOUC
This commit is contained in:
parent
0564d4cf86
commit
5520163bf7
2 changed files with 18 additions and 1 deletions
|
@ -91,8 +91,9 @@ class NewDeckStats(QDialog):
|
||||||
extra = "#night"
|
extra = "#night"
|
||||||
else:
|
else:
|
||||||
extra = ""
|
extra = ""
|
||||||
|
self.form.web.hide_while_preserving_layout()
|
||||||
self.form.web.load(QUrl(f"{self.mw.serverURL()}_anki/graphs.html" + extra))
|
self.form.web.load(QUrl(f"{self.mw.serverURL()}_anki/graphs.html" + extra))
|
||||||
|
self.form.web.inject_dynamic_style_and_show()
|
||||||
|
|
||||||
class DeckStats(QDialog):
|
class DeckStats(QDialog):
|
||||||
"""Legacy deck stats, used by some add-ons."""
|
"""Legacy deck stats, used by some add-ons."""
|
||||||
|
|
|
@ -587,3 +587,19 @@ body {{ zoom: {zoom}; background: {background}; direction: {lang_dir}; {font} }}
|
||||||
aqt.reviewer.Reviewer or aqt.deckbrowser.DeckBrowser."""
|
aqt.reviewer.Reviewer or aqt.deckbrowser.DeckBrowser."""
|
||||||
self.onBridgeCmd = func
|
self.onBridgeCmd = func
|
||||||
self._bridge_context = context
|
self._bridge_context = context
|
||||||
|
|
||||||
|
def hide_while_preserving_layout(self):
|
||||||
|
"Hide but keep existing size."
|
||||||
|
sp = self.sizePolicy()
|
||||||
|
sp.setRetainSizeWhenHidden(True)
|
||||||
|
self.setSizePolicy(sp)
|
||||||
|
self.hide()
|
||||||
|
|
||||||
|
def inject_dynamic_style_and_show(self):
|
||||||
|
"Add dynamic styling, and reveal."
|
||||||
|
css = self.standard_css()
|
||||||
|
self.evalWithCallback(f"""
|
||||||
|
const style = document.createElement('style');
|
||||||
|
style.innerHTML = `{css}`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
""", lambda arg: self.show())
|
||||||
|
|
Loading…
Reference in a new issue