Files
pay/guis/Flowee/AddressLabel.qml
T
tomFlowee dfabcde813 Use Basic QQ Controls theme
The non-themed import basically is just a proxy using some
auto-detection to find out which theme to use.
As the app only uses the basic theme, this is what we'll import.
2025-06-19 15:09:36 +02:00

104 lines
3.3 KiB
QML

/*
* This file is part of the Flowee project
* Copyright (C) 2024-2025 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls.Basic as QQC2
QQC2.Control {
id: root
required property var txInfo;
property alias highlight: highlight.visible
property alias showCopyIcon: copyIcon.visible
width: implicitWidth
height: implicitHeight
implicitHeight: Math.max(theLabel.implicitHeight, copyIcon.height)
implicitWidth: theLabel.implicitWidth
+ (copyIcon.visible ? (copyIcon.width + 10) : 0)
baselineOffset: theLabel.baselineOffset
Label {
id: theLabel
background: Rectangle {
color: Pay.useDarkSkin ? "#4fb2e7" : "yellow"
id: highlight
radius: height / 3
opacity: 0.2
}
width: parent.width - (copyIcon.visible ? (copyIcon.width + 6) : 0)
height: parent.height
elide: wrapMode === Text.NoWrap ? Text.ElideMiddle : Text.ElideNone
property bool allowCloak: true
onContentHeightChanged: {
if (text === root.txInfo.cloakedAddress) { // this font is bigger.
root.baselineOffset = baselineOffset;
root.implicitHeight = Math.max(theLabel.implicitHeight, root.showCopyIcon ? copyIcon.height : 0)
}
}
text: {
if (allowCloak) {
var cloaked = root.txInfo.cloakedAddress
if (cloaked !== "")
return cloaked;
}
return root.txInfo.address;
}
font.pixelSize: {
if (text === root.txInfo.cloakedAddress)
return root.font.pixelSize;
return root.font.pixelSize * 0.9;
}
MouseArea {
anchors.fill: parent
anchors.margins: -6 // a bit bigger
onClicked: parent.allowCloak = !parent.allowCloak
}
}
Rectangle {
id: copiedFeedback
anchors.fill: theLabel
color: palette.mid
opacity: 0
visible: opacity > 0
Timer {
running: parent.visible
onTriggered: parent.opacity = 0;
interval: 500
}
Behavior on opacity { NumberAnimation { duration: 250 } }
}
Image {
id: copyIcon
anchors.right: parent.right
width: 20
height: 20
source: "qrc:/edit-copy" + (Pay.useDarkSkin ? "-light" : "") + ".svg"
MouseArea {
anchors.fill: parent
anchors.margins: -15
onClicked: {
copiedFeedback.opacity = 0.6
Pay.copyToClipboard(Pay.chainPrefix + root.txInfo.address)
}
}
}
}