Files

173 lines
5.5 KiB
QML
Raw Permalink Normal View History

2023-02-02 13:28:18 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2023 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
2025-06-18 17:48:29 +02:00
import QtQuick.Controls.Basic as QQC2
2023-02-02 13:28:18 +01:00
import QtQuick.Layouts
import "../Flowee" as Flowee
2026-03-14 21:14:42 +01:00
import Flowee.org.pay
2023-02-02 13:28:18 +01:00
2023-03-15 16:06:23 +01:00
/*
* This is a simple widget that is used in the AccountHistory page.
* Notice that to work it expects in the parent context to be available several things,
* among others the isMoved and amountBch values for the transaction it is displaying
*/
2023-05-06 17:51:53 +02:00
ColumnLayout {
2023-02-02 13:28:18 +01:00
id: root
2023-03-15 16:06:23 +01:00
// set by the parent page
2023-02-02 13:28:18 +01:00
property QtObject infoObject: null
2023-03-15 16:06:23 +01:00
property int minedHeight: model.height // local cache
2023-07-05 12:24:31 +02:00
Flowee.Label {
2026-03-14 21:14:42 +01:00
property bool isRejected: root.minedHeight === -2 // -2 is the magic block-height indicating 'rejected'
2023-02-02 13:28:18 +01:00
text: {
if (isRejected)
return qsTr("Transaction is rejected")
if (typeof root.minedHeight < 1)
return qsTr("Processing")
2026-03-14 21:14:42 +01:00
return ""
}
visible: text !== ""
2023-07-05 12:24:31 +02:00
color: isRejected ? mainWindow.errorRed : palette.windowText
2023-02-02 13:28:18 +01:00
}
2023-05-06 17:51:53 +02:00
GridLayout {
columns: 2
width: parent.width
Flowee.Label {
2025-02-04 12:56:12 +01:00
id: minedLabel
visible: {
2026-03-14 21:14:42 +01:00
var h = root.minedHeight
2025-02-04 12:56:12 +01:00
if (h <= 0 )
2026-03-14 21:14:42 +01:00
return false
var boringTime = Pay.formatDateTime(model.date)
2025-02-04 12:56:12 +01:00
return boringTime !== minedDateLabel.text
}
2023-05-06 17:51:53 +02:00
text: qsTr("Mined") + ":"
}
2023-05-06 17:51:53 +02:00
Flowee.Label {
2025-02-04 12:56:12 +01:00
id: minedDateLabel
2023-05-06 17:51:53 +02:00
Layout.fillWidth: true
2025-02-04 12:56:12 +01:00
visible: minedLabel.visible
2023-05-06 17:51:53 +02:00
text: {
2026-03-14 21:14:42 +01:00
var h = root.minedHeight
2025-02-14 18:18:00 +01:00
if (h <= 0)
2026-03-14 21:14:42 +01:00
return ""
var rc = Pay.formatBlockTime(h)
var confirmations = Pay.headerChainHeight - h + 1
2024-02-11 18:34:32 +01:00
if (confirmations > 0 && confirmations < 20)
2026-03-14 21:14:42 +01:00
rc += " (" + qsTr("%1 blocks ago", "Confirmations", confirmations).arg(confirmations) + ")"
return rc
2023-05-06 17:51:53 +02:00
}
}
2025-02-14 18:18:00 +01:00
Flowee.Label {
visible: text !== ""
Layout.columnSpan: 2
text: {
2026-03-14 21:14:42 +01:00
var h = root.minedHeight
2025-02-14 18:18:00 +01:00
if (h <= 0 && h !== -2)
2026-03-14 21:14:42 +01:00
return qsTr("Waiting for block")
return ""
2025-02-14 18:18:00 +01:00
}
}
2023-05-06 17:51:53 +02:00
Flowee.Label {
id: paymentTypeLabel
Layout.columnSpan: isMoved ? 2 : 1
2025-02-04 12:36:45 +01:00
visible: text !== ""
2023-05-06 17:51:53 +02:00
text: {
if (model.isCoinbase)
2026-03-14 21:14:42 +01:00
return qsTr("Miner Reward") + ":"
2023-11-06 12:23:41 +01:00
if (model.isFused)
2026-03-14 21:14:42 +01:00
return qsTr("Fees") + ":"
2023-05-06 17:51:53 +02:00
if (isMoved)
2026-03-14 21:14:42 +01:00
return qsTr("Payment to self")
2025-02-04 12:36:45 +01:00
if (Pay.activityShowsBch)
2026-03-14 21:14:42 +01:00
return ""
2025-02-04 12:36:45 +01:00
if (model.fundsIn === 0)
2026-03-14 21:14:42 +01:00
return qsTr("Received") + ":"
return qsTr("Sent") + ":"
2023-05-06 17:51:53 +02:00
}
}
Flowee.BitcoinAmountLabel {
2025-02-04 12:36:45 +01:00
visible: isMoved === false && paymentTypeLabel.visible
2023-05-06 17:51:53 +02:00
Layout.fillWidth: true
2023-05-06 19:35:47 +02:00
colorizeValue: model.fundsOut - model.fundsIn + (infoObject == null ? 0 : infoObject.fees)
value: Math.abs(colorizeValue)
2023-05-06 17:51:53 +02:00
fiatTimestamp: model.date
2025-02-04 12:36:45 +01:00
showFiat: false
2023-02-02 13:28:18 +01:00
}
}
2023-06-05 10:47:50 +02:00
Image {
sourceSize.width: 22
sourceSize.height: 22
smooth: true
visible: {
if (infoObject == null)
2026-03-14 21:14:42 +01:00
return false
2023-06-05 10:47:50 +02:00
// visible if at least one output has a token.
2026-03-14 21:14:42 +01:00
var outputs = infoObject.knownOutputs
2023-06-05 10:47:50 +02:00
for (let o of outputs) {
2023-07-05 12:24:31 +02:00
if (o !== null && o.hasCashToken)
2026-03-14 21:14:42 +01:00
return true
2023-06-05 10:47:50 +02:00
}
2026-03-14 21:14:42 +01:00
return false
2023-06-05 10:47:50 +02:00
}
source: visible ? "qrc:/CashTokens.svg" : ""
Flowee.Label {
x: 30
text: qsTr("Holds a token")
anchors.verticalCenter: parent.verticalCenter
}
}
Flowee.Label {
2023-05-06 17:51:53 +02:00
text: qsTr("Sent to") + ":"
visible: receiverName.text !== ""
}
Flowee.LabelWithClipboard {
id: receiverName
2023-05-06 19:35:47 +02:00
Layout.alignment: Qt.AlignRight
2023-05-06 17:51:53 +02:00
visible: text !== ""
text: {
if (infoObject == null)
2026-03-14 21:14:42 +01:00
return ""
if (model.fundsIn === 0)
2026-03-14 21:14:42 +01:00
return "" // skip showing this for 'received' payments.
return infoObject.receiver
}
2023-05-06 17:51:53 +02:00
font.pixelSize: paymentTypeLabel.font.pixelSize * 0.8
}
Flowee.FiatTxInfo {
txInfo: infoObject
2023-05-06 17:51:53 +02:00
width: parent.width
2023-02-02 13:28:18 +01:00
}
TextButton {
id: txDetailsButton
text: qsTr("Transaction Details")
2024-12-23 18:51:55 +01:00
pageButton: true
2023-02-02 13:28:18 +01:00
onClicked: {
2025-02-04 15:50:24 +01:00
var newItem = thePile.push("./TransactionDetails.qml", { "wallet": portfolio.current, "txIndex": root.infoObject.txIndex })
2026-03-14 21:14:42 +01:00
popupOverlay.close()
2023-02-02 13:28:18 +01:00
}
}
}