summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2020-09-08 13:15:06 -0500
committerMatt Singleton <matt@xcolour.net>2020-09-08 13:15:06 -0500
commit407ca6b4ed2357ed6d35cd93ee3191761a9b65c5 (patch)
treed0510e114ac39f3561f44b622564687d9e589052
parent1aba6365aa5c7feade50c0b185206b8029a4938e (diff)
show response status in statusbar
-rwxr-xr-xbrowser.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/browser.py b/browser.py
index 16f1c29..625f4b1 100755
--- a/browser.py
+++ b/browser.py
@@ -9,6 +9,7 @@ import gemini
class GViewport(QtWidgets.QTextBrowser):
hoverUrlChanged = QtCore.Signal(str)
+ resourceLoadedStatus = QtCore.Signal(str)
def __init__(self, address_bar):
self.address_bar = address_bar
@@ -18,7 +19,8 @@ class GViewport(QtWidgets.QTextBrowser):
def mouseMoveEvent(self, event):
cur = self.cursorForPosition(event.localPos().toPoint())
hover_url = cur.charFormat().anchorHref()
- hover_url = gemini.urljoin(self.address_bar.text(), hover_url)
+ if hover_url:
+ hover_url = gemini.urljoin(self.address_bar.text(), hover_url)
if hover_url != self._hover_url:
self._hover_url = hover_url
self.hoverUrlChanged.emit(self._hover_url)
@@ -30,6 +32,7 @@ class GViewport(QtWidgets.QTextBrowser):
html = gemini.gem2html(gem['body'])
else:
html = '<h1>{} {}</h1>'.format(gem['status'], gem['meta'])
+ self.resourceLoadedStatus.emit('{status} {meta}'.format(status=gem['status'], meta=gem['meta']))
return html
def setRawSource(self):
@@ -50,7 +53,8 @@ class GBrowser(QtWidgets.QMainWindow):
self.init_ui()
def init_ui(self):
- self.statusBar().showMessage('Ready')
+ request_status = QtWidgets.QLabel()
+ self.statusBar().addWidget(request_status)
back = QtWidgets.QPushButton("back")
forward = QtWidgets.QPushButton("forward")
@@ -66,7 +70,8 @@ class GBrowser(QtWidgets.QMainWindow):
forward.clicked.connect(browser.forward)
browser.sourceChanged.connect(address.setUrl)
address.returnPressed.connect(browser.setRawSource)
- browser.hoverUrlChanged.connect(self.statusBar().showMessage)
+ browser.hoverUrlChanged.connect(self.set_status_url)
+ browser.resourceLoadedStatus.connect(request_status.setText)
self.addToolBar(toolbar)
self.setCentralWidget(browser)
@@ -79,6 +84,12 @@ class GBrowser(QtWidgets.QMainWindow):
self.setWindowTitle('Gemini Browser')
self.show()
+ def set_status_url(self, url):
+ if url:
+ self.statusBar().showMessage(url)
+ else:
+ self.statusBar().clearMessage()
+
def closeEvent(self, event):
settings = QtCore.QSettings("xcolour.net", "GeminiBrowser")
settings.setValue("geometry", self.saveGeometry())