diff --git a/electrum/gui/qml/components/OpenWallet.qml b/electrum/gui/qml/components/OpenWallet.qml index d072b54b1..47f2ade94 100644 --- a/electrum/gui/qml/components/OpenWallet.qml +++ b/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) } } diff --git a/electrum/gui/qml/components/WalletMainView.qml b/electrum/gui/qml/components/WalletMainView.qml index 3f7235a64..a5388a183 100644 --- a/electrum/gui/qml/components/WalletMainView.qml +++ b/electrum/gui/qml/components/WalletMainView.qml @@ -67,5 +67,12 @@ Item { } + Connections { + target: Daemon + function onWalletLoaded() { + tabbar.setCurrentIndex(1) + } + } + } diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index 94e2b2292..9877754e4 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/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() - } - } } } diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index 0d8f1ecb9..03852f8b5 100644 --- a/electrum/gui/qml/components/main.qml +++ b/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() + } + } } diff --git a/electrum/gui/qml/qedaemon.py b/electrum/gui/qml/qedaemon.py index 91130f42e..1a4751efa 100644 --- a/electrum/gui/qml/qedaemon.py +++ b/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 diff --git a/electrum/gui/qml/qewalletdb.py b/electrum/gui/qml/qewalletdb.py index 00f7fa1a9..fe0d3bb16 100644 --- a/electrum/gui/qml/qewalletdb.py +++ b/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')