From e3b70dd7de9955d1156ceb6c69063a5a4344b7ce Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Sun, 1 Apr 2018 19:09:01 +0200 Subject: [PATCH] Shortcut change and confirmation of encryption password. --- SamAuthenticator/AuthenticatorWindow.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/SamAuthenticator/AuthenticatorWindow.py b/SamAuthenticator/AuthenticatorWindow.py index 51944c2..cd10aa0 100644 --- a/SamAuthenticator/AuthenticatorWindow.py +++ b/SamAuthenticator/AuthenticatorWindow.py @@ -123,14 +123,26 @@ class AuthenticatorGUI(QMainWindow): QMessageBox.warning(self, "Unable to read data", "Unable to read data. " + str(e)) def save_data(self, data_file): - pass_from_dialog = QInputDialog.getText(self, "Input encryption password", + pass_from_dialog_1 = QInputDialog.getText(self, "Input encryption password", "New encryption password:", QLineEdit.Password, "") - ok_pressed = pass_from_dialog[1] - if not ok_pressed: + ok_pressed_1 = pass_from_dialog_1[1] + if not ok_pressed_1: return - password = pass_from_dialog[0] + pass_from_dialog_2 = QInputDialog.getText(self, "Repeat encryption password", + "Repeat encryption password:", + QLineEdit.Password, "") + ok_pressed_2 = pass_from_dialog_2[1] + if not ok_pressed_2: + return + + if pass_from_dialog_1[0] != pass_from_dialog_2[0]: + QMessageBox.warning(self, "Error", "Password mismatch. Please try again") + self.save_data(data_file) + return + + password = pass_from_dialog_1[0] if self.keys_data_model is not None: auth.write_keys_to_file(self.keys_data_model.getKeysObject(), password, data_file) @@ -194,8 +206,8 @@ class AuthenticatorGUI(QMainWindow): current_path = os.path.dirname(os.path.abspath(__file__)) toolbar.addWidget(left_spacer) - add_act = QAction(QIcon(os.path.join(current_path, "images/add.png")), "Add new key", self) - add_act.setShortcut('Ctrl+A') + add_act = QAction(QIcon(os.path.join(current_path, "images/add.png")), "Add new key (Ctrl+N)", self) + add_act.setShortcut('Ctrl+N') toolbar.addAction(add_act) remove_act = QAction(QIcon(os.path.join(current_path, "images/delete.png")), "Remove selected key", self) remove_act.setShortcut('Ctrl+D')