diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-19 21:09:43 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-19 21:09:43 +0200 |
| commit | 81139106f75bc06f45e9e579f9c6400d0eeb8940 (patch) | |
| tree | 9b21846b1b565cd3779284905c53f4fcc3cfcdb2 /sb_builder/mainwindow.py | |
| parent | da5363d1c0fb77dcf3030968a2cd5be355ee7f1a (diff) | |
| download | sb-builder-81139106f75bc06f45e9e579f9c6400d0eeb8940.tar.gz sb-builder-81139106f75bc06f45e9e579f9c6400d0eeb8940.zip | |
Ctrl+PgUp/PgDn cycle tabs from anywhere in the window
QTabWidget's built-in binding only works with focus on the tab bar,
and the table views take page keys. Window-level shortcuts, wrapping.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'sb_builder/mainwindow.py')
| -rw-r--r-- | sb_builder/mainwindow.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sb_builder/mainwindow.py b/sb_builder/mainwindow.py index e84389c..70eb121 100644 --- a/sb_builder/mainwindow.py +++ b/sb_builder/mainwindow.py @@ -20,6 +20,7 @@ import time from PyQt6.QtCore import QMetaType, QObject, QTimer, pyqtSignal, pyqtSlot from PyQt6.QtDBus import QDBusArgument, QDBusConnection, QDBusInterface, QDBusMessage +from PyQt6.QtGui import QKeySequence, QShortcut from PyQt6.QtWidgets import QLabel, QMainWindow, QMessageBox, QPushButton, QTabBar, QTabWidget from . import VERSION, config @@ -90,6 +91,9 @@ class MainWindow(QMainWindow): file_menu = self.menuBar().addMenu("&File") file_menu.addAction("&Reload config", self.reload_config) file_menu.addAction("&Quit", self.close).setShortcut("Ctrl+Q") + # window-wide: QTabWidget's own Ctrl+PgUp/PgDn needs focus on the tabs + self.tab_next = QShortcut(QKeySequence("Ctrl+PgDown"), self, lambda: self._cycle_tab(1)) + self.tab_prev = QShortcut(QKeySequence("Ctrl+PgUp"), self, lambda: self._cycle_tab(-1)) open_menu = self.menuBar().addMenu("&Open") open_menu.addAction("&Packages", self.open_packages) open_menu.addAction("&Jobs", self.open_jobs) @@ -264,6 +268,9 @@ class MainWindow(QMainWindow): self.tabs.setCurrentWidget(self.jobs_tab) return self.jobs_tab + def _cycle_tab(self, step): + self.tabs.setCurrentIndex((self.tabs.currentIndex() + step) % self.tabs.count()) + def open_packages(self): if self.packages_tab is None: self.packages_tab = PackagesTab(self.remote) |
