Browse Source

Added DVM Template column to Qube Manager

It is labelled "Template for DispVMs" and behaves like every
other column.

fixes QubesOS/qubes-issues#4912
Marta Marczykowska-Górecka 5 years ago
parent
commit
cf1dd0d355
3 changed files with 36 additions and 7 deletions
  1. 14 5
      qubesmanager/qube_manager.py
  2. 1 1
      qubesmanager/table_widgets.py
  3. 21 1
      ui/qubemanager.ui

+ 14 - 5
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

+ 1 - 1
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:

+ 21 - 1
ui/qubemanager.ui

@@ -136,7 +136,7 @@
        <number>10</number>
       </property>
       <property name="columnCount">
-       <number>11</number>
+       <number>12</number>
       </property>
       <attribute name="horizontalHeaderCascadingSectionResizes">
        <bool>false</bool>
@@ -234,6 +234,11 @@
         <string>Last backup</string>
        </property>
       </column>
+      <column>
+       <property name="text">
+        <string>Template for DispVMs</string>
+       </property>
+      </column>
      </widget>
     </item>
    </layout>
@@ -277,6 +282,7 @@
     <addaction name="action_backups"/>
     <addaction name="action_last_backup"/>
     <addaction name="separator"/>
+    <addaction name="action_dvm_template"/>
     <addaction name="action_toolbar"/>
     <addaction name="action_menubar"/>
     <addaction name="separator"/>
@@ -830,6 +836,20 @@
     <string>Launch a tool that allows multiple templates to be changed at once</string>
    </property>
   </action>
+  <action name="action_dvm_template">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Template for DispVMs</string>
+   </property>
+   <property name="toolTip">
+    <string>Template for DispVMs</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../resources.qrc"/>