Skip to content

Commit 2bcb248

Browse files
committed
qml: Introduce LabeledTextInput control
This control is primarily used in wallet forms where the user is expected to input values for sending or receiving transactions. It contains a Label describing the input as well as a TextInput where the actual string is entered. A Icon is also available on the right side of the component for extra actions.
1 parent 574817b commit 2bcb248

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ QML_RES_QML = \
390390
qml/controls/InformationPage.qml \
391391
qml/controls/IPAddressValueInput.qml \
392392
qml/controls/KeyValueRow.qml \
393+
qml/controls/LabeledTextInput.qml \
393394
qml/controls/NavButton.qml \
394395
qml/controls/PageIndicator.qml \
395396
qml/controls/NavigationBar.qml \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<file>controls/ContinueButton.qml</file>
2424
<file>controls/CoreText.qml</file>
2525
<file>controls/CoreTextField.qml</file>
26+
<file>controls/LabeledTextInput.qml</file>
2627
<file>controls/ExternalLink.qml</file>
2728
<file>controls/FocusBorder.qml</file>
2829
<file>controls/Header.qml</file>

src/qml/controls/LabeledTextInput.qml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
9+
Item {
10+
property alias labelText: label.text
11+
property alias text: input.text
12+
property alias placeholderText: input.placeholderText
13+
property alias iconSource: icon.source
14+
property alias customIcon: iconContainer.data
15+
property alias enabled: input.enabled
16+
17+
signal iconClicked
18+
signal textEdited
19+
20+
id: root
21+
implicitHeight: label.height + input.height
22+
23+
CoreText {
24+
id: label
25+
anchors.left: parent.left
26+
anchors.top: parent.top
27+
color: Theme.color.neutral7
28+
font.pixelSize: 15
29+
}
30+
31+
TextField {
32+
id: input
33+
anchors.left: parent.left
34+
anchors.right: iconContainer.left
35+
anchors.bottom: parent.bottom
36+
leftPadding: 0
37+
font.family: "Inter"
38+
font.styleName: "Regular"
39+
font.pixelSize: 18
40+
color: Theme.color.neutral9
41+
placeholderTextColor: Theme.color.neutral7
42+
background: Item {}
43+
onTextEdited: root.textEdited()
44+
}
45+
46+
Item {
47+
id: iconContainer
48+
anchors.right: parent.right
49+
anchors.verticalCenter: input.verticalCenter
50+
51+
Icon {
52+
id: icon
53+
source: ""
54+
color: Theme.color.neutral8
55+
size: 30
56+
enabled: source != ""
57+
onClicked: root.iconClicked()
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)