diff --git a/src/vorta/views/repo_tab.py b/src/vorta/views/repo_tab.py index 27e6b33d4..e2a9b0b2a 100644 --- a/src/vorta/views/repo_tab.py +++ b/src/vorta/views/repo_tab.py @@ -198,18 +198,15 @@ def create_ssh_key(self): ssh_add_window = SSHAddWindow() self._window = ssh_add_window # For tests ssh_add_window.setParent(self, QtCore.Qt.WindowType.Sheet) - ssh_add_window.create_ssh_key_message.connect(self.init_ssh) - ssh_add_window.create_ssh_key_message.connect(self.create_ssh_key_message) + ssh_add_window.reject.connect(self.init_ssh) + ssh_add_window.create_ssh_key_failure.connect(self.create_ssh_key_failure) ssh_add_window.open() - def create_ssh_key_message(self, exitCode: int, output_file: str): + def create_ssh_key_failure(self, exit_code): msg = QMessageBox() msg.setStandardButtons(QMessageBox.StandardButton.Ok) msg.setParent(self, QtCore.Qt.WindowType.Sheet) - if exitCode == 0: - msg.setText(self.tr(f"New key was copied to clipboard, and written to:\n{output_file}")) - else: - msg.setText(self.tr('Error during key generation.')) + msg.setText(self.tr(f'Error during key generation. Exited with code {exit_code}.')) msg.show() def ssh_copy_to_clipboard_action(self): @@ -233,7 +230,6 @@ def ssh_copy_to_clipboard_action(self): "Use it to set up remote repo permissions." ) ) - else: msg.setText(self.tr("Could not find public key.")) else: diff --git a/src/vorta/views/ssh_dialog.py b/src/vorta/views/ssh_dialog.py index 4f5d35c41..2c93f6df7 100644 --- a/src/vorta/views/ssh_dialog.py +++ b/src/vorta/views/ssh_dialog.py @@ -11,7 +11,8 @@ class SSHAddWindow(SSHAddBase, SSHAddUI): - create_ssh_key_message = QtCore.pyqtSignal(int, str) + create_ssh_key_success = QtCore.pyqtSignal() + create_ssh_key_failure = QtCore.pyqtSignal(int) def __init__(self): super().__init__() @@ -70,17 +71,16 @@ def generate_key(self): self.sshproc.finished.connect(self.generate_key_result) self.sshproc.start('ssh-keygen', ['-t', format, '-b', length, '-f', output_path, '-N', '']) - def generate_key_result(self, exitCode): - if exitCode == 0: + def generate_key_result(self, exit_code): + if exit_code == 0: output_path = os.path.expanduser(self.outputFileTextBox.text()) pub_key = open(output_path + '.pub').read().strip() clipboard = QApplication.clipboard() clipboard.setText(pub_key) self.reject() - self.create_ssh_key_message.emit(exitCode, output_path) else: self.reject() - self.create_ssh_key_message.emit(exitCode, "") + self.create_ssh_key_failure.emit(exit_code) def get_values(self): return {