From cf1dd0d355e44eaaf990f9872af47ce3421abbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Fri, 29 Mar 2019 18:50:01 +0100 Subject: [PATCH] Added DVM Template column to Qube Manager It is labelled "Template for DispVMs" and behaves like every other column. fixes QubesOS/qubes-issues#4912 --- qubesmanager/qube_manager.py | 19 ++++++++++++++----- qubesmanager/table_widgets.py | 2 +- ui/qubemanager.ui | 22 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/qubesmanager/qube_manager.py b/qubesmanager/qube_manager.py index 69f900e..3330204 100644 --- a/qubesmanager/qube_manager.py +++ b/qubesmanager/qube_manager.py @@ -126,7 +126,7 @@ class VmRowInTable: self.include_in_backups_widget = table_widgets.VMPropertyItem( vm, "include_in_backups", - empty_function=(lambda x: True if x is None or not x else False)) + empty_function=(lambda x: not bool(x))) table.setItem(row_no, VmManagerWindow.columns_indices[ 'Include in backups'], self.include_in_backups_widget) @@ -135,6 +135,11 @@ class VmRowInTable: table.setItem(row_no, VmManagerWindow.columns_indices[ 'Last backup'], self.last_backup_widget) + self.dvm_template_widget = table_widgets.VMPropertyItem( + vm, "template_for_dispvms", empty_function=(lambda x: not x)) + table.setItem(row_no, VmManagerWindow.columns_indices['DVM Template'], + self.dvm_template_widget) + self.table = table def update(self, update_size_on_disk=False, event=None): @@ -335,6 +340,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): "IP": 8, "Include in backups": 9, "Last backup": 10, + "DVM Template": 11 } def __init__(self, qt_app, qubes_app, dispatcher, parent=None): @@ -375,10 +381,10 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): self.columns_indices["NetVM"]: self.action_netvm, self.columns_indices["Size"]: self.action_size_on_disk, self.columns_indices["Internal"]: self.action_internal, - self.columns_indices["IP"]: self - .action_ip, self.columns_indices["Include in backups"]: self - .action_backups, self.columns_indices["Last backup"]: self - .action_last_backup + self.columns_indices["IP"]: self.action_ip, + self.columns_indices["Include in backups"]: self.action_backups, + self.columns_indices["Last backup"]: self.action_last_backup, + self.columns_indices["DVM Template"]: self.action_dvm_template } self.visible_columns_count = len(self.columns_indices) @@ -1181,6 +1187,9 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow): def on_action_size_on_disk_toggled(self, checked): self.showhide_column(self.columns_indices['Size'], checked) + def on_action_dvm_template_toggled(self, checked): + self.showhide_column(self.columns_indices['DVM Template'], checked) + # noinspection PyArgumentList @QtCore.pyqtSlot(name='on_action_about_qubes_triggered') def action_about_qubes_triggered(self): # pylint: disable=no-self-use diff --git a/qubesmanager/table_widgets.py b/qubesmanager/table_widgets.py index 43dd228..55ed83f 100644 --- a/qubesmanager/table_widgets.py +++ b/qubesmanager/table_widgets.py @@ -286,7 +286,7 @@ class VMPropertyItem(QtGui.QTableWidgetItem): self.setText("n/a") elif self.check_default and \ self.vm.property_is_default(self.property_name): - self.setText('default (' + str(val) + ')') + self.setText('default (' + str(val) + ')') elif val is True: self.setText("Yes") else: diff --git a/ui/qubemanager.ui b/ui/qubemanager.ui index d9a097f..4a272e3 100644 --- a/ui/qubemanager.ui +++ b/ui/qubemanager.ui @@ -136,7 +136,7 @@ 10 - 11 + 12 false @@ -234,6 +234,11 @@ Last backup + + + Template for DispVMs + + @@ -277,6 +282,7 @@ + @@ -830,6 +836,20 @@ Launch a tool that allows multiple templates to be changed at once + + + true + + + true + + + Template for DispVMs + + + Template for DispVMs + +