From 4d1437fd9043cb0c43c17de356253f8b9ba6327a Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 11 Sep 2023 15:43:12 +0100 Subject: [PATCH] Add the focus_to_booklist shortcut to quickview so that it works when qv is a window, not just when it is a pane. --- src/calibre/gui2/actions/show_quickview.py | 3 ++- src/calibre/gui2/dialogs/quickview.py | 28 +++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/calibre/gui2/actions/show_quickview.py b/src/calibre/gui2/actions/show_quickview.py index 62cc31d84d..61358d2a5a 100644 --- a/src/calibre/gui2/actions/show_quickview.py +++ b/src/calibre/gui2/actions/show_quickview.py @@ -133,7 +133,8 @@ class ShowQuickviewAction(InterfaceAction): return self.qv_button.set_state_to_hide() index = self.gui.library_view.currentIndex() - self.current_instance = Quickview(self.gui, index, self.qaction.shortcut()) + self.current_instance = Quickview(self.gui, index, self.qaction.shortcut(), + focus_booklist_shortcut=self.focus_bl_action.shortcut()) self.current_instance.reopen_after_dock_change.connect(self.open_quickview) self.current_instance.show() diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index f5c40fe437..f532dfe839 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -152,7 +152,7 @@ class Quickview(QDialog, Ui_Quickview): tab_pressed_signal = pyqtSignal(object, object) quickview_closed = pyqtSignal() - def __init__(self, gui, row, toggle_shortcut): + def __init__(self, gui, row, toggle_shortcut, focus_booklist_shortcut=None): self.is_pane = gprefs.get('quickview_is_pane', False) if not self.is_pane: QDialog.__init__(self, None, flags=Qt.WindowType.Window) @@ -296,14 +296,24 @@ class Quickview(QDialog, Ui_Quickview): # Add the quickview toggle as a shortcut for the close button # Don't add it if it identical to the current &X shortcut because that - # breaks &X - if (not self.is_pane and toggle_shortcut and - self.close_button.shortcut() != toggle_shortcut): - toggle_sc = QShortcut(toggle_shortcut, self.close_button) - toggle_sc.activated.connect(lambda: self.close_button_clicked()) - toggle_sc.setEnabled(True) - self.close_button.setToolTip(_('Alternate shortcut: ') + - toggle_shortcut.toString()) + # breaks &X. Also add the focus booklist shortcut + if not self.is_pane: + if toggle_shortcut and self.close_button.shortcut() != toggle_shortcut: + toggle_sc = QShortcut(toggle_shortcut, self.close_button) + toggle_sc.activated.connect(lambda: self.close_button_clicked()) + toggle_sc.setEnabled(True) + self.close_button.setToolTip(_('Alternate shortcut: ') + + toggle_shortcut.toString()) + if focus_booklist_shortcut is not None: + toggle_sc = QShortcut(focus_booklist_shortcut, self) + toggle_sc.activated.connect(self.focus_booklist) + toggle_sc.setEnabled(True) + + def focus_booklist(self): + from calibre.gui2.ui import get_gui + gui = get_gui() + gui.activateWindow() + gui.focus_current_view() def delayed_slave(self, current, func=None, dex=None): self.slave_timers[dex].stop()