add "export" button to deck menus
This commit is contained in:
parent
28bb109ded
commit
b4784b7437
@ -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.connect(a, SIGNAL("triggered()"), lambda did=did: self._rename(did))
|
||||||
a = m.addAction(_("Options"))
|
a = m.addAction(_("Options"))
|
||||||
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._options(did))
|
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 = m.addAction(_("Delete"))
|
||||||
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._delete(did))
|
a.connect(a, SIGNAL("triggered()"), lambda did=did: self._delete(did))
|
||||||
m.exec_(QCursor.pos())
|
m.exec_(QCursor.pos())
|
||||||
|
|
||||||
|
def _export(self, did):
|
||||||
|
self.mw.onExport(did=did)
|
||||||
|
|
||||||
def _rename(self, did):
|
def _rename(self, did):
|
||||||
self.mw.checkpoint(_("Rename Deck"))
|
self.mw.checkpoint(_("Rename Deck"))
|
||||||
deck = self.mw.col.decks.get(did)
|
deck = self.mw.col.decks.get(did)
|
||||||
|
@ -12,17 +12,17 @@ from anki.exporting import exporters
|
|||||||
|
|
||||||
class ExportDialog(QDialog):
|
class ExportDialog(QDialog):
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw, did=None):
|
||||||
QDialog.__init__(self, mw, Qt.Window)
|
QDialog.__init__(self, mw, Qt.Window)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.col = mw.col
|
self.col = mw.col
|
||||||
self.frm = aqt.forms.exporting.Ui_ExportDialog()
|
self.frm = aqt.forms.exporting.Ui_ExportDialog()
|
||||||
self.frm.setupUi(self)
|
self.frm.setupUi(self)
|
||||||
self.exporter = None
|
self.exporter = None
|
||||||
self.setup()
|
self.setup(did)
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self, did):
|
||||||
self.frm.format.insertItems(0, list(zip(*exporters())[0]))
|
self.frm.format.insertItems(0, list(zip(*exporters())[0]))
|
||||||
self.connect(self.frm.format, SIGNAL("activated(int)"),
|
self.connect(self.frm.format, SIGNAL("activated(int)"),
|
||||||
self.exporterChanged)
|
self.exporterChanged)
|
||||||
@ -32,6 +32,11 @@ class ExportDialog(QDialog):
|
|||||||
# save button
|
# save button
|
||||||
b = QPushButton(_("Export..."))
|
b = QPushButton(_("Export..."))
|
||||||
self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
|
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):
|
def exporterChanged(self, idx):
|
||||||
self.exporter = exporters()[idx][1](self.col)
|
self.exporter = exporters()[idx][1](self.col)
|
||||||
|
@ -764,9 +764,9 @@ title="%s">%s</button>''' % (
|
|||||||
import aqt.importing
|
import aqt.importing
|
||||||
aqt.importing.onImport(self)
|
aqt.importing.onImport(self)
|
||||||
|
|
||||||
def onExport(self):
|
def onExport(self, did=None):
|
||||||
import aqt.exporting
|
import aqt.exporting
|
||||||
aqt.exporting.ExportDialog(self)
|
aqt.exporting.ExportDialog(self, did=did)
|
||||||
|
|
||||||
# Cramming
|
# Cramming
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user