Files
pay/guis/desktop/WalletTransactionDetails.qml
T

250 lines
9.7 KiB
QML
Raw Permalink Normal View History

2020-12-17 23:12:39 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2020-2021 Tom Zander <tom@flowee.org>
2020-12-17 23:12:39 +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/>.
*/
2022-11-26 10:46:57 +01:00
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
2022-11-14 21:19:31 +01:00
import "../Flowee" as Flowee
2020-12-17 23:12:39 +01:00
GridLayout {
id: root
property QtObject infoObject: null
2022-08-12 21:22:04 +02:00
property var minedDate: model.date
2020-12-17 23:12:39 +01:00
columns: 2
Flowee.LabelWithClipboard {
menuText: qsTr("Copy transaction-ID")
2020-12-17 23:12:39 +01:00
Layout.columnSpan: 2
text: model.txid
2022-09-08 17:34:36 +02:00
font.pixelSize: 12
2020-12-17 23:12:39 +01:00
}
Label {
2021-01-29 10:27:24 +01:00
text: qsTr("Status") + ":"
2020-12-17 23:12:39 +01:00
}
Flowee.LabelWithClipboard {
2020-12-25 22:26:33 +01:00
id: rightColumn
Layout.fillWidth: true
2020-12-17 23:12:39 +01:00
text: {
2021-11-08 19:56:05 +01:00
if (txRoot.isRejected)
return qsTr("rejected")
2022-08-12 21:22:04 +02:00
if (typeof root.minedDate === "undefined")
2020-12-17 23:12:39 +01:00
return qsTr("unconfirmed")
2021-11-02 19:29:14 +01:00
var confirmations = Pay.headerChainHeight - model.height + 1;
2021-01-31 20:59:53 +01:00
return qsTr("%1 confirmations (mined in block %2)", "", confirmations)
.arg(confirmations).arg(model.height);
2020-12-17 23:12:39 +01:00
}
clipboardText: model.height
2021-12-09 19:46:22 +01:00
menuText: qsTr("Copy block height")
2020-12-17 23:12:39 +01:00
}
Label {
2021-12-04 20:09:43 +01:00
id: paymentTypeLabel
visible: {
let diff = model.fundsOut - model.fundsIn;
if (diff < 0 && diff > -1000) // this is our heuristic to mark it as 'moved'
return false;
return true;
}
2021-01-28 22:56:33 +01:00
text: mainLabel.text + ":"
2020-12-17 23:12:39 +01:00
}
Flowee.BitcoinAmountLabel {
2021-12-04 20:09:43 +01:00
visible: paymentTypeLabel.visible
2023-02-20 18:10:35 +01:00
value: model.fundsOut - model.fundsIn + infoObject.fees
2022-08-12 21:22:04 +02:00
fiatTimestamp: root.minedDate
2020-12-17 23:12:39 +01:00
}
2021-12-04 20:09:43 +01:00
Label {
id: feesLabel
visible: infoObject.createdByUs
text: qsTr("Fees") + ":"
}
Flowee.BitcoinAmountLabel {
visible: feesLabel.visible
2023-02-20 18:10:35 +01:00
value: infoObject.fees;
2022-08-12 21:22:04 +02:00
fiatTimestamp: root.minedDate
2021-12-04 20:09:43 +01:00
colorize: false
}
2020-12-17 23:12:39 +01:00
Label {
2021-01-29 10:27:24 +01:00
text: qsTr("Size") + ":"
2020-12-17 23:12:39 +01:00
}
Label {
2021-01-29 10:27:24 +01:00
text: qsTr("%1 bytes", "", infoObject.size).arg(infoObject.size)
2020-12-17 23:12:39 +01:00
}
Label {
2021-01-29 10:27:24 +01:00
text: qsTr("Inputs") + ":"
2020-12-25 22:26:33 +01:00
Layout.alignment: Qt.AlignTop
visible: infoObject.inputs.length > 0
2020-12-17 23:12:39 +01:00
}
ColumnLayout {
2020-12-25 22:26:33 +01:00
Layout.fillWidth: true
2020-12-17 23:12:39 +01:00
Repeater {
model: infoObject.inputs
delegate:
2020-12-25 22:26:33 +01:00
Item {
width: rightColumn.width
2022-08-28 22:21:14 +02:00
height: modelData === null ? 6 : (5 + inAddress.height)
2021-11-02 19:38:36 +01:00
Flowee.ArrowPoint {
2020-12-25 22:26:33 +01:00
id: arrowPoint
anchors.bottom: parent.bottom
color: arrowLine.color
}
Rectangle {
id: arrowLine
color: modelData === null ? "grey" : "#c5c537"
anchors.left: arrowPoint.right
anchors.leftMargin: -2 // overlap the line and the arrow
anchors.bottom: arrowPoint.bottom
2022-08-28 22:21:14 +02:00
anchors.bottomMargin: 6
2020-12-25 22:26:33 +01:00
anchors.right: parent.horizontalCenter
2022-08-28 22:21:14 +02:00
height: 1.6
2020-12-25 22:26:33 +01:00
}
Label {
id: inIndex
text: index
visible: modelData !== null
anchors.left: arrowPoint.right
2022-08-28 22:21:14 +02:00
anchors.leftMargin: 6
2020-12-25 22:26:33 +01:00
anchors.bottom: arrowLine.top
}
Rectangle {
2021-11-02 19:29:14 +01:00
color: Pay.useDarkSkin ? "#4fb2e7" : "yellow"
2020-12-25 22:26:33 +01:00
visible: inAddress.visible
x: inAddress.x - 3
y: inAddress.y -3
height: inAddress.height + 6
width: Math.min(inAddress.width, inAddress.contentWidth) + 6
radius: height / 3
opacity: 0.2
}
Flowee.LabelWithClipboard {
2020-12-25 22:26:33 +01:00
id: inAddress
menuText: qsTr("Copy Address")
text: {
if (modelData === null)
return "";
var cloaked = modelData.cloakedAddress
if (cloaked !== "")
return cloaked;
return modelData.address;
}
clipboardText: modelData === null ? "" : modelData.address
2020-12-25 22:26:33 +01:00
visible: modelData !== null
anchors.bottom: arrowLine.top
2020-12-25 22:26:33 +01:00
anchors.left: inIndex.right
2022-08-28 22:21:14 +02:00
anchors.leftMargin: 6
2020-12-25 22:26:33 +01:00
anchors.right: amount.left
2022-08-28 22:21:14 +02:00
anchors.rightMargin: 10
2020-12-25 22:26:33 +01:00
}
Flowee.BitcoinAmountLabel {
2020-12-25 22:26:33 +01:00
id: amount
visible: modelData !== null
value: modelData === null ? 0 : (-1 * modelData.value)
2022-08-12 21:22:04 +02:00
fiatTimestamp: root.minedDate
2020-12-25 22:26:33 +01:00
anchors.right: parent.right
anchors.bottom: arrowLine.top
}
2020-12-17 23:12:39 +01:00
}
}
}
Label {
2021-01-29 10:27:24 +01:00
text: qsTr("Outputs") + ":"
2020-12-25 22:26:33 +01:00
Layout.alignment: Qt.AlignTop
visible: infoObject.outputs.length > 0
2020-12-17 23:12:39 +01:00
}
ColumnLayout {
2020-12-25 22:26:33 +01:00
Layout.fillWidth: true
2020-12-17 23:12:39 +01:00
Repeater {
model: infoObject.outputs
delegate:
2020-12-25 22:26:33 +01:00
Item {
width: rightColumn.width
2022-08-28 22:21:14 +02:00
height: modelData === null ? 6 : (5 + outAddress.height)
2020-12-25 22:26:33 +01:00
Rectangle {
id: outArrowLine
/*
* There can be a nullptr, which means there is no info about this output.
* Then we have a bool 'forMe' which indicates the money goes to me or to
* someone else. Lets make the 'me' one the most visible one.
*/
color: modelData === null ? "grey" : (modelData.forMe ? "#c5c537" : "#67671d")
2020-12-25 22:26:33 +01:00
anchors.left: parent.horizontalCenter
anchors.bottom: outArrowPoint.bottom
2022-08-28 22:21:14 +02:00
anchors.bottomMargin: 6
2020-12-25 22:26:33 +01:00
anchors.right: outArrowPoint.right
2022-08-28 22:21:14 +02:00
anchors.rightMargin: -1 // overlap the line and the arrow
height: 1.6
2020-12-25 22:26:33 +01:00
}
2021-11-02 19:38:36 +01:00
Flowee.ArrowPoint {
2020-12-25 22:26:33 +01:00
id: outArrowPoint
anchors.bottom: parent.bottom
anchors.right: parent.right
color: outArrowLine.color
}
Label {
id: outIndex
visible: modelData !== null
text: index
anchors.left: parent.left
2022-08-28 22:21:14 +02:00
anchors.leftMargin: 6
2020-12-25 22:26:33 +01:00
anchors.bottom: outArrowLine.top
}
Rectangle {
2021-11-02 19:29:14 +01:00
color: Pay.useDarkSkin ? "#4fb2e7" : "yellow"
2020-12-26 16:51:54 +01:00
visible: modelData !== null && modelData.forMe
2020-12-25 22:26:33 +01:00
x: outAddress.x - 3
y: outAddress.y -3
height: outAddress.height + 6
width: Math.min(outAddress.width, outAddress.contentWidth) + 6
radius: height / 3
opacity: 0.2
}
Flowee.LabelWithClipboard {
2020-12-25 22:26:33 +01:00
id: outAddress
visible: modelData !== null
elide: Text.ElideMiddle
menuText: qsTr("Copy Address")
text: {
if (modelData === null)
return "";
var cloaked = modelData.cloakedAddress
if (cloaked !== "")
return cloaked;
return modelData.address;
}
clipboardText: modelData === null ? "" : modelData.address
2020-12-25 22:26:33 +01:00
anchors.left: outIndex.right
2022-08-28 22:21:14 +02:00
anchors.leftMargin: 6
anchors.rightMargin: 10
2020-12-25 22:26:33 +01:00
anchors.right: outAmount.left
anchors.bottom: outArrowLine.top
}
Flowee.BitcoinAmountLabel {
2020-12-25 22:26:33 +01:00
id: outAmount
visible: modelData !== null
value: modelData === null ? 0 : modelData.value
2022-08-12 21:22:04 +02:00
fiatTimestamp: root.minedDate
2020-12-26 16:51:54 +01:00
colorize: modelData !== null && modelData.forMe
2021-12-04 12:45:50 +01:00
anchors.right: outArrowPoint.left
2022-08-28 22:21:14 +02:00
anchors.rightMargin: 2
2020-12-25 22:26:33 +01:00
anchors.bottom: outArrowLine.top
2022-08-28 22:21:14 +02:00
anchors.bottomMargin: 6
2020-12-25 22:26:33 +01:00
}
2020-12-17 23:12:39 +01:00
}
}
}
}