2023-10-25 10:40:10 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQml.Models 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
|
|
|
StatusDialog {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property string sourceImage
|
|
|
|
required property string sourceUrl
|
|
|
|
required property string sourceVersion
|
|
|
|
required property int tokensCount
|
2023-10-20 08:19:48 +00:00
|
|
|
required property var tokensListModel // Expected roles: name, symbol, image, chainName, explorerUrl, isTest
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
signal linkClicked(string link)
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int symbolColumnWidth: 90
|
|
|
|
readonly property int addressColumnWidth: 106
|
|
|
|
readonly property int externalLinkBtnWidth: 32
|
|
|
|
}
|
|
|
|
|
|
|
|
width: 521 // by design
|
|
|
|
padding: 0
|
2024-10-15 19:26:12 +00:00
|
|
|
horizontalPadding: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
contentItem: StatusListView {
|
|
|
|
id: list
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
topMargin: Theme.padding
|
|
|
|
bottomMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
implicitHeight: contentHeight
|
|
|
|
|
|
|
|
header: ColumnLayout {
|
|
|
|
spacing: 20
|
|
|
|
width: list.width
|
|
|
|
|
|
|
|
CustomSourceInfoComponent {
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.margins: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Separator {}
|
|
|
|
|
|
|
|
CustomHeaderDelegate {}
|
|
|
|
}
|
|
|
|
delegate: CustomDelegate {}
|
2024-01-03 11:04:53 +00:00
|
|
|
/* This onCompleted has been added here because without it all
|
2023-10-20 08:19:48 +00:00
|
|
|
the items in the list get initialised before the popup is launched
|
|
|
|
creating a delay */
|
2024-01-03 11:04:53 +00:00
|
|
|
Component.onCompleted: model = root.tokensListModel
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
header: StatusDialogHeader {
|
2024-07-19 15:41:40 +00:00
|
|
|
headline.title: root.title
|
2023-10-25 10:40:10 +00:00
|
|
|
headline.subtitle: qsTr("%n token(s)", "", root.tokensCount)
|
|
|
|
actions.closeButton.onClicked: root.close()
|
|
|
|
leftComponent: StatusSmartIdenticon {
|
|
|
|
asset.name: root.sourceImage
|
|
|
|
asset.isImage: !!asset.name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: StatusDialogFooter {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Done")
|
|
|
|
type: StatusBaseButton.Type.Normal
|
|
|
|
|
|
|
|
onClicked: close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component CustomTextBlock: ColumnLayout {
|
|
|
|
id: textBlock
|
|
|
|
|
|
|
|
property string title
|
|
|
|
property string text
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: textBlock.title
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: textBlock.text
|
2023-10-20 08:19:48 +00:00
|
|
|
elide: Text.ElideRight
|
2023-10-25 10:40:10 +00:00
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component CustomExternalLinkButton: StatusFlatButton {
|
|
|
|
id: extButton
|
|
|
|
|
|
|
|
property string link
|
|
|
|
|
|
|
|
Layout.preferredHeight: d.externalLinkBtnWidth
|
|
|
|
Layout.preferredWidth: d.externalLinkBtnWidth
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
textColor: Theme.palette.baseColor1
|
|
|
|
textHoverColor: Theme.palette.directColor1
|
|
|
|
icon.name: "external-link"
|
2023-10-20 08:19:48 +00:00
|
|
|
onClicked: root.linkClicked(link)
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
component CustomSourceInfoComponent: ColumnLayout {
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
CustomTextBlock {
|
|
|
|
title: qsTr("Source")
|
|
|
|
text: root.sourceUrl
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomExternalLinkButton {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.rightMargin: Theme.halfPadding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
link: root.sourceUrl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomTextBlock {
|
|
|
|
title: qsTr("Version")
|
|
|
|
text: root.sourceVersion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component CustomHeaderDelegate: RowLayout {
|
|
|
|
height: 34
|
|
|
|
width: contentItem.width
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
text: qsTr("Name")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
Layout.preferredWidth: d.symbolColumnWidth - Layout.leftMargin
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
|
|
|
text: qsTr("Symbol")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
Layout.preferredWidth: d.addressColumnWidth - Layout.leftMargin
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
|
|
|
text: qsTr("Address")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
// Just a filler corresponding to external link column
|
|
|
|
Item {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
Layout.preferredWidth: d.externalLinkBtnWidth
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.rightMargin: Theme.bigPadding
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
component CustomDelegate: Rectangle {
|
|
|
|
width: contentItem.width
|
|
|
|
height: 64
|
|
|
|
color: (sensor.containsMouse || externalLinkBtn.hovered) ? Theme.palette.baseColor2 : "transparent"
|
|
|
|
radius: 8
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: sensor
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 0
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
|
|
|
spacing: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
asset.isImage: true
|
|
|
|
asset.name: model.image
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
text: model.name
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2023-10-20 08:19:48 +00:00
|
|
|
text: model.chainName + (model.isTest? " " + qsTr("(Test)") : "")
|
2023-10-25 10:40:10 +00:00
|
|
|
elide: Text.ElideMiddle
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
Layout.preferredWidth: d.symbolColumnWidth - Layout.leftMargin
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
|
|
|
text: model.symbol
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
Layout.preferredWidth: d.addressColumnWidth - Layout.leftMargin
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
|
|
|
text: model.address
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomExternalLinkButton {
|
|
|
|
id: externalLinkBtn
|
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.leftMargin: Theme.padding
|
|
|
|
Layout.rightMargin: Theme.bigPadding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
link: model.explorerUrl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|