diff options
Diffstat (limited to 'ui/main_window.py')
| -rw-r--r-- | ui/main_window.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ui/main_window.py b/ui/main_window.py index b3c657a..8aa2762 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -5,6 +5,7 @@ from PyQt6.QtWidgets import ( QLabel, QPushButton, QStackedWidget, QFrame, ) from PyQt6.QtCore import Qt, QFileSystemWatcher +from PyQt6.QtGui import QShortcut, QKeySequence from pathlib import Path from core.config import Config from core.article_scanner import scan_articles @@ -38,6 +39,19 @@ class MainWindow(QMainWindow): self._btn_group[0].setChecked(True) self._stack.setCurrentIndex(self._page_articles) self._setup_watcher() + self._setup_shortcuts() + + def _setup_shortcuts(self): + shortcuts = [ + ("Ctrl+Q", self.close), + ("Ctrl+N", self._do_new_article), + ("Ctrl+R", self._refresh_articles), + ("Ctrl+1", lambda: self._stack.setCurrentIndex(self._page_articles)), + ("Ctrl+2", lambda: self._stack.setCurrentIndex(self._page_no_translation)), + ("Ctrl+T", lambda: self._stack.setCurrentIndex(self._page_translations)), + ] + for key, slot in shortcuts: + QShortcut(QKeySequence(key), self).activated.connect(slot) def _build_ui(self): central = QWidget() |
