2020-06-29 17:23:28 +02:00
|
|
|
import QtQuick 2.13
|
2021-09-28 18:04:06 +03:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-12-08 23:20:43 +02:00
|
|
|
import shared.stores 1.0
|
2021-10-14 22:30:51 +02:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
import utils 1.0
|
2020-06-29 17:23:28 +02:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
StatusRoundButton {
|
2020-06-29 17:23:28 +02:00
|
|
|
id: copyToClipboardButton
|
2022-03-15 20:34:28 +01:00
|
|
|
|
2020-06-29 17:23:28 +02:00
|
|
|
property var onClick: function() {}
|
2020-07-09 11:19:10 -04:00
|
|
|
property string textToCopy: ""
|
2021-03-25 15:37:55 -04:00
|
|
|
property bool tooltipUnder: false
|
2022-01-28 09:19:49 +01:00
|
|
|
property var store
|
2020-06-29 17:23:28 +02:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
icon.name: "copy"
|
2021-02-18 14:07:23 -05:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
onPressed: {
|
|
|
|
if (!toolTip.visible) {
|
|
|
|
toolTip.visible = true
|
2021-02-18 14:07:23 -05:00
|
|
|
}
|
2020-06-29 17:23:28 +02:00
|
|
|
}
|
2022-03-15 20:34:28 +01:00
|
|
|
onClicked: {
|
|
|
|
if (textToCopy) {
|
|
|
|
store.copyToClipboard(textToCopy)
|
2020-07-09 11:19:10 -04:00
|
|
|
}
|
2022-03-15 20:34:28 +01:00
|
|
|
onClick()
|
2020-06-29 17:23:28 +02:00
|
|
|
}
|
2021-01-12 18:56:17 +04:00
|
|
|
|
2022-03-15 20:34:28 +01:00
|
|
|
StatusToolTip {
|
2021-01-12 18:56:17 +04:00
|
|
|
id: toolTip
|
2021-02-18 11:36:05 -05:00
|
|
|
//% "Copied!"
|
|
|
|
text: qsTrId("copied-")
|
2022-03-15 20:34:28 +01:00
|
|
|
orientation: tooltipUnder ? StatusToolTip.Orientation.Bottom: StatusToolTip.Orientation.Top
|
2021-01-12 18:56:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
2022-03-15 20:34:28 +01:00
|
|
|
id: hideTimer
|
2021-01-13 19:10:42 +04:00
|
|
|
interval: 2000
|
2021-01-12 18:56:17 +04:00
|
|
|
running: toolTip.visible
|
|
|
|
onTriggered: {
|
|
|
|
toolTip.visible = false;
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 17:23:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|