From b7b84113cc21f444b6ffdd86cf39008bc15e8f83 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sun, 16 Jan 2022 12:02:38 -0600 Subject: basic keybindings --- TODO.md | 15 ++++++++------- browser.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index c0e33d7..dc5ba0c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,13 +1,14 @@ - [x] open non-gemini links externally and display differently - [ ] keyboard navigation - - vim-style - - scroll - - highlight and follow links - - forward and back - - url bar - - [ ] search in page - - [ ] work with search pages + - [x] scroll + - [ ] highlight and follow links + - [x] forward and back + - [ ] url bar + - [ ] search in page - [x] stdlib url parsing in gemini module - [x] nice typography - [x] html templates - [ ] deal with non utf8 charsets + - [ ] handle all response codes + - [ ] errors (4x, 5x) + - [ ] search diff --git a/browser.py b/browser.py index 54cace9..8a542f9 100755 --- a/browser.py +++ b/browser.py @@ -87,6 +87,17 @@ class GBrowser(QtWidgets.QMainWindow): self.setWindowTitle('Gemini Browser') self.show() + # Shortcuts + down_shortcut = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_J), self) + down_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, QtCore.Qt.Key_Down, QtCore.Qt.NoModifier) + down_shortcut.activated.connect(lambda: QtWidgets.QApplication.sendEvent(self._browser.focusProxy(), down_event)) + up_shortcut = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_K), self) + up_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress, QtCore.Qt.Key_Up, QtCore.Qt.NoModifier) + up_shortcut.activated.connect(lambda: QtWidgets.QApplication.sendEvent(self._browser.focusProxy(), up_event)) + back_shortcut = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_H), self, self._browser.back) + forward_shortcut = QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_L), self, self._browser.forward) + reload_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Shift+R"), self, self._browser.reload) + def set_status_url(self, url): if url: self.statusBar().showMessage(url) -- cgit v1.2.3