qml: add loader overlay, avoid interacting with the to-be-unloaded wallet
This commit is contained in:
@@ -14,12 +14,13 @@ Pane {
|
||||
padding: 0
|
||||
|
||||
function createWallet() {
|
||||
var dialog = app.newWalletWizard.createObject(rootItem)
|
||||
var dialog = app.newWalletWizard.createObject(app)
|
||||
dialog.open()
|
||||
dialog.walletCreated.connect(function() {
|
||||
Daemon.availableWallets.reload()
|
||||
// and load the new wallet
|
||||
Daemon.load_wallet(dialog.path, dialog.wizard_data['password'])
|
||||
app.stack.pop()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -57,6 +58,7 @@ Pane {
|
||||
|
||||
onClicked: {
|
||||
Daemon.load_wallet(model.path)
|
||||
app.stack.pop()
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
@@ -118,12 +120,4 @@ Pane {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Daemon
|
||||
function onWalletLoaded() {
|
||||
Daemon.availableWallets.reload()
|
||||
app.stack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,6 +171,30 @@ ApplicationWindow
|
||||
}
|
||||
}
|
||||
|
||||
Pane {
|
||||
id: walletLoadingPane
|
||||
parent: Overlay.overlay
|
||||
anchors.fill: parent
|
||||
background: Rectangle { color: Material.dialogColor }
|
||||
visible: Daemon.loading
|
||||
|
||||
ColumnLayout {
|
||||
anchors.centerIn: parent
|
||||
spacing: 2 * constants.paddingXLarge
|
||||
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: qsTr('Opening wallet...')
|
||||
font.pixelSize: constants.fontSizeXXLarge
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
running: Daemon.loading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: coverTimer
|
||||
interval: 10
|
||||
|
||||
@@ -118,6 +118,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
_name = None
|
||||
_use_single_password = False
|
||||
_password = None
|
||||
_loading = False
|
||||
|
||||
_backendWalletLoaded = pyqtSignal([str], arguments=['password'])
|
||||
|
||||
@@ -125,6 +126,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
fxChanged = pyqtSignal()
|
||||
newWalletWizardChanged = pyqtSignal()
|
||||
serverConnectWizardChanged = pyqtSignal()
|
||||
loadingChanged = pyqtSignal()
|
||||
|
||||
walletLoaded = pyqtSignal([str,str], arguments=['name','path'])
|
||||
walletRequiresPassword = pyqtSignal([str,str], arguments=['name','path'])
|
||||
@@ -178,6 +180,9 @@ class QEDaemon(AuthMixin, QObject):
|
||||
return
|
||||
|
||||
def load_wallet_task():
|
||||
self._loading = True
|
||||
self.loadingChanged.emit()
|
||||
|
||||
try:
|
||||
wallet = self.daemon.load_wallet(self._path, password)
|
||||
|
||||
@@ -202,8 +207,11 @@ class QEDaemon(AuthMixin, QObject):
|
||||
except WalletFileException as e:
|
||||
self._logger.error(str(e))
|
||||
self.walletOpenError.emit(str(e))
|
||||
finally:
|
||||
self._loading = False
|
||||
self.loadingChanged.emit()
|
||||
|
||||
threading.Thread(target=load_wallet_task).start()
|
||||
threading.Thread(target=load_wallet_task, daemon=True).start()
|
||||
|
||||
@pyqtSlot()
|
||||
@pyqtSlot(str)
|
||||
@@ -252,6 +260,10 @@ class QEDaemon(AuthMixin, QObject):
|
||||
|
||||
self.availableWallets.remove_wallet(path)
|
||||
|
||||
@pyqtProperty(bool, notify=loadingChanged)
|
||||
def loading(self):
|
||||
return self._loading
|
||||
|
||||
@pyqtProperty(QEWallet, notify=walletLoaded)
|
||||
def currentWallet(self):
|
||||
return self._current_wallet
|
||||
|
||||
Reference in New Issue
Block a user