Files

215 lines
6.7 KiB
QML
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
* Copyright (C) 2021-2024 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/>.
*/
2022-11-26 10:46:57 +01:00
import QtQuick
2025-06-18 17:48:29 +02:00
import QtQuick.Controls.Basic as QQC2
2022-11-26 10:46:57 +01:00
import QtQuick.Layouts
2022-11-14 21:19:31 +01:00
import "../Flowee" as Flowee
Item {
id: root
property QtObject account: null
2025-11-12 00:18:14 +01:00
implicitHeight: column.height + 18
2026-02-12 20:11:32 +01:00
signal clicked
property int startPos: account.initialBlockHeight
2021-11-02 19:13:14 +01:00
//background
Rectangle {
2025-11-12 00:18:14 +01:00
id: background
2021-11-02 19:13:14 +01:00
property bool selected: portfolio.current === account
anchors.fill: parent
2022-08-28 22:21:14 +02:00
anchors.bottomMargin: 6
2021-11-02 19:13:14 +01:00
property bool hover: false
2022-08-28 22:21:14 +02:00
radius: 7
2025-11-12 00:18:14 +01:00
color: selected ? palette.light : palette.base
property var selectedItemGradient: Gradient {
orientation: Gradient.Horizontal
GradientStop {
2025-11-12 12:25:39 +01:00
position: Pay.useDarkSkin ? -2 : 0
color: Pay.useDarkSkin ? palette.midlight : palette.mid
2025-11-12 00:18:14 +01:00
}
GradientStop {
position: 1
color: palette.base
}
}
gradient: selected ? selectedItemGradient : undefined
border.width: 1.8
2021-11-02 19:13:14 +01:00
border.color: {
if (portfolio.current === account)
2026-02-12 20:11:32 +01:00
return Pay.useDarkSkin ? mainWindow.floweeGreen : mainWindow.floweeBlue
2021-11-02 19:13:14 +01:00
if (hover)
2026-02-12 20:11:32 +01:00
return mainWindow.floweeSalmon
2025-11-12 00:18:14 +01:00
return Pay.useDarkSkin ? "#999" : "#7b7f7f"
2021-11-02 19:13:14 +01:00
}
2025-11-12 00:18:14 +01:00
Behavior on border.color { ColorAnimation { } }
Timer {
id: startTimer
property int wavy: 0
2025-02-19 20:01:44 +01:00
running: {
if (root.account.isArchived || Pay.offline)
2026-02-12 20:11:32 +01:00
return false
2026-05-05 16:02:28 +02:00
if (root.account.needsPinToOpen && !root.account.isDecrypted)
2026-02-12 20:11:32 +01:00
return false
2025-02-19 20:01:44 +01:00
if (root.account.lastBlockSynched === root.startPos) {
if (Pay.chainHeight === root.startPos) // fresh new wallet
2026-02-12 20:11:32 +01:00
return false
return true
2025-02-19 20:01:44 +01:00
}
2026-02-12 20:11:32 +01:00
return false
2025-02-19 20:01:44 +01:00
}
interval: 300
repeat: true
onTriggered: {
2026-02-12 20:11:32 +01:00
var w = wavy
if (w >= 2)
2026-02-12 20:11:32 +01:00
wavy = 0
else
2026-02-12 20:11:32 +01:00
wavy = w + 1
}
}
Rectangle {
height: parent.height
width: {
2026-02-12 20:11:32 +01:00
let startPos = root.startPos
let end = Pay.expectedChainHeight
if (startPos == 0)
2026-02-12 20:11:32 +01:00
return 0
let currentPos = root.account.lastBlockSynched
if (currentPos === startPos) { // waiting for start
2026-02-12 20:11:32 +01:00
var wave = startTimer.wavy
if (wave > 10)
2026-02-12 20:11:32 +01:00
wave = 20 - wave
return wave * 8
}
2026-02-12 20:11:32 +01:00
let totalDistance = end - startPos
let ourProgress = currentPos - startPos
return parent.width * (ourProgress / totalDistance)
}
radius: parent.radius
border.width: parent.border.width
border.color: "#00000000"
color: mainWindow.floweeGreen
opacity: root.account.uptodate ? 0 : 0.2
Behavior on opacity { NumberAnimation {} }
Behavior on width { NumberAnimation { easing.type: Easing.InExpo; duration: startTimer.running ? 300 : 1} }
}
Rectangle {
height: parent.height
anchors.bottom: parent.bottom
width: {
2026-02-12 20:11:32 +01:00
let startPos = root.startPos
let end = Pay.expectedChainHeight
if (startPos == 0)
2026-02-12 20:11:32 +01:00
return 0
let currentPos = root.account.lastBlockSynched2
let totalDistance = end - startPos
let ourProgress = currentPos - startPos
return parent.width * (ourProgress / totalDistance)
}
radius: parent.radius
border.width: parent.border.width
border.color: "#00000000"
color: mainWindow.floweeGreen
opacity: root.account.uptodate ? 0 : 0.2
Behavior on opacity { NumberAnimation {} }
}
2021-11-02 19:13:14 +01:00
}
Column {
id: column
2022-08-28 22:21:14 +02:00
spacing: 3
x: 20
y: 6
width: parent.width // - 13
2024-05-28 23:23:31 +02:00
Flowee.Label {
text: root.account.name
font.bold: true
width: parent.width - 20
2021-07-30 21:47:15 +02:00
clip: true
}
WalletEncryptionStatus {
id: walletEncryptionStatus
width: parent.width
account: root.account
}
Flow {
width: parent.width
spacing: 10
2022-04-06 18:18:49 +02:00
visible: lastReceive.text !== "" && !root.account.isArchived
2024-05-28 23:23:31 +02:00
Flowee.Label {
2021-10-31 15:19:35 +01:00
text: qsTr("Last Transaction") + ":"
}
2024-05-28 23:23:31 +02:00
Flowee.Label {
2021-10-31 15:19:35 +01:00
id: lastReceive
2021-11-02 19:29:14 +01:00
text: Pay.formatDate(account.lastMinedTransaction)
}
2021-10-31 15:19:35 +01:00
}
2024-05-28 23:23:31 +02:00
Flowee.Label {
2022-04-06 18:18:49 +02:00
visible: root.account.isArchived
text: visible ? account.timeBehind : ""
}
}
Rectangle {
color: Pay.useDarkSkin ? mainWindow.floweeSalmon : mainWindow.floweeBlue
2022-08-28 22:21:14 +02:00
width: 7
height: 7
radius: 7
x: 12
anchors.verticalCenter: parent.verticalCenter
visible: {
if (portfolio.current === root.account)
2026-02-12 20:11:32 +01:00
return false
return root.account.hasFreshTransactions
}
}
2021-11-02 19:38:36 +01:00
Flowee.ArrowPoint {
id: point
2022-08-28 22:21:14 +02:00
x: 1.3
2026-02-12 20:11:32 +01:00
visible: portfolio.current === account
2025-11-12 00:18:14 +01:00
anchors.verticalCenter: background.verticalCenter
color: background.border.color
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
portfolio.current = account
root.clicked()
}
onEntered: background.hover = true
onExited: background.hover = false
}
AccountConfigMenu {
id: accountConfigMenu
anchors.right: parent.right
2022-08-28 22:21:14 +02:00
anchors.rightMargin: 6
y: 6
account: root.account
}
}