From 4b19e47b3f5f435daa6edcce2cb18d82f3a5e91a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 12 Nov 2018 12:01:54 +1000 Subject: [PATCH] show checkmark on current flag in reviewer context menu --- aqt/reviewer.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index 7f049bddd..6a7ec2d47 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -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 - label, scut, func = row + 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))