def initializePage(self): openHelp("changes") self.setCommitPage(True) self.setTitle(_("Upgrading")) self.label = l = QLabel() l.setTextInteractionFlags(Qt.TextSelectableByMouse) l.setWordWrap(True) v = QVBoxLayout() v.addWidget(l) prog = QProgressBar() prog.setMaximum(0) v.addWidget(prog) l2 = QLabel(_("Please be patient; this can take a while.")) l2.setTextInteractionFlags(Qt.TextSelectableByMouse) l2.setWordWrap(True) v.addWidget(l2) self.setLayout(v) # run the upgrade in a different thread self.thread = UpgradeThread(decks, colpath, upgrader.conf) self.thread.start() # and periodically update the GUI self.timer = QTimer(self) self.timer.connect(self.timer, SIGNAL("timeout()"), self.onTimer) self.timer.start(1000) self.onTimer()
def _linkHandler(self, url): if ":" in url: (cmd, arg) = url.split(":") else: cmd = url if cmd == "open": self._selDeck(arg) elif cmd == "opts": self._showOptions(arg) elif cmd == "shared": self._onShared() elif cmd == "import": self.mw.onImport() elif cmd == "lots": openHelp("using-decks-appropriately") elif cmd == "hidelots": self.mw.pm.profile['hideDeckLotsMsg'] = True self.refresh() elif cmd == "create": deck = getOnlyText(_("Name for deck:")) if deck: self.mw.col.decks.id(deck) self.refresh() elif cmd == "drag": draggedDeckDid, ontoDeckDid = arg.split(',') self._dragDeckOnto(draggedDeckDid, ontoDeckDid) elif cmd == "collapse": self._collapse(arg)
def __init__(self, mw, first=False, search=""): QDialog.__init__(self, mw) self.mw = mw self.deck = self.mw.col.decks.current() # context-sensitive extras like deck:foo self.search = search self.form = aqt.forms.dyndconf.Ui_Dialog() self.form.setupUi(self) if first: label = _("Build") else: label = _("Rebuild") self.ok = self.form.buttonBox.addButton( label, QDialogButtonBox.AcceptRole) self.mw.checkpoint(_("Options")) self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("cramming")) self.setWindowTitle(_("Options for %s") % self.deck['name']) self.setupExamples() self.setupOrder() self.loadConf() self.show() if first: if isMac or isWin: self.form.examples.showPopup() else: mw.progress.timer(200, self.form.examples.showPopup, False) self.exec_()
def __init__(self, mw, first=False, search="", deck=None): QDialog.__init__(self, mw) self.mw = mw self.deck = deck or self.mw.col.decks.current() self.search = search self.form = aqt.forms.dyndconf.Ui_Dialog() self.form.setupUi(self) if first: label = _("Build") else: label = _("Rebuild") self.ok = self.form.buttonBox.addButton( label, QDialogButtonBox.AcceptRole) self.mw.checkpoint(_("Options")) self.setWindowModality(Qt.WindowModal) self.form.buttonBox.helpRequested.connect(lambda: openHelp("filtered")) self.setWindowTitle(_("Options for %s") % self.deck['name']) restoreGeom(self, "dyndeckconf") self.setupOrder() self.loadConf() if search: self.form.search.setText(search) self.form.search.selectAll() self.show() self.exec_() saveGeom(self, "dyndeckconf")
def onHtmlEdit(self): self.saveNow() d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) d.connect(form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("editor")) orgHTML = self.note.fields[self.currentField] HTMLWithoutData = orgHTML start_md_data = orgHTML.find(const.START_HTML_MARKER) end_md_data = orgHTML.find(const.END_HTML_MARKER, start_md_data) containsData = start_md_data != -1 and end_md_data != -1 if containsData: mdData = orgHTML[start_md_data:(end_md_data+len(const.END_HTML_MARKER))] HTMLWithoutData = orgHTML[:start_md_data] form.textEdit.setPlainText(HTMLWithoutData) form.textEdit.moveCursor(QTextCursor.End) d.exec_() html = form.textEdit.toPlainText() if containsData: html += mdData # filter html through beautifulsoup so we can strip out things like a # leading </div> html = unicode(BeautifulSoup(html)) self.note.fields[self.currentField] = html self.loadNote() # focus field so it's saved self.web.setFocus() self.web.eval("focusField(%d);" % self.currentField)
def __init__(self, mw, deck): QDialog.__init__(self, mw) self.mw = mw self.deck = deck self.childDids = [ d[1] for d in self.mw.col.decks.children(self.deck['id'])] self._origNewOrder = None self.form = aqt.forms.dconf.Ui_Dialog() self.form.setupUi(self) self.mw.checkpoint(_("Options")) self.setupCombos() self.setupConfs() self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("deckoptions")) self.connect(self.form.confOpts, SIGNAL("clicked()"), self.confOpts) self.form.confOpts.setText(u"▾") self.connect(self.form.buttonBox.button(QDialogButtonBox.RestoreDefaults), SIGNAL("clicked()"), self.onRestore) self.setWindowTitle(_("Options for %s") % self.deck['name']) # qt doesn't size properly with altered fonts otherwise self.show() self.adjustSize() self.exec_()
def onCloze(self): # check that the model is set up for cloze deletion if '{{cloze:' not in self.note.model()['tmpls'][0]['qfmt']: openHelp("cloze") return # find the highest existing cloze highest = 0 for name, val in self.note.items(): m = re.findall("\{\{c(\d+)::", val) if m: highest = max(highest, sorted([int(x) for x in m])[-1]) # reuse last? if not self.mw.app.keyboardModifiers() & Qt.AltModifier: highest += 1 # must start at 1 highest = max(1, highest) self._eval("wrap('{{c%d::', '}}');" % highest)
def onAdvanced(self): d = QDialog(self) frm = aqt.forms.modelopts.Ui_Dialog() frm.setupUi(d) frm.latexHeader.setText(self.model["latexPre"]) frm.latexFooter.setText(self.model["latexPost"]) d.setWindowTitle(_("Options for %s") % self.model["name"]) self.connect(frm.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("latex")) d.exec_() self.model["latexPre"] = unicode(frm.latexHeader.toPlainText()) self.model["latexPost"] = unicode(frm.latexFooter.toPlainText())
def onAdvanced(self): d = QDialog(self) frm = aqt.forms.modelopts.Ui_Dialog() frm.setupUi(d) frm.latexHeader.setText(self.model['latexPre']) frm.latexFooter.setText(self.model['latexPost']) d.setWindowTitle(_("Options for %s") % self.model['name']) frm.buttonBox.helpRequested.connect(lambda: openHelp("latex")) restoreGeom(d, "modelopts") d.exec_() saveGeom(d, "modelopts") self.model['latexPre'] = unicode(frm.latexHeader.toPlainText()) self.model['latexPost'] = unicode(frm.latexFooter.toPlainText())
def __init__(self, mw, parent=None): self.mw = mw self.parent = parent or mw QDialog.__init__(self, self.parent, Qt.Window) self.col = mw.col self.mm = self.col.models self.mw.checkpoint(_("Note Types")) self.form = aqt.forms.models.Ui_Dialog() self.form.setupUi(self) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("notetypes")) self.setupModels() restoreGeom(self, "models") self.exec_()
def onHtmlEdit(self): self.saveNow() d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) d.connect(form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("HtmlEditor")) form.textEdit.setPlainText(self.note.fields[self.currentField]) form.textEdit.moveCursor(QTextCursor.End) d.exec_() self.note.fields[self.currentField] = unicode( form.textEdit.toPlainText()) self.loadNote(self.currentField)
def __init__(self, mw, names=None, accept=None, title=None, help="studydeck", current=None, cancel=True, parent=None, dyn=False, buttons=[], geomKey="default"): 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 addHook('reset', self.onReset) self.geomKey = "studyDeck-"+geomKey restoreGeom(self, self.geomKey) if not cancel: self.form.buttonBox.removeButton( self.form.buttonBox.button(QDialogButtonBox.Cancel)) if buttons: for b in buttons: self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole) else: b = QPushButton(_("Add")) b.setShortcut(QKeySequence("Ctrl+N")) b.setToolTip(shortcut(_("Add New Deck (Ctrl+N)"))) self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole) b.connect(b, SIGNAL("clicked()"), self.onAddDeck) if title: self.setWindowTitle(title) if not names: names = sorted(self.mw.col.decks.allNames(dyn=dyn)) self.nameFunc = None self.origNames = names else: self.nameFunc = names self.origNames = names() self.name = None self.ok = self.form.buttonBox.addButton( accept or _("Study"), QDialogButtonBox.AcceptRole) self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp(help)) self.connect(self.form.filter, SIGNAL("textEdited(QString)"), self.redraw) self.connect(self.form.list, SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.accept) self.show() # redraw after show so position at center correct self.redraw("", current) self.exec_()
def __init__(self, mw): QDialog.__init__(self, mw, Qt.Window) self.mw = mw self.prof = self.mw.pm.profile self.form = aqt.forms.preferences.Ui_Preferences() self.form.setupUi(self) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("profileprefs")) self.setupCollection() self.setupLang() self.setupNetwork() self.setupBackup() self.setupOptions() self.show()
def __init__(self, mw): QDialog.__init__(self, mw) self.mw = mw self.deck = self.mw.col.decks.current() self.form = aqt.forms.dyndconf.Ui_Dialog() self.form.setupUi(self) self.mw.checkpoint(_("Options")) self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("cramming")) self.setWindowTitle(_("Options for %s") % self.deck['name']) self.setupCombos() self.loadConf() self.exec_()
def __init__(self, mw): QDialog.__init__(self, mw, Qt.Window) self.mw = mw self.prof = self.mw.pm.profile self.form = aqt.forms.preferences.Ui_Preferences() self.form.setupUi(self) self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False) self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False) self.form.buttonBox.helpRequested.connect(lambda: openHelp("profileprefs")) self.silentlyClose = True self.setupLang() self.setupCollection() self.setupNetwork() self.setupBackup() self.setupOptions() self.show()
def onHtmlEdit(self): self.saveNow() d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) d.connect(form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("editor")) form.textEdit.setPlainText(self.note.fields[self.currentField]) form.textEdit.moveCursor(QTextCursor.End) d.exec_() html = form.textEdit.toPlainText() # filter html through beautifulsoup so we can strip out things like a # leading </div> html = unicode(BeautifulSoup(html)) self.note.fields[self.currentField] = html self.loadNote()
def _onHtmlEdit(self, field): d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) form.buttonBox.helpRequested.connect(lambda: openHelp("editor")) form.textEdit.setPlainText(self.note.fields[field]) form.textEdit.moveCursor(QTextCursor.End) d.exec_() html = form.textEdit.toPlainText() # filter html through beautifulsoup so we can strip out things like a # leading </div> with warnings.catch_warnings() as w: warnings.simplefilter('ignore', UserWarning) html = str(BeautifulSoup(html, "html.parser")) self.note.fields[field] = html self.loadNote(focusTo=field)
def __init__(self, mw, deck): QDialog.__init__(self, mw) self.mw = mw self.deck = deck self.childDids = [d[1] for d in self.mw.col.decks.children(self.deck["id"])] self.form = aqt.forms.dconf.Ui_Dialog() self.form.setupUi(self) self.mw.checkpoint(_("Options")) self.setupCombos() self.setupConfs() self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("deckoptions")) self.connect(self.form.confOpts, SIGNAL("clicked()"), self.confOpts) self.form.confOpts.setText(u"▾") self.connect(self.form.buttonBox.button(QDialogButtonBox.RestoreDefaults), SIGNAL("clicked()"), self.onRestore) self.setWindowTitle(_("Options for %s") % self.deck["name"]) self.exec_()
def __init__(self, mw, first=False, search=""): QDialog.__init__(self, mw) self.mw = mw self.form = aqt.forms.studydeck.Ui_Dialog() self.form.setupUi(self) self.form.filter.installEventFilter(self) self.ok = self.form.buttonBox.addButton( _("Study"), QDialogButtonBox.AcceptRole) self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("studydeck")) self.connect(self.form.filter, SIGNAL("textEdited(QString)"), self.redraw) self.redraw("") self.exec_()
def onAdvanced(self): d = QDialog(self) frm = aqt.forms.modelopts.Ui_Dialog() frm.setupUi(d) frm.latexsvg.setChecked(self.model.get("latexsvg", False)) frm.latexHeader.setText(self.model['latexPre']) frm.latexFooter.setText(self.model['latexPost']) frm.newStyleWhitespace.setChecked(self.model.get("prewrap", False)) d.setWindowTitle(_("Options for %s") % self.model['name']) frm.buttonBox.helpRequested.connect(lambda: openHelp("latex")) restoreGeom(d, "modelopts") d.exec_() saveGeom(d, "modelopts") self.model['latexsvg'] = frm.latexsvg.isChecked() self.model['latexPre'] = str(frm.latexHeader.toPlainText()) self.model['latexPost'] = str(frm.latexFooter.toPlainText()) self.model['prewrap'] = frm.newStyleWhitespace.isChecked()
def __init__(self, mw): if not mw.col: showInfo(_("Please open a profile first.")) return QDialog.__init__(self, mw, Qt.Window) self.mw = mw self.prof = self.mw.pm.profile self.form = aqt.forms.preferences.Ui_Preferences() self.form.setupUi(self) self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False) self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("profileprefs")) self.setupCollection() self.setupNetwork() self.setupBackup() self.setupOptions() self.show()
def onHtmlEdit(self): self.saveNow() d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) form.buttonBox.helpRequested.connect(lambda: openHelp("editor")) form.textEdit.setPlainText(self.note.fields[self.currentField]) form.textEdit.moveCursor(QTextCursor.End) d.exec_() html = form.textEdit.toPlainText() # filter html through beautifulsoup so we can strip out things like a # leading </div> html = str(BeautifulSoup(html, "html.parser")) self.note.fields[self.currentField] = html self.loadNote() # focus field so it's saved self.web.setFocus() self.web.eval("focusField(%d);" % self.currentField)
def __init__(self, mw, first=False, search=""): QDialog.__init__(self, mw) self.mw = mw self.deck = self.mw.col.decks.current() self.form = aqt.forms.dyndconf.Ui_Dialog() self.form.setupUi(self) if first: label = _("Build") else: label = _("Rebuild") self.ok = self.form.buttonBox.addButton( label, QDialogButtonBox.AcceptRole) self.mw.checkpoint(_("Options")) self.setWindowModality(Qt.WindowModal) self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), lambda: openHelp("cramming")) self.setWindowTitle(_("Options for %s") % self.deck['name']) self.setupCombos() self.loadConf() if first and search: self.form.search.setText(search) self.exec_()
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.StandardButton.Cancel)) if buttons is not None: for button_or_label in buttons: self.form.buttonBox.addButton( button_or_label, QDialogButtonBox.ButtonRole.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.ButtonRole.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.ButtonRole.AcceptRole) self.setWindowModality(Qt.WindowModality.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()
def helpRequested(self): openHelp("addingnotes")
def onHelp(self): openHelp("editing?id=customizing-fields")
def helpRequested(self): openHelp("importing")
def myHtmlEdit(self): self.saveNow() # Get field cursor position by using temporary marker html = self.web.page().mainFrame().evaluateJavaScript(""" // need to collapse selection to prevent losing selected text: window.getSelection().collapseToStart(); // use placeholder to mark current cursor position document.execCommand("insertText", false, "|-|c|-|"); function retHtml(){return currentField.innerHTML}; retHtml(); """) if html: self.web.eval(""" currentField.innerHTML = currentField.innerHTML.replace("|-|c|-|", "") saveField("key"); """) pos = len(html.split("|-|c|-|")[0]) txt = html.replace("|-|c|-|", "") if COSMETIC_NEWLINES: txt = re.sub(r"(</(div|p|br|li|ul|ol|blockquote)>)([^\n])", r"\1\n\3", txt) else: txt = self.note.fields[self.currentField] pos = len(txt) d = QDialog(self.widget) form = aqt.forms.edithtml.Ui_Dialog() form.setupUi(d) d.resize(*DIALOG_SIZE) form.buttonBox.helpRequested.connect(lambda: openHelp("editor")) form.textEdit.setPlainText(txt) cursor = form.textEdit.textCursor() cursor.setPosition(pos) form.textEdit.setTextCursor(cursor) d.exec_() # Get html cursor position curpos = form.textEdit.textCursor().position() html = form.textEdit.toPlainText() before, after = html[:curpos], html[curpos:] # Move cursor out of tag dlms = {"<": ">", "&": ";"} dlm = None for idx, c in enumerate(before): if dlm and c == dlms[dlm]: dlm = None elif c in dlms: dlm = c if dlm: tag_snips = before.split(dlm) tag_pre = dlm.join(tag_snips[0:-1]) tag_post = tag_snips[-1] before = tag_pre after = dlm + tag_post + after html = before + "|-|c|-|" + after # filter html through beautifulsoup so we can strip out things like a # leading </div> html = unicode(BeautifulSoup(html)) self.note.fields[self.currentField] = html self.loadNote() # focus field so it's saved self.web.setFocus() self.web.eval("focusField(%d);" % self.currentField) # Get cursor position in rendered text via marker text = self.web.page().mainFrame().evaluateJavaScript(""" function retTxt(){return currentField.innerText}; retTxt(); """) pos = len(text.replace("\n", "").split("|-|c|-|")[0]) # Remove temporary marker self.web.eval(""" currentField.innerHTML = currentField.innerHTML.replace("|-|c|-|", ""); saveField("key"); """) # Move cursor to new position self.web.page().mainFrame().evaluateJavaScript(js_move_cursor % pos)
def onHelp(self): openHelp("notetypes")
def onHelp(self): openHelp("AddModel")
def onHelp(self) -> None: openHelp("editing?id=adding-a-note-type")
def onHelp(self): openHelp("CardLayout")
def __init__( self, mw: AnkiQt, search: Optional[str] = None, search_2: Optional[str] = None, deck: Optional[Deck] = None, ) -> None: """If 'deck' is an existing filtered deck, load and modify its settings. Otherwise, build a new one and derive settings from the current deck. """ QDialog.__init__(self, mw) self.mw = mw self.col = self.mw.col self.did: Optional[int] = None self.form = aqt.forms.dyndconf.Ui_Dialog() self.form.setupUi(self) self.mw.checkpoint(tr(TR.ACTIONS_OPTIONS)) self.initialSetup() self.old_deck = self.col.decks.current() if deck and deck["dyn"]: # modify existing dyn deck label = tr(TR.ACTIONS_REBUILD) self.deck = deck self.loadConf() elif self.old_deck["dyn"]: # create new dyn deck from other dyn deck label = tr(TR.DECKS_BUILD) self.loadConf(deck=self.old_deck) self.new_dyn_deck() else: # create new dyn deck from regular deck label = tr(TR.DECKS_BUILD) self.new_dyn_deck() self.loadConf() self.set_default_searches(self.old_deck["name"]) self.form.name.setText(self.deck["name"]) self.form.name.setPlaceholderText(self.deck["name"]) self.set_custom_searches(search, search_2) qconnect(self.form.search_button.clicked, self.on_search_button) qconnect(self.form.search_button_2.clicked, self.on_search_button_2) qconnect(self.form.hint_button.clicked, self.on_hint_button) blue = theme_manager.color(colors.LINK) grey = theme_manager.color(colors.DISABLED) self.setStyleSheet(f"""QPushButton[label] {{ padding: 0; border: 0 }} QPushButton[label]:hover {{ text-decoration: underline }} QPushButton[label="search"] {{ color: {blue} }} QPushButton[label="hint"] {{ color: {grey} }}""") disable_help_button(self) self.setWindowModality(Qt.WindowModal) qconnect(self.form.buttonBox.helpRequested, lambda: openHelp(HelpPage.FILTERED_DECK)) self.setWindowTitle( without_unicode_isolation( tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))) self.form.buttonBox.button(QDialogButtonBox.Ok).setText(label) if self.col.schedVer() == 1: self.form.secondFilter.setVisible(False) restoreGeom(self, "dyndeckconf") self.show()
def onHelp(self): openHelp("fields")
def onHelp(self) -> None: openHelp(HelpPage.BROWSING_OTHER_MENU_ITEMS)
def helpRequested(self) -> None: openHelp(HelpPage.ADDING_CARD_AND_NOTE)
def helpRequested(self): openHelp("AddItems")
def __init__( self, mw, names=None, accept=None, title=None, help: HelpPageArgument = HelpPage.KEYBOARD_SHORTCUTS, current=None, cancel=True, parent=None, dyn=False, buttons=None, geomKey="default", ) -> None: QDialog.__init__(self, parent or mw) if buttons is None: buttons = [] 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 = "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: for b in buttons: self.form.buttonBox.addButton(b, QDialogButtonBox.ActionRole) else: b = QPushButton(tr(TR.ACTIONS_ADD)) b.setShortcut(QKeySequence("Ctrl+N")) b.setToolTip(shortcut(tr(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 = None self.ok = self.form.buttonBox.addButton(accept or tr(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_()
def onDocumentation(self): """Ask the OS to open the documentation web page""" openHelp("")
def onHelp(self): openHelp("templates")
def onHelp(self): openHelp(HelpPage.TEMPLATES)
def onDocumentation(self): openHelp("")
def onHelp(self): openHelp(HelpPage.CUSTOMIZING_FIELDS)
def onHelp(self): openHelp("Browser#ChangeModel")
def helpRequested(self) -> None: openHelp(HelpPage.IMPORTING)
def show_help(self) -> None: openHelp(HelpPage.BROWSING_FIND_AND_REPLACE)
def onHelp(self): openHelp("templates/intro")
def onFindReplaceHelp(self): openHelp("Browser#FindReplace")
def onHelp(self) -> None: openHelp(HelpPage.BROWSING)
def onHelp(self): openHelp("Browser")
def onHelp(self) -> None: openHelp(HelpPage.ADDING_A_NOTE_TYPE)
def onHelp(self) -> None: openHelp("notetypes")
def onHelp(self) -> None: openHelp(HelpPage.TEMPLATES)
def helpRequested(self): openHelp("editing?id=adding-cards-and-notes")