From 21d72cdc6cd259be9e441911be58a10ab1a056dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 28 Nov 2013 03:52:02 +0100 Subject: [PATCH] backups: UI improvements Prompt for retype the backup password, more thoroughly test if the user entered all required informations, use "dom0" instead of "None" for local backup indication. --- backupdlg.ui | 41 +++++++++++++++++++++++++----------- qubesmanager/backup.py | 30 ++++++++++++++++++++------ qubesmanager/backup_utils.py | 2 +- qubesmanager/restore.py | 11 +++++++++- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/backupdlg.ui b/backupdlg.ui index 9237243..77850ee 100644 --- a/backupdlg.ui +++ b/backupdlg.ui @@ -6,7 +6,7 @@ 0 0 - 700 + 650 399 @@ -215,7 +215,10 @@ - Backup directory: + Backup directory or VM command: + + + true @@ -227,7 +230,14 @@ Backup security - + + + + + <html><head/><body><p>Encryption / Verification<br/>passphrase:</p></body></html> + + + @@ -235,13 +245,6 @@ - - - - <html><head/><body><p>Encryption / Verification<br/>passphrase:</p></body></html> - - - @@ -255,13 +258,27 @@ - + + + + <html><head/><body><p>Reenter passphrase:</p></body></html> + + + + QLineEdit::Password + + + + QLineEdit::Password + + + @@ -317,7 +334,7 @@ p, li { white-space: pre-wrap; } - + 9 diff --git a/qubesmanager/backup.py b/qubesmanager/backup.py index 3219c6b..2d3b61d 100644 --- a/qubesmanager/backup.py +++ b/qubesmanager/backup.py @@ -93,13 +93,25 @@ class BackupVMsWindow(Ui_Backup, QWizard): self.shutdown_running_vms_button.clicked.connect(self.shutdown_all_running_selected) self.connect(self.dev_combobox, SIGNAL("activated(int)"), self.dev_combobox_activated) self.connect(self, SIGNAL("backup_progress(int)"), self.progress_bar.setValue) + self.dir_line_edit.connect(self.dir_line_edit, SIGNAL("textChanged(QString)"), self.backup_location_changed) self.select_vms_page.isComplete = self.has_selected_vms - self.select_dir_page.isComplete = self.has_selected_dir + self.select_dir_page.isComplete = self.has_selected_dir_and_pass #FIXME #this causes to run isComplete() twice, I don't know why - self.select_vms_page.connect(self.select_vms_widget, SIGNAL("selected_changed()"), SIGNAL("completeChanged()")) - + self.select_vms_page.connect( + self.select_vms_widget, + SIGNAL("selected_changed()"), + SIGNAL("completeChanged()")) + self.passphrase_line_edit.connect( + self.passphrase_line_edit, + SIGNAL("textChanged(QString)"), + self.backup_location_changed) + self.passphrase_line_edit_verify.connect( + self.passphrase_line_edit_verify, + SIGNAL("textChanged(QString)"), + self.backup_location_changed) + self.total_size = 0 self.__fill_vms_list__() fill_devs_list(self) @@ -354,10 +366,16 @@ class BackupVMsWindow(Ui_Backup, QWizard): def has_selected_vms(self): return self.select_vms_widget.selected_list.count() > 0 - def has_selected_dir(self): - return self.backup_dir != None - + def has_selected_dir_and_pass(self): + if not len(self.passphrase_line_edit.text()): + return False + if self.passphrase_line_edit.text() != self.passphrase_line_edit_verify.text(): + return False + return self.backup_location != None + def backup_location_changed(self, new_dir = None): + self.backup_location = str(self.dir_line_edit.text()) + self.select_dir_page.emit(SIGNAL("completeChanged()")) # Bases on the original code by: diff --git a/qubesmanager/backup_utils.py b/qubesmanager/backup_utils.py index 937ef8c..2cfb235 100644 --- a/qubesmanager/backup_utils.py +++ b/qubesmanager/backup_utils.py @@ -77,7 +77,7 @@ def umount_device(dev_mount_path): def fill_appvms_list(dialog): dialog.appvm_combobox.clear() - dialog.appvm_combobox.addItem("None") + dialog.appvm_combobox.addItem("dom0") dialog.appvm_combobox.setCurrentIndex(0) #current selected is null "" diff --git a/qubesmanager/restore.py b/qubesmanager/restore.py index be7c2ae..b185512 100644 --- a/qubesmanager/restore.py +++ b/qubesmanager/restore.py @@ -88,9 +88,10 @@ class RestoreVMsWindow(Ui_Restore, QWizard): self.select_dir_page.isComplete = self.has_selected_dir self.select_vms_page.isComplete = self.has_selected_vms + self.confirm_page.isComplete = self.all_vms_good #FIXME #this causes to run isComplete() twice, I don't know why - self.select_vms_page.connect(self.select_vms_widget, SIGNAL("selected_changed()"), SIGNAL("completeChanged()")) + self.select_vms_page.connect(self.select_vms_widget, SIGNAL("selected_changed()"), SIGNAL("completeChanged()")) fill_devs_list(self) fill_appvms_list(self) @@ -222,6 +223,7 @@ class RestoreVMsWindow(Ui_Restore, QWizard): self.confirm_text_edit.setFontFamily("Monospace") self.confirm_text_edit.setText("\n".join(self.func_output)) + self.confirm_page.emit(SIGNAL("completeChanged()")) elif self.currentPage() is self.commit_page: self.button(self.CancelButton).setDisabled(True) @@ -243,6 +245,13 @@ class RestoreVMsWindow(Ui_Restore, QWizard): umount_device(self.dev_mount_path) self.button(self.FinishButton).setEnabled(True) + def all_vms_good(self): + for vminfo in self.vms_to_restore.values(): + if not vminfo['good-to-go']: + print vminfo['vm'].name, str(vminfo) + return False + return True + def reject(self): if self.dev_mount_path != None: umount_device(self.dev_mount_path)