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