Browse Source

Add updates section to global settings (#800)

Marek Marczykowski-Górecki 10 years ago
parent
commit
59b98f7b51
2 changed files with 67 additions and 7 deletions
  1. 51 7
      globalsettingsdlg.ui
  2. 16 0
      qubesmanager/global_settings.py

+ 51 - 7
globalsettingsdlg.ui

@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>678</width>
-    <height>288</height>
+    <height>318</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -19,6 +19,12 @@
      <property name="enabled">
       <bool>true</bool>
      </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>140</height>
+      </size>
+     </property>
      <property name="title">
       <string>System defaults</string>
      </property>
@@ -78,11 +84,27 @@
      </layout>
     </widget>
    </item>
+   <item row="3" column="0" colspan="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
    <item row="0" column="1">
     <widget class="QGroupBox" name="groupBox_3">
      <property name="enabled">
       <bool>true</bool>
      </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>140</height>
+      </size>
+     </property>
      <property name="title">
       <string>Default memory settings</string>
      </property>
@@ -158,6 +180,9 @@
       <string>Kernel</string>
      </property>
      <layout class="QFormLayout" name="formLayout_2">
+      <property name="fieldGrowthPolicy">
+       <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+      </property>
       <item row="0" column="0">
        <widget class="QLabel" name="label_5">
         <property name="text">
@@ -172,13 +197,32 @@
     </widget>
    </item>
    <item row="2" column="0" colspan="2">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+    <widget class="QGroupBox" name="groupBox_4">
+     <property name="title">
+      <string>Updates</string>
      </property>
+     <layout class="QGridLayout" name="gridLayout_3">
+      <item row="0" column="0">
+       <widget class="QCheckBox" name="updates_dom0">
+        <property name="text">
+         <string>Check for dom0 updates</string>
+        </property>
+        <property name="tristate">
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QCheckBox" name="updates_vm">
+        <property name="toolTip">
+         <string>Unknown current state</string>
+        </property>
+        <property name="text">
+         <string>Check fo VM updates</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
   </layout>

+ 16 - 0
qubesmanager/global_settings.py

@@ -45,6 +45,8 @@ from ui_globalsettingsdlg import *
 
 from ConfigParser import SafeConfigParser
 from qubes.qubesutils import parse_size
+from qubes.qubesutils import updates_dom0_toggle,updates_vms_toggle,\
+    updates_dom0_status
 from qubes import qmemman_algo
 
 dont_keep_dvm_in_memory_path = '/var/lib/qubes/dvmdata/dont-use-shm'
@@ -67,6 +69,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
         self.__init_system_defaults__()
         self.__init_kernel_defaults__()
         self.__init_mem_defaults__()
+        self.__init_updates__()
 
 
     def __init_system_defaults__(self):
@@ -278,6 +281,18 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
                 os.remove(dont_keep_dvm_in_memory_path)
             self.anything_changed = True
 
+    def __init_updates__(self):
+        self.updates_val = False
+        self.updates_dom0_val = updates_dom0_status(self.qvm_collection)
+        self.updates_dom0.setChecked(self.updates_dom0_val)
+        self.updates_vm.setCheckState(Qt.PartiallyChecked)
+
+    def __apply_updates__(self):
+        if self.updates_dom0.isChecked() != self.updates_dom0_val:
+            updates_dom0_toggle(self.qvm_collection, self.updates_dom0.isChecked())
+        if self.updates_vm.checkState() != Qt.PartiallyChecked:
+            updates_vms_toggle(self.qvm_collection, self.updates_vm
+                               .isChecked())
 
     def reject(self):
         self.done(0)
@@ -289,6 +304,7 @@ class GlobalSettingsWindow(Ui_GlobalSettings, QDialog):
         self.__apply_system_defaults__()        
         self.__apply_kernel_defaults__()
         self.__apply_mem_defaults__()
+        self.__apply_updates__()
 
         if self.anything_changed == True:
             self.qvm_collection.save()