From 85ba1a3cc136c4690041d7fe7a4976e9ca0f9280 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 6 Oct 2020 09:41:20 +0530 Subject: [PATCH] Add a shirtcut (Shift+V) to open the last read book. Fixes #1897336 [[Enhancement] Add shortcut to view last viewed book](https://bugs.launchpad.net/calibre/+bug/1897336) --- manual/gui.rst | 2 ++ src/calibre/gui2/actions/view.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/manual/gui.rst b/manual/gui.rst index ddfb9c42bd..9d74c62ac1 100644 --- a/manual/gui.rst +++ b/manual/gui.rst @@ -716,6 +716,8 @@ calibre has several keyboard shortcuts to save you time and mouse movement. Thes - Edit book * - :kbd:`V` - View + * - :kbd:`Shift+V` + - View last read book * - :kbd:`Alt+V/Cmd+V in macOS` - View specific format * - :kbd:`Alt+Shift+J` diff --git a/src/calibre/gui2/actions/view.py b/src/calibre/gui2/actions/view.py index 6012debec5..d6cd999cff 100644 --- a/src/calibre/gui2/actions/view.py +++ b/src/calibre/gui2/actions/view.py @@ -63,6 +63,10 @@ class ViewAction(InterfaceAction): self.clear_history_action = cm('clear history', _('Clear recently viewed list'), triggered=self.clear_history) self.history_actions = [self.clear_sep1] + self.action_view_last_read = ac = self.create_action( + spec=(_('Continue reading previous book'), None, _('Continue reading the last opened book'), 'shift+v'), attr='action_view_last_read') + ac.triggered.connect(self.view_last_read) + self.gui.addAction(ac) def initialization_complete(self): self.build_menus(self.gui.current_db) @@ -82,6 +86,12 @@ class ViewAction(InterfaceAction): ac.view_historical.connect(self.view_historical) self.history_actions.append(ac) + def view_last_read(self): + history = self.gui.current_db.new_api.pref('gui_view_history', []) + for book_id, title in history: + self.view_historical(book_id) + break + def browse_annots(self): self.gui.iactions['Browse Annotations'].show_browser()