mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Ebook viewer: Respond to key presses even when the book display area does not have keyboard focus
This commit is contained in:
parent
9b19e1638e
commit
f6ac950be2
@ -979,6 +979,11 @@ class DocumentView(QWebView): # {{{
|
||||
return ret
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if not self.handle_key_press(event):
|
||||
return QWebView.keyPressEvent(self, event)
|
||||
|
||||
def handle_key_press(self, event):
|
||||
handled = True
|
||||
key = self.shortcuts.get_match(event)
|
||||
func = self.goto_location_actions.get(key, None)
|
||||
if func is not None:
|
||||
@ -996,7 +1001,8 @@ class DocumentView(QWebView): # {{{
|
||||
elif key == 'Right':
|
||||
self.scroll_by(x=15)
|
||||
else:
|
||||
return QWebView.keyPressEvent(self, event)
|
||||
handled = False
|
||||
return handled
|
||||
|
||||
def resizeEvent(self, event):
|
||||
ret = QWebView.resizeEvent(self, event)
|
||||
|
@ -755,6 +755,12 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
if self.current_index > 0:
|
||||
self.load_path(self.iterator.spine[self.current_index-1], pos=1.0)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
MainWindow.keyPressEvent(self, event)
|
||||
if not event.isAccepted():
|
||||
if not self.view.handle_key_press(event):
|
||||
event.ignore()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user