2023-03-22 15:48:44 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.panels 1.0 as SharedPanels
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2023-08-04 12:41:57 +00:00
|
|
|
property BasePopupStore store
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.margins: Style.current.padding
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
2023-08-04 12:41:57 +00:00
|
|
|
width: parent.width
|
2024-06-07 13:29:09 +00:00
|
|
|
text: root.store.isAddAccountPopup? qsTr("Enter seed phrase") : qsTr("Enter private key for %1 key pair").arg(root.store.selectedKeypair.name)
|
2023-03-22 15:48:44 +00:00
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
2023-08-04 12:41:57 +00:00
|
|
|
elide: Text.ElideRight
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SharedPanels.EnterSeedPhrase {
|
|
|
|
id: enterSeedPhrase
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
isSeedPhraseValid: function(mnemonic) {
|
|
|
|
return root.store.validSeedPhrase(mnemonic)
|
|
|
|
}
|
|
|
|
|
|
|
|
onSeedPhraseUpdated: {
|
|
|
|
if (valid) {
|
|
|
|
root.store.changeSeedPhrase(seedPhrase)
|
|
|
|
}
|
|
|
|
root.store.enteredSeedPhraseIsValid = valid
|
|
|
|
if (!enterSeedPhrase.isSeedPhraseValid(seedPhrase)) {
|
2023-08-04 12:41:57 +00:00
|
|
|
let err = qsTr("The entered seed phrase is already added")
|
|
|
|
if (!root.store.isAddAccountPopup) {
|
|
|
|
err = qsTr("This is not the correct seed phrase for %1 key").arg(root.store.selectedKeypair.name)
|
|
|
|
}
|
|
|
|
enterSeedPhrase.setWrongSeedPhraseMessage(err)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmitSeedPhrase: {
|
2023-08-04 12:41:57 +00:00
|
|
|
root.store.submitPopup()
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusModalDivider {
|
|
|
|
width: parent.width
|
2023-08-04 12:41:57 +00:00
|
|
|
visible: root.store.isAddAccountPopup && root.store.enteredSeedPhraseIsValid
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
width: parent.width
|
|
|
|
spacing: Style.current.halfPadding
|
2023-08-04 12:41:57 +00:00
|
|
|
visible: root.store.isAddAccountPopup && root.store.enteredSeedPhraseIsValid
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
StatusInput {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-ImportedSeedPhraseKeyName"
|
2023-03-22 15:48:44 +00:00
|
|
|
width: parent.width
|
|
|
|
label: qsTr("Key name")
|
|
|
|
charLimit: Constants.addAccountPopup.keyPairNameMaxLength
|
|
|
|
placeholderText: qsTr("Enter a name")
|
2023-08-04 12:41:57 +00:00
|
|
|
text: root.store.isAddAccountPopup? root.store.addAccountModule.newKeyPairName : ""
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
onTextChanged: {
|
2023-08-04 12:41:57 +00:00
|
|
|
if (!root.store.isAddAccountPopup) {
|
|
|
|
return
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
if (text.trim() == "") {
|
|
|
|
root.store.addAccountModule.newKeyPairName = ""
|
|
|
|
return
|
|
|
|
}
|
|
|
|
root.store.addAccountModule.newKeyPairName = text
|
|
|
|
}
|
|
|
|
|
2024-02-05 10:04:20 +00:00
|
|
|
validators: [
|
|
|
|
StatusMinLengthValidator {
|
2024-06-07 13:29:09 +00:00
|
|
|
errorMessage: qsTr("Key pair name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength)
|
2024-02-05 10:04:20 +00:00
|
|
|
minLength: Constants.addAccountPopup.keyPairAccountNameMinLength
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
onKeyPressed: {
|
2023-08-04 12:41:57 +00:00
|
|
|
root.store.submitPopup(event)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("For your future reference. This is only visible to you.")
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize2
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|