2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2021-10-21 08:22:05 +00:00
|
|
|
|
2022-07-28 20:56:44 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2024-08-27 14:35:52 +00:00
|
|
|
import StatusQ 0.1
|
2021-10-21 08:22:05 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2024-08-27 14:35:52 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-21 08:22:05 +00:00
|
|
|
|
2022-11-28 21:05:57 +00:00
|
|
|
import shared.controls 1.0
|
|
|
|
|
2022-07-28 20:56:44 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
2024-03-11 10:08:40 +00:00
|
|
|
|
|
|
|
property alias collectibleName: collectibleName.text
|
|
|
|
property alias collectibleId: collectibleId.text
|
|
|
|
|
2024-04-02 08:23:20 +00:00
|
|
|
property string collectionName
|
|
|
|
|
|
|
|
property string communityName
|
|
|
|
property string communityId
|
2024-03-11 10:08:40 +00:00
|
|
|
property string communityImage
|
2024-04-02 08:23:20 +00:00
|
|
|
|
2023-02-07 08:23:44 +00:00
|
|
|
property string networkShortName
|
2022-11-28 21:05:57 +00:00
|
|
|
property string networkColor
|
|
|
|
property string networkIconURL
|
2024-03-11 10:08:40 +00:00
|
|
|
property string networkExplorerName
|
2022-11-28 21:05:57 +00:00
|
|
|
|
2024-03-26 15:00:16 +00:00
|
|
|
property bool collectibleLinkEnabled
|
|
|
|
property bool collectionLinkEnabled
|
|
|
|
property bool explorerLinkEnabled
|
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
signal collectionTagClicked()
|
|
|
|
signal openCollectibleExternally()
|
|
|
|
signal openCollectibleOnExplorer()
|
2022-11-28 21:05:57 +00:00
|
|
|
|
2022-07-28 20:56:44 +00:00
|
|
|
RowLayout {
|
2024-03-11 10:08:40 +00:00
|
|
|
RowLayout {
|
|
|
|
StatusBaseText {
|
|
|
|
id: collectibleName
|
2022-11-28 21:05:57 +00:00
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
font.pixelSize: 22
|
|
|
|
lineHeight: 30
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
elide: Text.ElideRight
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
id: collectibleId
|
|
|
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
|
|
|
font.pixelSize: 22
|
|
|
|
lineHeight: 30
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
elide: Text.ElideRight
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
2022-11-28 21:05:57 +00:00
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
Item{Layout.fillWidth: true}
|
2022-11-28 21:05:57 +00:00
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 12
|
|
|
|
StatusButton {
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
text: root.networkExplorerName
|
|
|
|
icon.name: "external"
|
|
|
|
onClicked: root.openCollectibleOnExplorer()
|
2024-03-26 15:00:16 +00:00
|
|
|
visible: root.explorerLinkEnabled
|
2024-03-11 10:08:40 +00:00
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
text: "OpenSea"
|
|
|
|
icon.name: "external"
|
|
|
|
onClicked: root.openCollectibleExternally()
|
2024-03-26 15:00:16 +00:00
|
|
|
visible: root.collectibleLinkEnabled
|
2022-11-28 21:05:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 10
|
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
InformationTag {
|
|
|
|
id: collectionTag
|
2024-04-02 08:23:20 +00:00
|
|
|
readonly property bool isCollection: !!root.collectionName && !root.communityId
|
|
|
|
readonly property bool isUnkownCommunity: !!root.communityId && !root.communityName
|
|
|
|
property bool copySuccess: false
|
|
|
|
asset.name: {
|
|
|
|
if (!!root.communityImage) {
|
|
|
|
return root.communityImage
|
|
|
|
}
|
|
|
|
if (sensor.containsMouse) {
|
|
|
|
return "tiny/external"
|
|
|
|
}
|
|
|
|
if (root.isCollection) {
|
|
|
|
return "tiny/folder"
|
|
|
|
}
|
|
|
|
return "tiny/profile"
|
|
|
|
}
|
2024-03-11 10:08:40 +00:00
|
|
|
asset.isImage: !!root.communityImage
|
2024-04-02 08:23:20 +00:00
|
|
|
enabled: root.collectionLinkEnabled || !!root.communityId
|
|
|
|
tagPrimaryLabel.text: !!root.communityName ? root.communityName : root.collectionName
|
|
|
|
backgroundColor: sensor.containsMouse ? Theme.palette.baseColor5 : Theme.palette.baseColor4
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "copiedCommunity"
|
|
|
|
extend: "unkownCommunityHover"
|
|
|
|
when: collectionTag.copySuccess && collectionTag.isUnkownCommunity
|
|
|
|
PropertyChanges {
|
|
|
|
target: collectionTag
|
|
|
|
asset.name: "tiny/checkmark"
|
|
|
|
asset.color: Theme.palette.successColor1
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: statusToolTip
|
|
|
|
text: qsTr("Community address copied")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "unkownCommunityHover"
|
|
|
|
when: collectionTag.isUnkownCommunity && sensor.containsMouse
|
|
|
|
PropertyChanges {
|
|
|
|
target: collectionTag
|
|
|
|
asset.name: "tiny/copy"
|
|
|
|
tagPrimaryLabel.text: qsTr("Community %1").arg(Utils.compactAddress(root.communityId, 4))
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: statusToolTip
|
|
|
|
visible: true
|
|
|
|
text: qsTr("Community name could not be fetched")
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "unkownCommunity"
|
|
|
|
when: collectionTag.isUnkownCommunity
|
|
|
|
PropertyChanges {
|
|
|
|
target: collectionTag
|
|
|
|
asset.name: "tiny/help"
|
|
|
|
asset.color: Theme.palette.baseColor1
|
|
|
|
tagPrimaryLabel.text: qsTr("Unknown community")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2024-03-11 10:08:40 +00:00
|
|
|
MouseArea {
|
|
|
|
id: sensor
|
|
|
|
anchors.fill: parent
|
2024-04-02 08:23:20 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onContainsMouseChanged: {
|
|
|
|
if (!containsMouse)
|
|
|
|
collectionTag.copySuccess = false
|
|
|
|
}
|
2024-03-11 10:08:40 +00:00
|
|
|
onClicked: {
|
2024-04-02 08:23:20 +00:00
|
|
|
if (collectionTag.isUnkownCommunity) {
|
|
|
|
collectionTag.copySuccess = true
|
|
|
|
debounceTimer.restart()
|
2024-08-27 14:35:52 +00:00
|
|
|
ClipboardUtils.setText(root.communityId)
|
2024-04-02 08:23:20 +00:00
|
|
|
return
|
|
|
|
}
|
2024-03-11 10:08:40 +00:00
|
|
|
root.collectionTagClicked()
|
|
|
|
}
|
2024-04-02 08:23:20 +00:00
|
|
|
Timer {
|
|
|
|
id: debounceTimer
|
|
|
|
interval: 2000
|
|
|
|
running: collectionTag.copySuccess
|
|
|
|
onTriggered: collectionTag.copySuccess = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusToolTip {
|
|
|
|
id: statusToolTip
|
|
|
|
visible: false
|
|
|
|
delay: 0
|
|
|
|
orientation: StatusToolTip.Orientation.Top
|
2022-11-28 21:05:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InformationTag {
|
|
|
|
id: networkTag
|
2023-02-07 08:23:44 +00:00
|
|
|
readonly property bool isNetworkValid: networkShortName !== ""
|
2024-10-15 19:26:12 +00:00
|
|
|
asset.name: isNetworkValid && networkIconURL !== "" ? Theme.svg("tiny/" + networkIconURL) : ""
|
2024-02-20 09:04:39 +00:00
|
|
|
asset.isImage: true
|
2023-02-07 08:23:44 +00:00
|
|
|
tagPrimaryLabel.text: isNetworkValid ? networkShortName : "---"
|
2022-11-28 21:05:57 +00:00
|
|
|
tagPrimaryLabel.color: isNetworkValid ? networkColor : "black"
|
|
|
|
visible: isNetworkValid
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|