Browse Source

qml: styling channel details

patch-4
Sander van Grieken 2 years ago
parent
commit
e054e9f14e
  1. 426
      electrum/gui/qml/components/ChannelDetails.qml

426
electrum/gui/qml/components/ChannelDetails.qml

@ -11,255 +11,283 @@ Pane {
id: root id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
padding: 0
property string channelid property string channelid
property string title: qsTr("Channel details") ColumnLayout {
property QtObject menu: Menu {
id: menu
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Backup');
onTriggered: {
var dialog = app.genericShareDialog.createObject(root,
{
title: qsTr('Channel Backup for %1').arg(channeldetails.short_cid),
text: channeldetails.channelBackup(),
text_help: channeldetails.channelBackupHelpText()
}
)
dialog.open()
}
icon.source: '../../icons/file.png'
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Close channel');
enabled: channeldetails.canClose
onTriggered: {
var dialog = closechannel.createObject(root, { 'channelid': channelid })
dialog.open()
}
icon.source: '../../icons/closebutton.png'
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
text: qsTr('Delete channel');
enabled: channeldetails.canDelete
onTriggered: {
var dialog = app.messageDialog.createObject(root,
{
'text': qsTr('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.'),
'yesno': true
}
)
dialog.yesClicked.connect(function() {
channeldetails.deleteChannel()
app.stack.pop()
Daemon.currentWallet.historyModel.init_model() // needed here?
Daemon.currentWallet.channelModel.remove_channel(channelid)
})
dialog.open()
}
icon.source: '../../icons/delete.png'
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
enabled: channeldetails.isOpen
text: channeldetails.frozenForSending ? qsTr('Unfreeze (for sending)') : qsTr('Freeze (for sending)')
onTriggered: channeldetails.freezeForSending()
}
}
MenuItem {
icon.color: 'transparent'
action: Action {
enabled: channeldetails.isOpen
text: channeldetails.frozenForReceiving ? qsTr('Unfreeze (for receiving)') : qsTr('Freeze (for receiving)')
onTriggered: channeldetails.freezeForReceiving()
}
}
}
Flickable {
anchors.fill: parent anchors.fill: parent
contentHeight: rootLayout.height spacing: 0
clip:true
interactive: height < contentHeight
GridLayout {
id: rootLayout
width: parent.width
columns: 2
Label {
text: qsTr('Node name')
color: Material.accentColor
}
Label { Flickable {
text: channeldetails.name Layout.preferredWidth: parent.width
} Layout.fillHeight: true
Label { leftMargin: constants.paddingLarge
text: qsTr('Short channel ID') rightMargin: constants.paddingLarge
color: Material.accentColor topMargin: constants.paddingLarge
}
Label { contentHeight: rootLayout.height
text: channeldetails.short_cid clip:true
} interactive: height < contentHeight
Label { GridLayout {
text: qsTr('State') id: rootLayout
color: Material.accentColor width: parent.width
} columns: 2
Label { Label {
text: channeldetails.state Layout.columnSpan: 2
} text: qsTr('Channel details')
font.pixelSize: constants.fontSizeLarge
color: Material.accentColor
}
Label { Rectangle {
text: qsTr('Initiator') Layout.columnSpan: 2
color: Material.accentColor Layout.fillWidth: true
} height: 1
color: Material.accentColor
}
Label { Label {
text: channeldetails.initiator text: qsTr('Node name')
} color: Material.accentColor
}
Label { Label {
text: qsTr('Capacity') text: channeldetails.name
color: Material.accentColor }
}
RowLayout {
Label { Label {
font.family: FixedFont text: qsTr('Short channel ID')
text: Config.formatSats(channeldetails.capacity) color: Material.accentColor
} }
Label {
text: channeldetails.short_cid
}
Label { Label {
text: qsTr('State')
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit
} }
Label { Label {
text: Daemon.fx.enabled text: channeldetails.state
? '(' + Daemon.fx.fiatValue(channeldetails.capacity) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
} }
}
Label { Label {
text: qsTr('Can send') text: qsTr('Initiator')
color: Material.accentColor color: Material.accentColor
} }
RowLayout {
visible: !channeldetails.frozenForSending && channeldetails.isOpen
Label { Label {
font.family: FixedFont text: channeldetails.initiator
text: Config.formatSats(channeldetails.canSend)
} }
Label { Label {
text: qsTr('Capacity')
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit
} }
RowLayout {
Label {
font.family: FixedFont
text: Config.formatSats(channeldetails.capacity)
}
Label {
color: Material.accentColor
text: Config.baseUnit
}
Label {
text: Daemon.fx.enabled
? '(' + Daemon.fx.fiatValue(channeldetails.capacity) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
}
}
Label { Label {
text: Daemon.fx.enabled text: qsTr('Can send')
? '(' + Daemon.fx.fiatValue(channeldetails.canSend) + ' ' + Daemon.fx.fiatCurrency + ')' color: Material.accentColor
: ''
} }
}
Label {
visible: channeldetails.frozenForSending && channeldetails.isOpen
text: qsTr('n/a (frozen)')
}
Label {
visible: !channeldetails.isOpen
text: qsTr('n/a (channel not open)')
}
Label { RowLayout {
text: qsTr('Can Receive') visible: !channeldetails.frozenForSending && channeldetails.isOpen
color: Material.accentColor Label {
} font.family: FixedFont
text: Config.formatSats(channeldetails.canSend)
}
Label {
color: Material.accentColor
text: Config.baseUnit
}
Label {
text: Daemon.fx.enabled
? '(' + Daemon.fx.fiatValue(channeldetails.canSend) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
}
}
Label {
visible: channeldetails.frozenForSending && channeldetails.isOpen
text: qsTr('n/a (frozen)')
}
Label {
visible: !channeldetails.isOpen
text: qsTr('n/a (channel not open)')
}
RowLayout {
visible: !channeldetails.frozenForReceiving && channeldetails.isOpen
Label { Label {
font.family: FixedFont text: qsTr('Can Receive')
text: Config.formatSats(channeldetails.canReceive) color: Material.accentColor
}
RowLayout {
visible: !channeldetails.frozenForReceiving && channeldetails.isOpen
Label {
font.family: FixedFont
text: Config.formatSats(channeldetails.canReceive)
}
Label {
color: Material.accentColor
text: Config.baseUnit
}
Label {
text: Daemon.fx.enabled
? '(' + Daemon.fx.fiatValue(channeldetails.canReceive) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
}
}
Label {
visible: channeldetails.frozenForReceiving && channeldetails.isOpen
text: qsTr('n/a (frozen)')
} }
Label { Label {
visible: !channeldetails.isOpen
text: qsTr('n/a (channel not open)')
}
Label {
text: qsTr('Channel type')
color: Material.accentColor color: Material.accentColor
text: Config.baseUnit
} }
Label { Label {
text: Daemon.fx.enabled text: channeldetails.channelType
? '(' + Daemon.fx.fiatValue(channeldetails.canReceive) + ' ' + Daemon.fx.fiatCurrency + ')'
: ''
} }
}
Label {
visible: channeldetails.frozenForReceiving && channeldetails.isOpen
text: qsTr('n/a (frozen)')
}
Label {
visible: !channeldetails.isOpen
text: qsTr('n/a (channel not open)')
}
Label { Label {
text: qsTr('Channel type') text: qsTr('Remote node ID')
color: Material.accentColor Layout.columnSpan: 2
} color: Material.accentColor
}
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
padding: 0
leftPadding: constants.paddingSmall
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 {
text: channeldetails.channelType
} }
}
Label { FlatButton {
text: qsTr('Remote node ID') Layout.fillWidth: true
Layout.columnSpan: 2 text: qsTr('Backup');
color: Material.accentColor onClicked: {
var dialog = app.genericShareDialog.createObject(root,
{
title: qsTr('Channel Backup for %1').arg(channeldetails.short_cid),
text: channeldetails.channelBackup(),
text_help: channeldetails.channelBackupHelpText()
}
)
dialog.open()
} }
icon.source: '../../icons/file.png'
}
TextHighlightPane { RowLayout {
Layout.columnSpan: 2 Layout.fillWidth: true
FlatButton {
Layout.fillWidth: true Layout.fillWidth: true
padding: 0 Layout.preferredWidth: 1
leftPadding: constants.paddingSmall text: qsTr('Close channel');
enabled: channeldetails.canClose
onClicked: {
var dialog = closechannel.createObject(root, { 'channelid': channelid })
dialog.open()
}
icon.source: '../../icons/closebutton.png'
}
RowLayout { FlatButton {
width: parent.width Layout.fillWidth: true
Label { Layout.preferredWidth: 1
text: channeldetails.pubkey text: qsTr('Delete channel');
font.pixelSize: constants.fontSizeLarge enabled: channeldetails.canDelete
font.family: FixedFont onClicked: {
Layout.fillWidth: true var dialog = app.messageDialog.createObject(root,
wrapMode: Text.Wrap {
} 'text': qsTr('Are you sure you want to delete this channel? This will purge associated transactions from your wallet history.'),
ToolButton { 'yesno': true
icon.source: '../../icons/share.png' }
icon.color: 'transparent' )
onClicked: { dialog.yesClicked.connect(function() {
var dialog = app.genericShareDialog.createObject(root, channeldetails.deleteChannel()
{ title: qsTr('Channel node ID'), text: channeldetails.pubkey } app.stack.pop()
) Daemon.currentWallet.historyModel.init_model() // needed here?
dialog.open() Daemon.currentWallet.channelModel.remove_channel(channelid)
} })
} dialog.open()
} }
icon.source: '../../icons/delete.png'
} }
}
RowLayout {
Layout.fillWidth: true
FlatButton {
Layout.fillWidth: true
Layout.preferredWidth: 1
enabled: channeldetails.isOpen
text: channeldetails.frozenForSending ? qsTr('Unfreeze (for sending)') : qsTr('Freeze (for sending)')
icon.source: '../../icons/seal.png'
onClicked: channeldetails.freezeForSending()
}
FlatButton {
Layout.fillWidth: true
Layout.preferredWidth: 1
enabled: channeldetails.isOpen
text: channeldetails.frozenForReceiving ? qsTr('Unfreeze (for receiving)') : qsTr('Freeze (for receiving)')
icon.source: '../../icons/seal.png'
onClicked: channeldetails.freezeForReceiving()
}
} }
} }
ChannelDetails { ChannelDetails {

Loading…
Cancel
Save