From fd9c98a233e78814e4ea7754d250bc36d006c033 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Jun 2014 08:51:40 +0530 Subject: [PATCH] =?UTF-8?q?E-book=20viewer:=20Add=20a=20keyboard=20shortcu?= =?UTF-8?q?t=20to=20bookmark=20current=20location.=20Fixes=20#1326198=20[E?= =?UTF-8?q?nhancement=20to=20Reader=E2=80=93=20single=20keystroke=20bookma?= =?UTF-8?q?rk.](https://bugs.launchpad.net/calibre/+bug/1326198)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/calibre/gui2/viewer/keys.py | 3 +++ src/calibre/gui2/viewer/main.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/viewer/keys.py b/src/calibre/gui2/viewer/keys.py index 0d3b8d8ac0..ee312e2551 100644 --- a/src/calibre/gui2/viewer/keys.py +++ b/src/calibre/gui2/viewer/keys.py @@ -84,4 +84,7 @@ SHORTCUTS = { 'Next occurrence': (['Ctrl+S'], _('Go to next occurrence of selected word')), + 'Bookmark': (['Ctrl+B'], + _('Bookmark the current location')), + } diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index b47bc25a8b..77b4b7ca90 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -972,7 +972,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer): def set_bookmarks(self, bookmarks): self.bookmarks_menu.clear() - self.bookmarks_menu.addAction(_("Bookmark this location"), self.bookmark) + sc = _(' or ').join(self.view.shortcuts.get_shortcuts('Bookmark')) + self.bookmarks_menu.addAction(_("Bookmark this location [%s]") % sc, self.bookmark) self.bookmarks_menu.addAction(_("Manage Bookmarks"), self.manage_bookmarks) self.bookmarks_menu.addSeparator() current_page = None @@ -1126,6 +1127,10 @@ class EbookViewer(MainWindow, Ui_EbookViewer): key = self.view.shortcuts.get_match(event) except AttributeError: return MainWindow.keyPressEvent(self, event) + try: + bac = self.bookmarks_menu.actions()[0] + except (AttributeError, TypeError, IndexError, KeyError): + bac = None action = { 'Quit':self.action_quit, 'Show metadata':self.action_metadata, @@ -1138,6 +1143,7 @@ class EbookViewer(MainWindow, Ui_EbookViewer): 'Search online': self.view.search_online_action, 'Lookup word': self.view.dictionary_action, 'Next occurrence': self.view.search_action, + 'Bookmark': bac, }.get(key, None) if action is not None: event.accept()