summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2022-01-16 12:37:53 -0600
committerMatt Singleton <matt@xcolour.net>2022-01-16 13:04:41 -0600
commit938505844c11d5a0880de9ca738dbbc775693183 (patch)
tree2ee8d23c935d43e70e9d30f5e65ef1dfbfbdf7f8
parentb7b84113cc21f444b6ffdd86cf39008bc15e8f83 (diff)
get address bar working again and some new keybindings
-rwxr-xr-xbrowser.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/browser.py b/browser.py
index 8a542f9..0c718b4 100755
--- a/browser.py
+++ b/browser.py
@@ -58,14 +58,14 @@ class GBrowser(QtWidgets.QMainWindow):
self.setCentralWidget(self._browser)
# Navigation Toolbar
- back = QtWidgets.QPushButton("back")
- forward = QtWidgets.QPushButton("forward")
- address = GUrlBar()
+ back = QtWidgets.QPushButton('←', self)
+ forward = QtWidgets.QPushButton('→', self)
+ self._address = GUrlBar()
toolbar = QtWidgets.QToolBar()
toolbar.setObjectName('navigationToolbar')
toolbar.addWidget(back)
toolbar.addWidget(forward)
- toolbar.addWidget(address)
+ toolbar.addWidget(self._address)
self.addToolBar(toolbar)
# Status Bar
@@ -75,8 +75,8 @@ class GBrowser(QtWidgets.QMainWindow):
# Connect signals
back.clicked.connect(self._browser.back)
forward.clicked.connect(self._browser.forward)
- self._browser.urlChanged.connect(address.setUrl)
- address.returnPressed.connect(self._browser.load)
+ self._browser.urlChanged.connect(self._address.setUrl)
+ self._address.returnPressed.connect(self.loadAddress)
self._browser.page().linkHovered.connect(self.set_status_url)
self._browser.load(QtCore.QUrl(initial_url))
@@ -94,9 +94,11 @@ class GBrowser(QtWidgets.QMainWindow):
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)
+ QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_H), self, self._browser.back)
+ QtGui.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_L), self, self._browser.forward)
+ QtGui.QShortcut(QtGui.QKeySequence("Shift+R"), self, self._browser.reload)
+ QtGui.QShortcut(QtGui.QKeySequence("Esc"), self._address, lambda: self.setFocus())
+ QtGui.QShortcut(QtGui.QKeySequence("Shift+L"), self, lambda: self._address.setFocus())
def set_status_url(self, url):
if url:
@@ -111,6 +113,10 @@ class GBrowser(QtWidgets.QMainWindow):
self._browser.page().deleteLater()
super().closeEvent(event)
+ def loadAddress(self):
+ self._browser.load(self._address.text())
+ self._browser.setFocus()
+
scheme = QtWebEngineCore.QWebEngineUrlScheme(b'gemini')
scheme.setDefaultPort(1965)