status-desktop/ui/shared/CopyToClipBoardButton.qml
Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

80 lines
1.8 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../shared/status"
Rectangle {
id: copyToClipboardButton
height: 32
width: 32
radius: 8
color: Style.current.transparent
property var onClick: function() {}
property string textToCopy: ""
property bool tooltipUnder: false
Image {
width: 20
height: 20
sourceSize.width: width
sourceSize.height: height
source: Style.svg("copy-to-clipboard-icon")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
ColorOverlay {
anchors.fill: parent
antialiasing: true
source: parent
color: Style.current.primary
}
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
hoverEnabled: true
onExited: {
parent.color = Style.current.transparent
}
onEntered:{
parent.color = Style.current.backgroundHover
}
onPressed: {
parent.color = Style.current.backgroundHover
if (!toolTip.visible) {
toolTip.visible = true
}
}
onReleased: {
parent.color = Style.current.backgroundHover
}
onClicked: {
if (textToCopy) {
chatsModel.copyToClipboard(textToCopy)
}
onClick()
}
}
StatusToolTip {
id: toolTip
//% "Copied!"
text: qsTrId("copied-")
orientation: tooltipUnder ? "bottom" : "top"
}
Timer {
id:hideTimer
interval: 2000
running: toolTip.visible
onTriggered: {
toolTip.visible = false;
}
}
}