Added tooltip when copy invite URL to clipboard

This commit is contained in:
staked-smart-ace 2021-01-12 18:56:17 +04:00 committed by Iuri Matias
parent 8afcacfa6a
commit 2f2b06fb5e
2 changed files with 32 additions and 3 deletions

View File

@ -21,7 +21,8 @@ ModalPopup {
anchors.left: linkText.right
anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: linkText.verticalCenter
textToCopy: popup.getStatusText
textToCopy: popup.getStatusText.substr(popup.getStatusText.indexOf("https"))
textTooltip: "Copied \"" + popup.getStatusText.substr(popup.getStatusText.indexOf("https")) + "\" to clipboard"
}
}

View File

@ -10,6 +10,8 @@ Rectangle {
color: Style.current.transparent
property var onClick: function() {}
property string textToCopy: ""
property bool showTooltip: false
property string textTooltip: ""
Image {
width: 20
@ -32,10 +34,11 @@ Rectangle {
parent.color = Style.current.grey
}
onPressed: {
parent.color = Style.current.darkGrey
parent.color = Style.current.grey
parent.showTooltip = true
}
onReleased: {
parent.color = Style.current.transparent
parent.color = Style.current.grey
}
onClicked: {
if (textToCopy) {
@ -44,6 +47,31 @@ Rectangle {
onClick()
}
}
ToolTip {
id: toolTip
text: parent.textTooltip
parent: copyToClipboardButton
}
Timer {
id:showTimer
interval: 500
running: parent.showTooltip && !toolTip.visible
onTriggered: {
toolTip.visible = true;
}
}
Timer {
id:hideTimer
interval: 1500
running: toolTip.visible
onTriggered: {
toolTip.visible = false;
parent.showTooltip = false;
}
}
}