From 8e209427f5f08bb2ff57d657fb00f88117d4396b Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sun, 6 Sep 2020 17:23:18 -0500 Subject: restore window state and geometry --- browser.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/browser.py b/browser.py index c9bdc55..58b650c 100755 --- a/browser.py +++ b/browser.py @@ -77,15 +77,16 @@ class GBrowser(QtWidgets.QMainWindow): def __init__(self): QtWidgets.QMainWindow.__init__(self) - self.initUI() + self.init_ui() - def initUI(self): + def init_ui(self): self.statusBar().showMessage('Ready') back = QtWidgets.QPushButton("back") forward = QtWidgets.QPushButton("forward") address = GUrlBar() toolbar = QtWidgets.QToolBar() + toolbar.setObjectName('navigationToolbar') toolbar.addWidget(back) toolbar.addWidget(forward) toolbar.addWidget(address) @@ -102,10 +103,18 @@ class GBrowser(QtWidgets.QMainWindow): browser.setSource(QtCore.QUrl('gemini://gemini.circumlunar.space/')) - self.setGeometry(10, 10, 1024, 750) + settings = QtCore.QSettings("xcolour.net", "GeminiBrowser") + self.restoreGeometry(settings.value("geometry")) + self.restoreState(settings.value("windowState")) self.setWindowTitle('Gemini Browser') self.show() + def closeEvent(self, event): + settings = QtCore.QSettings("xcolour.net", "GeminiBrowser") + settings.setValue("geometry", self.saveGeometry()) + settings.setValue("windowState", self.saveState()) + super().closeEvent(event) + app = QtWidgets.QApplication(sys.argv) ex = GBrowser() sys.exit(app.exec_()) -- cgit v1.2.3