Skip to content

Commit 13535ca

Browse files
committed
qml: Introduce RequestPayment page
This page contains the form for the user to fill out to create a payment request.
1 parent 9f4411c commit 13535ca

File tree

5 files changed

+243
-2
lines changed

5 files changed

+243
-2
lines changed

Diff for: src/Makefile.qt.include

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ QML_RES_QML = \
447447
qml/pages/wallet/CreatePassword.qml \
448448
qml/pages/wallet/CreateWalletWizard.qml \
449449
qml/pages/wallet/DesktopWallets.qml \
450+
qml/pages/wallet/RequestPayment.qml \
450451
qml/pages/wallet/WalletBadge.qml \
451452
qml/pages/wallet/WalletSelect.qml
452453

Diff for: src/qml/bitcoin_qml.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<file>pages/wallet/CreatePassword.qml</file>
7979
<file>pages/wallet/CreateWalletWizard.qml</file>
8080
<file>pages/wallet/DesktopWallets.qml</file>
81+
<file>pages/wallet/RequestPayment.qml</file>
8182
<file>pages/wallet/WalletBadge.qml</file>
8283
<file>pages/wallet/WalletSelect.qml</file>
8384
</qresource>

Diff for: src/qml/controls/LabeledTextInput.qml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Item {
4040
color: Theme.color.neutral9
4141
placeholderTextColor: Theme.color.neutral7
4242
background: Item {}
43+
selectByMouse: true
4344
onTextEdited: root.textEdited()
4445
}
4546

Diff for: src/qml/pages/wallet/DesktopWallets.qml

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ Page {
130130
id: sendTab
131131
CoreText { text: "Send" }
132132
}
133-
Item {
133+
RequestPayment {
134134
id: receiveTab
135-
CoreText { text: "Receive" }
136135
}
137136
Item {
138137
id: blockClockTab

Diff for: src/qml/pages/wallet/RequestPayment.qml

+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
// Copyright (c) 2024 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
import QtQuick 2.15
6+
import QtQuick.Controls 2.15
7+
import QtQuick.Layouts 1.15
8+
import org.bitcoincore.qt 1.0
9+
10+
import "../../controls"
11+
import "../../components"
12+
import "../settings"
13+
14+
Page {
15+
id: root
16+
background: null
17+
18+
property int requestCounter: 0
19+
20+
ScrollView {
21+
clip: true
22+
width: parent.width
23+
height: parent.height
24+
contentWidth: width
25+
26+
CoreText {
27+
id: title
28+
anchors.left: contentRow.left
29+
anchors.top: parent.top
30+
anchors.topMargin: 20
31+
text: qsTr("Request a payment")
32+
font.pixelSize: 21
33+
bold: true
34+
}
35+
36+
RowLayout {
37+
id: contentRow
38+
anchors.top: title.bottom
39+
anchors.topMargin: 40
40+
anchors.horizontalCenter: parent.horizontalCenter
41+
spacing: 30
42+
ColumnLayout {
43+
id: columnLayout
44+
Layout.minimumWidth: 450
45+
Layout.maximumWidth: 470
46+
47+
spacing: 5
48+
49+
Item {
50+
BitcoinAmount {
51+
id: bitcoinAmount
52+
}
53+
54+
height: amountInput.height
55+
Layout.fillWidth: true
56+
CoreText {
57+
id: amountLabel
58+
width: 110
59+
anchors.left: parent.left
60+
anchors.verticalCenter: parent.verticalCenter
61+
horizontalAlignment: Text.AlignLeft
62+
color: Theme.color.neutral9
63+
text: "Amount"
64+
font.pixelSize: 18
65+
}
66+
67+
TextField {
68+
id: amountInput
69+
anchors.left: amountLabel.right
70+
anchors.verticalCenter: parent.verticalCenter
71+
leftPadding: 0
72+
font.family: "Inter"
73+
font.styleName: "Regular"
74+
font.pixelSize: 18
75+
color: Theme.color.neutral9
76+
placeholderTextColor: Theme.color.neutral7
77+
background: Item {}
78+
placeholderText: "0.00000000"
79+
selectByMouse: true
80+
onTextEdited: {
81+
amountInput.text = bitcoinAmount.sanitize(amountInput.text)
82+
}
83+
}
84+
Item {
85+
width: unitLabel.width + flipIcon.width
86+
height: Math.max(unitLabel.height, flipIcon.height)
87+
anchors.right: parent.right
88+
anchors.verticalCenter: parent.verticalCenter
89+
MouseArea {
90+
anchors.fill: parent
91+
onClicked: {
92+
if (bitcoinAmount.unit == BitcoinAmount.BTC) {
93+
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.BTC)
94+
bitcoinAmount.unit = BitcoinAmount.SAT
95+
} else {
96+
amountInput.text = bitcoinAmount.convert(amountInput.text, BitcoinAmount.SAT)
97+
bitcoinAmount.unit = BitcoinAmount.BTC
98+
}
99+
}
100+
}
101+
CoreText {
102+
id: unitLabel
103+
anchors.right: flipIcon.left
104+
anchors.verticalCenter: parent.verticalCenter
105+
text: bitcoinAmount.unitLabel
106+
font.pixelSize: 18
107+
color: Theme.color.neutral7
108+
}
109+
Icon {
110+
id: flipIcon
111+
anchors.right: parent.right
112+
anchors.verticalCenter: parent.verticalCenter
113+
source: "image://images/flip-vertical"
114+
color: Theme.color.neutral8
115+
size: 30
116+
}
117+
}
118+
}
119+
120+
Separator {
121+
Layout.fillWidth: true
122+
}
123+
124+
LabeledTextInput {
125+
id: label
126+
Layout.fillWidth: true
127+
labelText: qsTr("Label")
128+
placeholderText: qsTr("Enter label...")
129+
}
130+
131+
Separator {
132+
Layout.fillWidth: true
133+
}
134+
135+
LabeledTextInput {
136+
id: message
137+
Layout.fillWidth: true
138+
labelText: qsTr("Message")
139+
placeholderText: qsTr("Enter message...")
140+
}
141+
142+
Separator {
143+
Layout.fillWidth: true
144+
}
145+
146+
Item {
147+
Layout.fillWidth: true
148+
Layout.minimumHeight: addressLabel.height + copyLabel.height
149+
Layout.topMargin: 10
150+
height: addressLabel.height + copyLabel.height
151+
CoreText {
152+
id: addressLabel
153+
anchors.left: parent.left
154+
anchors.top: parent.top
155+
horizontalAlignment: Text.AlignLeft
156+
width: 110
157+
text: qsTr("Address")
158+
font.pixelSize: 18
159+
color: Theme.color.neutral9
160+
}
161+
CoreText {
162+
id: copyLabel
163+
anchors.left: parent.left
164+
anchors.top: addressLabel.bottom
165+
horizontalAlignment: Text.AlignLeft
166+
width: 110
167+
text: qsTr("copy")
168+
font.pixelSize: 18
169+
color: Theme.color.neutral7
170+
}
171+
172+
Rectangle {
173+
anchors.left: addressLabel.right
174+
anchors.right: parent.right
175+
anchors.top: parent.top
176+
anchors.bottom: parent.bottom
177+
color: Theme.color.neutral2
178+
radius: 5
179+
CoreText {
180+
id: address
181+
anchors.fill: parent
182+
anchors.leftMargin: 5
183+
horizontalAlignment: Text.AlignLeft
184+
font.pixelSize: 18
185+
color: Theme.color.neutral9
186+
wrap: true
187+
}
188+
}
189+
}
190+
191+
ContinueButton {
192+
id: continueButton
193+
Layout.fillWidth: true
194+
Layout.topMargin: 30
195+
text: qsTr("Create bitcoin address")
196+
onClicked: {
197+
if (!clearRequest.visible) {
198+
requestCounter = requestCounter + 1
199+
clearRequest.visible = true
200+
title.text = qsTr("Payment request #" + requestCounter)
201+
address.text = "bc1q f5xe y2tf 89k9 zy6k gnru wszy 5fsa truy 9te1 bu"
202+
continueButton.text = qsTr("Copy payment request")
203+
}
204+
}
205+
}
206+
207+
ContinueButton {
208+
id: clearRequest
209+
Layout.fillWidth: true
210+
Layout.topMargin: 10
211+
visible: false
212+
borderColor: Theme.color.neutral6
213+
borderHoverColor: Theme.color.orangeLight1
214+
borderPressedColor: Theme.color.orangeLight2
215+
backgroundColor: "transparent"
216+
backgroundHoverColor: "transparent"
217+
backgroundPressedColor: "transparent"
218+
text: qsTr("Clear")
219+
onClicked: {
220+
clearRequest.visible = false
221+
title.text = qsTr("Request a payment")
222+
address.text = ""
223+
continueButton.text = qsTr("Create bitcoin address")
224+
}
225+
}
226+
}
227+
228+
Rectangle {
229+
id: qrPlaceholder
230+
Layout.alignment: Qt.AlignTop
231+
Layout.minimumWidth: 150
232+
Layout.maximumWidth: 150
233+
color: Theme.color.neutral2
234+
width: 150
235+
height: 150
236+
}
237+
}
238+
}
239+
}

0 commit comments

Comments
 (0)