def onPrepareQA(self, html, card, context): if self.settings['prioEnabled']: answerShortcuts = ['1', '2', '3', '4'] else: answerShortcuts = ['4'] activeAnswerShortcuts = [ next((s for s in mw.stateShortcuts if s.key().toString() == i), None) for i in answerShortcuts ] if isIrCard(card): if context == 'reviewQuestion': self.qshortcuts = mw.applyShortcuts(self.shortcuts) mw.stateShortcuts += self.qshortcuts for shortcut in activeAnswerShortcuts: if shortcut: mw.stateShortcuts.remove(shortcut) sip.delete(shortcut) else: for shortcut in answerShortcuts: if not activeAnswerShortcuts[answerShortcuts.index(shortcut)]: mw.stateShortcuts += mw.applyShortcuts([ (shortcut, lambda: mw.reviewer._answerCard(int(shortcut))) ]) return html
def onPrepareQA(self, html, card, context): easyShortcut = next( (s for s in mw.stateShortcuts if s.key().toString() == '4'), None) if isIrCard(card): if context == 'reviewQuestion': self.qshortcuts = mw.applyShortcuts(self.shortcuts) mw.stateShortcuts += self.qshortcuts if easyShortcut: mw.stateShortcuts.remove(easyShortcut) sip.delete(easyShortcut) elif not easyShortcut: mw.stateShortcuts += mw.applyShortcuts( [('4', lambda: mw.reviewer._answerCard(4))]) return html
def onPrepareQA(self, html, card, context): if isIrCard(card): if context == 'reviewQuestion': self.qshortcuts = mw.applyShortcuts(self.shortcuts) mw.stateShortcuts += self.qshortcuts return html
"goto_first_deck": goto_first_deck, "goto_last_deck": goto_last_deck, "goto_next_deck": goto_next_deck, "goto_next_deck_same_lvl": goto_next_deck_same_lvl, "goto_parent_deck": goto_parent_deck, "goto_previous_deck": goto_previous_deck, "goto_previous_deck_same_lvl": goto_previous_deck_same_lvl, "open_overview": mw.onOverview, "study": study, "toggle_collapse": toggle_collapse, } config = mw.addonManager.getConfig(__name__) shortcut_config = [] for key, action in config["keys"].items(): shortcut_config.append((key, str2func[action])) scuts = mw.applyShortcuts(shortcut_config) def setup(state, _oldstate): """Enable the shortcuts only in the deck browser""" if state == "deckBrowser": for scut in scuts: scut.setEnabled(True) else: for scut in scuts: scut.setEnabled(False) gui_hooks.state_did_change.append(setup)