From 0185d335d3a75b35484bbe7b8630f6be0dccbae1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Dec 2009 13:23:47 -0700 Subject: [PATCH] E-book viewer: Add keyboard shortcuts for next section and previous section --- src/calibre/gui2/viewer/documentview.py | 6 ++++++ src/calibre/gui2/viewer/main.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 02f67cd76b..1624c9148d 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -695,6 +695,12 @@ class DocumentView(QWebView): self.scroll_by(x=-15) elif key == 'Right': self.scroll_by(x=15) + elif key == 'Next Section': + if self.manager is not None: + self.manager.goto_next_section() + elif key == 'Previous Section': + if self.manager is not None: + self.manager.goto_previous_section() else: return QWebView.keyPressEvent(self, event) diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index 99ef79bafe..cb2f3da7d6 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -453,6 +453,15 @@ class EbookViewer(MainWindow, Ui_EbookViewer): self.pending_bookmark = None return self.current_index + def goto_next_section(self): + nindex = (self.current_index + 1)%len(self.iterator.spine) + self.load_path(self.iterator.spine[nindex]) + + def goto_previous_section(self): + pindex = (self.current_index - 1 + len(self.iterator.spine)) \ + % len(self.iterator.spine) + self.load_path(self.iterator.spine[pindex]) + def load_path(self, path, pos=0.0): self.open_progress_indicator(_('Laying out %s')%self.current_title) self.view.load_path(path, pos=pos)