1
0

qml: refactor TxOutput into reusable component

This commit is contained in:
Sander van Grieken
2023-05-08 15:24:17 +02:00
committed by accumulator
parent daf1f37419
commit ab19ece4e0
7 changed files with 69 additions and 152 deletions

View File

@@ -182,37 +182,12 @@ ElDialog {
Repeater {
model: finalizer.outputs
delegate: TextHighlightPane {
delegate: TxOutput {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine
? modelData.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: modelData.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(modelData.value_sats)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
}
allowShare: false
model: modelData
}
}
}

View File

@@ -185,37 +185,12 @@ ElDialog {
Repeater {
model: cpfpfeebumper.valid ? cpfpfeebumper.outputs : []
delegate: TextHighlightPane {
delegate: TxOutput {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine
? modelData.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: modelData.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(modelData.value_sats)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
}
allowShare: false
model: modelData
}
}
}

View File

@@ -198,37 +198,12 @@ ElDialog {
Repeater {
model: rbffeebumper.valid ? rbffeebumper.outputs : []
delegate: TextHighlightPane {
delegate: TxOutput {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine
? modelData.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: modelData.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(modelData.value_sats)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
}
allowShare: false
model: modelData
}
}
}

View File

@@ -157,37 +157,12 @@ ElDialog {
Repeater {
model: txcanceller.valid ? txcanceller.outputs : []
delegate: TextHighlightPane {
delegate: TxOutput {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine
? modelData.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: modelData.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(modelData.value_sats)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
}
allowShare: false
model: modelData
}
}
}

View File

@@ -272,48 +272,11 @@ Pane {
Repeater {
model: txdetails.outputs
delegate: TextHighlightPane {
delegate: TxOutput {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: modelData.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: modelData.is_mine
? modelData.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: modelData.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(modelData.value)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root, {
title: qsTr('Tx Output'),
text: modelData.address
})
dialog.open()
}
}
}
model: modelData
}
}
}

View File

@@ -0,0 +1,54 @@
import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import org.electrum 1.0
TextHighlightPane {
id: root
property variant model
property bool allowShare: true
RowLayout {
width: parent.width
Label {
text: model.address
Layout.fillWidth: true
wrapMode: Text.Wrap
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
color: model.is_mine
? model.is_change
? constants.colorAddressInternal
: constants.colorAddressExternal
: model.is_billing
? constants.colorAddressBilling
: Material.foreground
}
Label {
text: Config.formatSats(model.value)
font.pixelSize: constants.fontSizeMedium
font.family: FixedFont
}
Label {
text: Config.baseUnit
font.pixelSize: constants.fontSizeMedium
color: Material.accentColor
}
ToolButton {
visible: allowShare
icon.source: Qt.resolvedUrl('../../../icons/share.png')
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(app, {
title: qsTr('Tx Output'),
text: model.address
})
dialog.open()
}
}
}
}

View File

@@ -213,7 +213,7 @@ class TxFeeSlider(FeeSlider):
for o in tx.outputs():
outputs.append({
'address': o.get_ui_address_str(),
'value_sats': o.value,
'value': o.value,
'is_mine': self._wallet.wallet.is_mine(o.get_ui_address_str()),
'is_change': self._wallet.wallet.is_change(o.get_ui_address_str()),
'is_billing': self._wallet.wallet.is_billing_address(o.get_ui_address_str())