mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 21:57:12 -05:00
option to apply options group to all child decks
This commit is contained in:
parent
c3c9156fdb
commit
a85addc5d5
1 changed files with 19 additions and 1 deletions
|
|
@ -5,7 +5,8 @@
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import aqt, simplejson
|
import aqt, simplejson
|
||||||
from anki.utils import ids2str
|
from anki.utils import ids2str
|
||||||
from aqt.utils import showInfo, showWarning, openHelp, getOnlyText
|
from aqt.utils import showInfo, showWarning, openHelp, getOnlyText, askUser, \
|
||||||
|
tooltip
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
class DeckConf(QDialog):
|
class DeckConf(QDialog):
|
||||||
|
|
@ -13,6 +14,8 @@ class DeckConf(QDialog):
|
||||||
QDialog.__init__(self, mw)
|
QDialog.__init__(self, mw)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.deck = deck
|
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 = aqt.forms.dconf.Ui_Dialog()
|
||||||
self.form.setupUi(self)
|
self.form.setupUi(self)
|
||||||
self.mw.checkpoint(_("Options"))
|
self.mw.checkpoint(_("Options"))
|
||||||
|
|
@ -69,6 +72,10 @@ class DeckConf(QDialog):
|
||||||
a.connect(a, SIGNAL("triggered()"), self.remGroup)
|
a.connect(a, SIGNAL("triggered()"), self.remGroup)
|
||||||
a = m.addAction(_("Rename"))
|
a = m.addAction(_("Rename"))
|
||||||
a.connect(a, SIGNAL("triggered()"), self.renameGroup)
|
a.connect(a, SIGNAL("triggered()"), self.renameGroup)
|
||||||
|
a = m.addAction(_("Set for all subdecks"))
|
||||||
|
a.connect(a, SIGNAL("triggered()"), self.setChildren)
|
||||||
|
if not self.childDids:
|
||||||
|
a.setEnabled(False)
|
||||||
m.exec_(QCursor.pos())
|
m.exec_(QCursor.pos())
|
||||||
|
|
||||||
def onConfChange(self, idx):
|
def onConfChange(self, idx):
|
||||||
|
|
@ -116,6 +123,17 @@ class DeckConf(QDialog):
|
||||||
self.conf['name'] = name
|
self.conf['name'] = name
|
||||||
self.loadConfs()
|
self.loadConfs()
|
||||||
|
|
||||||
|
def setChildren(self):
|
||||||
|
if not askUser(
|
||||||
|
_("Set all decks below %s to this option group?") %
|
||||||
|
self.deck['name']):
|
||||||
|
return
|
||||||
|
for did in self.childDids:
|
||||||
|
deck = self.mw.col.decks.get(did)
|
||||||
|
deck['conf'] = self.deck['conf']
|
||||||
|
self.mw.col.decks.save(deck)
|
||||||
|
tooltip(_("%d decks updated.") % len(self.childDids))
|
||||||
|
|
||||||
# Loading
|
# Loading
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue