Browse Source

improve wallet open flow

remove load_wallet from walletDB, route all wallet loading through QEDaemon.
QEDaemon emits walletLoaded and walletRequiresPassword signals. main.qml opens
OpenWallet view when extra user interaction is needed
patch-4
Sander van Grieken 3 years ago
parent
commit
670882c3c0
  1. 1
      electrum/gui/qml/components/OpenWallet.qml
  2. 7
      electrum/gui/qml/components/WalletMainView.qml
  3. 34
      electrum/gui/qml/components/Wallets.qml
  4. 53
      electrum/gui/qml/components/main.qml
  5. 16
      electrum/gui/qml/qedaemon.py
  6. 7
      electrum/gui/qml/qewalletdb.py

1
electrum/gui/qml/components/OpenWallet.qml

@ -118,6 +118,7 @@ Pane {
}
onReadyChanged: {
if (ready) {
Daemon.load_wallet(Daemon.path, password.text)
app.stack.pop(null)
}
}

7
electrum/gui/qml/components/WalletMainView.qml

@ -67,5 +67,12 @@ Item {
}
Connections {
target: Daemon
function onWalletLoaded() {
tabbar.setCurrentIndex(1)
}
}
}

34
electrum/gui/qml/components/Wallets.qml

@ -70,13 +70,17 @@ Pane {
delegate: AbstractButton {
width: ListView.view.width
height: 50
onClicked: console.log('delegate clicked')
onClicked: {
wallet_db.path = model.path
}
RowLayout {
x: 20
spacing: 20
x: 10
spacing: 10
width: parent.width - 20
Image {
source: "../../../gui/kivy/theming/light/wallet.png"
source: "../../kivy/theming/light/wallet.png"
}
Label {
@ -86,11 +90,12 @@ Pane {
}
Button {
text: 'Load'
onClicked: wallet_db.path = model.path
text: 'Open'
onClicked: {
Daemon.load_wallet(model.path)
}
}
}
}
}}}
@ -107,15 +112,14 @@ Pane {
}
}
Connections {
target: Daemon
function onWalletLoaded() {
app.stack.pop()
}
}
WalletDB {
id: wallet_db
onPathChanged: {
if (!ready) {
app.stack.push(Qt.resolvedUrl("OpenWallet.qml"), {"path": wallet_db.path})
} else {
Daemon.load_wallet(wallet_db.path, null)
app.stack.pop()
}
}
}
}

53
electrum/gui/qml/components/main.qml

@ -1,6 +1,6 @@
import QtQuick 2.6
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0
import QtQml 2.6
@ -36,7 +36,7 @@ ApplicationWindow
MouseArea {
anchors.fill: parent
onClicked: {
var dialog = app.messageDialog.createObject(app, {'message':
var dialog = app.messageDialog.createObject(app, {'text':
'Electrum is currently on ' + Network.networkName + ''
})
dialog.open()
@ -115,11 +115,6 @@ ApplicationWindow
id: _newWalletWizard
NewWalletWizard {
parent: Overlay.overlay
x: 12
y: 12
width: parent.width - 24
height: parent.height - 24
Overlay.modal: Rectangle {
color: "#aa000000"
}
@ -131,11 +126,6 @@ ApplicationWindow
id: _serverConnectWizard
ServerConnectWizard {
parent: Overlay.overlay
x: 12
y: 12
width: parent.width - 24
height: parent.height - 24
Overlay.modal: Rectangle {
color: "#aa000000"
}
@ -150,9 +140,12 @@ ApplicationWindow
modal: true
x: (parent.width - width) / 2
y: (parent.height - height) / 2
Overlay.modal: Rectangle {
color: "#aa000000"
}
title: "Message"
property alias message: messageLabel.text
title: qsTr("Message")
property alias text: messageLabel.text
Label {
id: messageLabel
text: "Lorem ipsum dolor sit amet..."
@ -162,8 +155,8 @@ ApplicationWindow
}
Component.onCompleted: {
//Daemon.load_wallet()
splashTimer.start()
if (!Config.autoConnectDefined) {
var dialog = serverConnectWizard.createObject(app)
// without completed serverConnectWizard we can't start
@ -172,6 +165,8 @@ ApplicationWindow
Qt.callLater(Qt.quit)
})
dialog.open()
} else {
Daemon.load_wallet()
}
}
@ -180,4 +175,32 @@ ApplicationWindow
app.header.visible = false
mainStackView.clear()
}
/* OpenWallet as a popup dialog attempt
Component {
id: _openWallet
Dialog {
parent: Overlay.overlay
modal: true
x: (parent.width - width) / 2
y: (parent.height - height) / 2
Overlay.modal: Rectangle {
color: "#aa000000"
}
title: qsTr("OpenWallet")
OpenWallet {
path: Daemon.path
}
}
}
*/
Connections {
target: Daemon
function onWalletRequiresPassword() {
app.stack.push(Qt.resolvedUrl("OpenWallet.qml"), {"path": Daemon.path})
// var dialog = _openWallet.createObject(app)
//dialog.open()
}
}
}

16
electrum/gui/qml/qedaemon.py

@ -82,15 +82,14 @@ class QEDaemon(QObject):
_logger = get_logger(__name__)
_loaded_wallets = QEWalletListModel()
_available_wallets = None
_current_wallet = None
_path = None
walletLoaded = pyqtSignal()
walletRequiresPassword = pyqtSignal()
activeWalletsChanged = pyqtSignal()
availableWalletsChanged = pyqtSignal()
_current_wallet = None
@pyqtSlot()
@pyqtSlot(str)
@pyqtSlot(str, str)
@ -98,15 +97,24 @@ class QEDaemon(QObject):
self._logger.debug('load wallet ' + str(path))
if path == None:
path = self.daemon.config.get('gui_last_wallet')
wallet = self.daemon.load_wallet(path, password)
self._path = path
self._logger.debug('load wallet #2 ' + str(path))
if path is not None:
wallet = self.daemon.load_wallet(path, password)
self._logger.debug('load wallet #3 ' + str(path))
if wallet != None:
self._loaded_wallets.add_wallet(wallet=wallet)
self._current_wallet = QEWallet(wallet)
self.walletLoaded.emit()
self.daemon.config.save_last_wallet(wallet)
else:
self._logger.info('fail open wallet')
self.walletRequiresPassword.emit()
@pyqtProperty('QString')
def path(self):
return self._path
@pyqtProperty(QEWallet, notify=walletLoaded)
def currentWallet(self):
return self._current_wallet

7
electrum/gui/qml/qewalletdb.py

@ -200,13 +200,6 @@ class QEWalletDB(QObject):
self._ready = True
self.readyChanged.emit()
self.daemon.load_wallet(self._path, self._password)
#wallet = Wallet(db, storage, config=self.config)
#wallet.start_network(self.network)
#self._wallets[path] = wallet
#return wallet
@pyqtSlot('QJSValue')
def create_storage(self, js_data):
self._logger.info('Creating wallet from wizard data')

Loading…
Cancel
Save