2022-02-11 09:44:49 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
2022-03-15 13:38:20 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2023-07-11 15:10:26 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-07-18 09:10:48 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-02-11 09:44:49 +00:00
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
|
|
|
import "./wallet"
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2022-02-11 09:44:49 +00:00
|
|
|
id: root
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
property var emojiPopup
|
2022-09-13 16:17:54 +00:00
|
|
|
property var rootStore
|
|
|
|
property var walletStore
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-03-15 13:38:20 +00:00
|
|
|
readonly property int mainViewIndex: 0;
|
|
|
|
readonly property int networksViewIndex: 1;
|
2023-07-11 15:10:26 +00:00
|
|
|
readonly property int editNetworksViewIndex: 2;
|
|
|
|
readonly property int accountOrderViewIndex: 3;
|
|
|
|
readonly property int accountViewIndex: 4;
|
2023-06-27 07:13:55 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
root.titleRowComponentLoader.sourceComponent = addNewAccountButtonComponent
|
|
|
|
}
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
function resetStack() {
|
2023-07-11 15:10:26 +00:00
|
|
|
if(stackContainer.currentIndex === root.editNetworksViewIndex) {
|
|
|
|
stackContainer.currentIndex = root.networksViewIndex
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stackContainer.currentIndex = mainViewIndex;
|
|
|
|
}
|
2022-03-15 13:38:20 +00:00
|
|
|
}
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackContainer
|
2022-03-02 12:54:58 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
width: root.contentWidth
|
2023-07-14 12:06:41 +00:00
|
|
|
height: stackContainer.currentIndex === root.mainViewIndex ? main.height:
|
|
|
|
stackContainer.currentIndex === root.networksViewIndex ? networksView.height:
|
|
|
|
stackContainer.currentIndex === root.editNetworksViewIndex ? editNetwork.height:
|
|
|
|
stackContainer.currentIndex === root.accountOrderViewIndex ? accountOrderView.height: accountView.height
|
2022-05-07 11:45:15 +00:00
|
|
|
currentIndex: mainViewIndex
|
2022-03-07 09:33:38 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
onCurrentIndexChanged: {
|
2022-09-13 16:17:54 +00:00
|
|
|
root.rootStore.backButtonName = ""
|
2022-05-07 11:45:15 +00:00
|
|
|
root.sectionTitle = qsTr("Wallet")
|
|
|
|
root.titleRowComponentLoader.sourceComponent = undefined
|
2023-07-11 15:10:26 +00:00
|
|
|
root.titleRowLeftComponentLoader.sourceComponent = undefined
|
|
|
|
root.titleRowLeftComponentLoader.visible = false
|
|
|
|
root.titleLayout.spacing = 5
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2023-06-27 07:13:55 +00:00
|
|
|
if (currentIndex == root.mainViewIndex) {
|
|
|
|
root.titleRowComponentLoader.sourceComponent = addNewAccountButtonComponent
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
if(currentIndex == root.networksViewIndex) {
|
2022-09-13 16:17:54 +00:00
|
|
|
root.rootStore.backButtonName = qsTr("Wallet")
|
2022-05-07 11:45:15 +00:00
|
|
|
root.sectionTitle = qsTr("Networks")
|
|
|
|
}
|
2023-07-11 15:10:26 +00:00
|
|
|
if(currentIndex == root.editNetworksViewIndex) {
|
|
|
|
root.rootStore.backButtonName = qsTr("Networks")
|
|
|
|
root.sectionTitle = qsTr("Edit %1").arg(!!editNetwork.combinedNetwork.prod && !!editNetwork.combinedNetwork.prod.chainName ? editNetwork.combinedNetwork.prod.chainName: "")
|
|
|
|
root.titleRowLeftComponentLoader.visible = true
|
|
|
|
root.titleRowLeftComponentLoader.sourceComponent = networkIcon
|
|
|
|
root.titleLayout.spacing = 12
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
else if(currentIndex == root.accountViewIndex) {
|
2022-09-13 16:17:54 +00:00
|
|
|
root.rootStore.backButtonName = qsTr("Wallet")
|
2022-05-07 11:45:15 +00:00
|
|
|
root.sectionTitle = ""
|
|
|
|
}
|
2023-06-20 11:59:15 +00:00
|
|
|
else if(currentIndex == root.accountOrderViewIndex) {
|
|
|
|
root.rootStore.backButtonName = qsTr("Wallet")
|
|
|
|
root.sectionTitle = qsTr("Edit account order")
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-04 09:09:58 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
MainView {
|
|
|
|
id: main
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-14 12:06:41 +00:00
|
|
|
Layout.fillHeight: false
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
2023-06-27 07:13:55 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
onGoToNetworksView: {
|
|
|
|
stackContainer.currentIndex = networksViewIndex
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
onGoToAccountView: {
|
2023-07-18 09:10:48 +00:00
|
|
|
root.walletStore.selectedAccount = account
|
|
|
|
accountView.keyPair = keypair
|
2022-05-07 11:45:15 +00:00
|
|
|
stackContainer.currentIndex = accountViewIndex
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
2022-03-07 09:33:38 +00:00
|
|
|
|
2023-06-20 11:59:15 +00:00
|
|
|
onGoToAccountOrderView: {
|
|
|
|
stackContainer.currentIndex = accountOrderViewIndex
|
|
|
|
}
|
2023-07-28 07:57:58 +00:00
|
|
|
onRunRenameKeypairFlow: {
|
|
|
|
renameKeypairPopup.keyUid = model.keyPair.keyUid
|
|
|
|
renameKeypairPopup.name = model.keyPair.name
|
|
|
|
renameKeypairPopup.accounts = model.keyPair.accounts
|
|
|
|
renameKeypairPopup.active = true
|
|
|
|
}
|
|
|
|
onRunRemoveKeypairFlow: {
|
|
|
|
removeKeypairPopup.name = model.keyPair.name
|
2023-08-08 19:01:19 +00:00
|
|
|
removeKeypairPopup.keyUid = model.keyPair.keyUid
|
|
|
|
removeKeypairPopup.accounts= model.keyPair.accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
removeKeypairPopup.active = true
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NetworksView {
|
2023-07-14 12:06:41 +00:00
|
|
|
id: networksView
|
2023-07-11 15:10:26 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-14 12:06:41 +00:00
|
|
|
Layout.fillHeight: false
|
2023-07-11 15:10:26 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
|
|
|
|
onGoBack: {
|
|
|
|
stackContainer.currentIndex = mainViewIndex
|
|
|
|
}
|
2023-07-11 15:10:26 +00:00
|
|
|
|
|
|
|
onEditNetwork: {
|
|
|
|
editNetwork.combinedNetwork = network
|
|
|
|
stackContainer.currentIndex = editNetworksViewIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EditNetworkView {
|
|
|
|
id: editNetwork
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
networksModule: root.walletStore.networksModule
|
|
|
|
onEvaluateRpcEndPoint: root.walletStore.evaluateRpcEndPoint(url)
|
2023-08-07 18:47:16 +00:00
|
|
|
onUpdateNetworkValues: {
|
|
|
|
root.walletStore.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl)
|
|
|
|
stackContainer.currentIndex = networksViewIndex
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
2023-06-20 11:59:15 +00:00
|
|
|
AccountOrderView {
|
2023-07-14 12:06:41 +00:00
|
|
|
id: accountOrderView
|
2023-07-11 15:10:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2023-06-20 11:59:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
onGoBack: {
|
|
|
|
stackContainer.currentIndex = mainViewIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
AccountView {
|
2023-04-17 11:36:40 +00:00
|
|
|
id: accountView
|
2023-07-18 09:10:48 +00:00
|
|
|
account: root.walletStore.selectedAccount
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
emojiPopup: root.emojiPopup
|
2023-07-18 09:10:48 +00:00
|
|
|
userProfilePublicKey: walletStore.userProfilePublicKey
|
|
|
|
onGoBack: stackContainer.currentIndex = mainViewIndex
|
|
|
|
onVisibleChanged: if(!visible) root.walletStore.selectedAccount = null
|
2023-07-28 07:57:58 +00:00
|
|
|
onRunRenameKeypairFlow: {
|
|
|
|
renameKeypairPopup.keyUid = keyPair.keyUid
|
|
|
|
renameKeypairPopup.name = keyPair.name
|
|
|
|
renameKeypairPopup.accounts = keyPair.accounts
|
|
|
|
renameKeypairPopup.active = true
|
|
|
|
}
|
|
|
|
onRunRemoveKeypairFlow: {
|
|
|
|
removeKeypairPopup.name = keyPair.name
|
2023-08-08 19:01:19 +00:00
|
|
|
removeKeypairPopup.keyUid = keyPair.keyUid
|
|
|
|
removeKeypairPopup.accounts= keyPair.accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
removeKeypairPopup.active = true
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DappPermissionsView {
|
|
|
|
walletStore: root.walletStore
|
|
|
|
}
|
2022-03-04 09:09:58 +00:00
|
|
|
|
2023-06-27 07:13:55 +00:00
|
|
|
Component {
|
|
|
|
id: addNewAccountButtonComponent
|
|
|
|
StatusButton {
|
2023-07-26 10:23:27 +00:00
|
|
|
objectName: "settings_Wallet_MainView_AddNewAccountButton"
|
2023-06-27 07:13:55 +00:00
|
|
|
text: qsTr("Add new account")
|
|
|
|
onClicked: root.walletStore.runAddAccountPopup()
|
|
|
|
}
|
|
|
|
}
|
2023-07-11 15:10:26 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: networkIcon
|
|
|
|
StatusRoundedImage {
|
|
|
|
width: 28
|
|
|
|
height: 28
|
|
|
|
image.source: Style.svg(!!editNetwork.combinedNetwork.prod && !!editNetwork.combinedNetwork.prod.iconUrl ? editNetwork.combinedNetwork.prod.iconUrl: "")
|
|
|
|
image.fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
|
|
|
}
|
2023-07-28 07:57:58 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: renameKeypairPopup
|
|
|
|
active: false
|
|
|
|
|
|
|
|
property string keyUid
|
|
|
|
property string name
|
|
|
|
property var accounts
|
|
|
|
|
|
|
|
sourceComponent: RenameKeypairPopup {
|
|
|
|
accountsModule: root.walletStore.accountsModule
|
|
|
|
keyUid: renameKeypairPopup.keyUid
|
|
|
|
name: renameKeypairPopup.name
|
|
|
|
accounts: renameKeypairPopup.accounts
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
renameKeypairPopup.active = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
renameKeypairPopup.item.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: removeKeypairPopup
|
|
|
|
active: false
|
|
|
|
|
|
|
|
property string name
|
2023-08-08 19:01:19 +00:00
|
|
|
property string keyUid
|
|
|
|
property var accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
|
2023-08-08 19:01:19 +00:00
|
|
|
sourceComponent: RemoveKeypairPopup {
|
|
|
|
name: removeKeypairPopup.name
|
|
|
|
relatedAccounts: removeKeypairPopup.accounts
|
|
|
|
getNetworkShortNames: function(chainIds) {return root.walletStore.getNetworkShortNames(chainIds)}
|
|
|
|
onClosed: removeKeypairPopup.active = false
|
|
|
|
onConfirmClicked: {
|
2023-07-28 07:57:58 +00:00
|
|
|
root.walletStore.deleteKeypair(removeKeypairPopup.keyUid)
|
|
|
|
removeKeypairPopup.active = false
|
|
|
|
}
|
|
|
|
}
|
2023-08-08 19:01:19 +00:00
|
|
|
onLoaded: removeKeypairPopup.item.open()
|
2023-07-28 07:57:58 +00:00
|
|
|
}
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
2022-04-13 10:10:51 +00:00
|
|
|
}
|