1
0
Files
electrum/electrum/gui/qml/components/controls/FeePicker.qml
2025-12-18 08:32:46 +01:00

186 lines
4.8 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
import org.electrum 1.0
Item {
id: root
required property QtObject finalizer
default property alias additionalItems: rootLayout.children
property string targetLabel: qsTr('Target')
property string feeLabel: qsTr('Mining fee')
property string feeRateLabel: qsTr('Fee rate')
property bool showTxInfo: true
property bool showPicker: true
property bool manualFeeEntry: finalizer.method == FeeSlider.FSMethod.MANUAL
implicitHeight: rootLayout.height
GridLayout {
id: rootLayout
width: parent.width
columns: 2
Label {
Layout.fillWidth: true
Layout.preferredWidth: 1
text: feeLabel
color: Material.accentColor
visible: showTxInfo
}
FormattedAmount {
Layout.fillWidth: true
Layout.preferredWidth: 2
amount: finalizer.fee
valid: finalizer.valid
visible: showTxInfo
}
Label {
Layout.fillWidth: true
Layout.preferredWidth: 1
text: feeRateLabel
color: Material.accentColor
visible: showTxInfo
}
RowLayout {
Layout.fillWidth: true
Layout.preferredWidth: 2
visible: showTxInfo
Label {
id: feeRate
text: finalizer.valid ? finalizer.feeRate : ''
font.family: FixedFont
}
Label {
Layout.fillWidth: true
text: finalizer.valid ? UI_UNIT_NAME.FEERATE_SAT_PER_VBYTE : ''
color: Material.accentColor
}
}
Label {
Layout.fillWidth: true
Layout.preferredWidth: 1
text: targetLabel
color: Material.accentColor
visible: showPicker
}
Label {
Layout.fillWidth: true
Layout.preferredWidth: 2
text: finalizer.target
visible: showPicker
}
RowLayout {
Layout.columnSpan: 2
Layout.fillWidth: true
visible: showPicker
Slider {
id: feeslider
Layout.fillWidth: true
leftPadding: constants.paddingMedium
enabled: !manualFeeEntry
snapMode: Slider.SnapOnRelease
stepSize: 1
from: 0
to: finalizer.sliderSteps
onValueChanged: {
if (activeFocus)
finalizer.sliderPos = value
}
Component.onCompleted: {
value = finalizer.sliderPos
}
Connections {
target: finalizer
function onSliderPosChanged() {
feeslider.value = finalizer.sliderPos
}
}
}
FeeMethodComboBox {
id: target
feeslider: finalizer
}
}
Label {
Layout.preferredWidth: 1
text: qsTr('Rate')
color: Material.accentColor
visible: showPicker && manualFeeEntry
}
GridLayout {
Layout.preferredWidth: 2
Layout.rowSpan: 2
visible: showPicker && manualFeeEntry
columns: 2
columnSpacing: constants.paddingMedium
TextField {
id: rate
Layout.fillWidth: true
text: finalizer.userFeerate
inputMethodHints: Qt.ImhDigitsOnly
validator: RegularExpressionValidator {
regularExpression: /^[0-9]*\.[0-9]?$/
}
onTextEdited: {
finalizer.userFeerate = text
}
}
Label {
Layout.fillWidth: true
color: Material.accentColor
text: qsTr('sat/vbyte')
}
TextField {
id: absolute
Layout.fillWidth: true
text: finalizer.userFee
inputMethodHints: Qt.ImhDigitsOnly
validator: RegularExpressionValidator {
regularExpression: /^[0-9]*$/
}
onTextEdited: {
finalizer.userFee = text
}
}
Label {
Layout.fillWidth: true
color: Material.accentColor
text: qsTr('sat')
}
}
Label {
Layout.preferredWidth: 1
visible: showPicker && manualFeeEntry
color: Material.accentColor
text: qsTr('Total')
}
}
}