Show import keys error in the UI
This commit is contained in:
@@ -2,18 +2,39 @@ import QtQuick 2.12
|
||||
import "../../Base"
|
||||
|
||||
HLoader {
|
||||
id: loader
|
||||
source: accountInfo.total_keys_to_import ?
|
||||
"ImportingKeys.qml" : "ImportExportKeys.qml"
|
||||
property bool importing: false
|
||||
|
||||
|
||||
function importKeys(file, passphrase, button=null) {
|
||||
if (button) button.loading = true
|
||||
importing = true
|
||||
|
||||
let path = file.toString().replace(/^file:\/\//, "")
|
||||
|
||||
py.callClientCoro(
|
||||
editAccount.userId, "import_keys", [path, passphrase], () => {
|
||||
importing = false
|
||||
if (button) button.loading = false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
id: encryptionUI
|
||||
source:
|
||||
accountInfo.import_error[0] ? "ImportError.qml" :
|
||||
importing || accountInfo.total_keys_to_import ? "ImportingKeys.qml" :
|
||||
"ImportExportKeys.qml"
|
||||
|
||||
onSourceChanged: animation.running = true
|
||||
|
||||
HNumberAnimation {
|
||||
SequentialAnimation {
|
||||
id: animation
|
||||
target: loader.item
|
||||
property: "scale"
|
||||
from: 0
|
||||
to: 1
|
||||
overshoot: 3
|
||||
HNumberAnimation {
|
||||
target: encryptionUI; property: "scale"; to: 0;
|
||||
}
|
||||
HNumberAnimation {
|
||||
target: encryptionUI; property: "scale"; to: 1; overshoot: 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
src/qml/Pages/EditAccount/ImportError.qml
Normal file
33
src/qml/Pages/EditAccount/ImportError.qml
Normal file
@@ -0,0 +1,33 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import "../../Base"
|
||||
import "../../utils.js" as Utils
|
||||
|
||||
HInterfaceBox {
|
||||
buttonModel: [
|
||||
{ name: "retry", text: qsTr("Retry"), iconName: "retry" },
|
||||
{ name: "cancel", text: qsTr("Cancel"), iconName: "cancel" },
|
||||
]
|
||||
|
||||
buttonCallbacks: ({
|
||||
retry: button => {
|
||||
encryptionUI.importKeys(
|
||||
accountInfo.import_error[0],
|
||||
accountInfo.import_error[1],
|
||||
button,
|
||||
)
|
||||
},
|
||||
cancel: button => { py.callClientCoro(userId, "clear_import_error") },
|
||||
})
|
||||
|
||||
|
||||
HLabel {
|
||||
color: theme.colors.errorText
|
||||
wrapMode: Text.Wrap
|
||||
text: qsTr("Couldn't import decryption keys file: %1")
|
||||
.arg(qsTr(accountInfo.import_error[2]))
|
||||
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
@@ -5,18 +5,6 @@ import "../../Base"
|
||||
import "../../utils.js" as Utils
|
||||
|
||||
HColumnLayout {
|
||||
function importKeys(file, passphrase) {
|
||||
importButton.loading = true
|
||||
|
||||
let path = file.toString().replace(/^file:\/\//, "")
|
||||
|
||||
py.callClientCoro(
|
||||
editAccount.userId, "import_keys", [path, passphrase], () => {
|
||||
if (importButton) importButton.loading = false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
HLabel {
|
||||
wrapMode: Text.Wrap
|
||||
text: qsTr(
|
||||
@@ -75,6 +63,7 @@ HColumnLayout {
|
||||
label.text: qsTr(
|
||||
"Please enter the passphrase that was used to protect this file:"
|
||||
)
|
||||
onAcceptedPasswordChanged: importKeys(file, acceptedPassword)
|
||||
onAcceptedPasswordChanged:
|
||||
encryptionUI.importKeys(file, acceptedPassword, importButton)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user