2020-06-29 15:23:28 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import "../imports"
|
2021-01-13 15:10:42 +00:00
|
|
|
import "../shared/status"
|
2020-06-29 15:23:28 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: copyToClipboardButton
|
|
|
|
height: 32
|
|
|
|
width: 32
|
|
|
|
radius: 8
|
2020-07-22 20:16:06 +00:00
|
|
|
color: Style.current.transparent
|
2020-06-29 15:23:28 +00:00
|
|
|
property var onClick: function() {}
|
2020-07-09 15:19:10 +00:00
|
|
|
property string textToCopy: ""
|
2020-06-29 15:23:28 +00:00
|
|
|
|
2020-08-28 19:09:00 +00:00
|
|
|
Image {
|
2020-06-29 15:23:28 +00:00
|
|
|
width: 20
|
|
|
|
height: 20
|
2020-08-28 19:09:00 +00:00
|
|
|
sourceSize.width: width
|
|
|
|
sourceSize.height: height
|
2020-06-29 15:23:28 +00:00
|
|
|
source: "./img/copy-to-clipboard-icon.svg"
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onExited: {
|
2020-07-09 15:19:10 +00:00
|
|
|
parent.color = Style.current.transparent
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
|
|
|
onEntered:{
|
2021-01-19 15:34:07 +00:00
|
|
|
parent.color = Style.current.backgroundHover
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2020-07-09 15:19:10 +00:00
|
|
|
onPressed: {
|
2021-01-19 15:34:07 +00:00
|
|
|
parent.color = Style.current.backgroundHover
|
2021-01-13 15:10:42 +00:00
|
|
|
if (!toolTip.visible) {
|
|
|
|
toolTip.visible = true
|
|
|
|
}
|
2020-07-09 15:19:10 +00:00
|
|
|
}
|
|
|
|
onReleased: {
|
2021-01-12 14:56:17 +00:00
|
|
|
parent.color = Style.current.grey
|
2020-07-09 15:19:10 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
if (textToCopy) {
|
|
|
|
chatsModel.copyToClipboard(textToCopy)
|
|
|
|
}
|
|
|
|
onClick()
|
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
2021-01-12 14:56:17 +00:00
|
|
|
|
2021-01-13 15:10:42 +00:00
|
|
|
StatusToolTip {
|
2021-01-12 14:56:17 +00:00
|
|
|
id: toolTip
|
2021-01-13 15:10:42 +00:00
|
|
|
text: qsTr("Copied!")
|
2021-01-12 14:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id:hideTimer
|
2021-01-13 15:10:42 +00:00
|
|
|
interval: 2000
|
2021-01-12 14:56:17 +00:00
|
|
|
running: toolTip.visible
|
|
|
|
onTriggered: {
|
|
|
|
toolTip.visible = false;
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|