2023-07-17 10:49:06 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Material
|
2022-05-12 16:53:44 +02:00
|
|
|
|
|
|
|
|
import org.electrum 1.0
|
|
|
|
|
|
|
|
|
|
import "controls"
|
|
|
|
|
|
|
|
|
|
Pane {
|
2022-06-30 15:06:45 +02:00
|
|
|
id: root
|
2023-04-17 15:35:39 +02:00
|
|
|
objectName: 'Channels'
|
|
|
|
|
|
2022-11-11 16:23:24 +01:00
|
|
|
padding: 0
|
2022-06-30 15:06:45 +02:00
|
|
|
|
2022-05-12 16:53:44 +02:00
|
|
|
ColumnLayout {
|
|
|
|
|
id: layout
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: parent.height
|
2022-11-11 16:23:24 +01:00
|
|
|
spacing: 0
|
2022-05-12 16:53:44 +02:00
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
|
id: summaryLayout
|
2022-11-11 16:46:24 +01:00
|
|
|
Layout.preferredWidth: parent.width
|
2022-11-11 16:23:24 +01:00
|
|
|
Layout.topMargin: constants.paddingLarge
|
|
|
|
|
Layout.leftMargin: constants.paddingLarge
|
|
|
|
|
Layout.rightMargin: constants.paddingLarge
|
|
|
|
|
|
2022-05-12 16:53:44 +02:00
|
|
|
columns: 2
|
|
|
|
|
|
2023-01-17 00:34:01 +01:00
|
|
|
Heading {
|
2022-10-31 17:17:44 +01:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
|
text: qsTr('Lightning Channels')
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-12 16:53:44 +02:00
|
|
|
Label {
|
|
|
|
|
Layout.columnSpan: 2
|
2022-06-30 21:07:08 +02:00
|
|
|
text: qsTr('You have %1 open channels').arg(Daemon.currentWallet.channelModel.numOpenChannels)
|
2022-06-02 16:35:31 +02:00
|
|
|
color: Material.accentColor
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Label {
|
2023-04-17 19:52:54 +00:00
|
|
|
text: qsTr('You can send') + ':'
|
2022-05-12 16:53:44 +02:00
|
|
|
color: Material.accentColor
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 13:49:32 +01:00
|
|
|
FormattedAmount {
|
|
|
|
|
amount: Daemon.currentWallet.lightningCanSend
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Label {
|
2023-04-17 19:52:54 +00:00
|
|
|
text: qsTr('You can receive') + ':'
|
2022-05-12 16:53:44 +02:00
|
|
|
color: Material.accentColor
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 13:49:32 +01:00
|
|
|
FormattedAmount {
|
|
|
|
|
amount: Daemon.currentWallet.lightningCanReceive
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|
2022-06-02 16:35:31 +02:00
|
|
|
}
|
2022-05-12 16:53:44 +02:00
|
|
|
|
|
|
|
|
Frame {
|
|
|
|
|
id: channelsFrame
|
2022-11-11 16:23:24 +01:00
|
|
|
Layout.fillWidth: true
|
2022-05-12 16:53:44 +02:00
|
|
|
Layout.fillHeight: true
|
2022-11-11 16:23:24 +01:00
|
|
|
Layout.topMargin: constants.paddingLarge
|
|
|
|
|
Layout.bottomMargin: constants.paddingLarge
|
|
|
|
|
Layout.leftMargin: constants.paddingMedium
|
|
|
|
|
Layout.rightMargin: constants.paddingMedium
|
|
|
|
|
|
2022-05-12 16:53:44 +02:00
|
|
|
verticalPadding: 0
|
|
|
|
|
horizontalPadding: 0
|
|
|
|
|
background: PaneInsetBackground {}
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
spacing: 0
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2023-07-13 16:19:37 +02:00
|
|
|
ElListView {
|
2022-05-12 16:53:44 +02:00
|
|
|
id: listview
|
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
clip: true
|
2023-03-14 10:06:31 +01:00
|
|
|
model: Daemon.currentWallet.channelModel
|
|
|
|
|
|
|
|
|
|
section.property: 'is_backup'
|
|
|
|
|
section.criteria: ViewSection.FullString
|
|
|
|
|
section.delegate: RowLayout {
|
|
|
|
|
width: ListView.view.width
|
|
|
|
|
required property string section
|
|
|
|
|
Label {
|
|
|
|
|
visible: section == 'true'
|
|
|
|
|
text: qsTr('Channel backups')
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.topMargin: constants.paddingLarge
|
|
|
|
|
font.pixelSize: constants.fontSizeSmall
|
|
|
|
|
color: Material.accentColor
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-12 16:53:44 +02:00
|
|
|
|
2022-06-01 16:57:07 +02:00
|
|
|
delegate: ChannelDelegate {
|
2022-06-22 11:36:25 +02:00
|
|
|
onClicked: {
|
|
|
|
|
app.stack.push(Qt.resolvedUrl('ChannelDetails.qml'), { 'channelid': model.cid })
|
|
|
|
|
}
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
2023-01-03 18:22:29 +01:00
|
|
|
|
|
|
|
|
Label {
|
2023-01-30 16:26:44 +01:00
|
|
|
visible: listview.model.count == 0
|
2023-01-03 18:22:29 +01:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
width: listview.width * 4/5
|
|
|
|
|
font.pixelSize: constants.fontSizeXXLarge
|
|
|
|
|
color: constants.mutedForeground
|
2023-01-06 10:58:47 +01:00
|
|
|
text: qsTr('No Lightning channels yet in this wallet')
|
2023-01-03 18:22:29 +01:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
}
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 18:35:46 +02:00
|
|
|
ButtonContainer {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
FlatButton {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredWidth: 1
|
|
|
|
|
text: qsTr('Swap');
|
2024-11-15 02:14:16 +01:00
|
|
|
enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 ||
|
|
|
|
|
(Daemon.currentWallet.lightningCanReceive.satsInt > 0 && Daemon.currentWallet.confirmedBalance.satsInt > 0)
|
2023-03-31 18:35:46 +02:00
|
|
|
icon.source: Qt.resolvedUrl('../../icons/update.png')
|
2023-04-12 12:31:47 +02:00
|
|
|
onClicked: app.startSwap()
|
2023-03-31 18:35:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlatButton {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredWidth: 1
|
2023-04-05 11:50:54 +02:00
|
|
|
enabled: Daemon.currentWallet.confirmedBalance.satsInt > 0
|
2023-03-31 18:35:46 +02:00
|
|
|
text: qsTr('Open Channel')
|
|
|
|
|
onClicked: {
|
2023-09-04 15:02:40 +02:00
|
|
|
if (Daemon.currentWallet.channelModel.count == 0) {
|
|
|
|
|
var txt = Daemon.currentWallet.channelModel.lightningWarningMessage() + '\n\n' +
|
|
|
|
|
qsTr('Do you want to create your first channel?')
|
|
|
|
|
var confirmdialog = app.messageDialog.createObject(root, {
|
|
|
|
|
text: txt,
|
|
|
|
|
yesno: true
|
|
|
|
|
})
|
|
|
|
|
confirmdialog.accepted.connect(function () {
|
|
|
|
|
var dialog = openChannelDialog.createObject(root)
|
|
|
|
|
dialog.open()
|
|
|
|
|
})
|
|
|
|
|
confirmdialog.open()
|
|
|
|
|
} else {
|
|
|
|
|
var dialog = openChannelDialog.createObject(root)
|
|
|
|
|
dialog.open()
|
|
|
|
|
}
|
2023-03-31 18:35:46 +02:00
|
|
|
}
|
|
|
|
|
icon.source: '../../icons/lightning.png'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
|
id: openChannelDialog
|
|
|
|
|
OpenChannelDialog {
|
|
|
|
|
onClosed: destroy()
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-16 16:50:23 +01:00
|
|
|
|
2022-05-12 16:53:44 +02:00
|
|
|
}
|