def setup(self, did): """ keyword arguments: did -- if None, then export whole anki. If did, export this deck (at least as default). """ self.exporters = exporters() # if a deck specified, start with .apkg type selected idx = 0 if did: for c, (k, e) in enumerate(self.exporters): if e.ext == ".apkg": idx = c break self.frm.format.insertItems(0, [e[0] for e in self.exporters]) self.frm.format.setCurrentIndex(idx) self.frm.format.activated.connect(self.exporterChanged) self.exporterChanged(idx) # deck list self.decks = [_("All Decks")] + sorted(self.col.decks.allNames()) self.frm.deck.addItems(self.decks) # save button b = QPushButton(_("Export...")) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole) # set default option if accessed through deck button if did: name = self.mw.col.decks.get(did)['name'] index = self.frm.deck.findText(name) self.frm.deck.setCurrentIndex(index)
def setup(self, did: Optional[int]) -> None: self.exporters = exporters(self.col) # if a deck specified, start with .apkg type selected idx = 0 if did or self.cids: for c, (k, e) in enumerate(self.exporters): if e.ext == ".apkg": idx = c break self.frm.format.insertItems(0, [e[0] for e in self.exporters]) self.frm.format.setCurrentIndex(idx) qconnect(self.frm.format.activated, self.exporterChanged) self.exporterChanged(idx) # deck list if self.cids is None: self.decks = [tr(TR.EXPORTING_ALL_DECKS)] self.decks.extend(d.name for d in self.col.decks.all_names_and_ids()) else: self.decks = [tr(TR.EXPORTING_SELECTED_NOTES)] self.frm.deck.addItems(self.decks) # save button b = QPushButton(tr(TR.EXPORTING_EXPORT)) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole) # set default option if accessed through deck button if did: name = self.mw.col.decks.get(did)["name"] index = self.frm.deck.findText(name) self.frm.deck.setCurrentIndex(index)
def setup(self, did: Optional[int]): self.exporters = exporters() # if a deck specified, start with .apkg type selected idx = 0 if did or self.cids: for c, (k, e) in enumerate(self.exporters): if e.ext == ".apkg": idx = c break self.frm.format.insertItems(0, [e[0] for e in self.exporters]) self.frm.format.setCurrentIndex(idx) self.frm.format.activated.connect(self.exporterChanged) self.exporterChanged(idx) # deck list if self.cids is None: self.decks = [_("All Decks")] + sorted(self.col.decks.allNames()) else: self.decks = [_("Selected Notes")] self.frm.deck.addItems(self.decks) # save button b = QPushButton(_("Export...")) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole) # set default option if accessed through deck button if did: name = self.mw.col.decks.get(did)["name"] index = self.frm.deck.findText(name) self.frm.deck.setCurrentIndex(index)
def exporterChanged(self, idx): self.exporter = exporters()[idx][1](self.col) self.isApkg = hasattr(self.exporter, "includeSched") self.hideTags = hasattr(self.exporter, "hideTags") self.frm.includeSched.setVisible(self.isApkg) self.frm.includeMedia.setVisible(self.isApkg) self.frm.includeTags.setVisible(not self.isApkg and not self.hideTags)
def setup(self): self.frm.format.insertItems(0, list(zip(*exporters())[0])) self.connect(self.frm.format, SIGNAL("activated(int)"), self.exporterChanged) self.exporterChanged(0) self.decks = [_("All Decks")] + sorted(self.col.decks.allNames()) self.frm.deck.addItems(self.decks) # save button b = QPushButton(_("Export...")) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
def setup(self, did): self.frm.format.insertItems(0, list(zip(*exporters()))[0]) self.frm.format.activated.connect(self.exporterChanged) self.exporterChanged(0) self.decks = [_("All Decks")] + sorted(self.col.decks.allNames()) self.frm.deck.addItems(self.decks) # save button b = QPushButton(_("Export...")) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole) # set default option if accessed through deck button if did: name = self.mw.col.decks.get(did)['name'] index = self.frm.deck.findText(name) self.frm.deck.setCurrentIndex(index)
def exporterChanged(self, idx): """Ability to only show includeSched checkbutton for our exporters""" from anki.exporting import exporters self.exporter = exporters()[idx][1](self.col) self.isApkg = (hasattr(self.exporter, "includeSched") and not hasattr(self.exporter, "glossary")) hasSchedToggle = hasattr(self.exporter, "glossary") self.isTextNote = hasattr(self.exporter, "includeTags") self.hideTags = hasattr(self.exporter, "hideTags") self.frm.includeSched.setVisible(self.isApkg or hasSchedToggle) if hasSchedToggle: self.frm.includeSched.setChecked(False) self.frm.includeMedia.setVisible(self.isApkg) self.frm.includeTags.setVisible(not self.isApkg and not self.hideTags)
def setup(self, did): self.exporters = exporters() # if a deck specified, start with .apkg type selected idx = 0 if did: for c, (k,e) in enumerate(self.exporters): if e.ext == ".apkg": idx = c break self.frm.format.insertItems(0, [e[0] for e in self.exporters]) self.frm.format.setCurrentIndex(idx) self.frm.format.activated.connect(self.exporterChanged) self.exporterChanged(idx) # deck list self.decks = [_("All Decks")] + sorted(self.col.decks.allNames()) self.frm.deck.addItems(self.decks) # save button b = QPushButton(_("Export...")) self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole) # set default option if accessed through deck button if did: name = self.mw.col.decks.get(did)['name'] index = self.frm.deck.findText(name) self.frm.deck.setCurrentIndex(index)
def exporterChanged(self, idx): self.exporter = exporters()[idx][1](self.col) isAnki = hasattr(self.exporter, "includeSched") self.frm.includeSched.setShown(isAnki) self.frm.includeMedia.setShown(isAnki) self.frm.includeTags.setShown(not isAnki)