Browse Source

qml: parent channel open progress dialog to main.qml as it might live longer than OpenChannel

master
Sander van Grieken 3 years ago
parent
commit
e9a1824a77
  1. 8
      electrum/gui/qml/components/ChannelOpenProgressDialog.qml
  2. 21
      electrum/gui/qml/components/OpenChannel.qml
  3. 5
      electrum/gui/qml/components/main.qml

8
electrum/gui/qml/components/ChannelOpenProgressDialog.qml

@ -27,6 +27,12 @@ ElDialog {
property alias error: errorText.text property alias error: errorText.text
property alias peer: peerText.text property alias peer: peerText.text
function reset() {
state = ''
errorText.text = ''
peerText.text = ''
}
Item { Item {
id: s id: s
state: '' state: ''
@ -52,6 +58,7 @@ ElDialog {
id: content id: content
anchors.centerIn: parent anchors.centerIn: parent
width: parent.width width: parent.width
spacing: constants.paddingLarge
RowLayout { RowLayout {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -103,6 +110,7 @@ ElDialog {
id: infoText id: infoText
visible: false visible: false
text: qsTr('Channel will be open after 3 confirmations') text: qsTr('Channel will be open after 3 confirmations')
width: parent.width
} }
} }
} }

21
electrum/gui/qml/components/OpenChannel.qml

@ -157,12 +157,6 @@ Pane {
} }
} }
property var channelOpenProgressDialogInstance
Component {
id: channelOpenProgressDialog
ChannelOpenProgressDialog { }
}
ChannelOpener { ChannelOpener {
id: channelopener id: channelopener
wallet: Daemon.currentWallet wallet: Daemon.currentWallet
@ -190,21 +184,22 @@ Pane {
} }
onChannelOpening: { onChannelOpening: {
console.log('Channel is opening') console.log('Channel is opening')
channelOpenProgressDialogInstance = channelOpenProgressDialog.createObject(app, {peer: peer}) app.channelOpenProgressDialog.reset()
channelOpenProgressDialogInstance.open() app.channelOpenProgressDialog.peer = peer
app.channelOpenProgressDialog.open()
} }
onChannelOpenError: { onChannelOpenError: {
channelOpenProgressDialogInstance.state = 'failed' app.channelOpenProgressDialog.state = 'failed'
channelOpenProgressDialogInstance.error = message app.channelOpenProgressDialog.error = message
} }
onChannelOpenSuccess: { onChannelOpenSuccess: {
var message = 'success!' var message = 'success!'
if (!has_backup) if (!has_backup)
message = message + ' (but no backup. TODO: show QR)' message = message + ' (but no backup. TODO: show QR)'
channelOpenProgressDialogInstance.state = 'success' app.channelOpenProgressDialog.state = 'success'
channelOpenProgressDialogInstance.error = message app.channelOpenProgressDialog.error = message
channelopener.wallet.channelModel.new_channel(cid) channelopener.wallet.channelModel.new_channel(cid)
// app.stack.pop() app.stack.pop()
} }
} }

5
electrum/gui/qml/components/main.qml

@ -186,6 +186,11 @@ ApplicationWindow
} }
} }
property alias channelOpenProgressDialog: _channelOpenProgressDialog
ChannelOpenProgressDialog {
id: _channelOpenProgressDialog
}
NotificationPopup { NotificationPopup {
id: notificationPopup id: notificationPopup
} }

Loading…
Cancel
Save