Files
pay/desktop/WalletTransaction.qml
T

176 lines
5.4 KiB
QML
Raw Permalink Normal View History

2020-05-24 13:20:03 +02:00
/*
* This file is part of the Flowee project
2021-04-21 00:11:57 +02:00
* Copyright (C) 2020-2021 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/>.
*/
2021-05-23 00:27:34 +02:00
import QtQuick 2.11
import QtQuick.Controls 2.11
import "widgets" as Flowee
2020-05-24 13:20:03 +02:00
Item {
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)
2020-12-17 23:12:39 +01:00
rc += detailsPane.item.height + 10;
return rc;
}
2020-10-12 19:37:28 +02:00
width: mainLabel.width + bitcoinAmountLabel.width + 30
2021-11-09 20:49:37 +01:00
property bool isRejected: model.height === -2 // -2 is the magic block-height indicating 'rejected'
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
model.isCashFusion
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
2021-12-04 13:19:39 +01:00
width: model.isNew ? mainLabel.height * 0.4 : 0
2021-11-02 20:07:58 +01:00
height: width
radius: height
color: Pay.useDarkSkin ? mainWindow.floweeSalmon : mainWindow.floweeBlue
}
2020-10-17 20:26:36 +02:00
Label {
2020-05-24 13:20:03 +02:00
id: mainLabel
2021-11-02 20:07:58 +01:00
anchors.left: isNewIndicator.right
anchors.leftMargin: model.isNew ? 10 : 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")
if (model.isCashFusion)
return qsTr("Cash Fusion")
2020-05-24 13:20:03 +02:00
if (model.fundsIn === 0)
return qsTr("Received")
let diff = model.fundsOut - model.fundsIn;
if (diff < 0 && diff > -1000) // then the diff is likely just fees.
2020-05-24 13:20:03 +02:00
return qsTr("Moved");
return qsTr("Sent")
}
}
2020-10-17 20:26:36 +02:00
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")
var dat = model.date;
2020-11-04 18:59:24 +01:00
if (typeof dat === "undefined")
2021-11-09 20:49:37 +01:00
text = qsTr("unconfirmed")
2021-11-10 23:13:31 +01:00
else
text = Pay.formatDateTime(dat);
2020-11-04 18:59:24 +01:00
}
2021-11-08 19:56:05 +01:00
opacity: txRoot.isRejected ? 1 : 0.5
2020-05-24 13:20:03 +02:00
font.pointSize: mainLabel.font.pointSize * 0.8
2021-11-08 19:56:05 +01:00
color: txRoot.isRejected ? (Pay.useDarkSkin ? "#ec2327" : "#b41214") : palette.text
2021-11-09 20:49:37 +01:00
Component.onCompleted: updateText()
Timer {
interval: 60000
running: !txRoot.isRejected
repeat: true
onTriggered: parent.updateText()
}
2020-05-24 13:20:03 +02:00
}
2021-12-14 13:19:29 +01:00
Flowee.CashFusionIcon {
id: fusedIcon
visible: model.isCashFusion
anchors.right: userComment.left
anchors.rightMargin: 10
anchors.verticalCenter: userComment.verticalCenter
}
2021-11-16 15:01:02 +01:00
Label {
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
2021-12-14 13:19:29 +01:00
leftMargin: fusedIcon.visible ? 44 : 10
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
2021-11-21 12:19:19 +01:00
value: {
let inputs = model.fundsIn
let outputs = model.fundsOut
let diff = model.fundsOut - model.fundsIn
if (!model.isCashFusion
&& diff < 0 && diff > -1000) // then the diff is likely just fees.
2021-11-21 12:19:19 +01:00
return inputs;
return diff;
}
2022-08-12 21:22:04 +02:00
fiatTimestamp: model.date;
2020-05-24 13:20:03 +02:00
anchors.top: mainLabel.top
2020-10-24 12:50:18 +02:00
fontPtSize: date.font.pointSize
2020-05-24 13:20:03 +02:00
anchors.right: parent.right
}
2021-11-08 19:56:05 +01:00
// visual separator
2020-05-24 13:20:03 +02:00
Rectangle {
width: parent.width / 100 * 80
height: 1
color: "#99999B"
opacity: 0.5
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 5
}
2020-12-17 23:12:39 +01:00
MouseArea {
anchors.fill: parent
onClicked: detailsPane.source = (detailsPane.source == "") ? "./WalletTransactionDetails.qml" : ""
}
Loader {
id: detailsPane
anchors.bottom: parent.bottom
anchors.bottomMargin: 10
2020-12-25 22:26:33 +01:00
x: 10 // indent it
width: parent.width - 10
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
}