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.
This commit is contained in:
Damien Elmes 2022-12-04 21:12:20 +10:00
parent 1ca05b00ec
commit 6095b01301
2 changed files with 1 additions and 1 deletions

View file

@ -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)

View file

@ -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()