2023-02-06 20:29:03 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2026-03-15 11:44:59 +01:00
|
|
|
* Copyright (C) 2022-2026 Tom Zander <tom@flowee.org>
|
2023-02-06 20:29:03 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2025-06-18 17:48:29 +02:00
|
|
|
import QtQuick.Controls.Basic as QQC2
|
2023-02-06 20:29:03 +01:00
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import "../Flowee" as Flowee
|
|
|
|
|
|
2024-12-26 19:14:17 +01:00
|
|
|
// see also AccountSelectorWidget.qml
|
2025-06-19 14:47:19 +02:00
|
|
|
Flowee.Popup {
|
2023-02-06 21:55:54 +01:00
|
|
|
id: root
|
2023-02-06 20:29:03 +01:00
|
|
|
closePolicy: QQC2.Popup.CloseOnEscape | QQC2.Popup.CloseOnPressOutsideParent
|
2024-02-03 23:36:44 +01:00
|
|
|
height: columnLayout.height + 16
|
2023-02-06 21:55:54 +01:00
|
|
|
focus: true // to allow Escape to close it
|
|
|
|
|
|
|
|
|
|
property QtObject selectedAccount: portfolio.current
|
2023-06-28 19:23:47 +02:00
|
|
|
property bool showTotalBalance: true
|
|
|
|
|
property bool showEncryptedAccounts: true
|
2026-03-15 11:44:59 +01:00
|
|
|
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
|
|
|
|
|
}
|
2023-02-06 20:29:03 +01:00
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: menuOverlay
|
2026-03-14 21:14:42 +01:00
|
|
|
function onOpenChanged() { root.close() }
|
2023-02-06 20:29:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
background: Rectangle {
|
2025-02-24 22:56:13 +01:00
|
|
|
color: palette.base
|
2023-02-21 16:40:46 +01:00
|
|
|
border.color: palette.midlight
|
2023-02-06 20:29:03 +01:00
|
|
|
border.width: 1
|
|
|
|
|
radius: 5
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-07 11:44:31 +01:00
|
|
|
Column {
|
2023-02-06 20:29:03 +01:00
|
|
|
id: columnLayout
|
|
|
|
|
width: parent.width
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
text: qsTr("Your Wallets")
|
|
|
|
|
font.bold: true
|
2026-03-15 11:44:59 +01:00
|
|
|
visible: !root.showAllWalletsEntry && portfolio.accounts.length > 1
|
2025-06-19 14:47:19 +02:00
|
|
|
x: 6
|
2023-02-06 20:29:03 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-15 11:44:59 +01:00
|
|
|
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()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-02-06 20:29:03 +01:00
|
|
|
Repeater { // portfolio holds all our accounts
|
|
|
|
|
width: parent.width
|
2023-06-28 19:23:47 +02:00
|
|
|
model: {
|
|
|
|
|
var accounts = portfolio.accounts
|
|
|
|
|
if (root.showEncryptedAccounts === false) {
|
|
|
|
|
// then we filter them out here.
|
2026-03-14 21:14:42 +01:00
|
|
|
let copy = accounts
|
|
|
|
|
accounts = []
|
2023-06-28 19:23:47 +02:00
|
|
|
for (let account of copy) {
|
|
|
|
|
if (account.isDecrypted || !account.needsPinToOpen)
|
2026-03-14 21:14:42 +01:00
|
|
|
accounts.push(account)
|
2023-06-28 19:23:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-14 21:14:42 +01:00
|
|
|
return accounts
|
2023-06-28 19:23:47 +02:00
|
|
|
}
|
2023-02-06 20:29:03 +01:00
|
|
|
delegate: Item {
|
|
|
|
|
width: columnLayout.width
|
2025-10-29 18:54:29 +01:00
|
|
|
height: ali.implicitHeight
|
|
|
|
|
AccountListItem {
|
|
|
|
|
id: ali
|
|
|
|
|
account: modelData
|
|
|
|
|
width: parent.width
|
2023-06-28 11:19:40 +02:00
|
|
|
}
|
2023-02-06 20:29:03 +01:00
|
|
|
Rectangle {
|
2023-02-14 15:31:18 +01:00
|
|
|
id: selectedItemIndicator
|
2026-03-15 11:44:59 +01:00
|
|
|
visible: !(root.showAllWalletsEntry && root.allWalletsEntrySelected) && modelData === root.selectedAccount
|
2023-02-14 15:31:18 +01:00
|
|
|
anchors.fill: parent
|
2025-02-24 22:56:13 +01:00
|
|
|
anchors.leftMargin: -10
|
|
|
|
|
anchors.rightMargin: -10
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.highlight
|
2023-02-14 18:44:53 +01:00
|
|
|
opacity: 0.15
|
|
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
height: parent.height
|
2025-06-19 14:47:19 +02:00
|
|
|
width: 5
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.highlight
|
2023-02-14 18:44:53 +01:00
|
|
|
visible: selectedItemIndicator.visible
|
2023-02-06 20:29:03 +01:00
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
onClicked: {
|
2026-03-15 14:57:30 +01:00
|
|
|
if (root.showAllWalletsEntry)
|
|
|
|
|
root.allWalletsEntrySelected = false
|
2023-02-06 21:55:54 +01:00
|
|
|
root.selectedAccount = modelData
|
2026-03-14 21:14:42 +01:00
|
|
|
root.close()
|
2023-02-06 20:29:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-28 11:19:40 +02:00
|
|
|
|
2024-02-03 23:36:44 +01:00
|
|
|
Item { width: 10; height: 10 } // spacer
|
2023-06-28 11:19:40 +02:00
|
|
|
Item {
|
|
|
|
|
width: parent.width
|
|
|
|
|
opacity: 0.8 // less bright || dark text
|
2023-06-28 19:23:47 +02:00
|
|
|
visible: !portfolio.singleAccountSetup && root.showTotalBalance
|
2023-06-28 11:19:40 +02:00
|
|
|
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") + ":"
|
2024-02-03 23:36:44 +01:00
|
|
|
font.pixelSize: root.font.pixelSize * 0.9
|
2023-06-28 11:19:40 +02:00
|
|
|
}
|
|
|
|
|
Flowee.BitcoinAmountLabel {
|
|
|
|
|
id: totalAmount
|
|
|
|
|
value: portfolio.totalBalance
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 6
|
2025-02-24 22:56:13 +01:00
|
|
|
anchors.baseline: totalLabel.baseline
|
2024-02-03 23:36:44 +01:00
|
|
|
font.pixelSize: root.font.pixelSize * 0.9
|
2023-06-28 11:19:40 +02:00
|
|
|
colorize: false
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-06 20:29:03 +01:00
|
|
|
}
|
|
|
|
|
}
|