show checkmark on current flag in reviewer context menu

This commit is contained in:
Damien Elmes 2018-11-12 12:01:54 +10:00
parent a3eb44d950
commit 4b19e47b3f

View File

@ -582,12 +582,17 @@ time = %(time)d;
# note the shortcuts listed here also need to be defined above
def _contextMenu(self):
currentFlag = self.card and self.card.userFlag()
opts = [
[_("Flag Card"), [
[_("Red Flag"), "Ctrl+1", lambda: self.setFlag(1)],
[_("Orange Flag"), "Ctrl+2", lambda: self.setFlag(2)],
[_("Green Flag"), "Ctrl+3", lambda: self.setFlag(3)],
[_("Blue Flag"), "Ctrl+4", lambda: self.setFlag(4)],
[_("Red Flag"), "Ctrl+1", lambda: self.setFlag(1),
dict(checked=currentFlag == 1)],
[_("Orange Flag"), "Ctrl+2", lambda: self.setFlag(2),
dict(checked=currentFlag == 2)],
[_("Green Flag"), "Ctrl+3", lambda: self.setFlag(3),
dict(checked=currentFlag == 3)],
[_("Blue Flag"), "Ctrl+4", lambda: self.setFlag(4),
dict(checked=currentFlag == 4)],
]],
[_("Mark Note"), "*", self.onMark],
[_("Bury Card"), "-", self.onBuryCard],
@ -620,13 +625,19 @@ time = %(time)d;
subm = m.addMenu(row[0])
self._addMenuItems(subm, row[1])
continue
if len(row) == 4:
label, scut, func, opts = row
else:
label, scut, func = row
opts = {}
a = m.addAction(label)
if scut:
a.setShortcut(QKeySequence(scut))
if opts.get("checked"):
a.setCheckable(True)
a.setChecked(True)
a.triggered.connect(func)
def onOptions(self):
self.mw.onDeckConf(self.mw.col.decks.get(
self.card.odid or self.card.did))