diff --git a/manual/gui.rst b/manual/gui.rst index 98b16ad47e..a4fd0eb7d0 100644 --- a/manual/gui.rst +++ b/manual/gui.rst @@ -704,6 +704,10 @@ Calibre has several keyboard shortcuts to save you time and mouse movement. Thes - Clear the additional restriction * - :kbd:`Ctrl+*` - Create a temporary virtual library based on the current search + * - :kbd:`Ctrl+Right` + - Select the next virtual library tab + * - :kbd:`Ctrl+Left` + - Select the previous virtua library tab * - :kbd:`N or F3` - Find the next book that matches the current search (only works if the highlight checkbox next to the search bar is checked) * - :kbd:`Shift+N or Shift+F3` diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py index 715f524651..e6f1e30067 100644 --- a/src/calibre/gui2/init.py +++ b/src/calibre/gui2/init.py @@ -325,6 +325,25 @@ class VLTabs(QTabBar): # {{{ self.tabCloseRequested.connect(self.tab_close) self.setStyleSheet('QTabBar::tab:selected { font-weight: bold } QTabBar::tab { text-align: center }') self.setVisible(gprefs['show_vl_tabs']) + self.next_action = a = QAction(self) + a.triggered.connect(partial(self.next_tab, delta=1)), self.gui.addAction(a) + self.previous_action = a = QAction(self) + a.triggered.connect(partial(self.next_tab, delta=-1)), self.gui.addAction(a) + self.gui.keyboard.register_shortcut( + 'virtual-library-tab-bar-next', _('Next virtual library'), action=self.next_action, + default_keys=('Ctrl+Right',), + description=_('Switch to the next Virtual Library in the Virtual Library tab bar') + ) + self.gui.keyboard.register_shortcut( + 'virtual-library-tab-bar-previous', _('Previous virtual library'), action=self.previous_action, + default_keys=('Ctrl+Left',), + description=_('Switch to the previous Virtual Library in the Virtual Library tab bar') + ) + + def next_tab(self, delta=1): + if self.count() > 1 and self.isVisible(): + idx = (self.currentIndex() + delta) % self.count() + self.setCurrentIndex(idx) def enable_bar(self): gprefs['show_vl_tabs'] = True