Skip to content

Commit a17b84e

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 8763690 commit a17b84e

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

src/Makefile.qt.include

+1
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ QML_RES_QML = \
310310
qml/components/StorageOptions.qml \
311311
qml/controls/ContinueButton.qml \
312312
qml/controls/Header.qml \
313+
qml/controls/Information.qml \
313314
qml/controls/PageIndicator.qml \
314315
qml/controls/OptionButton.qml \
315316
qml/controls/OptionSwitch.qml \

src/qml/bitcoin_qml.qrc

+1
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

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.alignment: Qt.AlignRight | Qt.AlignHCenter
42+
active: root.description.length > 0
43+
visible: active
44+
sourceComponent: TextEdit {
45+
font.family: "Inter"
46+
font.styleName: "Regular"
47+
font.pixelSize: root.descriptionSize
48+
color: Theme.color.neutral8
49+
textFormat: Text.RichText
50+
text: "<style>a:link { color: " + Theme.color.neutral8 + "; text-decoration: none;}</style>" + "<a href=\"" + link + "\">" + root.description + "</a>"
51+
readOnly: isReadonly
52+
onLinkActivated: Qt.openUrlExternally(link)
53+
horizontalAlignment: Text.AlignRight
54+
wrapMode: Text.WordWrap
55+
}
56+
}
57+
Loader {
58+
Layout.preferredWidth: root.iconWidth
59+
Layout.preferredHeight: root.iconHeight
60+
Layout.alignment: Qt.AlignRight | Qt.AlignHCenter
61+
active: root.hasIcon
62+
visible: active
63+
sourceComponent: Image {
64+
horizontalAlignment: Image.AlignRight
65+
source: root.iconSource
66+
fillMode: Image.PreserveAspectFit
67+
mipmap: true
68+
MouseArea {
69+
anchors.fill: parent
70+
onClicked: {
71+
Qt.openUrlExternally(link)
72+
}
73+
}
74+
}
75+
}
76+
}
77+
Loader {
78+
Layout.fillWidth:true
79+
Layout.columnSpan: 2
80+
active: !last
81+
visible: active
82+
sourceComponent: Rectangle {
83+
height: 1
84+
color: Theme.color.neutral5
85+
}
86+
}
87+
}
88+
}

0 commit comments

Comments
 (0)