2021-10-05 20:50:22 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2023-01-05 12:50:55 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-07-14 11:03:36 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
2023-03-30 12:55:07 +00:00
|
|
|
import shared.popups 1.0
|
2022-10-27 09:26:34 +00:00
|
|
|
import shared.popups.keycard 1.0
|
2023-03-15 09:17:25 +00:00
|
|
|
import shared.stores 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../stores"
|
2023-03-22 15:48:44 +00:00
|
|
|
import "../addaccount"
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-02-09 09:43:23 +00:00
|
|
|
Rectangle {
|
2022-07-18 10:39:31 +00:00
|
|
|
id: root
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "walletLeftTab"
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-04-04 11:31:04 +00:00
|
|
|
property var networkConnectionStore
|
2023-05-12 07:11:44 +00:00
|
|
|
property var selectAllAccounts: function(){}
|
2021-10-05 20:50:22 +00:00
|
|
|
property var changeSelectedAccount: function(){}
|
2023-01-05 12:50:55 +00:00
|
|
|
property bool showSavedAddresses: false
|
2023-05-12 07:11:44 +00:00
|
|
|
property bool showAllAccounts: true
|
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
onShowSavedAddressesChanged: {
|
2023-05-12 07:11:44 +00:00
|
|
|
walletAccountsListView.headerItem.highlighted = root.showAllAccounts
|
|
|
|
walletAccountsListView.footerItem.button.highlighted = root.showSavedAddresses
|
|
|
|
}
|
|
|
|
|
|
|
|
onShowAllAccountsChanged: {
|
|
|
|
walletAccountsListView.headerItem.highlighted = root.showAllAccounts
|
|
|
|
walletAccountsListView.footerItem.button.highlighted = root.showSavedAddresses
|
|
|
|
selectAllAccounts()
|
2023-01-05 12:50:55 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
property var emojiPopup: null
|
2021-10-05 20:50:22 +00:00
|
|
|
|
|
|
|
color: Style.current.secondaryMenuBackground
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
Loader {
|
|
|
|
id: addAccount
|
|
|
|
active: false
|
|
|
|
asynchronous: true
|
|
|
|
|
|
|
|
sourceComponent: AddAccountPopup {
|
2023-03-28 13:47:54 +00:00
|
|
|
store.emojiPopup: root.emojiPopup
|
|
|
|
store.addAccountModule: walletSection.addAccountModule
|
2023-03-22 15:48:44 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
addAccount.item.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-27 12:49:32 +00:00
|
|
|
Loader {
|
|
|
|
id: walletBckgAccountContextMenu
|
|
|
|
sourceComponent: AccountContextMenu {
|
2023-04-13 10:27:56 +00:00
|
|
|
|
|
|
|
uniqueIdentifier: "wallet-background"
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
walletBckgAccountContextMenu.active = false
|
|
|
|
}
|
|
|
|
|
2023-03-27 12:49:32 +00:00
|
|
|
onAddNewAccountClicked: {
|
|
|
|
RootStore.runAddAccountPopup()
|
|
|
|
}
|
|
|
|
|
|
|
|
onAddWatchOnlyAccountClicked: {
|
|
|
|
RootStore.runAddWatchOnlyAccountPopup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-30 12:55:07 +00:00
|
|
|
Loader {
|
|
|
|
id: removeAccountConfirmation
|
|
|
|
active: false
|
|
|
|
|
|
|
|
property bool simple
|
|
|
|
property string accountKeyUid
|
|
|
|
property string accountName
|
|
|
|
property string accountAddress
|
|
|
|
property string accountDerivationPath
|
|
|
|
|
|
|
|
sourceComponent: RemoveAccountConfirmationPopup {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: 400
|
|
|
|
|
|
|
|
simple: removeAccountConfirmation.simple
|
|
|
|
accountName: removeAccountConfirmation.accountName
|
|
|
|
accountAddress: removeAccountConfirmation.accountAddress
|
|
|
|
accountDerivationPath: removeAccountConfirmation.accountDerivationPath
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
removeAccountConfirmation.active = false
|
|
|
|
}
|
|
|
|
|
|
|
|
onRemoveAccount: {
|
|
|
|
close()
|
2023-05-04 14:34:00 +00:00
|
|
|
RootStore.deleteAccount(address)
|
2023-03-30 12:55:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
removeAccountConfirmation.item.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
Connections {
|
|
|
|
target: walletSection
|
|
|
|
|
|
|
|
function onDisplayAddAccountPopup() {
|
|
|
|
addAccount.active = true
|
|
|
|
}
|
|
|
|
function onDestroyAddAccountPopup() {
|
|
|
|
addAccount.active = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-27 12:49:32 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
walletBckgAccountContextMenu.active = true
|
|
|
|
walletBckgAccountContextMenu.item.popup(mouse.x, mouse.y)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-18 10:39:31 +00:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: Style.current.padding
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
Item {
|
2022-07-18 10:39:31 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-05 12:50:55 +00:00
|
|
|
Layout.preferredHeight: walletTitleText.height
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
|
2023-03-27 12:49:32 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
onClicked: {
|
|
|
|
mouse.accepted = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: walletTitleText
|
|
|
|
text: qsTr("Wallet")
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: 17
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
objectName: "addAccountButton"
|
|
|
|
icon.name: "add-circle"
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.smallPadding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
width: height
|
|
|
|
height: parent.height * 2
|
|
|
|
color: hovered || highlighted ? Theme.palette.primaryColor3
|
|
|
|
: "transparent"
|
2023-03-22 15:48:44 +00:00
|
|
|
onClicked: RootStore.runAddAccountPopup()
|
2023-01-05 12:50:55 +00:00
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
StatusListView {
|
2023-01-05 12:50:55 +00:00
|
|
|
id: walletAccountsListView
|
|
|
|
|
2022-10-21 07:17:48 +00:00
|
|
|
objectName: "walletAccountsListView"
|
2022-07-14 11:03:36 +00:00
|
|
|
spacing: Style.current.smallPadding
|
2022-07-18 10:39:31 +00:00
|
|
|
Layout.fillWidth: true
|
2022-07-19 15:36:09 +00:00
|
|
|
Layout.fillHeight: true
|
2022-07-18 10:39:31 +00:00
|
|
|
Layout.topMargin: Style.current.halfPadding
|
|
|
|
|
2022-07-20 14:54:30 +00:00
|
|
|
// ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
readonly property Item firstItem: count > 0 ? itemAtIndex(0) : null
|
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
delegate: StatusListItem {
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "walletAccount-" + model.name
|
|
|
|
readonly property bool itemLoaded: !model.assetsLoading // needed for e2e tests
|
2023-01-05 12:50:55 +00:00
|
|
|
width: ListView.view.width - Style.current.padding * 2
|
|
|
|
highlighted: !ListView.view.footerItem.button.highlighted &&
|
2023-04-25 16:54:50 +00:00
|
|
|
RootStore.overview.name === model.name
|
2023-02-15 14:55:16 +00:00
|
|
|
anchors.horizontalCenter: !!parent ? parent.horizontalCenter : undefined
|
2022-07-14 11:03:36 +00:00
|
|
|
title: model.name
|
2023-01-08 22:23:51 +00:00
|
|
|
subTitle: LocaleUtils.currencyAmountToLocaleString(model.currencyBalance)
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.emoji: !!model.emoji ? model.emoji: ""
|
|
|
|
asset.color: model.color
|
|
|
|
asset.name: !model.emoji ? "filled-account": ""
|
2023-01-05 12:50:55 +00:00
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.letterSize: 14
|
|
|
|
asset.isLetterIdenticon: !!model.emoji ? true : false
|
|
|
|
asset.bgColor: Theme.palette.primaryColor3
|
2022-07-14 11:03:36 +00:00
|
|
|
statusListItemTitle.font.weight: Font.Medium
|
|
|
|
color: sensor.containsMouse || highlighted ? Theme.palette.baseColor3 : "transparent"
|
2023-04-25 16:54:50 +00:00
|
|
|
statusListItemSubTitle.loading: !!model.assetsLoading
|
2023-03-23 10:23:02 +00:00
|
|
|
errorMode: networkConnectionStore.accountBalanceNotAvailable
|
2023-03-15 09:17:25 +00:00
|
|
|
errorIcon.tooltip.maxWidth: 300
|
2023-03-23 10:23:02 +00:00
|
|
|
errorIcon.tooltip.text: networkConnectionStore.accountBalanceNotAvailableText
|
2022-07-14 11:03:36 +00:00
|
|
|
onClicked: {
|
2023-03-27 12:49:32 +00:00
|
|
|
if (mouse.button === Qt.RightButton) {
|
|
|
|
accountContextMenu.active = true
|
|
|
|
accountContextMenu.item.popup(mouse.x, mouse.y)
|
|
|
|
return
|
|
|
|
}
|
2023-05-12 07:11:44 +00:00
|
|
|
root.showSavedAddresses = false
|
|
|
|
root.showAllAccounts = false
|
2023-04-27 13:22:27 +00:00
|
|
|
changeSelectedAccount(model.address)
|
2022-03-28 08:19:57 +00:00
|
|
|
}
|
2023-01-05 12:50:55 +00:00
|
|
|
components: [
|
|
|
|
StatusIcon {
|
2023-04-18 16:05:24 +00:00
|
|
|
width: !!icon ? 15: 0
|
|
|
|
height: !!icon ? 15: 0
|
2023-01-05 12:50:55 +00:00
|
|
|
color: Theme.palette.directColor1
|
2023-04-18 16:05:24 +00:00
|
|
|
icon: model.walletType === Constants.watchWalletType ? "show" : ""
|
|
|
|
},
|
|
|
|
StatusIcon {
|
|
|
|
width: !!icon ? 15: 0
|
|
|
|
height: !!icon ? 15: 0
|
|
|
|
color: Theme.palette.directColor1
|
2023-05-24 09:15:44 +00:00
|
|
|
icon: model.keycardAccount ? "keycard" : ""
|
2023-01-05 12:50:55 +00:00
|
|
|
}
|
|
|
|
]
|
2023-03-27 12:49:32 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: accountContextMenu
|
|
|
|
sourceComponent: AccountContextMenu {
|
2023-04-13 10:27:56 +00:00
|
|
|
|
|
|
|
uniqueIdentifier: model.name
|
2023-03-27 12:49:32 +00:00
|
|
|
account: model
|
|
|
|
|
2023-04-13 10:27:56 +00:00
|
|
|
onClosed: {
|
|
|
|
accountContextMenu.active = false
|
|
|
|
}
|
|
|
|
|
2023-03-27 12:49:32 +00:00
|
|
|
onEditAccountClicked: {
|
2023-03-30 13:00:55 +00:00
|
|
|
RootStore.runEditAccountPopup(model.address)
|
2023-03-27 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteAccountClicked: {
|
2023-03-30 12:55:07 +00:00
|
|
|
removeAccountConfirmation.simple = model.walletType === Constants.watchWalletType || model.walletType === Constants.keyWalletType
|
|
|
|
removeAccountConfirmation.accountName = model.name
|
|
|
|
removeAccountConfirmation.accountAddress = model.address
|
|
|
|
removeAccountConfirmation.accountDerivationPath = model.path
|
|
|
|
removeAccountConfirmation.active = true
|
2023-03-27 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onAddNewAccountClicked: {
|
|
|
|
RootStore.runAddAccountPopup()
|
|
|
|
}
|
|
|
|
|
|
|
|
onAddWatchOnlyAccountClicked: {
|
|
|
|
RootStore.runAddWatchOnlyAccountPopup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
}
|
2022-03-28 08:19:57 +00:00
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
readonly property bool footerOverlayed: contentHeight > availableHeight
|
|
|
|
|
2023-05-12 07:11:44 +00:00
|
|
|
header: Button {
|
|
|
|
id: header
|
|
|
|
verticalPadding: Style.current.padding
|
|
|
|
horizontalPadding: Style.current.padding
|
|
|
|
highlighted: true
|
|
|
|
|
|
|
|
leftInset: Style.current.padding
|
|
|
|
bottomInset: Style.current.padding
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
MouseArea {
|
|
|
|
id: mouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
root.showSavedAddresses = false
|
|
|
|
root.showAllAccounts = true
|
|
|
|
}
|
|
|
|
hoverEnabled: true
|
|
|
|
}
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: header.highlighted || mouseArea.containsMouse ? Style.current.backgroundHover : root.color
|
|
|
|
implicitWidth: parent.ListView.view.width - Style.current.padding * 2
|
|
|
|
implicitHeight: parent.ListView.view.firstItem.height + Style.current.padding
|
|
|
|
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: -10
|
|
|
|
radius: 20
|
|
|
|
samples: 41
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: Theme.palette.dropShadow2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
StatusBaseText {
|
|
|
|
id: allAccounts
|
|
|
|
leftPadding: Style.current.padding
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: qsTr("All accounts")
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusTextWithLoadingState {
|
|
|
|
id: walletAmountValue
|
|
|
|
objectName: "walletLeftListAmountValue"
|
|
|
|
customColor: Style.current.textColor
|
|
|
|
text: {
|
|
|
|
LocaleUtils.currencyAmountToLocaleString(RootStore.totalCurrencyBalance)
|
|
|
|
}
|
|
|
|
font.pixelSize: 22
|
|
|
|
loading: RootStore.assetsLoading
|
|
|
|
visible: !networkConnectionStore.accountBalanceNotAvailable
|
|
|
|
anchors.top: allAccounts.bottom
|
|
|
|
anchors.topMargin: 4
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
leftPadding: Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusFlatRoundButton {
|
|
|
|
id: errorIcon
|
|
|
|
width: 14
|
|
|
|
height: visible ? 14 : 0
|
|
|
|
icon.width: 14
|
|
|
|
icon.height: 14
|
|
|
|
icon.name: "tiny/warning"
|
|
|
|
icon.color: Theme.palette.dangerColor1
|
|
|
|
tooltip.text: networkConnectionStore.accountBalanceNotAvailableText
|
|
|
|
tooltip.maxWidth: 200
|
|
|
|
visible: networkConnectionStore.accountBalanceNotAvailable
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-05 12:50:55 +00:00
|
|
|
footerPositioning: footerOverlayed ? ListView.OverlayFooter : ListView.InlineFooter
|
|
|
|
footer: Control {
|
|
|
|
id: footer
|
|
|
|
|
|
|
|
z: 2 // to be on top of delegates when in ListView.OverlayFooter
|
|
|
|
horizontalPadding: Style.current.padding
|
|
|
|
verticalPadding: Style.current.padding
|
|
|
|
|
|
|
|
property alias button: savedAddressesBtn
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: root.color
|
|
|
|
implicitWidth: root.width
|
|
|
|
implicitHeight: parent.ListView.view.firstItem.height + Style.current.xlPadding
|
|
|
|
|
|
|
|
layer.enabled: parent.ListView.view.footerOverlayed
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: -10
|
|
|
|
radius: 20
|
|
|
|
samples: 41
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: Theme.palette.dropShadow2
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusMenuSeparator {
|
|
|
|
id: footerSeparator
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
visible: !footer.ListView.view.footerOverlayed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: StatusButton {
|
|
|
|
id: savedAddressesBtn
|
|
|
|
|
|
|
|
objectName: "savedAddressesBtn"
|
|
|
|
size: StatusBaseButton.Size.Large
|
|
|
|
normalColor: "transparent"
|
|
|
|
hoverColor: Theme.palette.primaryColor3
|
|
|
|
asset.color: Theme.palette.primaryColor1
|
|
|
|
asset.bgColor: Theme.palette.primaryColor3
|
2022-07-14 11:03:36 +00:00
|
|
|
font.weight: Font.Medium
|
2023-01-05 12:50:55 +00:00
|
|
|
text: qsTr("Saved addresses")
|
|
|
|
icon.name: "address"
|
|
|
|
icon.width: 40
|
|
|
|
icon.height: 40
|
|
|
|
isRoundIcon: true
|
|
|
|
textColor: Theme.palette.directColor1
|
|
|
|
textAlignment: Qt.AlignVCenter | Qt.AlignLeft
|
|
|
|
textFillWidth: true
|
|
|
|
spacing: parent.ListView.view.firstItem.statusListItemTitleArea.anchors.leftMargin
|
|
|
|
onClicked: {
|
2023-05-12 07:11:44 +00:00
|
|
|
root.showAllAccounts = false
|
|
|
|
root.showSavedAddresses = true
|
2023-01-05 12:50:55 +00:00
|
|
|
}
|
2023-03-27 12:49:32 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
acceptedButtons: Qt.RightButton
|
2023-05-12 07:11:44 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2023-03-27 12:49:32 +00:00
|
|
|
propagateComposedEvents: true
|
|
|
|
onClicked: {
|
|
|
|
mouse.accepted = true
|
|
|
|
}
|
|
|
|
}
|
2022-07-18 10:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
|
|
|
|
model: RootStore.accounts
|
2022-07-18 10:39:31 +00:00
|
|
|
}
|
2022-03-01 10:14:13 +00:00
|
|
|
}
|
2022-07-26 18:46:07 +00:00
|
|
|
}
|