2020-09-10 19:56:05 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 13:41:18 +00:00
|
|
|
import "../"
|
|
|
|
import "../panels"
|
|
|
|
import "../controls"
|
2020-09-10 19:56:05 +00:00
|
|
|
|
|
|
|
Popup {
|
|
|
|
id: root
|
2020-09-11 15:36:22 +00:00
|
|
|
closePolicy: Popup.NoAutoClose
|
2020-09-10 19:56:05 +00:00
|
|
|
height: 68
|
|
|
|
padding: 0
|
|
|
|
margins: 0
|
2021-07-16 05:37:07 +00:00
|
|
|
width: Math.max(Math.max(titleText.width, linkStyledText.width)
|
|
|
|
+ (toastImage.visible? toastImage.width + rowId.spacing : 0)
|
|
|
|
+ rowId.leftPadding + rowId.rightPadding,
|
|
|
|
343)
|
2020-09-10 19:56:05 +00:00
|
|
|
x: parent.width - width - Style.current.bigPadding
|
|
|
|
y: parent.height - height - Style.current.bigPadding
|
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
|
|
|
|
//% "View on Etherscan"
|
|
|
|
readonly property string defaultLinkText: qsTrId("view-on-etherscan")
|
|
|
|
|
|
|
|
property string uuid: "" // set this if you want to distinct among multiple toasts
|
2021-09-28 15:04:06 +00:00
|
|
|
property url source: Style.svg("check-circle")
|
2021-07-16 05:37:07 +00:00
|
|
|
property color iconColor: Style.current.primary
|
|
|
|
property bool iconRotates: false
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Transaction pending..."
|
|
|
|
property string title: qsTrId("ens-transaction-pending")
|
2021-07-16 05:37:07 +00:00
|
|
|
property string link: "https://etherscan.io/"
|
|
|
|
property string linkText: defaultLinkText
|
|
|
|
property int dissapearInMs: 4000 /* setting this to -1 makes caller responsible to close it */
|
|
|
|
property bool displayCloseButton: true
|
2022-02-09 09:43:23 +00:00
|
|
|
property bool displayLink: true
|
2021-07-16 05:37:07 +00:00
|
|
|
|
2020-09-11 15:36:22 +00:00
|
|
|
onOpened: {
|
2021-07-16 05:37:07 +00:00
|
|
|
if(dissapearInMs == -1)
|
|
|
|
return
|
|
|
|
|
2020-09-11 15:36:22 +00:00
|
|
|
timer.setTimeout(function() {
|
|
|
|
root.close()
|
2021-07-16 05:37:07 +00:00
|
|
|
}, dissapearInMs);
|
2020-09-11 15:36:22 +00:00
|
|
|
}
|
2020-09-14 14:58:21 +00:00
|
|
|
onClosed: {
|
|
|
|
// Reset props
|
2021-09-28 15:04:06 +00:00
|
|
|
source = Style.svg("check-circle")
|
2020-09-14 14:58:21 +00:00
|
|
|
iconColor = Style.current.primary
|
|
|
|
iconRotates = false
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Transaction pending..."
|
|
|
|
title = qsTrId("ens-transaction-pending")
|
2021-07-16 05:37:07 +00:00
|
|
|
link = "https://etherscan.io/"
|
|
|
|
linkText = defaultLinkText
|
|
|
|
dissapearInMs = 4000
|
|
|
|
displayCloseButton = true
|
|
|
|
displayLink = true
|
2020-09-14 14:58:21 +00:00
|
|
|
}
|
2020-09-11 15:36:22 +00:00
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
}
|
|
|
|
|
2020-09-10 19:56:05 +00:00
|
|
|
background: Rectangle {
|
2020-09-11 15:18:10 +00:00
|
|
|
id: container
|
2020-09-10 19:56:05 +00:00
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow{
|
|
|
|
width: container.width
|
|
|
|
height: container.height
|
|
|
|
x: container.x
|
|
|
|
y: container.y + 10
|
|
|
|
visible: container.visible
|
|
|
|
source: container
|
|
|
|
horizontalOffset: 0
|
|
|
|
verticalOffset: 2
|
|
|
|
radius: 10
|
|
|
|
samples: 15
|
2021-07-29 19:20:15 +00:00
|
|
|
color: Style.current.dropShadow
|
2020-09-10 19:56:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
Row {
|
|
|
|
id: rowId
|
|
|
|
anchors.fill: parent
|
|
|
|
leftPadding: 12
|
|
|
|
rightPadding: 12
|
|
|
|
topPadding: Style.current.padding
|
|
|
|
bottomPadding: Style.current.padding
|
|
|
|
spacing: 12
|
2020-09-10 19:56:05 +00:00
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
RoundedIcon {
|
|
|
|
id: toastImage
|
|
|
|
visible: root.source != ""
|
|
|
|
width: 32
|
|
|
|
height: 32
|
|
|
|
iconHeight: 20
|
|
|
|
iconWidth: 20
|
|
|
|
color: Utils.setColorAlpha(root.iconColor, 0.1)
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source: root.source
|
|
|
|
iconColor: root.iconColor
|
|
|
|
rotates: root.iconRotates
|
|
|
|
}
|
2020-09-10 19:56:05 +00:00
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
Column {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: titleText
|
|
|
|
text: root.title
|
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Medium
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: linkStyledText
|
|
|
|
visible: displayLink
|
|
|
|
text: `<a href='${root.link}' style='color:${Style.current.textColorTertiary};text-decoration:none;'>${root.linkText}</a>`
|
|
|
|
color: Style.current.textColorTertiary
|
|
|
|
textFormat: Text.RichText
|
|
|
|
font.pixelSize: 13
|
|
|
|
font.weight: Font.Medium
|
|
|
|
onLinkActivated: {
|
2021-12-06 21:10:54 +00:00
|
|
|
Global.openLink(root.link)
|
2021-07-16 05:37:07 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
2020-09-11 15:18:10 +00:00
|
|
|
}
|
2020-09-10 19:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: closeImage
|
2021-07-16 05:37:07 +00:00
|
|
|
visible: displayCloseButton
|
2020-09-10 19:56:05 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("plusSign")
|
2020-09-10 19:56:05 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
width: 9
|
|
|
|
height: 9
|
|
|
|
rotation: 45
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ColorOverlay {
|
2021-07-16 05:37:07 +00:00
|
|
|
visible: displayCloseButton
|
2020-09-10 19:56:05 +00:00
|
|
|
anchors.fill: closeImage
|
|
|
|
source: closeImage
|
|
|
|
rotation: 45
|
|
|
|
color: Style.current.textColor
|
|
|
|
}
|
|
|
|
}
|