Fix saving geometry if mainwindow is closed on shutdown. Fixes #159.
This commit is contained in:
parent
cb951643b6
commit
cbdade6518
@ -59,6 +59,7 @@ class Application(QApplication):
|
|||||||
_crashdlg: The crash dialog currently open.
|
_crashdlg: The crash dialog currently open.
|
||||||
_crashlogfile: A file handler to the fatal crash logfile.
|
_crashlogfile: A file handler to the fatal crash logfile.
|
||||||
_event_filter: The EventFilter for the application.
|
_event_filter: The EventFilter for the application.
|
||||||
|
geometry: The geometry of the last closed main window.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
@ -72,6 +73,7 @@ class Application(QApplication):
|
|||||||
'tabs': False,
|
'tabs': False,
|
||||||
'main': False,
|
'main': False,
|
||||||
}
|
}
|
||||||
|
self.geometry = None
|
||||||
self._shutting_down = False
|
self._shutting_down = False
|
||||||
self._crashdlg = None
|
self._crashdlg = None
|
||||||
self._crashlogfile = None
|
self._crashlogfile = None
|
||||||
@ -367,12 +369,9 @@ class Application(QApplication):
|
|||||||
|
|
||||||
def _save_geometry(self):
|
def _save_geometry(self):
|
||||||
"""Save the window geometry to the state config."""
|
"""Save the window geometry to the state config."""
|
||||||
last_win_id = sorted(objreg.window_registry)[-1]
|
if self.geometry is not None:
|
||||||
main_window = objreg.get('main-window', scope='window',
|
|
||||||
window=last_win_id)
|
|
||||||
state_config = objreg.get('state-config')
|
state_config = objreg.get('state-config')
|
||||||
data = bytes(main_window.saveGeometry())
|
geom = base64.b64encode(self.geometry).decode('ASCII')
|
||||||
geom = base64.b64encode(data).decode('ASCII')
|
|
||||||
try:
|
try:
|
||||||
state_config.add_section('geometry')
|
state_config.add_section('geometry')
|
||||||
except configparser.DuplicateSectionError:
|
except configparser.DuplicateSectionError:
|
||||||
|
@ -330,4 +330,5 @@ class MainWindow(QWidget):
|
|||||||
e.ignore()
|
e.ignore()
|
||||||
return
|
return
|
||||||
e.accept()
|
e.accept()
|
||||||
|
objreg.get('app').geometry = bytes(self.saveGeometry())
|
||||||
log.destroy.debug("Closing window {}".format(self.win_id))
|
log.destroy.debug("Closing window {}".format(self.win_id))
|
||||||
|
Loading…
Reference in New Issue
Block a user