Show balance on transfer

This commit is contained in:
Daniel 2026-06-22 12:13:24 +02:00
parent 277243cf3a
commit eca1b332d3
2 changed files with 71 additions and 18 deletions

View File

@ -66,11 +66,32 @@ ColumnLayout {
readonly property int stepCount: 4
property string notesTip: ""
// Address whose notes are currently loaded. Selecting/entering a
// different address clears the old notes and loads the new ones.
property string loadedAddress: ""
// result state
property bool resultPending: false
property bool resultSuccess: false
property string resultText: ""
// Clear any loaded notes and (re)load for `addr` but only when it
// actually differs from what's already loaded.
function loadNotesFor(addr) {
var a = (addr || "").trim()
if (a === "" || a === loadedAddress)
return
loadedAddress = a
noteSelector.clearSelection()
noteSelector.notes = []
noteSelector.errorText = ""
notesTip = ""
if (!root.nodeRunning)
return
root.setNotesLoading()
root.getNotesRequested(a, "")
}
function fundingKeyList() {
return fundingKeysArea.text.split("\n")
.map(function(s) { return s.trim() })
@ -143,6 +164,8 @@ ColumnLayout {
noteSelector.clearSelection()
noteSelector.notes = []
noteSelector.errorText = ""
walletField.text = ""
loadedAddress = ""
channelIdField.text = ""
changeKeyField.text = ""
fundingKeysArea.text = ""
@ -224,19 +247,23 @@ ColumnLayout {
model: root.accountsModel
textRole: "address"
currentIndex: -1
onActivated: function(index) { walletField.text = currentText }
// Selecting a (different) known address loads its notes.
onActivated: function(index) {
walletField.text = currentText
d.loadNotesFor(currentText)
}
}
LogosTextField {
id: walletField
Layout.fillWidth: true
placeholderText: qsTr("Wallet address hex")
}
LogosButton {
text: qsTr("Load notes")
enabled: root.nodeRunning && walletField.text.trim().length > 0
onClicked: {
root.setNotesLoading()
root.getNotesRequested(walletField.text.trim(), "")
// LogosTextField has no editingFinished; reach the inner
// TextInput. Manually entered address loads on commit
// (Enter / focus out).
Connections {
target: walletField.textInput
function onEditingFinished() { d.loadNotesFor(walletField.text) }
}
}
}

View File

@ -115,6 +115,9 @@ ColumnLayout {
Layout.fillWidth: true
padding: Theme.spacing.large
editable: true
// Balance of the selected row, shown read-only in the closed box (the
// editable text holds only the address it's used as the transfer key).
valueRole: "balance"
font.pixelSize: Theme.typography.secondaryText
background: Rectangle {
@ -140,7 +143,8 @@ ColumnLayout {
id: comboTextField
anchors.fill: parent
leftPadding: 0
rightPadding: comboControl.count > 0 ? comboIndicator.width + Theme.spacing.small : Theme.spacing.small
rightPadding: (comboControl.count > 0 ? comboIndicator.width + Theme.spacing.small : Theme.spacing.small)
+ (balanceLabel.visible ? balanceLabel.width + Theme.spacing.small : 0)
topPadding: 0
bottomPadding: 0
verticalAlignment: Text.AlignVCenter
@ -151,6 +155,17 @@ ColumnLayout {
color: Theme.palette.text
background: Item { }
}
LogosText {
id: balanceLabel
anchors.right: parent.right
anchors.rightMargin: (comboControl.count > 0 ? comboIndicator.width + Theme.spacing.small : 0)
+ Theme.spacing.small
anchors.verticalCenter: parent.verticalCenter
visible: comboControl.currentIndex >= 0 && text.length > 0
text: comboControl.currentValue || ""
font.pixelSize: Theme.typography.secondaryText
color: Theme.palette.textSecondary
}
MouseArea {
anchors.fill: parent
visible: comboControl.count > 0
@ -163,15 +178,26 @@ ColumnLayout {
delegate: ItemDelegate {
id: comboDelegate
width: comboControl.width
contentItem: LogosText {
width: parent.width
height: contentHeight + Theme.spacing.large
font.pixelSize: Theme.typography.secondaryText
font.bold: true
text: (typeof model.address !== "undefined" ? model.address : modelData) || ""
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
contentItem: RowLayout {
spacing: Theme.spacing.small
LogosText {
Layout.fillWidth: true
Layout.preferredHeight: implicitHeight + Theme.spacing.large
font.pixelSize: Theme.typography.secondaryText
font.bold: true
text: (typeof model.address !== "undefined" ? model.address : modelData) || ""
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
LogosText {
visible: (typeof model.balance !== "undefined") && (model.balance || "").length > 0
text: model.balance || ""
font.pixelSize: Theme.typography.secondaryText
color: Theme.palette.textSecondary
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
}
background: Rectangle {
color: comboDelegate.highlighted ?