2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-10 18:40:27 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
2020-06-10 20:32:04 +00:00
|
|
|
import "../../../imports"
|
|
|
|
import "../../../shared"
|
|
|
|
|
|
|
|
ModalPopup {
|
2020-06-10 15:55:24 +00:00
|
|
|
property var currentAccount: walletModel.currentAccount
|
2020-06-10 20:21:23 +00:00
|
|
|
property var changeSelectedAccount
|
2020-06-10 20:32:04 +00:00
|
|
|
id: popup
|
|
|
|
// TODO add icon when we have that feature
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Status account settings"
|
|
|
|
title: qsTrId("status-account-settings")
|
2020-07-22 20:40:32 +00:00
|
|
|
height: 675
|
2020-06-10 20:32:04 +00:00
|
|
|
|
|
|
|
property int marginBetweenInputs: 35
|
2020-06-22 18:49:58 +00:00
|
|
|
property string accountNameValidationError: ""
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
if (accountNameInput.text === "") {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "You need to enter an account name"
|
|
|
|
accountNameValidationError = qsTrId("you-need-to-enter-an-account-name")
|
2020-06-22 18:49:58 +00:00
|
|
|
} else {
|
|
|
|
accountNameValidationError = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return accountNameValidationError === ""
|
|
|
|
}
|
2020-06-10 20:32:04 +00:00
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
accountNameInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: accountNameInput
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Enter an account name..."
|
|
|
|
placeholderText: qsTrId("enter-an-account-name...")
|
|
|
|
//% "Account name"
|
|
|
|
label: qsTrId("account-name")
|
2020-06-10 15:55:24 +00:00
|
|
|
text: currentAccount.name
|
2020-06-22 18:49:58 +00:00
|
|
|
validationError: popup.accountNameValidationError
|
2020-06-10 20:32:04 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 05:18:54 +00:00
|
|
|
ColorSelector {
|
2020-06-10 20:32:04 +00:00
|
|
|
id: accountColorInput
|
2020-07-30 05:18:54 +00:00
|
|
|
selectedColor: currentAccount.iconColor
|
|
|
|
model: Constants.accountColors
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: accountNameInput.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
2020-07-30 05:18:54 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-06-10 20:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: typeText
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Type"
|
|
|
|
label: qsTrId("type")
|
2020-06-10 15:55:24 +00:00
|
|
|
text: {
|
|
|
|
var result = ""
|
|
|
|
switch (currentAccount.walletType) {
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Watch-only"
|
|
|
|
case Constants.watchWalletType: result = qsTrId("watch-only"); break;
|
2020-06-10 15:55:24 +00:00
|
|
|
case Constants.keyWalletType:
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Off Status tree"
|
|
|
|
case Constants.seedWalletType: result = qsTrId("off-status-tree"); break;
|
|
|
|
//% "On Status tree"
|
|
|
|
default: result = qsTrId("on-status-tree")
|
2020-06-10 15:55:24 +00:00
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: accountColorInput.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: addressText
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Wallet address"
|
|
|
|
label: qsTrId("wallet-address")
|
2020-06-10 15:55:24 +00:00
|
|
|
text: currentAccount.address
|
2020-07-02 15:14:31 +00:00
|
|
|
fontFamily: Style.current.fontHexRegular.name
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: typeText.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: pathText
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Derivation path"
|
|
|
|
label: qsTrId("derivation-path")
|
2020-06-10 15:55:24 +00:00
|
|
|
text: currentAccount.path
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: addressText.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: storageText
|
2020-06-10 15:55:24 +00:00
|
|
|
visible: currentAccount.walletType !== Constants.watchWalletType
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Storage"
|
|
|
|
label: qsTrId("storage")
|
|
|
|
//% "This device"
|
|
|
|
text: qsTrId("this-device")
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: pathText.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
StyledButton {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: saveBtn.left
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Delete account"
|
|
|
|
label: qsTrId("delete-account")
|
2020-07-02 15:14:31 +00:00
|
|
|
btnColor: Style.current.white
|
|
|
|
textColor: Style.current.red
|
2020-06-10 20:32:04 +00:00
|
|
|
|
2020-06-10 20:21:23 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: deleteError
|
|
|
|
title: "Deleting account failed"
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
2020-06-10 20:28:24 +00:00
|
|
|
|
2020-06-10 20:21:23 +00:00
|
|
|
}
|
|
|
|
|
2020-06-10 20:28:24 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: confirmationDialog
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Are you sure?"
|
|
|
|
title: qsTrId("are-you-sure?")
|
|
|
|
//% "A deleted account cannot be retrieved later. Only press yes if you backed up your key/seed or don't care about this account anymore"
|
|
|
|
text: qsTrId("a-deleted-account-cannot-be-retrieved-later.-only-press-yes-if-you-backed-up-your-key/seed-or-don't-care-about-this-account-anymore")
|
2020-06-10 20:28:24 +00:00
|
|
|
icon: StandardIcon.Warning
|
|
|
|
standardButtons: StandardButton.Yes | StandardButton.No
|
|
|
|
onAccepted: {
|
|
|
|
const error = walletModel.deleteAccount(currentAccount.address);
|
|
|
|
if (error) {
|
2020-06-30 20:01:37 +00:00
|
|
|
errorSound.play()
|
2020-06-10 20:28:24 +00:00
|
|
|
deleteError.text = error
|
|
|
|
deleteError.open()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change active account to the first
|
|
|
|
changeSelectedAccount(0)
|
|
|
|
popup.close();
|
2020-06-10 20:21:23 +00:00
|
|
|
}
|
2020-06-10 20:28:24 +00:00
|
|
|
}
|
2020-06-10 20:21:23 +00:00
|
|
|
|
2020-06-10 20:28:24 +00:00
|
|
|
onClicked : {
|
|
|
|
confirmationDialog.open()
|
2020-06-10 20:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
StyledButton {
|
|
|
|
id: saveBtn
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
2020-07-02 15:14:31 +00:00
|
|
|
anchors.rightMargin: Style.current.padding
|
2020-07-06 20:39:55 +00:00
|
|
|
//% "Save changes"
|
|
|
|
label: qsTrId("save-changes")
|
2020-06-10 20:32:04 +00:00
|
|
|
|
|
|
|
disabled: accountNameInput.text === ""
|
|
|
|
|
2020-06-10 18:40:27 +00:00
|
|
|
MessageDialog {
|
|
|
|
id: changeError
|
|
|
|
title: "Changing settings failed"
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
|
|
|
|
2020-06-10 20:32:04 +00:00
|
|
|
onClicked : {
|
2020-06-22 18:49:58 +00:00
|
|
|
if (!validate()) {
|
|
|
|
return
|
2020-06-10 18:40:27 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 05:18:54 +00:00
|
|
|
const error = walletModel.changeAccountSettings(currentAccount.address, accountNameInput.text, accountColorInput.selectedColor);
|
2020-06-10 18:40:27 +00:00
|
|
|
|
|
|
|
if (error) {
|
2020-06-30 20:01:37 +00:00
|
|
|
errorSound.play()
|
2020-06-10 18:40:27 +00:00
|
|
|
changeError.text = error
|
|
|
|
changeError.open()
|
|
|
|
return
|
|
|
|
}
|
2020-06-10 20:32:04 +00:00
|
|
|
popup.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:500;width:400}
|
|
|
|
}
|
|
|
|
##^##*/
|