# Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html from __future__ import annotations import aqt from aqt import gui_hooks from aqt.qt import * from aqt.utils import addCloseShortcut, disable_help_button, restoreGeom, saveGeom from aqt.webview import AnkiWebView class DeckOptionsDialog(QDialog): "The new deck configuration screen." TITLE = "deckOptions" silentlyClose = True def __init__(self, mw: aqt.main.AnkiQt) -> None: QDialog.__init__(self, mw, Qt.Window) self.mw = mw self._setup_ui() self.show() def _setup_ui(self) -> None: self.setWindowModality(Qt.ApplicationModal) self.mw.garbage_collect_on_dialog_finish(self) self.setMinimumWidth(400) disable_help_button(self) restoreGeom(self, self.TITLE) addCloseShortcut(self) self.web = AnkiWebView(title=self.TITLE) self.web.setVisible(False) self.web.load_ts_page("deckconfig") layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.web) self.setLayout(layout) deck_id = self.mw.col.decks.get_current_id() self.web.eval( f"""const $deckOptions = anki.deckConfig( document.getElementById('main'), {deck_id});""" ) gui_hooks.deck_options_did_load(self) def reject(self) -> None: self.web = None saveGeom(self, self.TITLE) QDialog.reject(self)