ac74aa90bb
Only show fungible token UTXOs that actually are in the selected wallet.
186 lines
6.3 KiB
QML
186 lines
6.3 KiB
QML
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2022-2026 Tom Zander <tom@flowee.org>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
import QtQuick
|
|
import QtQuick.Controls.Basic as QQC2
|
|
import QtQuick.Layouts
|
|
import "../Flowee" as Flowee
|
|
|
|
// see also AccountSelectorWidget.qml
|
|
Flowee.Popup {
|
|
id: root
|
|
closePolicy: QQC2.Popup.CloseOnEscape | QQC2.Popup.CloseOnPressOutsideParent
|
|
height: columnLayout.height + 16
|
|
focus: true // to allow Escape to close it
|
|
|
|
property QtObject selectedAccount: portfolio.current
|
|
property bool showTotalBalance: true
|
|
property bool showEncryptedAccounts: true
|
|
property bool showAllWalletsEntry: false
|
|
property bool allWalletsEntrySelected: false
|
|
/// the name of the currently selected entry.
|
|
property string selectedName: {
|
|
if (showAllWalletsEntry && allWalletsEntrySelected)
|
|
return title.text
|
|
return selectedAccount.name
|
|
}
|
|
|
|
Connections {
|
|
target: menuOverlay
|
|
function onOpenChanged() { root.close() }
|
|
}
|
|
|
|
background: Rectangle {
|
|
color: palette.base
|
|
border.color: palette.midlight
|
|
border.width: 1
|
|
radius: 5
|
|
}
|
|
|
|
Column {
|
|
id: columnLayout
|
|
width: parent.width
|
|
Flowee.Label {
|
|
text: qsTr("Your Wallets")
|
|
font.bold: true
|
|
visible: !root.showAllWalletsEntry && portfolio.accounts.length > 1
|
|
x: 6
|
|
}
|
|
|
|
Item {
|
|
width: columnLayout.width
|
|
visible: root.showAllWalletsEntry
|
|
height: title.height + subTitle.height + 6 * 3
|
|
Flowee.Label {
|
|
id: title
|
|
x: 6
|
|
y: 6
|
|
width: parent.width - 12
|
|
text: qsTr("All Wallets")
|
|
elide: Text.ElideRight
|
|
}
|
|
Flowee.Label {
|
|
id: subTitle
|
|
x: 6
|
|
width: parent.width - 12
|
|
anchors.top: title.bottom
|
|
anchors.topMargin: 6
|
|
text: qsTr("Combining all your wallets")
|
|
elide: Text.ElideRight
|
|
font.pixelSize: title.font.pixelSize * 0.8
|
|
}
|
|
Rectangle {
|
|
visible: root.allWalletsEntrySelected
|
|
anchors.fill: parent
|
|
anchors.leftMargin: -10
|
|
anchors.rightMargin: -10
|
|
color: palette.highlight
|
|
opacity: 0.15
|
|
}
|
|
Rectangle {
|
|
height: parent.height
|
|
width: 5
|
|
color: palette.highlight
|
|
visible: root.allWalletsEntrySelected
|
|
}
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
root.allWalletsEntrySelected = true
|
|
root.close()
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
Repeater { // portfolio holds all our accounts
|
|
width: parent.width
|
|
model: {
|
|
var accounts = portfolio.accounts
|
|
if (root.showEncryptedAccounts === false) {
|
|
// then we filter them out here.
|
|
let copy = accounts
|
|
accounts = []
|
|
for (let account of copy) {
|
|
if (account.isDecrypted || !account.needsPinToOpen)
|
|
accounts.push(account)
|
|
}
|
|
}
|
|
return accounts
|
|
}
|
|
delegate: Item {
|
|
width: columnLayout.width
|
|
height: ali.implicitHeight
|
|
AccountListItem {
|
|
id: ali
|
|
account: modelData
|
|
width: parent.width
|
|
}
|
|
Rectangle {
|
|
id: selectedItemIndicator
|
|
visible: !(root.showAllWalletsEntry && root.allWalletsEntrySelected) && modelData === root.selectedAccount
|
|
anchors.fill: parent
|
|
anchors.leftMargin: -10
|
|
anchors.rightMargin: -10
|
|
color: palette.highlight
|
|
opacity: 0.15
|
|
}
|
|
Rectangle {
|
|
height: parent.height
|
|
width: 5
|
|
color: palette.highlight
|
|
visible: selectedItemIndicator.visible
|
|
}
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
if (root.showAllWalletsEntry)
|
|
root.allWalletsEntrySelected = false
|
|
root.selectedAccount = modelData
|
|
root.close()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Item { width: 10; height: 10 } // spacer
|
|
Item {
|
|
width: parent.width
|
|
opacity: 0.8 // less bright || dark text
|
|
visible: !portfolio.singleAccountSetup && root.showTotalBalance
|
|
implicitHeight: 5 + totalLabel.implicitHeight +
|
|
(totalLabel.width + 6 + 6 + totalAmount.width + 6 > width
|
|
? totalAmount.implicitHeight : 0)
|
|
Flowee.Label {
|
|
id: totalLabel
|
|
x: 6
|
|
text: qsTr("Balance Total") + ":"
|
|
font.pixelSize: root.font.pixelSize * 0.9
|
|
}
|
|
Flowee.BitcoinAmountLabel {
|
|
id: totalAmount
|
|
value: portfolio.totalBalance
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 6
|
|
anchors.baseline: totalLabel.baseline
|
|
font.pixelSize: root.font.pixelSize * 0.9
|
|
colorize: false
|
|
}
|
|
}
|
|
}
|
|
}
|