Created
August 18, 2018 21:34
-
-
Save balaam/d7fb7344ea2eebce21e25772ce3a58c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import the main window object (mw) from aqt | |
# from the anki tutorial: https://apps.ankiweb.net/docs/addons.html | |
from aqt import mw | |
# import the "show info" tool from utils.py | |
from aqt.utils import showInfo, getTag, tooltip | |
# import all of the Qt GUI library | |
from aqt.qt import * | |
from aqt.reviewer import Reviewer | |
originalShortcutkeys = Reviewer._shortcutKeys | |
quick_tags = { | |
'g': {'tags': 'good_candidate', 'suspend': True}, | |
'h': {'suspend': True}, | |
'j': {'delete': True} | |
} | |
def addTags(note, tagString): | |
tagList = mw.col.tags.split(tagString) | |
for tag in tagList: | |
note.addTag(tag) | |
note.flush() | |
def doTagAction(tagDef): | |
mw.checkpoint(("Add Tags")) | |
note = mw.reviewer.card.note() | |
msg = "Card processed." | |
if 'tags' in tagDef: | |
addTags(note, tagDef['tags']) | |
msg = msg + " Tagged." | |
if 'suspend' in tagDef and tagDef['suspend']: | |
mw.col.sched.suspendCards([mw.reviewer.card.id]) | |
mw.reset() | |
msg = msg + " Suspended." | |
if 'delete' in tagDef and tagDef['delete']: | |
mw.col.remCards([mw.reviewer.card.id]) | |
mw.reset() | |
msg = msg + " Deleted." | |
tooltip(msg) | |
def newShortcutHandler(self): | |
originalList = originalShortcutkeys(self); | |
originalList.append(("g", lambda: doTagAction({'tags': 'good_candidate', 'suspend': True}))) | |
originalList.append(("h", lambda: doTagAction({'suspend': True}))) | |
originalList.append(("j", lambda: doTagAction({'delete': True}))) | |
return originalList | |
Reviewer._shortcutKeys = newShortcutHandler | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment