2020-06-29 15:23:28 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-02-18 19:07:23 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 13:39:12 +00:00
|
|
|
import "./"
|
2021-10-14 10:24:37 +00:00
|
|
|
import "../"
|
|
|
|
import "../status"
|
2020-06-29 15:23:28 +00:00
|
|
|
|
2021-10-14 10:24:37 +00:00
|
|
|
// TODO: Replace with StatusQ components
|
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: ""
|
2021-03-25 19:37:55 +00:00
|
|
|
property bool tooltipUnder: false
|
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
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("copy-to-clipboard-icon")
|
2020-06-29 15:23:28 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-02-18 19:07:23 +00:00
|
|
|
|
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: parent
|
|
|
|
antialiasing: true
|
|
|
|
source: parent
|
|
|
|
color: Style.current.primary
|
|
|
|
}
|
2020-06-29 15:23:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-02-25 15:28:56 +00:00
|
|
|
parent.color = Style.current.backgroundHover
|
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-02-18 16:36:05 +00:00
|
|
|
//% "Copied!"
|
|
|
|
text: qsTrId("copied-")
|
2021-03-25 19:37:55 +00:00
|
|
|
orientation: tooltipUnder ? "bottom" : "top"
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|