diff options
| author | Danilo M. <danix@danix.xyz> | 2026-05-03 15:49:56 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-05-03 15:49:56 +0200 |
| commit | d938c12635dfed074f58295e86d72d7867268ea5 (patch) | |
| tree | 145e4e8dd186d5e409ec0467b803ea1ff2504754 | |
| parent | d0215cc927dcc2ee7d3f177419196901c8167eee (diff) | |
| download | publisher-d938c12635dfed074f58295e86d72d7867268ea5.tar.gz publisher-d938c12635dfed074f58295e86d72d7867268ea5.zip | |
feat: add keyboard shortcuts (Ctrl+Q/N/R/1/2/T)
Ctrl+Q quit, Ctrl+N new article, Ctrl+R refresh, Ctrl+1 articles view,
Ctrl+2 missing translations, Ctrl+T translations view.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -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() |
