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
|
|
|
|
title: qsTr("Status account settings")
|
2020-06-22 18:47:16 +00:00
|
|
|
height: 635
|
2020-06-10 20:32:04 +00:00
|
|
|
|
|
|
|
property int marginBetweenInputs: 35
|
2020-06-10 15:55:24 +00:00
|
|
|
property string selectedColor: currentAccount.iconColor
|
2020-06-10 20:32:04 +00:00
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
accountNameInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
|
|
|
|
Input {
|
|
|
|
id: accountNameInput
|
|
|
|
placeholderText: qsTr("Enter an account name...")
|
|
|
|
label: qsTr("Account name")
|
2020-06-10 15:55:24 +00:00
|
|
|
text: currentAccount.name
|
2020-06-10 20:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Select {
|
|
|
|
id: accountColorInput
|
|
|
|
anchors.top: accountNameInput.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
bgColor: selectedColor
|
|
|
|
label: qsTr("Account color")
|
|
|
|
selectOptions: Constants.accountColors.map(color => {
|
|
|
|
return {
|
|
|
|
text: "",
|
|
|
|
bgColor: color,
|
|
|
|
height: 52,
|
|
|
|
onClicked: function () {
|
|
|
|
selectedColor = color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: typeText
|
2020-06-10 15:55:24 +00:00
|
|
|
label: qsTr("Type")
|
|
|
|
text: {
|
|
|
|
var result = ""
|
|
|
|
switch (currentAccount.walletType) {
|
|
|
|
case Constants.watchWalletType: result = qsTr("Watch-only"); break;
|
|
|
|
case Constants.keyWalletType:
|
|
|
|
case Constants.seedWalletType: result = qsTr("Off Status tree"); break;
|
|
|
|
default: result = qsTr("On Status tree")
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: accountColorInput.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: addressText
|
2020-06-10 15:55:24 +00:00
|
|
|
label: qsTr("Wallet address")
|
|
|
|
text: currentAccount.address
|
2020-06-10 20:32:04 +00:00
|
|
|
anchors.top: typeText.bottom
|
|
|
|
anchors.topMargin: marginBetweenInputs
|
|
|
|
}
|
|
|
|
|
|
|
|
TextWithLabel {
|
|
|
|
id: pathText
|
2020-06-10 15:55:24 +00:00
|
|
|
label: qsTr("Derivation path")
|
|
|
|
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
|
|
|
|
label: qsTr("Storage")
|
|
|
|
text: qsTr("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
|
|
|
|
anchors.rightMargin: Theme.padding
|
2020-06-10 15:55:24 +00:00
|
|
|
label: qsTr("Delete account")
|
2020-06-10 20:32:04 +00:00
|
|
|
btnColor: Theme.white
|
|
|
|
textColor: Theme.red
|
|
|
|
|
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
|
|
|
|
title: qsTr("Are you sure?")
|
|
|
|
text: qsTr("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")
|
|
|
|
icon: StandardIcon.Warning
|
|
|
|
standardButtons: StandardButton.Yes | StandardButton.No
|
|
|
|
onAccepted: {
|
|
|
|
const error = walletModel.deleteAccount(currentAccount.address);
|
|
|
|
if (error) {
|
|
|
|
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
|
|
|
|
anchors.rightMargin: Theme.padding
|
2020-06-10 15:55:24 +00:00
|
|
|
label: qsTr("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-10 18:40:27 +00:00
|
|
|
if (accountNameInput.text === "") {
|
|
|
|
changeError.text = qsTr("Account name cannot be empty")
|
|
|
|
changeError.open()
|
|
|
|
}
|
|
|
|
|
2020-06-10 18:10:08 +00:00
|
|
|
const error = walletModel.changeAccountSettings(currentAccount.address, accountNameInput.text, selectedColor);
|
2020-06-10 18:40:27 +00:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
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}
|
|
|
|
}
|
|
|
|
##^##*/
|