refactor tray menu: deduplicate

This commit is contained in:
Thomas Waldmann 2018-11-24 03:41:09 +01:00
parent 94f03f052c
commit 162f6bf7a5
1 changed files with 1 additions and 5 deletions

View File

@ -17,14 +17,9 @@ class TrayMenu(QSystemTrayIcon):
self.status.setEnabled(False)
self.profile_menu = menu.addMenu('Backup Now')
for profile in BackupProfileModel.select():
new_item = self.profile_menu.addAction(profile.name)
new_item.setData(profile.id)
new_item.triggered.connect(lambda profile_id=profile.id: self.app.create_backup_action(profile_id))
self.cancel_action = menu.addAction("Cancel Backup")
self.cancel_action.triggered.connect(self.app.backup_cancelled_event.emit)
self.cancel_action.setVisible(False)
settings_action = menu.addAction("Settings")
settings_action.triggered.connect(self.app.open_main_window_action)
@ -34,6 +29,7 @@ class TrayMenu(QSystemTrayIcon):
exit_action = menu.addAction("Exit")
exit_action.triggered.connect(self.app.quit)
self.on_user_click()
self.activated.connect(self.on_user_click)
self.setContextMenu(menu)