add cmd+w shortcut to add cards window & stats window

This commit is contained in:
Damien Elmes 2012-12-22 09:11:29 +09:00
parent 551c1cf662
commit b84681c2fe
3 changed files with 11 additions and 2 deletions

View File

@ -9,7 +9,7 @@ import anki
from anki.errors import *
from anki.utils import stripHTML
from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
tooltip, openHelp
tooltip, openHelp, addCloseShortcut
from anki.sound import clearAudioQueue
from anki.hooks import addHook, remHook
from anki.utils import stripHTMLMedia, isMac
@ -34,6 +34,7 @@ class AddCards(QDialog):
restoreGeom(self, "add")
addHook('reset', self.onReset)
addHook('currentModelChanged', self.onReset)
addCloseShortcut(self)
self.show()
self.setupNewNote()

View File

@ -6,7 +6,7 @@ from aqt.qt import *
import os, time
from aqt.webview import AnkiWebView
from aqt.utils import saveGeom, restoreGeom, maybeHideClose, openFolder, \
showInfo
showInfo, addCloseShortcut
from anki.utils import namedtmp
from anki.hooks import addHook
import aqt
@ -42,6 +42,7 @@ class DeckStats(QDialog):
c(f.life, s, lambda: self.changePeriod(2))
c(f.web, SIGNAL("loadFinished(bool)"), self.loadFin)
maybeHideClose(self.form.buttonBox)
addCloseShortcut(self)
self.refresh()
self.exec_()

View File

@ -358,6 +358,13 @@ def maybeHideClose(bbox):
if b:
bbox.removeButton(b)
def addCloseShortcut(widg):
if not isMac:
return
widg._closeShortcut = QShortcut(QKeySequence("Ctrl+W"), widg)
widg.connect(widg._closeShortcut, SIGNAL("activated()"),
widg, SLOT("reject()"))
# Tooltips
######################################################################