Files
pay/guis/desktop/Transaction.qml
T

223 lines
6.9 KiB
QML
Raw Permalink Normal View History

2020-05-24 13:20:03 +02:00
/*
* This file is part of the Flowee project
2025-01-07 00:36:51 +01:00
* Copyright (C) 2020-2025 Tom Zander <tom@flowee.org>
2020-05-24 13:20:03 +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-14 21:19:31 +01:00
import "../Flowee" as Flowee
2024-12-23 22:26:54 +01:00
import "../Utils.js" as Utils
2020-05-24 13:20:03 +02:00
2023-02-14 14:56:18 +01:00
Rectangle {
2021-11-08 19:56:05 +01:00
id: txRoot
2020-12-17 23:12:39 +01:00
height: {
var rc = mainLabel.height + 10 + date.height
2021-10-31 15:19:35 +01:00
if (detailsPane.item != null)
2024-02-11 18:34:32 +01:00
rc += detailsPane.item.height;
2020-12-17 23:12:39 +01:00
return rc;
}
2020-10-12 19:37:28 +02:00
width: mainLabel.width + bitcoinAmountLabel.width + 30
2024-01-22 17:36:09 +01:00
property int minedHeight: model.height
property bool isRejected: minedHeight === -2 // -2 is the magic block-height indicating 'rejected'
2024-12-23 22:26:54 +01:00
property bool isMoved: Utils.isMoved(model);
2021-11-08 19:56:05 +01:00
2020-05-24 13:20:03 +02:00
/*
we have
model.fundsIn the amount of satoshis consumed by inputs we own
model.fundsOut the amout of satoshis locked up in outputs we own
model.txid
model.height
model.date
2021-11-16 15:01:02 +01:00
model.isCoinbase
2023-11-06 12:23:41 +01:00
model.isFused
2021-11-16 15:01:02 +01:00
model.comment
2020-05-24 13:20:03 +02:00
*/
2021-11-02 20:07:58 +01:00
// overlay that indicates the transactions is new since last sync.
Rectangle {
id: isNewIndicator
anchors.verticalCenter: mainLabel.verticalCenter
2022-08-28 22:21:14 +02:00
width: model.isNew ? 5 : 0 // avoid taking space
2021-11-02 20:07:58 +01:00
height: width
2022-08-28 22:21:14 +02:00
radius: width
2021-11-02 20:07:58 +01:00
color: Pay.useDarkSkin ? mainWindow.floweeSalmon : mainWindow.floweeBlue
}
2024-05-28 23:23:31 +02:00
Flowee.Label {
2020-05-24 13:20:03 +02:00
id: mainLabel
2021-11-02 20:07:58 +01:00
anchors.left: isNewIndicator.right
2022-08-28 22:21:14 +02:00
anchors.leftMargin: model.isNew ? 3 : 0
2020-05-24 13:20:03 +02:00
text: {
2021-11-16 15:01:02 +01:00
if (model.isCoinbase)
return qsTr("Miner Reward")
2023-11-06 12:23:41 +01:00
if (model.isFused)
return qsTr("Fused")
2020-05-24 13:20:03 +02:00
if (model.fundsIn === 0)
return qsTr("Received")
2024-12-23 22:26:54 +01:00
if (isMoved)
2020-05-24 13:20:03 +02:00
return qsTr("Moved");
return qsTr("Sent")
}
}
2024-05-28 23:23:31 +02:00
Flowee.Label {
2020-05-24 13:20:03 +02:00
id: date
anchors.top: mainLabel.bottom
2021-11-09 20:49:37 +01:00
function updateText() {
2021-11-08 19:56:05 +01:00
if (txRoot.isRejected)
2021-11-09 20:49:37 +01:00
text = qsTr("rejected")
else
text = Pay.formatDateTime(model.date);
2020-11-04 18:59:24 +01:00
}
2024-02-11 18:34:32 +01:00
opacity: detailsPane.item === null ? 0.8 : 1;
font.pointSize: mainLabel.font.pointSize * 0.9
2022-12-14 14:41:55 +01:00
color: txRoot.isRejected ? (Pay.useDarkSkin ? "#ec2327" : "#b41214") : palette.windowText
2021-11-09 20:49:37 +01:00
2024-12-23 22:07:07 +01:00
Component.onCompleted: date.updateText()
2021-11-09 20:49:37 +01:00
Timer {
interval: 60000
running: !txRoot.isRejected
repeat: true
2024-12-23 22:07:07 +01:00
onTriggered: date.updateText()
2021-11-09 20:49:37 +01:00
}
2020-05-24 13:20:03 +02:00
}
2023-11-06 12:23:41 +01:00
Flowee.CFIcon {
2021-12-14 13:19:29 +01:00
id: fusedIcon
2023-11-06 12:23:41 +01:00
visible: model.isFused
2021-12-14 13:19:29 +01:00
anchors.right: userComment.left
2022-08-28 22:21:14 +02:00
anchors.rightMargin: 6
2021-12-14 13:19:29 +01:00
anchors.verticalCenter: userComment.verticalCenter
2022-08-28 22:21:14 +02:00
width: 16
height: 16
2021-12-14 13:19:29 +01:00
}
2024-05-28 23:23:31 +02:00
Flowee.Label {
2021-11-16 15:01:02 +01:00
id: userComment
2021-11-16 15:19:25 +01:00
y: (date.y + date.height - height) / 2
2021-11-16 15:01:02 +01:00
anchors {
// Pick the widest label to be aligned to
left: date.width > mainLabel.width ? date.right : mainLabel.right
right: bitcoinAmountLabel.left
2022-08-28 22:21:14 +02:00
leftMargin: fusedIcon.visible ? 25 : 6
2021-12-14 13:19:29 +01:00
rightMargin: 10
2021-11-16 15:01:02 +01:00
}
2021-12-04 20:09:43 +01:00
text: model.comment
2021-11-16 15:01:02 +01:00
elide: Text.ElideRight
Connections {
target: date
function onTextChanged() {
if (date.width > mainLabel.width) {
userComment.anchors.left = date.right
} else {
userComment.anchors.left = mainLabel.right
}
}
}
}
Flowee.BitcoinAmountLabel {
2020-05-24 13:20:03 +02:00
id: bitcoinAmountLabel
visible: Pay.activityShowsBch || !Pay.isMainChain
2024-02-11 18:34:32 +01:00
fiatTimestamp: model.date
2025-03-16 22:18:18 +01:00
fiatWidth: Pay.isMainChain ? 90 : 0
2021-11-21 12:19:19 +01:00
value: {
let inputs = model.fundsIn
let outputs = model.fundsOut
let diff = model.fundsOut - model.fundsIn
2023-11-06 12:23:41 +01:00
if (!model.isFused
&& diff < 0 && diff > -1000) // then the diff is likely just fees.
2021-11-21 12:19:19 +01:00
return inputs;
return diff;
}
2020-05-24 13:20:03 +02:00
anchors.top: mainLabel.top
anchors.right: parent.right
2024-12-23 22:26:54 +01:00
colorize: !isMoved
2020-05-24 13:20:03 +02:00
}
2023-03-21 22:25:41 +01:00
Flowee.Label {
anchors.top: mainLabel.top
anchors.right: parent.right
visible: bitcoinAmountLabel.visible === false
2023-03-21 22:25:41 +01:00
text: {
if (isRejected)
return "";
2024-02-11 18:34:32 +01:00
var fiatPrice = Fiat.historicalPrice(model.date);
2023-03-21 22:25:41 +01:00
return Fiat.formattedPrice(bitcoinAmountLabel.value, fiatPrice)
}
color: {
var num = bitcoinAmountLabel.value
if (num > 0) // positive value
return Pay.useDarkSkin ? "#86ffa8" : "green";
else if (num < 0) // negative
return Pay.useDarkSkin ? "#ffdede" : "#444446";
// zero is shown without normally
return palette.windowText
}
}
2025-01-07 00:36:51 +01:00
Item {
id: checks
width: row.width
height: 18
anchors.right: parent.right
anchors.top: mainLabel.bottom
property int txHeight: model.height
2025-02-24 19:53:55 +01:00
property int confirmations: Pay.chainHeight - txHeight + 1
2025-01-07 00:36:51 +01:00
visible: txHeight === -1 || confirmations < 5
Row {
id: row
height: parent.height
spacing: -3
Flowee.Label {
text: "?"
font.bold: true
font.pixelSize: 14
color: Pay.useDarkSkin ? "#5d94c7" : mainWindow.floweeBlue
visible: checks.txHeight === -1
}
Repeater {
model: {
if (checks.txHeight < 0)
return 0;
var c = checks.confirmations;
return c < 5 ? c : 0;
}
Flowee.Label {
text: "✓"
font.pixelSize: 18
color: Pay.useDarkSkin ? "#86ffa8" : "green";
}
}
}
}
2020-05-24 13:20:03 +02:00
2020-12-17 23:12:39 +01:00
MouseArea {
anchors.fill: parent
2024-02-11 18:34:32 +01:00
onClicked: detailsPane.source = (detailsPane.source == "") ? "./TransactionInfoSmall.qml" : ""
2020-12-17 23:12:39 +01:00
}
Loader {
id: detailsPane
anchors.bottom: parent.bottom
2022-08-28 22:21:14 +02:00
anchors.bottomMargin: 6
2024-02-11 18:34:32 +01:00
width: parent.width
2021-04-21 00:11:57 +02:00
onLoaded: item.infoObject = portfolio.current.txInfo(model.walletIndex, item)
2020-12-17 23:12:39 +01:00
}
Behavior on height { NumberAnimation { duration: 100 } }
2020-05-24 13:20:03 +02:00
}