diff options
-rwxr-xr-x | browser.py | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -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) |