Esempio n. 1
0
 def __init__(
     self,
     mw: aqt.AnkiQt,
     names: Callable = None,
     accept: str = None,
     title: str = None,
     help: HelpPageArgument = HelpPage.KEYBOARD_SHORTCUTS,
     current: Optional[str] = None,
     cancel: bool = True,
     parent: Optional[QWidget] = None,
     dyn: bool = False,
     buttons: Optional[List[Union[str, QPushButton]]] = None,
     geomKey: str = "default",
 ) -> None:
     QDialog.__init__(self, parent or mw)
     self.mw = mw
     self.form = aqt.forms.studydeck.Ui_Dialog()
     self.form.setupUi(self)
     self.form.filter.installEventFilter(self)
     self.cancel = cancel
     gui_hooks.state_did_reset.append(self.onReset)
     self.geomKey = f"studyDeck-{geomKey}"
     restoreGeom(self, self.geomKey)
     disable_help_button(self)
     if not cancel:
         self.form.buttonBox.removeButton(
             self.form.buttonBox.button(QDialogButtonBox.Cancel))
     if buttons is not None:
         for button_or_label in buttons:
             self.form.buttonBox.addButton(button_or_label,
                                           QDialogButtonBox.ActionRole)
     else:
         b = QPushButton(tr.actions_add())
         b.setShortcut(QKeySequence("Ctrl+N"))
         b.setToolTip(shortcut(tr.decks_add_new_deck_ctrlandn()))
         self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole)
         qconnect(b.clicked, self.onAddDeck)
     if title:
         self.setWindowTitle(title)
     if not names:
         names_ = [
             d.name for d in self.mw.col.decks.all_names_and_ids(
                 include_filtered=dyn, skip_empty_default=True)
         ]
         self.nameFunc = None
         self.origNames = names_
     else:
         self.nameFunc = names
         self.origNames = names()
     self.name: Optional[str] = None
     self.ok = self.form.buttonBox.addButton(accept or tr.decks_study(),
                                             QDialogButtonBox.AcceptRole)
     self.setWindowModality(Qt.WindowModal)
     qconnect(self.form.buttonBox.helpRequested, lambda: openHelp(help))
     qconnect(self.form.filter.textEdited, self.redraw)
     qconnect(self.form.list.itemDoubleClicked, self.accept)
     self.show()
     # redraw after show so position at center correct
     self.redraw("", current)
     self.exec_()
Esempio n. 2
0
 def __init__(self, mw: aqt.AnkiQt):
     super().__init__(
         mw,
         "previousReviewerCardInfo",
         without_unicode_isolation(
             tr.card_stats_previous_card(context=tr.decks_study())),
     )