From 56528aaece9e667217aa74e136158377728aebcc Mon Sep 17 00:00:00 2001 From: donoban Date: Sat, 14 Nov 2020 12:39:21 +0100 Subject: [PATCH] Added QMessageBox if netvm is halted and user wants to start it --- qubesmanager/qube_manager.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 9e91195..7b357af 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -650,10 +650,27 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): for info in self.get_selected_vms(): info.vm.template = template - def change_network(self, netvm): + def change_network(self, netvm_name): try: + check_power = any(info.state['power'] == 'Running' for info + in self.get_selected_vms()) + netvm = self.qubes_cache.get_vm(name=netvm_name) + if check_power and netvm.state['power'] != 'Running': + reply = QMessageBox.question( + self, self.tr("Qube Start Confirmation"), + self.tr("
Can not change netvm to a halted Qube.
" + "Do you want to start the Qube '{0}'?").format( + netvm_name), + QMessageBox.Yes | QMessageBox.Cancel) + + if reply == QMessageBox.Yes: + with common_threads.busy_cursor(): + netvm.vm.start() + else: + return + for info in self.get_selected_vms(): - info.vm.netvm = netvm + info.vm.netvm = netvm_name except exc.QubesValueError as ex: QMessageBox.warning( self,