mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 14:11:09 +00:00
fix(liquidity): reuse wallet copy controls
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
|
||||
Button {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
property string value: ""
|
||||
property string accessibleName: qsTr("Copy address")
|
||||
property int buttonWidth: 30
|
||||
property int labelFontPixelSize: 10
|
||||
property bool copied: false
|
||||
|
||||
implicitWidth: root.buttonWidth
|
||||
implicitHeight: 24
|
||||
visible: root.value.length > 0
|
||||
enabled: root.value.length > 0
|
||||
hoverEnabled: true
|
||||
text: root.copied ? "\u2713" : qsTr("Copy")
|
||||
Accessible.name: root.copied ? qsTr("Copied") : root.accessibleName
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: Accessible.name
|
||||
onClicked: {
|
||||
root.copyToClipboard()
|
||||
root.copied = true
|
||||
copiedReset.restart()
|
||||
}
|
||||
|
||||
contentItem: Text {
|
||||
text: root.text
|
||||
color: root.enabled ? root.theme.colors.ctaBg : root.theme.colors.textPlaceholder
|
||||
font.pixelSize: root.labelFontPixelSize
|
||||
font.weight: Font.Medium
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
radius: 5
|
||||
color: root.hovered || root.activeFocus ? root.theme.colors.selection : "transparent"
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: copiedReset
|
||||
|
||||
interval: 1600
|
||||
repeat: false
|
||||
onTriggered: root.copied = false
|
||||
}
|
||||
|
||||
TextEdit {
|
||||
id: clipboardProxy
|
||||
|
||||
visible: false
|
||||
}
|
||||
|
||||
function copyToClipboard() {
|
||||
clipboardProxy.text = root.value
|
||||
clipboardProxy.selectAll()
|
||||
clipboardProxy.copy()
|
||||
clipboardProxy.deselect()
|
||||
clipboardProxy.text = ""
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
|
||||
import Logos.Wallet as Wallet
|
||||
|
||||
RowLayout {
|
||||
id: root
|
||||
|
||||
@@ -56,16 +58,15 @@ RowLayout {
|
||||
ToolTip.visible: root.canCopy && addressText.truncated && addressHover.hovered
|
||||
ToolTip.text: root.address
|
||||
|
||||
AmmCopyButton {
|
||||
Wallet.CopyButton {
|
||||
id: copyAddressButton
|
||||
|
||||
objectName: "copyAddressButton"
|
||||
Layout.preferredWidth: visible ? 48 : 0
|
||||
Layout.preferredHeight: 24
|
||||
theme: root.theme
|
||||
value: root.address
|
||||
accessibleName: qsTr("Copy %1 address").arg(root.label)
|
||||
buttonWidth: 48
|
||||
labelFontPixelSize: 11
|
||||
Layout.preferredWidth: visible ? implicitWidth : 0
|
||||
Layout.preferredHeight: implicitHeight
|
||||
copyText: root.address
|
||||
copyLabel: qsTr("Copy %1 address").arg(root.label)
|
||||
visible: root.canCopy
|
||||
enabled: root.canCopy
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
|
||||
import Logos.Wallet as Wallet
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
@@ -157,12 +159,14 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
AmmCopyButton {
|
||||
Wallet.CopyButton {
|
||||
objectName: "copyLpDestinationButton"
|
||||
Layout.preferredWidth: visible ? implicitWidth : 0
|
||||
Layout.preferredHeight: implicitHeight
|
||||
theme: root.theme
|
||||
value: String(root.snapshot.selectedLpHoldingId || "")
|
||||
copyText: String(root.snapshot.selectedLpHoldingId || "")
|
||||
copyLabel: qsTr("Copy LP destination")
|
||||
visible: copyText.length > 0
|
||||
enabled: copyText.length > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls.Basic
|
||||
import QtQuick.Layouts
|
||||
|
||||
import "../shared"
|
||||
import Logos.Wallet as Wallet
|
||||
|
||||
AmmTokenAmountSurface {
|
||||
id: root
|
||||
@@ -119,12 +118,14 @@ AmmTokenAmountSurface {
|
||||
}
|
||||
}
|
||||
|
||||
AmmCopyButton {
|
||||
Wallet.CopyButton {
|
||||
objectName: "copySelectedHoldingButton"
|
||||
Layout.preferredWidth: visible ? implicitWidth : 0
|
||||
Layout.preferredHeight: implicitHeight
|
||||
theme: root.theme
|
||||
value: root.selectedHoldingId
|
||||
copyText: root.selectedHoldingId
|
||||
copyLabel: qsTr("Copy selected holding")
|
||||
visible: copyText.length > 0
|
||||
enabled: copyText.length > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import Logos.Wallet as Wallet
|
||||
|
||||
Popup {
|
||||
id: root
|
||||
|
||||
@@ -322,15 +324,16 @@ Popup {
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
AmmCopyButton {
|
||||
Wallet.CopyButton {
|
||||
id: copyTokenDefinitionButton
|
||||
|
||||
objectName: "copyTokenDefinitionButton"
|
||||
Layout.preferredWidth: visible ? implicitWidth : 0
|
||||
Layout.preferredHeight: implicitHeight
|
||||
theme: root.theme
|
||||
value: tokenRow.tokenDefinitionId
|
||||
accessibleName: qsTr("Copy TokenDefinition address")
|
||||
copyText: tokenRow.tokenDefinitionId
|
||||
copyLabel: qsTr("Copy TokenDefinition address")
|
||||
visible: copyText.length > 0
|
||||
enabled: copyText.length > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user