From 81139106f75bc06f45e9e579f9c6400d0eeb8940 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 19 Oct 2026 21:09:43 +0200 Subject: 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 --- sb_builder/mainwindow.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sb_builder') 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) -- cgit v1.2.3