From 6095b0130190237c4447cca478d478a1c142b6c4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 4 Dec 2022 21:12:20 +1000 Subject: [PATCH] Avoid hiding webview when refreshing When opening the graphs screen in dark mode, we want to load the page first and then reveal the webview, to prevent a flash of white that can appear as the page loads. Previously we did this for any call to load_ts_page(), but this results in flicker when refreshing an existing webview, such as the move from deck list to congrats screen. In those cases, at least on the machines I have to test with here, the refresh is smoother without the hide and show step. The new window case is still not ideal - while the hide+show prevents a flash of white, there is a flash of black instead, presumably as the webview draws the initially-blank framebuffer with the contents of the webview. --- qt/aqt/stats.py | 1 + qt/aqt/webview.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/qt/aqt/stats.py b/qt/aqt/stats.py index 6af03e118..7f9dfe0bc 100644 --- a/qt/aqt/stats.py +++ b/qt/aqt/stats.py @@ -50,6 +50,7 @@ class NewDeckStats(QDialog): maybeHideClose(self.form.buttonBox) addCloseShortcut(self) gui_hooks.stats_dialog_will_show(self) + self.form.web.hide_while_preserving_layout() self.show() self.refresh() self.form.web.set_bridge_command(self._on_bridge_cmd, self) diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 5a2e9fd3c..93653f51a 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -675,7 +675,6 @@ html {{ {font} }} extra = "#night" else: extra = "" - self.hide_while_preserving_layout() self.load_url(QUrl(f"{mw.serverURL()}_anki/pages/{name}.html{extra}")) self.add_dynamic_css_and_classes_then_show()