Skip to content

Commit ab5d3f2

Browse files
shaavanhebasto
authored andcommitted
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. Github-Pull: bitcoin-core#124 Rebased-From: a17b84e
1 parent 3a01005 commit ab5d3f2

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

src/qml/BitcoinApp/Controls/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ qt6_add_qml_module(bitcoin_qml_controls
1515
QML_FILES
1616
ContinueButton.qml
1717
Header.qml
18+
Information.qml
1819
OptionButton.qml
1920
OptionSwitch.qml
2021
PageIndicator.qml
Lines changed: 88 additions & 0 deletions
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
6+
import QtQuick.Controls
7+
import QtQuick.Layouts
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)