Skip to content

Commit 0a0e48f

Browse files
committed
qml: Add Information.qml in src/qml/controls
- This is an object similar to Setting.qml - Instead of a switch button this allows to have the text as the option's value. - The text could also double as an hyperlink if the link is given. - The header text has the property that it could be set to be an editable text. - Adds an optional property to display image instead of descriptive text, which also optionally can have a link attached to it.
1 parent 622ee46 commit 0a0e48f

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ QML_RES_QML = \
309309
qml/components/StorageOptions.qml \
310310
qml/controls/ContinueButton.qml \
311311
qml/controls/Header.qml \
312+
qml/controls/Information.qml \
312313
qml/controls/PageIndicator.qml \
313314
qml/controls/OptionButton.qml \
314315
qml/controls/OptionSwitch.qml \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<file>components/StorageOptions.qml</file>
77
<file>controls/ContinueButton.qml</file>
88
<file>controls/Header.qml</file>
9+
<file>controls/Information.qml</file>
910
<file>controls/PageIndicator.qml</file>
1011
<file>controls/OptionButton.qml</file>
1112
<file>controls/OptionSwitch.qml</file>

src/qml/controls/Information.qml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Copyright (c) 2022 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+
Control {
10+
id: root
11+
property bool last: parent && root === parent.children[parent.children.length - 1]
12+
required property string header
13+
property string subtext
14+
property int subtextMargin: 3
15+
property string description
16+
property int descriptionMargin: 10
17+
property int descriptionSize: 18
18+
property bool isReadonly: true
19+
property bool hasIcon: false
20+
property string iconSource
21+
property int iconWidth: 30
22+
property int iconHeight: 30
23+
property string link
24+
contentItem: ColumnLayout {
25+
spacing: 20
26+
width: parent.width
27+
RowLayout {
28+
Header {
29+
Layout.fillWidth: true
30+
center: false
31+
header: root.header
32+
headerSize: 18
33+
description: root.subtext
34+
descriptionSize: 15
35+
descriptionMargin: root.subtextMargin
36+
wrap: false
37+
}
38+
Loader {
39+
Layout.fillWidth: true
40+
Layout.preferredWidth: 0
41+
Layout.rightMargin: 12
42+
active: root.description.length > 0
43+
visible: active
44+
sourceComponent: TextEdit {
45+
topPadding: root.descriptionMargin
46+
font.family: "Inter"
47+
font.styleName: "Regular"
48+
font.pointSize: root.descriptionSize
49+
color: Theme.color.neutral8
50+
textFormat: Text.RichText
51+
text: "<style>a:link { color: " + Theme.color.neutral8 + "; text-decoration: none;}</style>" + "<a href=\"" + link + "\">" + root.description + "</a>"
52+
readOnly: isReadonly
53+
onLinkActivated: Qt.openUrlExternally(link)
54+
horizontalAlignment: Text.AlignRight
55+
wrapMode: Text.WordWrap
56+
}
57+
}
58+
Loader {
59+
Layout.preferredWidth: root.iconWidth
60+
Layout.preferredHeight: root.iconHeight
61+
Layout.alignment: Qt.AlignRight
62+
Layout.rightMargin: 12
63+
active: root.hasIcon
64+
visible: active
65+
sourceComponent: Image {
66+
horizontalAlignment: Image.AlignRight
67+
source: root.iconSource
68+
fillMode: Image.PreserveAspectFit
69+
mipmap: true
70+
MouseArea {
71+
anchors.fill: parent
72+
onClicked: {
73+
Qt.openUrlExternally(link)
74+
}
75+
}
76+
}
77+
}
78+
}
79+
Loader {
80+
Layout.fillWidth:true
81+
Layout.columnSpan: 2
82+
active: !last
83+
visible: active
84+
sourceComponent: Rectangle {
85+
height: 1
86+
color: Theme.color.neutral5
87+
}
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)