2021-01-05 00:25:23 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2024-10-14 12:48:47 +02:00
|
|
|
* Copyright (C) 2020-2024 Tom Zander <tom@flowee.org>
|
2021-01-05 00:25:23 +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
|
2024-05-28 23:23:31 +02:00
|
|
|
import QtQuick.Controls as QQC2
|
2022-11-26 10:46:57 +01:00
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Shapes
|
|
|
|
|
import Flowee.org.pay
|
2022-11-14 21:19:31 +01:00
|
|
|
import "../Flowee" as Flowee
|
2021-01-05 00:25:23 +01:00
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Item {
|
2021-01-05 00:25:23 +01:00
|
|
|
id: receivePane
|
2021-01-16 17:01:42 +01:00
|
|
|
|
2021-04-20 19:30:56 +02:00
|
|
|
property QtObject account: portfolio.current
|
2023-05-02 10:40:04 +02:00
|
|
|
|
|
|
|
|
PaymentRequest {
|
|
|
|
|
id: request
|
2021-04-21 17:17:47 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-02 10:40:04 +02:00
|
|
|
onAccountChanged: {
|
|
|
|
|
var state = request.state;
|
|
|
|
|
if (request.state === PaymentRequest.Unpaid) {
|
|
|
|
|
// I can only change the wallet without cost
|
|
|
|
|
// if no payment has been seen.
|
|
|
|
|
request.account = account;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onActiveFocusChanged: {
|
|
|
|
|
if (activeFocus)
|
|
|
|
|
request.start();
|
2021-04-21 18:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-04-21 17:17:47 +02:00
|
|
|
id: instructions
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2025-01-09 18:24:58 +01:00
|
|
|
y: 20
|
2021-04-30 17:54:26 +02:00
|
|
|
text: qsTr("Share your QR code or copy address to receive")
|
|
|
|
|
opacity: 0.5
|
2021-04-21 17:17:47 +02:00
|
|
|
}
|
2021-01-05 00:25:23 +01:00
|
|
|
|
2023-02-09 14:56:39 +01:00
|
|
|
Flowee.QRWidget {
|
|
|
|
|
id: qr
|
2023-03-21 23:33:23 +01:00
|
|
|
width: Math.min(parent.width, 360)
|
2021-04-21 17:17:47 +02:00
|
|
|
anchors.top: instructions.bottom
|
2023-03-21 23:33:23 +01:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-01-06 15:26:46 +01:00
|
|
|
anchors.topMargin: 20
|
2023-05-02 10:40:04 +02:00
|
|
|
qrText: request.qr
|
|
|
|
|
|
|
|
|
|
Flowee.Label {
|
|
|
|
|
visible: request.failReason !== PaymentRequest.NoFailure
|
|
|
|
|
text: {
|
|
|
|
|
var f = request.failReason;
|
|
|
|
|
if (f === PaymentRequest.AccountEncrypted)
|
|
|
|
|
return qsTr("Encrypted Wallet");
|
|
|
|
|
if (f === PaymentRequest.AccountImporting)
|
|
|
|
|
return qsTr("Import Running...");
|
|
|
|
|
if (f === PaymentRequest.NoAccountSet)
|
|
|
|
|
return "No Account Set"; // not translated b/c cause is bug in QML
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
width: parent.width - 40
|
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
font.pointSize: 18
|
|
|
|
|
}
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-18 14:27:24 +01:00
|
|
|
// the "payment received" screen.
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 20
|
|
|
|
|
anchors.left: parent.left
|
2024-05-28 23:23:31 +02:00
|
|
|
anchors.leftMargin: 10
|
2021-01-18 14:27:24 +01:00
|
|
|
anchors.right: parent.right
|
2024-05-28 23:23:31 +02:00
|
|
|
anchors.rightMargin: 10
|
2023-02-09 14:56:39 +01:00
|
|
|
anchors.bottom: qr.bottom
|
2021-01-18 14:27:24 +01:00
|
|
|
radius: 10
|
|
|
|
|
gradient: Gradient {
|
|
|
|
|
GradientStop {
|
|
|
|
|
position: 0.6
|
|
|
|
|
color: {
|
2023-05-02 10:40:04 +02:00
|
|
|
var state = request.state;
|
2021-01-18 14:27:24 +01:00
|
|
|
if (state === PaymentRequest.PaymentSeen || state === PaymentRequest.Unpaid)
|
2023-02-21 16:40:46 +01:00
|
|
|
return palette.base
|
2021-01-18 14:27:24 +01:00
|
|
|
if (state === PaymentRequest.DoubleSpentSeen)
|
|
|
|
|
return "#640e0f" // red
|
|
|
|
|
return "#3e8b4e" // in all other cases: green
|
|
|
|
|
}
|
|
|
|
|
Behavior on color { ColorAnimation {} }
|
|
|
|
|
}
|
|
|
|
|
GradientStop {
|
|
|
|
|
position: 0.1
|
2023-02-21 16:40:46 +01:00
|
|
|
color: palette.base
|
2021-01-18 14:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-02 10:40:04 +02:00
|
|
|
opacity: request.state === PaymentRequest.Unpaid ? 0: 1
|
2021-01-18 14:27:24 +01:00
|
|
|
|
|
|
|
|
// animating timer to indicate our checking the security of the transaction.
|
|
|
|
|
// (i.e. waiting for the double spent proof)
|
|
|
|
|
Item {
|
|
|
|
|
id: feedback
|
|
|
|
|
width: 160
|
|
|
|
|
height: 160
|
|
|
|
|
y: (parent.height - height) / 3 * 2
|
2023-05-02 10:40:04 +02:00
|
|
|
visible: request.state !== PaymentRequest.DoubleSpentSeen
|
2021-01-18 14:27:24 +01:00
|
|
|
Shape {
|
|
|
|
|
id: circleShape
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
opacity: progressCircle.sweepAngle === 340 ? 0 : 1
|
|
|
|
|
x: 40
|
|
|
|
|
ShapePath {
|
|
|
|
|
strokeWidth: 20
|
|
|
|
|
strokeColor: "#9ea0b0"
|
|
|
|
|
fillColor: "transparent"
|
|
|
|
|
capStyle: ShapePath.RoundCap
|
|
|
|
|
startX: 100; startY: 10
|
|
|
|
|
|
|
|
|
|
PathAngleArc {
|
|
|
|
|
id: progressCircle
|
|
|
|
|
centerX: 80
|
|
|
|
|
centerY: 80
|
|
|
|
|
radiusX: 70; radiusY: 70
|
|
|
|
|
startAngle: -80
|
2023-05-02 10:40:04 +02:00
|
|
|
sweepAngle: request.state === PaymentRequest.Unpaid ? 0: 340
|
2021-01-18 14:27:24 +01:00
|
|
|
|
2021-11-02 19:29:14 +01:00
|
|
|
Behavior on sweepAngle { NumberAnimation { duration: Pay.dspTimeout } }
|
2021-01-18 14:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-01-18 14:27:24 +01:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
text: qsTr("Checking") // checking security
|
|
|
|
|
}
|
|
|
|
|
Behavior on opacity { OpacityAnimator {} }
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-01-18 14:27:24 +01:00
|
|
|
color: "green"
|
|
|
|
|
text: "✔"
|
|
|
|
|
opacity: 1 - circleShape.opacity
|
|
|
|
|
font.pixelSize: 130
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-01-20 11:34:15 +01:00
|
|
|
id: feedbackLabel
|
2021-01-18 14:27:24 +01:00
|
|
|
text: {
|
2023-05-02 10:40:04 +02:00
|
|
|
var s = request.state;
|
2021-01-18 14:27:24 +01:00
|
|
|
if (s === PaymentRequest.DoubleSpentSeen)
|
2021-01-20 11:34:15 +01:00
|
|
|
// double-spent-proof received
|
2024-10-14 12:48:47 +02:00
|
|
|
return qsTr("High risk transaction")
|
2021-01-18 14:27:24 +01:00
|
|
|
if (s === PaymentRequest.PaymentSeen)
|
|
|
|
|
return qsTr("Payment Seen")
|
|
|
|
|
if (s === PaymentRequest.PaymentSeenOk)
|
|
|
|
|
return qsTr("Payment Accepted")
|
|
|
|
|
if (s === PaymentRequest.Confirmed)
|
|
|
|
|
return qsTr("Payment Settled")
|
2021-01-20 11:34:15 +01:00
|
|
|
return "INTERNAL ERROR";
|
2021-01-18 14:27:24 +01:00
|
|
|
}
|
2021-02-04 19:21:45 +01:00
|
|
|
width: parent.width - 40
|
2021-01-18 14:27:24 +01:00
|
|
|
anchors.verticalCenter: feedback.verticalCenter
|
|
|
|
|
anchors.left: feedback.visible ? feedback.right : parent.left
|
|
|
|
|
anchors.leftMargin: 20
|
2021-02-04 19:21:45 +01:00
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
2021-01-18 14:27:24 +01:00
|
|
|
font.pointSize: 20
|
|
|
|
|
}
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2023-05-02 10:40:04 +02:00
|
|
|
visible: request.state === PaymentRequest.DoubleSpentSeen
|
2021-01-20 11:34:15 +01:00
|
|
|
anchors.top: feedbackLabel.bottom
|
2021-02-04 19:21:45 +01:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
width: parent.width - 20
|
|
|
|
|
horizontalAlignment: Qt.AlignRight
|
2021-01-20 11:34:15 +01:00
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
text: qsTr("Instant payment failed. Wait for confirmation. (double spent proof received)")
|
|
|
|
|
}
|
2021-01-18 14:27:24 +01:00
|
|
|
|
|
|
|
|
Behavior on opacity { OpacityAnimator {} }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// entry-fields
|
2021-01-05 00:25:23 +01:00
|
|
|
GridLayout {
|
|
|
|
|
id: grid
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2023-02-09 14:56:39 +01:00
|
|
|
anchors.top: qr.bottom
|
2021-01-06 15:26:46 +01:00
|
|
|
anchors.topMargin: 30
|
2024-05-28 23:23:31 +02:00
|
|
|
anchors.leftMargin: 10
|
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
|
|
2021-01-05 00:25:23 +01:00
|
|
|
columns: 2
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-01-29 10:27:24 +01:00
|
|
|
text: qsTr("Description") + ":"
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|
2021-11-03 19:26:50 +01:00
|
|
|
Flowee.TextField {
|
2021-01-05 00:25:23 +01:00
|
|
|
id: description
|
|
|
|
|
Layout.fillWidth: true
|
2023-05-02 10:40:04 +02:00
|
|
|
enabled: request.state === PaymentRequest.Unpaid
|
|
|
|
|
onTextChanged: request.message = text
|
2021-11-04 23:16:50 +01:00
|
|
|
focus: true
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|
2021-01-06 15:26:46 +01:00
|
|
|
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-01-05 00:25:23 +01:00
|
|
|
id: payAmount
|
2021-01-29 10:27:24 +01:00
|
|
|
text: qsTr("Amount") + ":"
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|
2021-05-08 00:03:07 +02:00
|
|
|
RowLayout {
|
|
|
|
|
spacing: 10
|
2021-11-03 13:45:26 +01:00
|
|
|
Flowee.BitcoinValueField {
|
2021-05-08 00:03:07 +02:00
|
|
|
id: bitcoinValueField
|
2023-05-02 10:40:04 +02:00
|
|
|
enabled: request.state === PaymentRequest.Unpaid
|
|
|
|
|
onValueChanged: request.amount = value
|
2021-05-08 00:03:07 +02:00
|
|
|
}
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Label {
|
2021-05-08 00:03:07 +02:00
|
|
|
Layout.alignment: Qt.AlignBaseline
|
|
|
|
|
anchors.baselineOffset: bitcoinValueField.baselineOffset
|
|
|
|
|
text: Fiat.formattedPrice(bitcoinValueField.value, Fiat.price)
|
|
|
|
|
}
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|
2021-01-06 15:26:46 +01:00
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
|
Layout.fillWidth: true
|
2024-05-28 23:23:31 +02:00
|
|
|
Item {
|
2021-01-06 15:26:46 +01:00
|
|
|
Layout.fillWidth: true
|
2024-05-28 23:23:31 +02:00
|
|
|
width: 1; height: 1
|
2021-01-06 15:26:46 +01:00
|
|
|
}
|
2024-05-28 23:23:31 +02:00
|
|
|
Flowee.Button {
|
2023-05-02 10:40:04 +02:00
|
|
|
text: request.state === PaymentRequest.Unpaid ? qsTr("Clear") : qsTr("Done")
|
2021-01-06 23:15:54 +01:00
|
|
|
onClicked: {
|
2023-05-02 10:40:04 +02:00
|
|
|
request.clear();
|
|
|
|
|
request.account = portfolio.current;
|
|
|
|
|
description.text = "";
|
|
|
|
|
bitcoinValueField.value = 0;
|
|
|
|
|
request.start();
|
2021-04-21 20:01:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-05 00:25:23 +01:00
|
|
|
}
|