mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
[Qt 6.7] Set ForceDarkMode attribute in AnkiWebView (#3622)
* Set ForceDarkMode attribute in AnkiWebView * Use hasattr for backward compatibility * Make mypy happy
This commit is contained in:
parent
d014f72377
commit
36d0fddd38
1 changed files with 8 additions and 0 deletions
|
@ -838,6 +838,14 @@ html {{ {font} }}
|
||||||
def on_theme_did_change(self) -> None:
|
def on_theme_did_change(self) -> None:
|
||||||
# avoid flashes if page reloaded
|
# avoid flashes if page reloaded
|
||||||
self._page.setBackgroundColor(theme_manager.qcolor(colors.CANVAS))
|
self._page.setBackgroundColor(theme_manager.qcolor(colors.CANVAS))
|
||||||
|
if hasattr(QWebEngineSettings.WebAttribute, "ForceDarkMode"):
|
||||||
|
force_dark_mode = getattr(QWebEngineSettings.WebAttribute, "ForceDarkMode")
|
||||||
|
page_settings = self._page.settings()
|
||||||
|
if page_settings is not None:
|
||||||
|
page_settings.setAttribute(
|
||||||
|
force_dark_mode,
|
||||||
|
theme_manager.get_night_mode(),
|
||||||
|
)
|
||||||
# update night-mode class, and legacy nightMode/night-mode body classes
|
# update night-mode class, and legacy nightMode/night-mode body classes
|
||||||
self.eval(
|
self.eval(
|
||||||
f"""
|
f"""
|
||||||
|
|
Loading…
Reference in a new issue