From 32e400661c286b1152cf91a5f00955044b443e40 Mon Sep 17 00:00:00 2001 From: donoban Date: Fri, 13 Nov 2020 23:52:49 +0100 Subject: [PATCH] Added network_menu updates --- qubesmanager/qube_manager.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index f0b0233..9e91195 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -739,6 +739,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive) self.proxy.layoutChanged.connect(self.save_sorting) self.proxy.layoutChanged.connect(self.update_template_menu) + self.proxy.layoutChanged.connect(self.update_network_menu) self.table.setModel(self.proxy) self.table.setItemDelegateForColumn(3, StateIconDelegate()) @@ -1021,6 +1022,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): # Since selection could have multiple domains # enable all first and then filter them self.template_menu.setEnabled(True) + self.network_menu.setEnabled(True) for action in self.toolbar.actions() + self.context_menu.actions(): action.setEnabled(True) @@ -1068,6 +1070,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self.action_set_keyboard_layout.setEnabled(False) self.action_run_command_in_vm.setEnabled(False) self.template_menu.setEnabled(False) + self.network_menu.setEnabled(False) elif vm.klass == 'DispVM': self.action_appmenus.setEnabled(False) self.action_restartvm.setEnabled(False) @@ -1083,6 +1086,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): self.update_logs_menu() self.update_template_menu() + self.update_network_menu() def update_template_menu(self): if not self.template_menu.isEnabled(): @@ -1096,6 +1100,21 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow): if entry.data() == vm.template: entry.setChecked(True) + def update_network_menu(self): + if not self.network_menu.isEnabled(): + return + + for entry in self.network_menu.actions(): + entry.setChecked(False) + + for vm in self.get_selected_vms(): + if vm.netvm == "n/a": + self.network_menu.actions()[0].setChecked(True) + else: + for entry in self.network_menu.actions(): + if entry.data() == vm.netvm: + entry.setChecked(True) + # noinspection PyArgumentList @pyqtSlot(name='on_action_createvm_triggered') def action_createvm_triggered(self):