2025-06-24 22:19:37 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2025 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
|
|
|
|
|
import QtQuick.Controls.Basic as QQC2
|
|
|
|
|
import "../Flowee" as Flowee
|
|
|
|
|
import "../Utils.js" as Utils
|
|
|
|
|
import Flowee.org.pay;
|
|
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
|
id: root
|
|
|
|
|
|
2025-08-11 16:40:11 +02:00
|
|
|
model: RepeatPaymentsModel {
|
|
|
|
|
id: repeatPaymentsModel
|
|
|
|
|
}
|
2025-08-12 21:55:04 +02:00
|
|
|
|
|
|
|
|
onActiveFocusChanged: {
|
|
|
|
|
if (!activeFocus) // move 'approved' items to the proper section
|
|
|
|
|
model.updateOrdering();
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-24 22:19:37 +02:00
|
|
|
clip: true
|
|
|
|
|
focus: true
|
2025-06-26 00:02:57 +02:00
|
|
|
spacing: 6
|
2025-08-12 21:55:04 +02:00
|
|
|
section.property: "section"
|
|
|
|
|
section.labelPositioning: ViewSection.InlineLabels + ViewSection.CurrentLabelAtStart
|
|
|
|
|
section.delegate: Item {
|
|
|
|
|
height: label.height + 3
|
|
|
|
|
width: root.width
|
|
|
|
|
Rectangle {
|
|
|
|
|
color: palette.base
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
id: label
|
|
|
|
|
x: 10
|
|
|
|
|
font.bold: true
|
|
|
|
|
font.pixelSize: mainWindow.font.pixelSize * 1.1
|
|
|
|
|
text: {
|
|
|
|
|
if (section == 1) // yes, 2 equals
|
|
|
|
|
return qsTr("Payments to Approve")
|
|
|
|
|
// if (section == 2)
|
|
|
|
|
return qsTr("Approved Payments");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MouseArea { anchors.fill: parent } // eat all taps
|
|
|
|
|
}
|
2025-06-26 00:02:57 +02:00
|
|
|
delegate: Item {
|
|
|
|
|
id: delegateRoot
|
|
|
|
|
width: ListView.view.width
|
2025-08-11 16:40:11 +02:00
|
|
|
height: 10 + comment.height + 10 + upcomingDate.height + nextDate.height + amountBch.height + 8
|
2025-06-26 00:02:57 +02:00
|
|
|
|
2025-08-12 21:16:19 +02:00
|
|
|
property QtObject payment: model.payment
|
|
|
|
|
|
2025-06-26 00:02:57 +02:00
|
|
|
Flowee.Label {
|
|
|
|
|
id: comment
|
2025-08-11 16:40:11 +02:00
|
|
|
text: model.comment
|
2025-06-26 00:02:57 +02:00
|
|
|
width: parent.width - 20
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
x: 10
|
2025-08-11 16:40:11 +02:00
|
|
|
y: 10
|
2025-06-26 00:02:57 +02:00
|
|
|
height: text === "" ? 0: contentHeight
|
2025-08-11 16:40:11 +02:00
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
id: upcomingDate
|
|
|
|
|
text: {
|
2025-08-11 19:15:01 +02:00
|
|
|
let d = model.upcomingDate;
|
2025-08-11 16:40:11 +02:00
|
|
|
let now = new Date();
|
|
|
|
|
// close to 'now'
|
|
|
|
|
if (Math.abs(now - d) < 18 * 3600 * 1000) { // 18h in ms
|
|
|
|
|
return Pay.formatDateTime(d);
|
|
|
|
|
}
|
|
|
|
|
Pay.formatDate(d)
|
|
|
|
|
}
|
|
|
|
|
anchors.right: parent.right
|
2025-08-12 21:55:04 +02:00
|
|
|
anchors.rightMargin: 30
|
2025-08-11 16:40:11 +02:00
|
|
|
anchors.top: comment.bottom
|
|
|
|
|
anchors.topMargin: 10
|
2025-06-26 00:02:57 +02:00
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
id: nextDate
|
2025-08-11 16:40:11 +02:00
|
|
|
text: Pay.formatDate(model.nextDate)
|
|
|
|
|
anchors.right: upcomingDate.right
|
|
|
|
|
anchors.top: upcomingDate.bottom
|
|
|
|
|
font.pixelSize: upcomingDate.font.pixelSize * 0.9
|
|
|
|
|
color: palette.dark
|
2025-06-26 00:02:57 +02:00
|
|
|
}
|
2025-08-11 16:40:11 +02:00
|
|
|
|
2025-06-26 00:02:57 +02:00
|
|
|
Flowee.BitcoinAmountLabel {
|
|
|
|
|
// check if the payment prefers fiat over sats
|
|
|
|
|
id: amountBch
|
2025-08-11 16:40:11 +02:00
|
|
|
value: model.valueSats
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 10
|
2025-06-26 00:02:57 +02:00
|
|
|
showFiat: false
|
|
|
|
|
colorize: false
|
2025-08-11 16:40:11 +02:00
|
|
|
anchors.top: nextDate.bottom
|
2025-06-26 00:02:57 +02:00
|
|
|
anchors.topMargin: 6
|
2025-08-11 16:40:11 +02:00
|
|
|
visible: model.fiatFollows
|
2025-06-26 00:02:57 +02:00
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
id: amountFiat
|
2025-08-11 16:40:11 +02:00
|
|
|
visible: !model.fiatFollows
|
|
|
|
|
text: Fiat.formattedPrice(model.valueFiat)
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
anchors.top: nextDate.bottom
|
2025-06-26 00:02:57 +02:00
|
|
|
anchors.topMargin: 6
|
|
|
|
|
}
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2025-08-12 21:16:19 +02:00
|
|
|
onClicked: thePile.push("RepeatPaymentDetails.qml", { savedPayment: model.payment});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
anchors.bottom: upcomingDate.bottom
|
2025-08-12 21:55:04 +02:00
|
|
|
x: 10
|
|
|
|
|
width: checkLabel.contentWidth + 20
|
|
|
|
|
height: Math.max(24, checkLabel.contentHeight)
|
2025-08-12 21:16:19 +02:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
radius: 4
|
|
|
|
|
color: palette.base
|
|
|
|
|
border.color: palette.highlight
|
|
|
|
|
border.width: 1.3
|
|
|
|
|
width: 24
|
|
|
|
|
height: 24
|
2025-08-12 21:55:04 +02:00
|
|
|
anchors.bottom: checkLabel.bottom
|
2025-08-12 21:16:19 +02:00
|
|
|
}
|
|
|
|
|
Flowee.Label {
|
2025-08-12 21:55:04 +02:00
|
|
|
id: checkLabel
|
2025-08-12 21:16:19 +02:00
|
|
|
x: 30
|
|
|
|
|
text: qsTr("Approved")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Flowee.CheckShape {
|
|
|
|
|
id: check
|
|
|
|
|
transformOrigin: Item.BottomLeft
|
|
|
|
|
smooth: true
|
|
|
|
|
scale: 1.6
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.bottomMargin: 3
|
|
|
|
|
visible: model.isApproved
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
anchors.margins: -5
|
|
|
|
|
onClicked: delegateRoot.payment.approved = !delegateRoot.payment.approved
|
2025-08-11 19:15:01 +02:00
|
|
|
}
|
2025-06-26 00:02:57 +02:00
|
|
|
}
|
2025-08-12 21:16:19 +02:00
|
|
|
|
2025-08-11 16:40:11 +02:00
|
|
|
Rectangle {
|
|
|
|
|
width: parent.width * 0.7
|
|
|
|
|
height: 1.2
|
|
|
|
|
color: palette.midlight
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
}
|
2025-06-24 22:19:37 +02:00
|
|
|
}
|
|
|
|
|
}
|