From: Danilo M. Date: Sun, 3 May 2026 13:49:56 +0000 (+0200) Subject: feat: add keyboard shortcuts (Ctrl+Q/N/R/1/2/T) X-Git-Tag: v1.2~1 X-Git-Url: https://git.danix.xyz/?a=commitdiff_plain;h=d938c12635dfed074f58295e86d72d7867268ea5;p=publisher.git 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 --- 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()