mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix keyboard shortcuts not working for diff view when in dialog
This commit is contained in:
parent
56807d7b3e
commit
520be76781
@ -231,6 +231,10 @@ class Diff(Dialog):
|
||||
kwargs = {'syntax':syntax_map.get(name, None), 'context':self.context}
|
||||
add(args, kwargs)
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if not self.view.handle_key(ev):
|
||||
return Dialog.keyPressEvent(self, ev)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
app = QApplication([])
|
||||
|
@ -910,7 +910,7 @@ class DiffView(QWidget): # {{{
|
||||
self.changes, self.delta = changes, delta
|
||||
self.adjust_range()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
def handle_key(self, ev):
|
||||
amount, d = None, 1
|
||||
key = ev.key()
|
||||
if key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_J, Qt.Key_K):
|
||||
@ -923,8 +923,11 @@ class DiffView(QWidget): # {{{
|
||||
d = -1
|
||||
elif key in (Qt.Key_Home, Qt.Key_End):
|
||||
self.scrollbar.setValue(0 if key == Qt.Key_Home else self.scrollbar.maximum())
|
||||
return True
|
||||
|
||||
if amount is not None:
|
||||
self.scrollbar.setValue(self.scrollbar.value() + d * amount)
|
||||
return True
|
||||
return False
|
||||
# }}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user