2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
2023-08-04 12:41:57 +00:00
|
|
|
import "../../common"
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property AddAccountStore store
|
|
|
|
|
|
|
|
columns: 3
|
2024-10-15 19:26:12 +00:00
|
|
|
columnSpacing: Theme.padding
|
|
|
|
rowSpacing: Theme.halfPadding
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int oneHalfWidth: (root.width - root.columnSpacing) * 0.5
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: qsTr("Derivation Path")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusLinkText {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-ResetDerivationPath"
|
2023-05-25 07:28:55 +00:00
|
|
|
enabled: !root.store.selectedOrigin.migratedToKeycard &&
|
|
|
|
root.store.derivedAddressModel.count > 0 &&
|
2023-05-18 18:28:46 +00:00
|
|
|
root.store.addAccountModule.suggestedDerivationPath !== root.store.addAccountModule.derivationPath
|
2023-03-22 15:48:44 +00:00
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: qsTr("Reset")
|
|
|
|
color: enabled? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.store.resetDerivationPath()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.preferredWidth: d.oneHalfWidth
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: qsTr("Account")
|
|
|
|
}
|
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
RowLayout {
|
2023-03-22 15:48:44 +00:00
|
|
|
Layout.preferredWidth: d.oneHalfWidth
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
DerivationPathInput {
|
|
|
|
id: derivationPathInput
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-DerivationPathInput"
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-05-03 11:47:43 +00:00
|
|
|
enabled: root.store.derivedAddressModel.count > 0
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
levelsLimit: 4 // Allow only 5 separators in the derivation path
|
|
|
|
|
|
|
|
onDerivationPathChanged: {
|
|
|
|
let t = derivationPath
|
|
|
|
if(t.length > 0) {
|
|
|
|
if(root.store.derivationPathRegEx.test(t)) {
|
|
|
|
root.store.changeDerivationPathPostponed(t)
|
|
|
|
} else {
|
|
|
|
root.store.addAccountModule.derivationPath = t
|
|
|
|
}
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
onEditingFinished: {
|
2023-08-04 12:41:57 +00:00
|
|
|
root.store.submitPopup(null)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
input.rightComponent: StatusIcon {
|
|
|
|
icon: "chevron-down"
|
|
|
|
color: Theme.palette.baseColor1
|
2023-05-25 07:28:55 +00:00
|
|
|
visible: !root.store.selectedOrigin.migratedToKeycard
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
2024-10-15 19:26:12 +00:00
|
|
|
derivationPathSelection.popup(0, derivationPathInput.height + Theme.halfPadding)
|
2023-03-15 22:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
DerivationPathSelection {
|
|
|
|
id: derivationPathSelection
|
|
|
|
|
|
|
|
roots: root.store.roots
|
|
|
|
translation: root.store.translation
|
|
|
|
selectedRootPath: root.store.selectedRootPath
|
2023-03-22 15:48:44 +00:00
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
onSelected: {
|
|
|
|
root.store.changeRootDerivationPath(rootPath)
|
2023-05-03 11:18:50 +00:00
|
|
|
derivationPathInput.resetDerivationPath(root.store.selectedRootPath, root.store.addAccountModule.derivationPath)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-03 11:18:50 +00:00
|
|
|
Component.onCompleted: {
|
2023-03-15 22:34:48 +00:00
|
|
|
derivationPathInput.resetDerivationPath(root.store.selectedRootPath, root.store.addAccountModule.derivationPath)
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.addAccountModule
|
|
|
|
function onDerivationPathChanged() {
|
|
|
|
derivationPathInput.resetDerivationPath(root.store.selectedRootPath, root.store.addAccountModule.derivationPath)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
// Propagate the error state to the store
|
|
|
|
Binding {
|
|
|
|
target: root.store
|
|
|
|
property: "derivationPathEditingNotValid"
|
|
|
|
value: derivationPathInput.errorMessage !== ""
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: generatedAddress
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-GeneratedAddress"
|
2023-03-22 15:48:44 +00:00
|
|
|
Layout.preferredWidth: d.oneHalfWidth
|
2023-03-15 22:34:48 +00:00
|
|
|
Layout.preferredHeight: derivationPathInput.height
|
2023-03-22 15:48:44 +00:00
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
enabled: root.store.derivedAddressModel.count > 1
|
|
|
|
statusListItemTitle.elide: Qt.ElideMiddle
|
|
|
|
loading: root.store.derivedAddressModel.count === 0
|
|
|
|
|
|
|
|
title: {
|
|
|
|
if (!!root.store.selectedDerivedAddress && root.store.selectedDerivedAddress.address !== "") {
|
|
|
|
return root.store.selectedDerivedAddress.address
|
|
|
|
}
|
|
|
|
else if (root.store.derivedAddressModel.count > 1) {
|
|
|
|
return qsTr("Select address")
|
|
|
|
}
|
|
|
|
|
2024-11-01 13:27:34 +00:00
|
|
|
return Constants.zeroAddress
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusIcon {
|
|
|
|
visible: root.store.derivedAddressModel.count > 1
|
|
|
|
icon: "chevron-down"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
onClicked: {
|
2024-10-15 19:26:12 +00:00
|
|
|
accountAddressSelection.popup(-generatedAddress.x, generatedAddress.y + generatedAddress.height + Theme.halfPadding)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AccountAddressSelection {
|
|
|
|
id: accountAddressSelection
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-GeneratedAddressesList"
|
2023-03-22 15:48:44 +00:00
|
|
|
width: root.width
|
|
|
|
store: root.store
|
|
|
|
|
|
|
|
onSelected: {
|
|
|
|
accountAddressSelection.close()
|
|
|
|
root.store.changeSelectedDerivedAddress(address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-15 22:34:48 +00:00
|
|
|
RowLayout {
|
2023-03-22 15:48:44 +00:00
|
|
|
Layout.preferredWidth: d.oneHalfWidth
|
|
|
|
Layout.columnSpan: 2
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: basePathName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-04-03 18:30:01 +00:00
|
|
|
visible: !errorMessageText.visible && !warningMessageText.visible
|
2023-03-15 22:34:48 +00:00
|
|
|
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize2
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: root.store.translation(root.store.selectedRootPath, true)
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: errorMessageText
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: !!derivationPathInput.errorMessage
|
|
|
|
|
|
|
|
font.pixelSize: basePathName.font.pixelSize
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
|
|
|
|
text: derivationPathInput.errorMessage
|
|
|
|
}
|
2023-04-03 18:30:01 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: warningMessageText
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: !!derivationPathInput.warningMessage
|
|
|
|
|
|
|
|
font.pixelSize: basePathName.font.pixelSize
|
|
|
|
color: Theme.palette.warningColor1
|
|
|
|
|
|
|
|
text: derivationPathInput.warningMessage
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddressDetails {
|
|
|
|
Layout.preferredWidth: d.oneHalfWidth
|
|
|
|
addressDetailsItem: root.store.selectedDerivedAddress
|
|
|
|
defaultMessage: ""
|
|
|
|
defaultMessageCondition: !root.store.selectedDerivedAddress || root.store.selectedDerivedAddress.address === ""
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusCheckBox {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-ConfirmAddingNonEthDerivationPath"
|
2023-03-22 15:48:44 +00:00
|
|
|
visible: root.store.derivationPathOutOfTheDefaultStatusDerivationTree
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.columnSpan: 3
|
|
|
|
font.pixelSize: Constants.addAccountPopup.labelFontSize1
|
|
|
|
text: qsTr("I understand that this non-Ethereum derivation path is incompatible with Keycard")
|
|
|
|
onToggled: {
|
|
|
|
root.store.derivationPathOutOfTheDefaultStatusDerivationTreeConfirmed = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|