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