Kaynağa Gözat

Add option to turn off computer after backup to Backup GUI

A simple checkbox to turn off the computer after backup finishes
successfully. It is off by default and must be switched on every time
(unexpected system shutdowns are a huge pain, much more problematic
than forgetting to shut down can be).

fixes QubesOS/qubes-issues#2039
Marta Marczykowska-Górecka 6 yıl önce
ebeveyn
işleme
80b3a82963
2 değiştirilmiş dosya ile 28 ekleme ve 0 silme
  1. 6 0
      qubesmanager/backup.py
  2. 22 0
      ui/backupdlg.ui

+ 6 - 0
qubesmanager/backup.py

@@ -348,6 +348,12 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, multiselectwidget.QtGui.QWizard):
             self.button(self.FinishButton).setEnabled(True)
             self.showFileDialog.setEnabled(False)
             self.cleanup_temporary_files()
+
+            # turn off only when backup was successful
+            if self.thread_monitor.success and \
+                    self.turn_off_checkbox.isChecked():
+                os.system('systemctl poweroff')
+                
         signal.signal(signal.SIGCHLD, old_sigchld_handler)
 
     def reject(self):

+ 22 - 0
ui/backupdlg.ui

@@ -310,6 +310,28 @@
       </property>
      </widget>
     </item>
+    <item row="4" column="0">
+     <widget class="QGroupBox" name="groupBox_4">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="title">
+       <string>Other</string>
+      </property>
+      <layout class="QGridLayout" name="gridLayout_4">
+       <item row="0" column="0">
+        <widget class="QCheckBox" name="turn_off_checkbox">
+         <property name="text">
+          <string>Turn computer off after backup is finished</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </item>
    </layout>
   </widget>
   <widget class="QWizardPage" name="confirm_page">