diff --git a/src/gui/Dialogs/ImportKeys.qml b/src/gui/Dialogs/ImportKeys.qml index 5b2fa52c..72fb466f 100644 --- a/src/gui/Dialogs/ImportKeys.qml +++ b/src/gui/Dialogs/ImportKeys.qml @@ -3,6 +3,7 @@ import QtQuick 2.12 import Qt.labs.platform 1.1 import "../Popups" +import "../PythonBridge" HFileDialogOpener { fill: false @@ -15,27 +16,37 @@ HFileDialogOpener { property string userId: "" property bool importing: false + property Future importFuture: null PasswordPopup { id: importPasswordPopup - details.text: qsTr("Passphrase used to protect this file:") + details.text: + importing ? + qsTr("This might take a while...") : + qsTr("Passphrase used to protect this file:") okText: qsTr("Import") + onCancelled: if (importFuture) importFuture.cancel() + property url file: "" function verifyPassword(pass, callback) { importing = true + + const call = py.callClientCoro const path = file.toString().replace(/^file:\/\//, "") - py.callClientCoro(userId, "import_keys", [path, pass], () => { - importing = false + importFuture = call(userId, "import_keys", [path, pass], () => { + importing = false + importFuture = null callback(true) }, (type, args, error, traceback, uuid) => { - let unknown = false + let unknown = false + importFuture = null callback( type === "EncryptionError" ? diff --git a/src/gui/Popups/PasswordPopup.qml b/src/gui/Popups/PasswordPopup.qml index e834cdd5..b13b1355 100644 --- a/src/gui/Popups/PasswordPopup.qml +++ b/src/gui/Popups/PasswordPopup.qml @@ -17,6 +17,9 @@ BoxPopup { onOpened: passwordField.forceActiveFocus() + signal cancelled() + + property bool validateWhileTyping: false property string acceptedPassword: "" @@ -54,7 +57,10 @@ BoxPopup { button.loading = false }) }, - cancel: button => { popup.close() }, + cancel: button => { + popup.close() + cancelled() + }, })