E-book viewer: Add keyboard shortcuts for next section and previous section

This commit is contained in:
Kovid Goyal 2009-12-10 13:23:47 -07:00
parent 994a0015bd
commit 0185d335d3
2 changed files with 15 additions and 0 deletions

View File

@ -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)

View File

@ -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)