Files

202 lines
6.6 KiB
QML
Raw Permalink Normal View History

2024-07-03 23:06:15 +02:00
/*
* This file is part of the Flowee project
2025-01-09 15:57:54 +01:00
* Copyright (C) 2023-2025 Tom Zander <tom@flowee.org>
2024-07-03 23:06:15 +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/>.
*/
import QtQuick
import "../Flowee" as Flowee
import Flowee.org.pay
2024-07-03 23:06:15 +02:00
Item {
property double amountBch: isMoved ? model.fundsIn
: (model.fundsOut - model.fundsIn)
property bool isRejected: model.height === -2 // special height as defined by the wallet
2025-02-04 15:50:24 +01:00
property alias commentEditable: editIcon.visible
2024-07-03 23:06:15 +02:00
2025-01-07 00:36:51 +01:00
baselineOffset: dateLine.y + dateLine.baselineOffset
2024-07-03 23:06:15 +02:00
implicitWidth: 360
implicitHeight: 80
Item {
id: ruler
width: parent.width
2025-01-07 00:36:51 +01:00
height: 4
2024-07-03 23:06:15 +02:00
anchors.verticalCenter: parent.verticalCenter
}
// icon
Image {
2024-12-18 11:48:07 +01:00
id: mainIcon
2026-03-14 21:14:42 +01:00
property bool receiving: model.fundsIn === 0
2024-07-03 23:06:15 +02:00
source: {
if (model.isFused)
2026-03-14 21:14:42 +01:00
return "qrc:/cf.svg"
2024-12-18 11:48:07 +01:00
if (receiving)
2026-03-14 21:14:42 +01:00
var base = "receiving"
2024-07-03 23:06:15 +02:00
else if (isMoved)
2026-03-14 21:14:42 +01:00
base = "move"
2024-07-03 23:06:15 +02:00
else
2026-03-14 21:14:42 +01:00
base = "send"
return "qrc:/tx-"+ base + (Pay.useDarkSkin ? "-light.svg" : ".svg")
2024-07-03 23:06:15 +02:00
}
width: 45
height: 45
2025-06-19 14:47:19 +02:00
x: 10
2024-07-03 23:06:15 +02:00
smooth: true
anchors.verticalCenter: ruler.verticalCenter
opacity: isRejected ? 0.6 : 1
2024-12-18 11:48:07 +01:00
}
Image {
visible: itIsChristmas
source: "qrc:/hat.svg"
width: 60
height: 60
rotation: mainIcon.receiving ? 45 : 0
2025-06-19 14:47:19 +02:00
x: mainIcon.receiving ? 4 : -2
2024-12-18 11:48:07 +01:00
y: -2
2024-07-03 23:06:15 +02:00
}
Flowee.Label {
id: commentLabel
anchors.right: price.visible ? price.left : price.right
2025-06-19 14:47:19 +02:00
anchors.rightMargin: 20
2024-07-03 23:06:15 +02:00
anchors.left: parent.left
2025-06-19 14:47:19 +02:00
anchors.leftMargin: 62
2025-02-04 15:50:24 +01:00
y: {
if (price.visible && Pay.activityShowsBch) // baseline align to price
return price.y + price.baselineOffset - baselineOffset
return parent.height / 2 - height
}
2025-02-17 12:44:23 +01:00
elide: Text.ElideRight
2025-04-17 19:25:51 +02:00
text: {
2024-07-03 23:06:15 +02:00
var comment = model.comment
if (comment !== "")
2026-03-14 21:14:42 +01:00
return comment
2025-02-04 15:50:24 +01:00
else if (model.isCoinbase)
2026-03-14 21:14:42 +01:00
return qsTr("Miner Reward")
2025-02-04 15:50:24 +01:00
else if (model.isFused)
2026-03-14 21:14:42 +01:00
return qsTr("Fused")
2025-02-04 15:50:24 +01:00
else if (model.fundsIn === 0)
2026-03-14 21:14:42 +01:00
return qsTr("Received")
2025-02-04 15:50:24 +01:00
else if (isMoved)
2026-03-14 21:14:42 +01:00
return qsTr("Moved")
return qsTr("Sent")
2024-07-03 23:06:15 +02:00
}
}
2025-02-04 15:50:24 +01:00
Image {
id: editIcon
x: commentLabel.x + commentLabel.contentWidth + 6
y: commentLabel.y + commentLabel.baselineOffset - height
width: 16
height: 16
smooth: true
visible: false
source: "qrc:/edit-pen" + (Pay.useDarkSkin ? "-light" : "") + ".svg"
enabled: editWidget.visible === false
MouseArea {
anchors.fill: parent
anchors.margins: -15
onClicked: {
2026-03-14 21:14:42 +01:00
editWidget.visible = !editWidget.visible
2025-02-04 15:50:24 +01:00
if (editWidget.focus)
2026-03-14 21:14:42 +01:00
editWidget.forceActiveFocus()
2025-02-04 15:50:24 +01:00
}
}
}
Flowee.TextField {
id: editWidget
property QtObject infoObject: null
anchors.left: parent.left
anchors.leftMargin: 10
anchors.right: commentLabel.right
2025-04-18 19:03:17 +02:00
anchors.rightMargin: -25 // to go over the edit button
2025-02-04 15:50:24 +01:00
visible: false
focus: visible
text: model.comment
onEditingFinished: {
if (editWidget.infoObject === null)
2026-03-14 21:14:42 +01:00
editWidget.infoObject = portfolio.current.txInfo(model.walletIndex, editWidget)
editWidget.infoObject.userComment = text
commentLabel.text = text
visible = false
2025-02-04 15:50:24 +01:00
}
2026-03-14 21:14:42 +01:00
Component.onCompleted: { cursorPosition = 0 }
2025-02-04 15:50:24 +01:00
}
2024-07-03 23:06:15 +02:00
Flowee.Label {
id: dateLine
anchors.top: ruler.bottom
anchors.left: commentLabel.left
2026-03-14 21:14:42 +01:00
color: isRejected ? mainWindow.errorRed : palette.text
2024-07-03 23:06:15 +02:00
text: {
2026-03-14 21:14:42 +01:00
var minedHeight = model.height
2024-07-03 23:06:15 +02:00
if (minedHeight === -2)
return qsTr("Rejected")
2026-03-14 21:14:42 +01:00
var date = model.date
return Pay.formatDate(date, FloweePay.NoYear) + " " + Qt.formatTime(date)
2024-07-03 23:06:15 +02:00
}
}
// price in a green rectangle
Rectangle {
id: price
width: amount.width + 10
height: amount.height + 8
anchors.right: parent.right
y: {
2025-01-09 15:57:54 +01:00
if (Pay.activityShowsBch) // my bottom at parent verticalCenter
2024-07-03 23:06:15 +02:00
return parent.height / 2 - height
return parent.height / 2 - height / 2 // i.e my verticalCenter = parent.verticalCenter
}
2025-06-19 14:47:19 +02:00
anchors.rightMargin: 5
radius: 5
2024-07-03 23:06:15 +02:00
baselineOffset: amount.baselineOffset + 4 // 4 is half the spacing added at height:
2025-01-09 15:57:54 +01:00
visible: !model.isFused && Pay.isMainChain
2024-07-03 23:06:15 +02:00
color: (isMoved || amountBch < 0) ? "#00000000"
: (Pay.useDarkSkin ? "#1d6828" : "#97e282") // green background
Flowee.Label {
id: amount
text: {
2026-03-14 21:14:42 +01:00
var dummy = Fiat.currencyName // trigger a recalc when user changes currency
var fiatPrice = Fiat.historicalPrice(model.date)
return Fiat.formattedPrice(Math.abs(amountBch), fiatPrice)
2024-07-03 23:06:15 +02:00
}
anchors.centerIn: parent
opacity: Math.abs(amountBch) < 2000 ? 0.5 : 1
font.strikeout: isRejected
}
}
Flowee.Label { // plus or minus in front of the price
visible: price.visible && !isMoved
text: amountBch >= 0 ? "+" : "-"
anchors.baseline: price.baseline
anchors.right: price.left
opacity: price.opacity
}
Flowee.BitcoinAmountLabel {
2025-01-09 15:57:54 +01:00
visible: !Pay.isMainChain || (price.visible && Pay.activityShowsBch)
2024-07-03 23:06:15 +02:00
anchors.right: parent.right
2025-06-19 14:47:19 +02:00
anchors.rightMargin: 10
2024-07-03 23:06:15 +02:00
anchors.baseline: dateLine.baseline
value: amountBch
showFiat: false
fontPixelSize: amount.font.pixelSize * 0.9
colorize: isMoved === false
}
}