Files
pallectrum/electrum/gui/qml/components/CloseChannelDialog.qml

204 lines
6.0 KiB
QML
Raw Normal View History

2022-06-29 00:17:17 +02:00
import QtQuick 2.6
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import org.electrum 1.0
import "controls"
ElDialog {
2022-06-29 00:17:17 +02:00
id: dialog
2023-02-06 13:12:14 +01:00
2022-06-29 00:17:17 +02:00
width: parent.width
height: parent.height
property string channelid
title: qsTr('Close Channel')
2023-01-02 16:58:37 +01:00
iconSource: Qt.resolvedUrl('../../icons/lightning_disconnected.png')
2022-06-29 00:17:17 +02:00
modal: true
parent: Overlay.overlay
Overlay.modal: Rectangle {
color: "#aa000000"
}
2023-02-06 13:12:14 +01:00
property bool _closing: false
2022-06-29 00:17:17 +02:00
closePolicy: Popup.NoAutoClose
2022-10-21 14:11:14 +02:00
padding: 0
ColumnLayout {
anchors.fill: parent
2022-10-21 14:11:14 +02:00
spacing: 0
2022-06-29 00:17:17 +02:00
Flickable {
Layout.preferredWidth: parent.width
Layout.fillHeight: true
2022-06-29 00:17:17 +02:00
leftMargin: constants.paddingLarge
rightMargin: constants.paddingLarge
2022-06-29 00:17:17 +02:00
contentHeight: rootLayout.height
clip:true
interactive: height < contentHeight
GridLayout {
id: rootLayout
width: parent.width
columns: 2
Label {
Layout.fillWidth: true
visible: channeldetails.name
text: qsTr('Channel name')
color: Material.accentColor
}
2022-06-29 00:17:17 +02:00
Label {
Layout.fillWidth: true
visible: channeldetails.name
text: channeldetails.name
}
Label {
text: qsTr('Short channel ID')
color: Material.accentColor
}
Label {
text: channeldetails.short_cid
}
Label {
text: qsTr('Remote node ID')
Layout.columnSpan: 2
color: Material.accentColor
}
2022-10-21 14:11:14 +02:00
TextHighlightPane {
Layout.columnSpan: 2
Layout.fillWidth: true
Label {
width: parent.width
text: channeldetails.pubkey
font.pixelSize: constants.fontSizeLarge
font.family: FixedFont
Layout.fillWidth: true
wrapMode: Text.Wrap
}
2022-10-21 14:11:14 +02:00
}
Item { Layout.preferredHeight: constants.paddingMedium; Layout.preferredWidth: 1; Layout.columnSpan: 2 }
InfoTextArea {
Layout.columnSpan: 2
Layout.fillWidth: true
Layout.bottomMargin: constants.paddingLarge
2023-02-06 13:12:14 +01:00
text: channeldetails.message_force_close
2022-10-21 14:11:14 +02:00
}
Label {
text: qsTr('Choose closing method')
Layout.columnSpan: 2
color: Material.accentColor
2022-10-21 14:11:14 +02:00
}
ColumnLayout {
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
ButtonGroup {
id: closetypegroup
}
RadioButton {
2023-02-06 13:12:14 +01:00
id: closetypeCoop
ButtonGroup.group: closetypegroup
property string closetype: 'cooperative'
2023-02-06 13:12:14 +01:00
enabled: !_closing && channeldetails.canCoopClose
text: qsTr('Cooperative close')
}
RadioButton {
2023-02-06 13:12:14 +01:00
id: closetypeRemoteForce
ButtonGroup.group: closetypegroup
property string closetype: 'remote_force'
2023-02-06 13:12:14 +01:00
enabled: !_closing && channeldetails.canForceClose
text: qsTr('Request Force-close')
}
RadioButton {
2023-02-06 13:12:14 +01:00
id: closetypeLocalForce
ButtonGroup.group: closetypegroup
property string closetype: 'local_force'
2023-02-06 13:12:14 +01:00
enabled: !_closing && channeldetails.canForceClose && !channeldetails.isBackup
text: qsTr('Local Force-close')
}
2022-10-21 14:11:14 +02:00
}
ColumnLayout {
Layout.columnSpan: 2
2023-02-06 13:12:14 +01:00
Layout.maximumWidth: parent.width
Label {
id: errorText
2023-02-06 13:12:14 +01:00
Layout.alignment: Qt.AlignHCenter
Layout.maximumWidth: parent.width
visible: !_closing && errorText
wrapMode: Text.Wrap
}
Label {
2023-02-06 13:12:14 +01:00
Layout.alignment: Qt.AlignHCenter
text: qsTr('Closing...')
2023-02-06 13:12:14 +01:00
visible: _closing
}
BusyIndicator {
2023-02-06 13:12:14 +01:00
Layout.alignment: Qt.AlignHCenter
visible: _closing
}
2022-10-21 14:11:14 +02:00
}
}
2022-06-29 00:17:17 +02:00
}
2022-10-21 14:11:14 +02:00
FlatButton {
2022-06-29 00:17:17 +02:00
Layout.columnSpan: 2
2022-10-21 14:11:14 +02:00
Layout.fillWidth: true
text: qsTr('Close channel')
2022-10-21 14:11:14 +02:00
icon.source: '../../icons/closebutton.png'
2023-02-06 13:12:14 +01:00
enabled: !_closing
2022-06-29 00:17:17 +02:00
onClicked: {
2023-02-06 13:12:14 +01:00
_closing = true
channeldetails.closeChannel(closetypegroup.checkedButton.closetype)
2022-06-29 00:17:17 +02:00
}
}
}
ChannelDetails {
id: channeldetails
wallet: Daemon.currentWallet
channelid: dialog.channelid
2023-02-06 13:12:14 +01:00
onChannelChanged : {
// init default choice
if (channeldetails.canCoopClose)
closetypeCoop.checked = true
else
closetypeRemoteForce.checked = true
}
2022-06-29 00:17:17 +02:00
onChannelCloseSuccess: {
2023-02-06 13:12:14 +01:00
_closing = false
2022-06-29 00:17:17 +02:00
dialog.close()
}
onChannelCloseFailed: {
2023-02-06 13:12:14 +01:00
_closing = false
2022-06-29 00:17:17 +02:00
errorText.text = message
}
}
}