Deck options: hide webview after showing dialog

This seems to reduce flicker, presumably because the webview doesn't pick
up the correct geometry until the dialog is shown.
This commit is contained in:
Damien Elmes 2022-12-08 22:17:26 +10:00
parent 93d14de95c
commit 1215ee7849

View file

@ -33,7 +33,6 @@ class DeckOptionsDialog(QDialog):
self.mw = mw self.mw = mw
self._deck = deck self._deck = deck
self._setup_ui() self._setup_ui()
self.show()
def _setup_ui(self) -> None: def _setup_ui(self) -> None:
self.setWindowModality(Qt.WindowModality.ApplicationModal) self.setWindowModality(Qt.WindowModality.ApplicationModal)
@ -44,12 +43,13 @@ class DeckOptionsDialog(QDialog):
addCloseShortcut(self) addCloseShortcut(self)
self.web = AnkiWebView(title=self.TITLE) self.web = AnkiWebView(title=self.TITLE)
self.web.setVisible(False)
self.web.load_ts_page("deck-options") self.web.load_ts_page("deck-options")
layout = QVBoxLayout() layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0) layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(self.web) layout.addWidget(self.web)
self.setLayout(layout) self.setLayout(layout)
self.show()
self.web.hide_while_preserving_layout()
self.web.eval( self.web.eval(
f"""const $deckOptions = anki.setupDeckOptions({self._deck["id"]});""" f"""const $deckOptions = anki.setupDeckOptions({self._deck["id"]});"""