From b4784b7437e982c71473ab4d2fa0338dab8b096f Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Thu, 19 Jun 2014 19:13:12 -0500 Subject: [PATCH] add "export" button to deck menus --- aqt/deckbrowser.py | 5 +++++ aqt/exporting.py | 11 ++++++++--- aqt/main.py | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/aqt/deckbrowser.py b/aqt/deckbrowser.py index 74ad1b0a3..ca13c78b3 100644 --- a/aqt/deckbrowser.py +++ b/aqt/deckbrowser.py @@ -268,10 +268,15 @@ where id > ?""", (self.mw.col.sched.dayCutoff-86400)*1000) a.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did)) a = m.addAction(_("Options")) a.connect(a, SIGNAL("triggered()"), lambda did=did: self._options(did)) + a = m.addAction(_("Export")) + a.connect(a, SIGNAL("triggered()"), lambda did=did: self._export(did)) a = m.addAction(_("Delete")) a.connect(a, SIGNAL("triggered()"), lambda did=did: self._delete(did)) m.exec_(QCursor.pos()) + def _export(self, did): + self.mw.onExport(did=did) + def _rename(self, did): self.mw.checkpoint(_("Rename Deck")) deck = self.mw.col.decks.get(did) diff --git a/aqt/exporting.py b/aqt/exporting.py index 7f4ee90c4..cb5bdd1ae 100644 --- a/aqt/exporting.py +++ b/aqt/exporting.py @@ -12,17 +12,17 @@ from anki.exporting import exporters class ExportDialog(QDialog): - def __init__(self, mw): + def __init__(self, mw, did=None): QDialog.__init__(self, mw, Qt.Window) self.mw = mw self.col = mw.col self.frm = aqt.forms.exporting.Ui_ExportDialog() self.frm.setupUi(self) self.exporter = None - self.setup() + self.setup(did) self.exec_() - def setup(self): + def setup(self, did): self.frm.format.insertItems(0, list(zip(*exporters())[0])) self.connect(self.frm.format, SIGNAL("activated(int)"), self.exporterChanged) @@ -32,6 +32,11 @@ class ExportDialog(QDialog): # 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) diff --git a/aqt/main.py b/aqt/main.py index 05c28c684..126912861 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -764,9 +764,9 @@ title="%s">%s''' % ( import aqt.importing aqt.importing.onImport(self) - def onExport(self): + def onExport(self, did=None): import aqt.exporting - aqt.exporting.ExportDialog(self) + aqt.exporting.ExportDialog(self, did=did) # Cramming ##########################################################################