diff --git a/TODO b/TODO index efc15e2..f4bcde0 100644 --- a/TODO +++ b/TODO @@ -119,7 +119,7 @@ TODO Signal end of chapter with some text Graphical themes Change focus rectangle dimensions - Universal Ctrl + Tab + ✓ Universal Ctrl + Tab Allow tabs to detach and form their own windows Goodreads API: Ratings, Read, Recommendations Get ISBN using python-isbnlib diff --git a/lector/__main__.py b/lector/__main__.py index 660103b..948b079 100755 --- a/lector/__main__.py +++ b/lector/__main__.py @@ -342,6 +342,15 @@ def __init__(self): self.ksCloseTab.setContext(QtCore.Qt.ApplicationShortcut) self.ksCloseTab.activated.connect(self.tab_close) + self.ksNextTab = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Tab'), self) + self.ksNextTab.setContext(QtCore.Qt.ApplicationShortcut) + self.ksNextTab.activated.connect(lambda: self.cycle_tabs(1)) + + self.ksPreviousTab = QtWidgets.QShortcut( + QtGui.QKeySequence('Ctrl+Shift+Tab'), self) + self.ksPreviousTab.setContext(QtCore.Qt.ApplicationShortcut) + self.ksPreviousTab.activated.connect(lambda: self.cycle_tabs(-1)) + self.ksDeletePressed = QtWidgets.QShortcut(QtGui.QKeySequence('Delete'), self) self.ksDeletePressed.setContext(QtCore.Qt.ApplicationShortcut) self.ksDeletePressed.activated.connect(self.delete_pressed) @@ -689,6 +698,14 @@ def tab_disallow_library_movement(self, tab_index): else: self.tabWidget.setMovable(True) + def cycle_tabs(self, direction): + tab_count = self.tabWidget.count() + if tab_count < 2: + return + + current_tab = self.tabWidget.currentIndex() + self.tabWidget.setCurrentIndex((current_tab + direction) % tab_count) + def set_toc_position(self, event=None): currentIndex = self.bookToolBar.tocTreeView.currentIndex() required_position = currentIndex.data(QtCore.Qt.UserRole)