From fe63689320fbeb6a95683759e1c64ab9ce94d522 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Fri, 2 Jul 2021 10:17:46 -0700 Subject: [PATCH] Remove restart from systray and replace it with new window --- dangerzone/gui/__init__.py | 4 +++- dangerzone/gui/main_window.py | 2 +- dangerzone/gui/systray.py | 17 +++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dangerzone/gui/__init__.py b/dangerzone/gui/__init__.py index 386ecf5..3474b94 100644 --- a/dangerzone/gui/__init__.py +++ b/dangerzone/gui/__init__.py @@ -23,6 +23,7 @@ from ..global_common import GlobalCommon # this is a class whose job is to hold a QApplication object and customize it class ApplicationWrapper(QtCore.QObject): document_selected = QtCore.Signal(str) + new_window = QtCore.Signal() application_activated = QtCore.Signal() def __init__(self): @@ -112,7 +113,7 @@ def gui_main(custom_container, filename): vm = None # Create the system tray - systray = SysTray(global_common, gui_common, app) + systray = SysTray(global_common, gui_common, app, app_wrapper) # Start the VM if vm: @@ -169,6 +170,7 @@ def gui_main(custom_container, filename): # If we get a file open event, open it app_wrapper.document_selected.connect(select_document) + app_wrapper.new_window.connect(select_document) # If the application is activated and all windows are closed, open a new one app_wrapper.application_activated.connect(application_activated) diff --git a/dangerzone/gui/main_window.py b/dangerzone/gui/main_window.py index 4829e1c..d33f4e2 100644 --- a/dangerzone/gui/main_window.py +++ b/dangerzone/gui/main_window.py @@ -51,7 +51,7 @@ class MainWindow(QtWidgets.QMainWindow): self.doc_selection_widget.document_selected.connect(self.document_selected) # Only use the waiting widget if we have a VM - if self.global_common.vm: + if self.global_common.vm and self.global_common.vm.state != self.global_common.vm.STATE_ON: self.waiting_widget.show() self.doc_selection_widget.hide() else: diff --git a/dangerzone/gui/systray.py b/dangerzone/gui/systray.py index 49d4af0..7905c43 100644 --- a/dangerzone/gui/systray.py +++ b/dangerzone/gui/systray.py @@ -3,11 +3,12 @@ from PySide2 import QtWidgets class SysTray(QtWidgets.QSystemTrayIcon): - def __init__(self, global_common, gui_common, app): + def __init__(self, global_common, gui_common, app, app_wrapper): super(SysTray, self).__init__() self.global_common = global_common self.gui_common = gui_common self.app = app + self.app_wrapper = app_wrapper self.setIcon(self.gui_common.get_window_icon()) @@ -17,8 +18,9 @@ class SysTray(QtWidgets.QSystemTrayIcon): self.status_action = menu.addAction("...") self.status_action.setEnabled(False) menu.addSeparator() - self.restart_action = menu.addAction("Restart") - self.restart_action.triggered.connect(self.restart_clicked) + + self.new_action = menu.addAction("New window") + self.new_action.triggered.connect(self.new_window) self.quit_action = menu.addAction("Quit") self.quit_action.triggered.connect(self.quit_clicked) @@ -32,16 +34,15 @@ class SysTray(QtWidgets.QSystemTrayIcon): def vm_state_change(self, state): if state == self.global_common.vm.STATE_OFF: self.status_action.setText("Dangerzone VM is off") - self.restart_action.setEnabled(True) elif state == self.global_common.vm.STATE_STARTING: self.status_action.setText("Dangerzone VM is starting...") - self.restart_action.setEnabled(False) elif state == self.global_common.vm.STATE_ON: self.status_action.setText("Dangerzone VM is running") - self.restart_action.setEnabled(True) + elif state == self.global_common.vm.STATE_FAIL: + self.status_action.setText("Dangerzone VM failed to start") - def restart_clicked(self): - self.global_common.vm.restart() + def new_window(self): + self.app_wrapper.new_window.emit() def quit_clicked(self): self.app.quit()