Files
purple-electrumwallet/electrum/gui/qml/components/controls/BtcField.qml
T
Sander van Grieken 9772a6d5b6 qml: add workarounds for issue assigning custom types to QObject properties
- on the python side, for pyqtProperty's with a setter, the pyqtProperty should be declared as QVariant type
- on the qml side, properties should be declared 'var', not the custom type.
2026-04-22 10:15:30 +02:00

38 lines
947 B
QML

import QtQuick
import QtQuick.Controls
import org.electrum 1.0
TextField {
id: amount
required property TextField fiatfield
property bool msatPrecision: false
font.family: FixedFont
placeholderText: qsTr('Amount')
inputMethodHints: Qt.ImhDigitsOnly
validator: RegularExpressionValidator {
regularExpression: msatPrecision ? Config.btcAmountRegexMsat : Config.btcAmountRegex
}
property var 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()
}