From 12764595cf3d0645c04f6e82af36fd7f940adb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Wed, 23 Sep 2020 21:44:07 +0200 Subject: [PATCH] Added show password button to Backup/Restore The button shows the password while pressed (emulating common password practices). fixes QubesOS/qubes-issues#6076 --- icons/eye-off.svg | 1 + icons/eye.svg | 1 + qubesmanager/backup.py | 11 ++++++++++ qubesmanager/restore.py | 11 ++++++++++ resources.qrc | 2 ++ ui/backupdlg.ui | 48 ++++++++++++++++++++++++----------------- ui/restoredlg.ui | 31 ++++++++++++++++++-------- 7 files changed, 76 insertions(+), 29 deletions(-) create mode 100644 icons/eye-off.svg create mode 100644 icons/eye.svg diff --git a/icons/eye-off.svg b/icons/eye-off.svg new file mode 100644 index 0000000..77c54cb --- /dev/null +++ b/icons/eye-off.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/eye.svg b/icons/eye.svg new file mode 100644 index 0000000..9cde243 --- /dev/null +++ b/icons/eye.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/qubesmanager/backup.py b/qubesmanager/backup.py index c1ba6e9..051bd30 100644 --- a/qubesmanager/backup.py +++ b/qubesmanager/backup.py @@ -121,6 +121,9 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, QtWidgets.QWizard): self.unrecognized_config_label.setVisible(False) self.load_settings() + self.show_passwd_button.pressed.connect(self.show_password) + self.show_passwd_button.released.connect(self.hide_password) + selected = self.vms_to_include() self.__fill_vms_list__(selected) @@ -130,6 +133,14 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, QtWidgets.QWizard): self.dispatcher = dispatcher dispatcher.add_handler('backup-progress', self.on_backup_progress) + def show_password(self): + self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Normal) + self.show_passwd_button.setIcon(QtGui.QIcon(':/eye.svg')) + + def hide_password(self): + self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Password) + self.show_passwd_button.setIcon(QtGui.QIcon(':/eye-off.svg')) + def setup_application(self): self.qt_app.setApplicationName(self.tr("Qubes Backup VMs")) self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager")) diff --git a/qubesmanager/restore.py b/qubesmanager/restore.py index bda55be..5ea974c 100644 --- a/qubesmanager/restore.py +++ b/qubesmanager/restore.py @@ -110,6 +110,17 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtWidgets.QWizard): backup_utils.fill_appvms_list(self) + self.passwd_show_button.pressed.connect(self.show_password) + self.passwd_show_button.released.connect(self.hide_password) + + def show_password(self): + self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Normal) + self.passwd_show_button.setIcon(QtGui.QIcon(':/eye.svg')) + + def hide_password(self): + self.passphrase_line_edit.setEchoMode(QtWidgets.QLineEdit.Password) + self.passwd_show_button.setIcon(QtGui.QIcon(':/eye-off.svg')) + def setup_application(self): self.qt_app.setApplicationName(self.tr("Qubes Restore VMs")) self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager")) diff --git a/resources.qrc b/resources.qrc index c499d27..36ee91e 100644 --- a/resources.qrc +++ b/resources.qrc @@ -1,5 +1,7 @@ + icons/eye.svg + icons/eye-off.svg icons/apps.png icons/settings.png icons/wall.png diff --git a/ui/backupdlg.ui b/ui/backupdlg.ui index f1f7818..f66e0ac 100644 --- a/ui/backupdlg.ui +++ b/ui/backupdlg.ui @@ -256,38 +256,46 @@ Backup security - - - QFormLayout::AllNonFixedFieldsGrow - - - - - <html><head/><body><p>Encryption / Verification<br/>passphrase:</p></body></html> - - - - - - - QLineEdit::Password - - - - + + <html><head/><body><p>Reenter passphrase:</p></body></html> - + + + + <html><head/><body><p>Encryption / Verification<br/>passphrase:</p></body></html> + + + + + + + QLineEdit::Password + + + + QLineEdit::Password + + + + + + + + :/eye-off:/eye-off + + + diff --git a/ui/restoredlg.ui b/ui/restoredlg.ui index 19e26a8..5b76c85 100644 --- a/ui/restoredlg.ui +++ b/ui/restoredlg.ui @@ -142,6 +142,13 @@ Security options + + + + Encrypted backup: + + + @@ -152,10 +159,10 @@ - - - - Encrypted backup: + + + + QLineEdit::Password @@ -166,10 +173,14 @@ - - - - QLineEdit::Password + + + + + + + + :/eye-off:/eye-off @@ -288,6 +299,8 @@ p, li { white-space: pre-wrap; } commit_text_edit showFileDialog - + + +