2021-04-21 20:01:58 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2024-12-23 23:36:27 +01:00
|
|
|
* Copyright (C) 2021-2024 Tom Zander <tom@flowee.org>
|
2021-04-21 20:01:58 +02: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/>.
|
|
|
|
|
*/
|
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
|
2021-04-21 20:01:58 +02:00
|
|
|
|
|
|
|
|
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
|
2021-04-21 20:01:58 +02:00
|
|
|
|
2024-12-23 23:36:27 +01:00
|
|
|
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 { } }
|
2024-12-23 23:36:27 +01:00
|
|
|
|
2025-01-27 13:15:12 +01:00
|
|
|
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
|
|
|
}
|
2025-01-27 13:15:12 +01:00
|
|
|
interval: 300
|
|
|
|
|
repeat: true
|
|
|
|
|
onTriggered: {
|
2026-02-12 20:11:32 +01:00
|
|
|
var w = wavy
|
2025-01-27 13:15:12 +01:00
|
|
|
if (w >= 2)
|
2026-02-12 20:11:32 +01:00
|
|
|
wavy = 0
|
2025-01-27 13:15:12 +01:00
|
|
|
else
|
2026-02-12 20:11:32 +01:00
|
|
|
wavy = w + 1
|
2025-01-27 13:15:12 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-23 23:36:27 +01:00
|
|
|
Rectangle {
|
|
|
|
|
height: parent.height
|
|
|
|
|
width: {
|
2026-02-12 20:11:32 +01:00
|
|
|
let startPos = root.startPos
|
2024-12-23 23:36:27 +01:00
|
|
|
let end = Pay.expectedChainHeight
|
|
|
|
|
if (startPos == 0)
|
2026-02-12 20:11:32 +01:00
|
|
|
return 0
|
|
|
|
|
let currentPos = root.account.lastBlockSynched
|
2025-01-27 13:15:12 +01:00
|
|
|
if (currentPos === startPos) { // waiting for start
|
2026-02-12 20:11:32 +01:00
|
|
|
var wave = startTimer.wavy
|
2025-01-27 13:15:12 +01:00
|
|
|
if (wave > 10)
|
2026-02-12 20:11:32 +01:00
|
|
|
wave = 20 - wave
|
|
|
|
|
return wave * 8
|
2025-01-27 13:15:12 +01:00
|
|
|
}
|
2026-02-12 20:11:32 +01:00
|
|
|
let totalDistance = end - startPos
|
|
|
|
|
let ourProgress = currentPos - startPos
|
|
|
|
|
return parent.width * (ourProgress / totalDistance)
|
2024-12-23 23:36:27 +01:00
|
|
|
}
|
|
|
|
|
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 {} }
|
2025-01-27 13:15:12 +01:00
|
|
|
Behavior on width { NumberAnimation { easing.type: Easing.InExpo; duration: startTimer.running ? 300 : 1} }
|
2024-12-23 23:36:27 +01:00
|
|
|
}
|
|
|
|
|
Rectangle {
|
|
|
|
|
height: parent.height
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
width: {
|
2026-02-12 20:11:32 +01:00
|
|
|
let startPos = root.startPos
|
2024-12-23 23:36:27 +01:00
|
|
|
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)
|
2024-12-23 23:36:27 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2021-04-21 20:01:58 +02: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 {
|
2021-04-21 20:01:58 +02:00
|
|
|
text: root.account.name
|
|
|
|
|
font.bold: true
|
2022-06-19 22:30:11 +02:00
|
|
|
width: parent.width - 20
|
2021-07-30 21:47:15 +02:00
|
|
|
clip: true
|
2022-06-19 22:30:11 +02:00
|
|
|
}
|
2022-06-24 15:38:25 +02:00
|
|
|
WalletEncryptionStatus {
|
|
|
|
|
id: walletEncryptionStatus
|
2022-06-19 22:30:11 +02:00
|
|
|
width: parent.width
|
2022-06-24 15:38:25 +02:00
|
|
|
account: root.account
|
2021-04-21 20:01:58 +02:00
|
|
|
}
|
|
|
|
|
Flow {
|
2022-06-19 22:30:11 +02:00
|
|
|
width: parent.width
|
2021-04-21 20:01:58 +02:00
|
|
|
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") + ":"
|
2021-04-21 20:01:58 +02:00
|
|
|
}
|
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-04-21 20:01:58 +02:00
|
|
|
}
|
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 : ""
|
|
|
|
|
}
|
2021-04-21 20:01:58 +02:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 20:51:00 +02:00
|
|
|
Rectangle {
|
|
|
|
|
color: Pay.useDarkSkin ? mainWindow.floweeSalmon : mainWindow.floweeBlue
|
2022-08-28 22:21:14 +02:00
|
|
|
width: 7
|
|
|
|
|
height: 7
|
|
|
|
|
radius: 7
|
|
|
|
|
x: 12
|
2022-04-06 20:51:00 +02:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
|
|
visible: {
|
|
|
|
|
if (portfolio.current === root.account)
|
2026-02-12 20:11:32 +01:00
|
|
|
return false
|
2022-04-06 20:51:00 +02:00
|
|
|
|
|
|
|
|
return root.account.hasFreshTransactions
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-02 19:38:36 +01:00
|
|
|
Flowee.ArrowPoint {
|
2021-04-21 20:01:58 +02:00
|
|
|
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
|
2021-04-21 20:01:58 +02:00
|
|
|
color: background.border.color
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
hoverEnabled: true
|
2022-04-05 17:20:52 +02:00
|
|
|
onClicked: {
|
|
|
|
|
portfolio.current = account
|
|
|
|
|
root.clicked()
|
|
|
|
|
}
|
2021-04-21 20:01:58 +02:00
|
|
|
onEntered: background.hover = true
|
|
|
|
|
onExited: background.hover = false
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-18 19:08:08 +02:00
|
|
|
AccountConfigMenu {
|
|
|
|
|
id: accountConfigMenu
|
2021-04-21 20:01:58 +02:00
|
|
|
anchors.right: parent.right
|
2022-08-28 22:21:14 +02:00
|
|
|
anchors.rightMargin: 6
|
|
|
|
|
y: 6
|
2022-08-18 19:08:08 +02:00
|
|
|
account: root.account
|
2021-04-21 20:01:58 +02:00
|
|
|
}
|
|
|
|
|
}
|