Browse Source

qml: deduplicate swap initiation, move to main.qml

master
Sander van Grieken 3 years ago
parent
commit
27cd7fe8a8
  1. 24
      electrum/gui/qml/components/BalanceDetails.qml
  2. 27
      electrum/gui/qml/components/Channels.qml
  3. 26
      electrum/gui/qml/components/main.qml

24
electrum/gui/qml/components/BalanceDetails.qml

@ -171,15 +171,7 @@ Pane {
visible: Daemon.currentWallet.isLightning visible: Daemon.currentWallet.isLightning
enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0
icon.source: Qt.resolvedUrl('../../icons/update.png') icon.source: Qt.resolvedUrl('../../icons/update.png')
onClicked: { onClicked: app.startSwap()
var swaphelper = app.swaphelper.createObject(app)
swaphelper.swapStarted.connect(function() {
var dialog = swapProgressDialog.createObject(app, { swaphelper: swaphelper })
dialog.open()
})
var dialog = swapDialog.createObject(rootItem, { swaphelper: swaphelper })
dialog.open()
}
} }
FlatButton { FlatButton {
@ -199,20 +191,6 @@ Pane {
} }
Component {
id: swapDialog
SwapDialog {
onClosed: destroy()
}
}
Component {
id: swapProgressDialog
SwapProgressDialog {
onClosed: destroy()
}
}
Component { Component {
id: openChannelDialog id: openChannelDialog
OpenChannelDialog { OpenChannelDialog {

27
electrum/gui/qml/components/Channels.qml

@ -125,15 +125,7 @@ Pane {
text: qsTr('Swap'); text: qsTr('Swap');
enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0 enabled: Daemon.currentWallet.lightningCanSend.satsInt > 0 || Daemon.currentWallet.lightningCanReceive.satInt > 0
icon.source: Qt.resolvedUrl('../../icons/update.png') icon.source: Qt.resolvedUrl('../../icons/update.png')
onClicked: { onClicked: app.startSwap()
var swaphelper = app.swaphelper.createObject(app)
swaphelper.swapStarted.connect(function() {
var dialog = swapProgressDialog.createObject(app, { swaphelper: swaphelper })
dialog.open()
})
var dialog = swapDialog.createObject(root, { swaphelper: swaphelper })
dialog.open()
}
} }
FlatButton { FlatButton {
@ -152,23 +144,6 @@ Pane {
} }
Component {
id: swapDialog
SwapDialog {
onClosed: {
console.log('Destroying SwapDialog ' + this)
destroy()
}
}
}
Component {
id: swapProgressDialog
SwapProgressDialog {
onClosed: destroy()
}
}
Component { Component {
id: openChannelDialog id: openChannelDialog
OpenChannelDialog { OpenChannelDialog {

26
electrum/gui/qml/components/main.qml

@ -362,6 +362,21 @@ ApplicationWindow
id: _channelOpenProgressDialog id: _channelOpenProgressDialog
} }
Component {
id: swapDialog
SwapDialog {
onClosed: destroy()
}
}
Component {
id: swapProgressDialog
SwapProgressDialog {
onClosed: destroy()
}
}
NotificationPopup { NotificationPopup {
id: notificationPopup id: notificationPopup
width: parent.width width: parent.width
@ -572,6 +587,17 @@ ApplicationWindow
} }
} }
function startSwap() {
var swaphelper = app.swaphelper.createObject(app)
var swapdialog = swapDialog.createObject(app, { swaphelper: swaphelper })
swaphelper.swapStarted.connect(function() {
swapdialog.close()
var progressdialog = swapProgressDialog.createObject(app, { swaphelper: swaphelper })
progressdialog.open()
})
swapdialog.open()
}
property var _lastActive: 0 // record time of last activity property var _lastActive: 0 // record time of last activity
property bool _lockDialogShown: false property bool _lockDialogShown: false

Loading…
Cancel
Save