mirror of https://github.com/borgbase/vorta
Save main window state before closing
This commit is contained in:
parent
96e4d4bef2
commit
9fc495f51d
|
@ -215,6 +215,14 @@ def get_misc_settings():
|
|||
'key': 'previous_profile_id', 'str_value': '1', 'type': 'internal',
|
||||
'label': 'Previously selected profile'
|
||||
},
|
||||
{
|
||||
'key': 'previous_window_width', 'str_value': '800', 'type': 'internal',
|
||||
'label': 'Previous window width'
|
||||
},
|
||||
{
|
||||
'key': 'previous_window_height', 'str_value': '600', 'type': 'internal',
|
||||
'label': 'Previous window height'
|
||||
},
|
||||
]
|
||||
if sys.platform == 'darwin':
|
||||
settings += [
|
||||
|
|
|
@ -30,6 +30,11 @@ class MainWindow(MainWindowBase, MainWindowUI):
|
|||
self.app = parent
|
||||
self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint)
|
||||
|
||||
# Use previous window state
|
||||
previous_window_width = SettingsModel.get(key='previous_window_width')
|
||||
previous_window_height = SettingsModel.get(key='previous_window_height')
|
||||
self.resize(int(previous_window_width.str_value), int(previous_window_height.str_value))
|
||||
|
||||
# Select previously used profile, if available
|
||||
prev_profile_id = SettingsModel.get(key='previous_profile_id')
|
||||
self.current_profile = BackupProfileModel.get_or_none(id=prev_profile_id.str_value)
|
||||
|
@ -168,6 +173,14 @@ class MainWindow(MainWindowBase, MainWindowUI):
|
|||
self.set_status(self.tr('Task cancelled'))
|
||||
|
||||
def closeEvent(self, event):
|
||||
# Save window state in SettingsModel
|
||||
SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().width())})\
|
||||
.where(SettingsModel.key == 'previous_window_width')\
|
||||
.execute()
|
||||
SettingsModel.update({SettingsModel.str_value: str(self.frameGeometry().height())})\
|
||||
.where(SettingsModel.key == 'previous_window_height')\
|
||||
.execute()
|
||||
|
||||
if not is_system_tray_available():
|
||||
run_in_background = QMessageBox.question(self,
|
||||
trans_late("MainWindow QMessagebox",
|
||||
|
|
Loading…
Reference in New Issue