mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Add platform-specific classes to body of ts pages (#2211)
This commit is contained in:
parent
5551a37f03
commit
0d541563a0
1 changed files with 7 additions and 5 deletions
|
@ -647,11 +647,12 @@ html {{ {font} }}
|
||||||
self.setSizePolicy(sp)
|
self.setSizePolicy(sp)
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
def inject_dynamic_style_and_show(self) -> None:
|
def add_dynamic_css_and_classes_then_show(self) -> None:
|
||||||
"Add dynamic styling, and reveal."
|
"Add dynamic styling, set platform-specific body classes and reveal."
|
||||||
css = self.standard_css()
|
css = self.standard_css()
|
||||||
|
body_classes = theme_manager.body_class().split(" ")
|
||||||
|
|
||||||
def after_style(arg: Any) -> None:
|
def after_injection(arg: Any) -> None:
|
||||||
gui_hooks.webview_did_inject_style_into_page(self)
|
gui_hooks.webview_did_inject_style_into_page(self)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
@ -661,9 +662,10 @@ html {{ {font} }}
|
||||||
const style = document.createElement('style');
|
const style = document.createElement('style');
|
||||||
style.innerHTML = `{css}`;
|
style.innerHTML = `{css}`;
|
||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
|
document.body.classList.add({", ".join([f'"{c}"' for c in body_classes])});
|
||||||
}})();
|
}})();
|
||||||
""",
|
""",
|
||||||
after_style,
|
after_injection,
|
||||||
)
|
)
|
||||||
|
|
||||||
def load_ts_page(self, name: str) -> None:
|
def load_ts_page(self, name: str) -> None:
|
||||||
|
@ -677,7 +679,7 @@ html {{ {font} }}
|
||||||
self.hide_while_preserving_layout()
|
self.hide_while_preserving_layout()
|
||||||
self.setZoomFactor(1)
|
self.setZoomFactor(1)
|
||||||
self.load_url(QUrl(f"{mw.serverURL()}_anki/pages/{name}.html{extra}"))
|
self.load_url(QUrl(f"{mw.serverURL()}_anki/pages/{name}.html{extra}"))
|
||||||
self.inject_dynamic_style_and_show()
|
self.add_dynamic_css_and_classes_then_show()
|
||||||
|
|
||||||
def force_load_hack(self) -> None:
|
def force_load_hack(self) -> None:
|
||||||
"""Force process to initialize.
|
"""Force process to initialize.
|
||||||
|
|
Loading…
Reference in a new issue