Esempio n. 1
0
 def __init__(
     self,
     mw: AnkiQt,
     note: Note,
     ord=0,
     parent: Optional[QWidget] = None,
     fill_empty: bool = False,
 ):
     QDialog.__init__(self, parent or mw, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = aqt.mw
     self.note = note
     self.ord = ord
     self.col = self.mw.col.weakref()
     self.mm = self.mw.col.models
     self.model = note.model()
     self.templates = self.model["tmpls"]
     self.fill_empty_action_toggled = fill_empty
     self.night_mode_is_enabled = self.mw.pm.night_mode()
     self.mobile_emulation_enabled = False
     self.have_autoplayed = False
     self.mm._remove_from_cache(self.model["id"])
     self.mw.checkpoint(tr(TR.CARD_TEMPLATES_CARD_TYPES))
     self.change_tracker = ChangeTracker(self.mw)
     self.setupTopArea()
     self.setupMainArea()
     self.setupButtons()
     self.setupShortcuts()
     self.setWindowTitle(
         without_unicode_isolation(
             tr(TR.CARD_TEMPLATES_CARD_TYPES_FOR, val=self.model["name"])
         )
     )
     disable_help_button(self)
     v1 = QVBoxLayout()
     v1.addWidget(self.topArea)
     v1.addWidget(self.mainArea)
     v1.addLayout(self.buttons)
     v1.setContentsMargins(12, 12, 12, 12)
     self.setLayout(v1)
     gui_hooks.card_layout_will_show(self)
     self.redraw_everything()
     restoreGeom(self, "CardLayout")
     restoreSplitter(self.mainArea, "CardLayoutMainArea")
     self.setWindowModality(Qt.ApplicationModal)
     self.show()
     # take the focus away from the first input area when starting up,
     # as users tend to accidentally type into the template
     self.setFocus()
Esempio n. 2
0
 def __init__(
     self,
     mw: AnkiQt,
     note: Note,
     ord=0,
     parent: Optional[QWidget] = None,
     fill_empty: bool = False,
 ):
     QDialog.__init__(self, parent or mw, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = aqt.mw
     self.note = note
     self.ord = ord
     self.col = self.mw.col.weakref()
     self.mm = self.mw.col.models
     self.model = note.model()
     self.templates = self.model["tmpls"]
     self._want_fill_empty_on = fill_empty
     self.have_autoplayed = False
     self.mm._remove_from_cache(self.model["id"])
     self.mw.checkpoint(_("Card Types"))
     self.change_tracker = ChangeTracker(self.mw)
     self.setupTopArea()
     self.setupMainArea()
     self.setupButtons()
     self.setupShortcuts()
     self.setWindowTitle(_("Card Types for %s") % self.model["name"])
     v1 = QVBoxLayout()
     v1.addWidget(self.topArea)
     v1.addWidget(self.mainArea)
     v1.addLayout(self.buttons)
     v1.setContentsMargins(12, 12, 12, 12)
     self.setLayout(v1)
     gui_hooks.card_layout_will_show(self)
     self.redraw_everything()
     restoreGeom(self, "CardLayout")
     restoreSplitter(self.mainArea, "CardLayoutMainArea")
     self.setWindowModality(Qt.ApplicationModal)
     self.show()
     # take the focus away from the first input area when starting up,
     # as users tend to accidentally type into the template
     self.setFocus()
Esempio n. 3
0
 def __init__(self, mw: AnkiQt) -> None:
     QDialog.__init__(self, None, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = mw
     self.form = aqt.forms.addcards.Ui_Dialog()
     self.form.setupUi(self)
     self.setWindowTitle(_("Add"))
     self.setMinimumHeight(300)
     self.setMinimumWidth(400)
     self.setupChoosers()
     self.setupEditor()
     self.setupButtons()
     self.onReset()
     self.history: List[int] = []
     self.previousNote = None
     restoreGeom(self, "add")
     addHook("reset", self.onReset)
     addHook("currentModelChanged", self.onModelChange)
     addCloseShortcut(self)
     self.show()
Esempio n. 4
0
 def __init__(self, mw: AnkiQt) -> None:
     QDialog.__init__(self, None, Qt.Window)
     mw.setupDialogGC(self)
     self.mw = mw
     self.form = aqt.forms.addcards.Ui_Dialog()
     self.form.setupUi(self)
     self.setWindowTitle(tr(TR.ACTIONS_ADD))
     self.setMinimumHeight(300)
     self.setMinimumWidth(400)
     self.setupChoosers()
     self.setupEditor()
     self.setupButtons()
     self.onReset()
     self.history: List[int] = []
     self.previousNote = None
     restoreGeom(self, "add")
     gui_hooks.state_did_reset.append(self.onReset)
     gui_hooks.current_note_type_did_change.append(self.onModelChange)
     addCloseShortcut(self)
     gui_hooks.add_cards_did_init(self)
     self.show()