2021-01-19 14:34:41 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 10:24:37 +00:00
|
|
|
import "../"
|
2021-10-14 13:09:35 +00:00
|
|
|
import "../panels"
|
2021-10-14 10:24:37 +00:00
|
|
|
import "../controls"
|
2021-01-19 14:34:41 +00:00
|
|
|
|
2021-10-14 10:24:37 +00:00
|
|
|
// TODO: replace with StatusQ components
|
2021-01-19 14:34:41 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
height: control.height
|
|
|
|
width: control.width + copyToClipBoardBtn.width + Style.current.smallPadding
|
|
|
|
property bool hovered: false
|
|
|
|
property string address: ""
|
|
|
|
property bool expanded: false
|
|
|
|
property int addressWidth
|
|
|
|
property int originalButtonWidth
|
2022-01-31 13:29:27 +00:00
|
|
|
property var store
|
2021-01-19 14:34:41 +00:00
|
|
|
|
|
|
|
Button {
|
|
|
|
id: control
|
|
|
|
width: root.addressWidth
|
|
|
|
leftPadding: 8
|
|
|
|
rightPadding: 8
|
|
|
|
contentItem: StyledText {
|
|
|
|
id: addressText
|
|
|
|
text: root.address
|
|
|
|
font.pixelSize: 13
|
2022-09-15 15:23:51 +00:00
|
|
|
font.family: Style.current.monoFont.name
|
2021-01-19 14:34:41 +00:00
|
|
|
color: Style.current.secondaryText
|
|
|
|
elide: Text.ElideMiddle
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: root.hovered ? Style.current.backgroundHover : "transparent"
|
|
|
|
radius: Style.current.radius
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: {
|
|
|
|
if (root.expanded) {
|
|
|
|
control.width = root.originalButtonWidth
|
|
|
|
this.width = control.width
|
|
|
|
} else {
|
|
|
|
root.originalButtonWidth = root.addressWidth
|
|
|
|
control.width = control.maxWidth > 0 ?
|
|
|
|
Math.min(addressText.implicitWidth, control.maxWidth) :
|
|
|
|
addressText.implicitWidth + control.leftPadding + control.rightPadding
|
|
|
|
}
|
|
|
|
this.width = control.width
|
|
|
|
root.expanded = !root.expanded
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
propagateComposedEvents: true
|
|
|
|
onPressed: mouse.accepted = false
|
|
|
|
onEntered: {
|
|
|
|
if (!root.hovered) {
|
|
|
|
root.hovered = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
if (root.hovered) {
|
|
|
|
root.hovered = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyToClipBoardButton {
|
|
|
|
id: copyToClipBoardBtn
|
|
|
|
visible: root.hovered
|
|
|
|
anchors.left: control.right
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2022-03-15 19:34:28 +00:00
|
|
|
color: Style.current.transparent
|
2021-01-19 14:34:41 +00:00
|
|
|
textToCopy: root.address
|
2023-02-20 12:55:39 +00:00
|
|
|
onCopyClicked: root.store.copyToClipboard(textToCopy)
|
2021-01-19 14:34:41 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
propagateComposedEvents: true
|
|
|
|
onPressed: mouse.accepted = false
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
|
|
|
if (!root.hovered) {
|
|
|
|
root.hovered = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
if (root.hovered) {
|
|
|
|
root.hovered = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|