1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-22 07:43:09 +00:00

Save main window state before closing

This commit is contained in:
Hofer Julian 2020-06-22 10:36:23 +02:00 committed by GitHub
parent 96e4d4bef2
commit 9fc495f51d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -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 += [

View file

@ -30,6 +30,11 @@ def __init__(self, parent=None):
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 @@ def backup_cancelled_event(self):
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",