Files
pallectrum/electrum/gui/qml/components/controls/BtcField.qml
SomberNight 71627b91c4 qml: set BtcField.textAsSats initial value to match its text
textAsSats was being set to 0 initially, regardless of actual text, only healing after onTextChanged.

fixes https://github.com/spesmilo/electrum/issues/9974
2025-06-24 09:19:13 +00:00

37 lines
867 B
QML

import QtQuick
import QtQuick.Controls
import org.electrum 1.0
TextField {
id: amount
required property TextField fiatfield
font.family: FixedFont
placeholderText: qsTr('Amount')
inputMethodHints: Qt.ImhDigitsOnly
validator: RegularExpressionValidator {
regularExpression: Config.btcAmountRegex
}
property Amount textAsSats
onTextChanged: {
textAsSats = Config.unitsToSats(amount.text)
if (fiatfield.activeFocus)
return
fiatfield.text = text == '' ? '' : Daemon.fx.fiatValue(amount.textAsSats)
}
Connections {
target: Config
function onBaseUnitChanged() {
amount.text = amount.textAsSats.satsInt != 0
? Config.satsToUnits(amount.textAsSats)
: ''
}
}
Component.onCompleted: amount.textChanged()
}