def __init__(self, mw: AnkiQt, nt: NotetypeDict, parent: Optional[QWidget] = None) -> None: QDialog.__init__(self, parent or mw) self.mw = mw self.col = self.mw.col self.mm = self.mw.col.models self.model = nt self.mm._remove_from_cache(self.model["id"]) self.mw.checkpoint(tr.editing_fields()) self.change_tracker = ChangeTracker(self.mw) self.form = aqt.forms.fields.Ui_Dialog() self.form.setupUi(self) self.setWindowTitle( without_unicode_isolation( tr.fields_fields_for(val=self.model["name"]))) disable_help_button(self) self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False) self.form.buttonBox.button( QDialogButtonBox.Cancel).setAutoDefault(False) self.form.buttonBox.button(QDialogButtonBox.Save).setAutoDefault(False) self.currentIdx: Optional[int] = None self.fillFields() self.setupSignals() self.form.fieldList.setDragDropMode(QAbstractItemView.InternalMove) self.form.fieldList.dropEvent = self.onDrop # type: ignore[assignment] self.form.fieldList.setCurrentRow(0) self.exec_()
def __init__( self, mw: AnkiQt, nt: NotetypeDict, parent: Optional[QWidget] = None, open_at: int = 0, ) -> None: QDialog.__init__(self, parent or mw) mw.garbage_collect_on_dialog_finish(self) self.mw = mw self.col = self.mw.col self.mm = self.mw.col.models self.model = nt self.mm._remove_from_cache(self.model["id"]) self.change_tracker = ChangeTracker(self.mw) self.setWindowTitle( without_unicode_isolation( tr.fields_fields_for(val=self.model["name"]))) if os.getenv("ANKI_EXPERIMENTAL_FIELDS_WEB"): form = aqt.forms.fields_web.Ui_Dialog() form.setupUi(self) self.webview = form.webview self.webview.set_title("fields") self.show() self.refresh() self.webview.set_bridge_command(self._on_bridge_cmd, self) self.activateWindow() return self.form = aqt.forms.fields.Ui_Dialog() self.form.setupUi(self) self.webview = None disable_help_button(self) self.form.buttonBox.button( QDialogButtonBox.StandardButton.Help).setAutoDefault(False) self.form.buttonBox.button( QDialogButtonBox.StandardButton.Cancel).setAutoDefault(False) self.form.buttonBox.button( QDialogButtonBox.StandardButton.Save).setAutoDefault(False) self.currentIdx: Optional[int] = None self.fillFields() self.setupSignals() self.form.fieldList.setDragDropMode( QAbstractItemView.DragDropMode.InternalMove) self.form.fieldList.dropEvent = self.onDrop # type: ignore[assignment] self.form.fieldList.setCurrentRow(open_at) self.exec()