mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
E-book viewer: Add keyboard shortcuts for next section and previous section
This commit is contained in:
parent
994a0015bd
commit
0185d335d3
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user