mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
add shortcut to close addcards window (#2031)
This commit is contained in:
parent
e4f1d9952b
commit
65601196ee
2 changed files with 9 additions and 0 deletions
|
@ -21,6 +21,7 @@ from aqt.qt import *
|
||||||
from aqt.sound import av_player
|
from aqt.sound import av_player
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
HelpPage,
|
HelpPage,
|
||||||
|
add_close_shortcut,
|
||||||
askUser,
|
askUser,
|
||||||
downArrow,
|
downArrow,
|
||||||
openHelp,
|
openHelp,
|
||||||
|
@ -48,6 +49,7 @@ class AddCards(QMainWindow):
|
||||||
self.setup_choosers()
|
self.setup_choosers()
|
||||||
self.setupEditor()
|
self.setupEditor()
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
|
add_close_shortcut(self)
|
||||||
self._load_new_note()
|
self._load_new_note()
|
||||||
self.history: list[NoteId] = []
|
self.history: list[NoteId] = []
|
||||||
self._last_added_note: Optional[Note] = None
|
self._last_added_note: Optional[Note] = None
|
||||||
|
|
|
@ -848,6 +848,13 @@ def addCloseShortcut(widg: QDialog) -> None:
|
||||||
setattr(widg, "_closeShortcut", shortcut)
|
setattr(widg, "_closeShortcut", shortcut)
|
||||||
|
|
||||||
|
|
||||||
|
def add_close_shortcut(widg: QWidget) -> None:
|
||||||
|
if not is_mac:
|
||||||
|
return
|
||||||
|
shortcut = QShortcut(QKeySequence("Ctrl+W"), widg)
|
||||||
|
qconnect(shortcut.activated, widg.close)
|
||||||
|
|
||||||
|
|
||||||
def downArrow() -> str:
|
def downArrow() -> str:
|
||||||
if is_win:
|
if is_win:
|
||||||
return "▼"
|
return "▼"
|
||||||
|
|
Loading…
Reference in a new issue