# -*- coding: utf-8 -*-
# See github page to report issues or to contribute:
# https://github.com/Arthaey/anki-custom-keyboard-shortcuts
#
# Also available for Anki at https://ankiweb.net/shared/info/

from aqt.qt import QMainWindow
from aqt.main import AnkiQt

GLOBAL_DECKS_SHORTCUT    = "d"
GLOBAL_OVERVIEW_SHORTCUT = "s"
GLOBAL_ADD_SHORTCUT      = "a"
GLOBAL_BROWSE_SHORTCUT   = "b"
GLOBAL_STATS_SHORTCUT    = "S"
GLOBAL_SYNC_SHORTCUT     = "y"

# Copy-pasted from aqt/main.py
def _keyPressEvent(self, evt):
    # do we have a delegate?
    if self.keyHandler:
        # did it eat the key?
        if self.keyHandler(evt):
            return
    # run standard handler
    QMainWindow.keyPressEvent(self, evt)
    # check global keys
    key = unicode(evt.text())
    if key == GLOBAL_DECKS_SHORTCUT:
        self.moveToState("deckBrowser")
    elif key == GLOBAL_OVERVIEW_SHORTCUT:
        if self.state == "overview":
            self.col.startTimebox()
            self.moveToState("review")
        else:
            self.moveToState("overview")
    elif key == GLOBAL_ADD_SHORTCUT:
        self.onAddCard()
    elif key == GLOBAL_BROWSE_SHORTCUT:
        self.onBrowse()
    elif key == GLOBAL_STATS_SHORTCUT:
        self.onStats()
    elif key == GLOBAL_SYNC_SHORTCUT:
        self.onSync()

# Replaces the method entirely; wrapping would cause the customized shortcuts to
# run *in addition to* the original shortcuts.
AnkiQt.keyPressEvent = _keyPressEvent

ab2d6df4fa2814f62f2dfe689de8f367a341f314
<mask token>

<mask token>


def _keyPressEvent(self, evt):
    if self.keyHandler:
        if self.keyHandler(evt):
            return
    QMainWindow.keyPressEvent(self, evt)
    key = unicode(evt.text())
    if key == GLOBAL_DECKS_SHORTCUT:
        self.moveToState('deckBrowser')
    elif key == GLOBAL_OVERVIEW_SHORTCUT:
        if self.state == 'overview':
            self.col.startTimebox()
            self.moveToState('review')
        else:
            self.moveToState('overview')
    elif key == GLOBAL_ADD_SHORTCUT:
        self.onAddCard()
    elif key == GLOBAL_BROWSE_SHORTCUT:
        self.onBrowse()
    elif key == GLOBAL_STATS_SHORTCUT:
        self.onStats()
    elif key == GLOBAL_SYNC_SHORTCUT:
        self.onSync()


<mask token>

<mask token>
GLOBAL_DECKS_SHORTCUT = 'd'
GLOBAL_OVERVIEW_SHORTCUT = 's'
GLOBAL_ADD_SHORTCUT = 'a'
GLOBAL_BROWSE_SHORTCUT = 'b'
GLOBAL_STATS_SHORTCUT = 'S'
GLOBAL_SYNC_SHORTCUT = 'y'


def _keyPressEvent(self, evt):
    if self.keyHandler:
        if self.keyHandler(evt):
            return
    QMainWindow.keyPressEvent(self, evt)
    key = unicode(evt.text())
    if key == GLOBAL_DECKS_SHORTCUT:
        self.moveToState('deckBrowser')
    elif key == GLOBAL_OVERVIEW_SHORTCUT:
        if self.state == 'overview':
            self.col.startTimebox()
            self.moveToState('review')
        else:
            self.moveToState('overview')
    elif key == GLOBAL_ADD_SHORTCUT:
        self.onAddCard()
    elif key == GLOBAL_BROWSE_SHORTCUT:
        self.onBrowse()
    elif key == GLOBAL_STATS_SHORTCUT:
        self.onStats()
    elif key == GLOBAL_SYNC_SHORTCUT:
        self.onSync()


AnkiQt.keyPressEvent = _keyPressEvent

from aqt.qt import QMainWindow
from aqt.main import AnkiQt
GLOBAL_DECKS_SHORTCUT = 'd'
GLOBAL_OVERVIEW_SHORTCUT = 's'
GLOBAL_ADD_SHORTCUT = 'a'
GLOBAL_BROWSE_SHORTCUT = 'b'
GLOBAL_STATS_SHORTCUT = 'S'
GLOBAL_SYNC_SHORTCUT = 'y'


def _keyPressEvent(self, evt):
    if self.keyHandler:
        if self.keyHandler(evt):
            return
    QMainWindow.keyPressEvent(self, evt)
    key = unicode(evt.text())
    if key == GLOBAL_DECKS_SHORTCUT:
        self.moveToState('deckBrowser')
    elif key == GLOBAL_OVERVIEW_SHORTCUT:
        if self.state == 'overview':
            self.col.startTimebox()
            self.moveToState('review')
        else:
            self.moveToState('overview')
    elif key == GLOBAL_ADD_SHORTCUT:
        self.onAddCard()
    elif key == GLOBAL_BROWSE_SHORTCUT:
        self.onBrowse()
    elif key == GLOBAL_STATS_SHORTCUT:
        self.onStats()
    elif key == GLOBAL_SYNC_SHORTCUT:
        self.onSync()


AnkiQt.keyPressEvent = _keyPressEvent

# -*- coding: utf-8 -*-
# See github page to report issues or to contribute:
# https://github.com/Arthaey/anki-custom-keyboard-shortcuts
#
# Also available for Anki at https://ankiweb.net/shared/info/

from aqt.qt import QMainWindow
from aqt.main import AnkiQt

GLOBAL_DECKS_SHORTCUT    = "d"
GLOBAL_OVERVIEW_SHORTCUT = "s"
GLOBAL_ADD_SHORTCUT      = "a"
GLOBAL_BROWSE_SHORTCUT   = "b"
GLOBAL_STATS_SHORTCUT    = "S"
GLOBAL_SYNC_SHORTCUT     = "y"

# Copy-pasted from aqt/main.py
def _keyPressEvent(self, evt):
    # do we have a delegate?
    if self.keyHandler:
        # did it eat the key?
        if self.keyHandler(evt):
            return
    # run standard handler
    QMainWindow.keyPressEvent(self, evt)
    # check global keys
    key = unicode(evt.text())
    if key == GLOBAL_DECKS_SHORTCUT:
        self.moveToState("deckBrowser")
    elif key == GLOBAL_OVERVIEW_SHORTCUT:
        if self.state == "overview":
            self.col.startTimebox()
            self.moveToState("review")
        else:
            self.moveToState("overview")
    elif key == GLOBAL_ADD_SHORTCUT:
        self.onAddCard()
    elif key == GLOBAL_BROWSE_SHORTCUT:
        self.onBrowse()
    elif key == GLOBAL_STATS_SHORTCUT:
        self.onStats()
    elif key == GLOBAL_SYNC_SHORTCUT:
        self.onSync()

# Replaces the method entirely; wrapping would cause the customized shortcuts to
# run *in addition to* the original shortcuts.
AnkiQt.keyPressEvent = _keyPressEvent
