Browse Source

qml: refactor TxOutput into reusable component

master
Sander van Grieken 3 years ago committed by accumulator
parent
commit
ab19ece4e0
  1. 31
      electrum/gui/qml/components/ConfirmTxDialog.qml
  2. 31
      electrum/gui/qml/components/CpfpBumpFeeDialog.qml
  3. 31
      electrum/gui/qml/components/RbfBumpFeeDialog.qml
  4. 31
      electrum/gui/qml/components/RbfCancelDialog.qml
  5. 41
      electrum/gui/qml/components/TxDetails.qml
  6. 54
      electrum/gui/qml/components/controls/TxOutput.qml
  7. 2
      electrum/gui/qml/qetxfinalizer.py

31
electrum/gui/qml/components/ConfirmTxDialog.qml

@ -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
}
}
}

31
electrum/gui/qml/components/CpfpBumpFeeDialog.qml

@ -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
}
}
}

31
electrum/gui/qml/components/RbfBumpFeeDialog.qml

@ -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
}
}
}

31
electrum/gui/qml/components/RbfCancelDialog.qml

@ -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
}
}
}

41
electrum/gui/qml/components/TxDetails.qml

@ -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
}
}
}

54
electrum/gui/qml/components/controls/TxOutput.qml

@ -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()
}
}
}
}

2
electrum/gui/qml/qetxfinalizer.py

@ -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())

Loading…
Cancel
Save