Browse Source

qml: refactor ChannelDetails. Add funding outpoint

master
Sander van Grieken 2 years ago
parent
commit
3967323842
  1. 213
      electrum/gui/qml/components/ChannelDetails.qml
  2. 8
      electrum/gui/qml/qechanneldetails.py

213
electrum/gui/qml/components/ChannelDetails.qml

@ -55,16 +55,6 @@ Pane {
text: channeldetails.name
}
Label {
text: qsTr('Short channel ID')
color: Material.accentColor
}
Label {
Layout.fillWidth: true
text: channeldetails.shortCid
}
Label {
text: qsTr('State')
color: Material.accentColor
@ -78,80 +68,14 @@ Pane {
}
Label {
visible: !channeldetails.isBackup
text: qsTr('Initiator')
color: Material.accentColor
}
Label {
visible: !channeldetails.isBackup
text: channeldetails.initiator
}
Label {
text: qsTr('Channel type')
color: Material.accentColor
}
Label {
text: channeldetails.channelType
}
Label {
visible: channeldetails.isBackup
text: qsTr('Backup type')
color: Material.accentColor
}
Label {
visible: channeldetails.isBackup
text: channeldetails.backupType == 'imported'
? qsTr('imported')
: channeldetails.backupType == 'on-chain'
? qsTr('on-chain')
: '?'
}
Label {
text: qsTr('Remote node ID')
Layout.columnSpan: 2
color: Material.accentColor
}
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: channeldetails.pubkey
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root, {
title: qsTr('Channel node ID'),
text: channeldetails.pubkey
})
dialog.open()
}
}
}
}
}
Label {
Layout.topMargin: constants.paddingSmall
text: qsTr('Capacity and ratio')
color: Material.accentColor
}
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
padding: constants.paddingLarge
@ -271,6 +195,133 @@ Pane {
text: qsTr('n/a (channel not open)')
}
}
}
Heading {
Layout.columnSpan: 2
text: qsTr('Technical properties')
}
Label {
text: qsTr('Short channel ID')
color: Material.accentColor
}
Label {
Layout.fillWidth: true
text: channeldetails.shortCid
}
Label {
visible: !channeldetails.isBackup
text: qsTr('Initiator')
color: Material.accentColor
}
Label {
visible: !channeldetails.isBackup
text: channeldetails.initiator
}
Label {
text: qsTr('Channel type')
color: Material.accentColor
}
Label {
text: channeldetails.channelType
}
Label {
visible: channeldetails.isBackup
text: qsTr('Backup type')
color: Material.accentColor
}
Label {
visible: channeldetails.isBackup
text: channeldetails.backupType == 'imported'
? qsTr('imported')
: channeldetails.backupType == 'on-chain'
? qsTr('on-chain')
: '?'
}
Label {
Layout.columnSpan: 2
Layout.topMargin: constants.paddingSmall
text: qsTr('Remote node ID')
color: Material.accentColor
}
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: channeldetails.pubkey
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root, {
title: qsTr('Channel node ID'),
text: channeldetails.pubkey
})
dialog.open()
}
}
}
}
Label {
Layout.columnSpan: 2
Layout.topMargin: constants.paddingSmall
text: qsTr('Funding Outpoint')
color: Material.accentColor
}
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
RowLayout {
width: parent.width
Label {
text: channeldetails.fundingOutpoint.txid + ':' + channeldetails.fundingOutpoint.index
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
TapHandler {
onTapped: {
app.stack.push(Qt.resolvedUrl('TxDetails.qml'), {
txid: channeldetails.fundingOutpoint.txid
})
}
}
}
ToolButton {
icon.source: '../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(root, {
title: qsTr('Funding Outpoint'),
text: channeldetails.fundingOutpoint.txid + ':' + channeldetails.fundingOutpoint.index
})
dialog.open()
}
}
}
}
}
}
@ -284,6 +335,7 @@ Pane {
Layout.preferredWidth: 1
visible: !channeldetails.isBackup
text: qsTr('Backup')
icon.source: '../../icons/file.png'
onClicked: {
var dialog = app.genericShareDialog.createObject(root, {
title: qsTr('Channel Backup for %1').arg(channeldetails.shortCid),
@ -293,7 +345,6 @@ Pane {
})
dialog.open()
}
icon.source: '../../icons/file.png'
}
FlatButton {
@ -301,11 +352,11 @@ Pane {
Layout.preferredWidth: 1
text: qsTr('Close channel');
visible: channeldetails.canClose
icon.source: '../../icons/closebutton.png'
onClicked: {
var dialog = closechannel.createObject(root, { channelid: channelid })
dialog.open()
}
icon.source: '../../icons/closebutton.png'
}
FlatButton {
@ -313,6 +364,7 @@ Pane {
Layout.preferredWidth: 1
text: qsTr('Delete channel');
visible: channeldetails.canDelete
icon.source: '../../icons/delete.png'
onClicked: {
var dialog = app.messageDialog.createObject(root, {
title: qsTr('Are you sure?'),
@ -327,7 +379,6 @@ Pane {
})
dialog.open()
}
icon.source: '../../icons/delete.png'
}
}

8
electrum/gui/qml/qechanneldetails.py

@ -113,6 +113,14 @@ class QEChannelDetails(AuthMixin, QObject, QtEventListener):
return ''
return 'Local' if self._channel.constraints.is_initiator else 'Remote'
@pyqtProperty('QVariantMap', notify=channelChanged)
def fundingOutpoint(self):
outpoint = self._channel.funding_outpoint
return {
'txid': outpoint.txid,
'index': outpoint.output_index
}
@pyqtProperty(QEAmount, notify=channelChanged)
def capacity(self):
self._capacity.copyFrom(QEAmount(amount_sat=self._channel.get_capacity()))

Loading…
Cancel
Save