aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-07-12 20:34:10 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-07-12 20:34:10 -0500
commit79dcb92d182908bf2caba6fc56cacf4548266871 (patch)
tree78041e39ab1dd12b3ad646c2e3b8ef194646e1ba
parent8bbc2e87bc19b6cbdf4cb2fe54395cb95290dfeb (diff)
parentab9e31e7cc5ab68a8291ff6ee1aa6d423484eea0 (diff)
downloadmonzero-gui-79dcb92d182908bf2caba6fc56cacf4548266871.tar.gz
monzero-gui-79dcb92d182908bf2caba6fc56cacf4548266871.tar.xz
monzero-gui-79dcb92d182908bf2caba6fc56cacf4548266871.zip
Merge pull request #2247
ab9e31e WalletManager: async close with splash screen (xiphon)
-rw-r--r--main.qml46
-rw-r--r--pages/settings/SettingsInfo.qml9
-rw-r--r--src/libwalletqt/WalletManager.cpp6
-rw-r--r--src/libwalletqt/WalletManager.h3
4 files changed, 34 insertions, 30 deletions
diff --git a/main.qml b/main.qml
index 743af497..c6300b52 100644
--- a/main.qml
+++ b/main.qml
@@ -283,7 +283,7 @@ ApplicationWindow {
titleBar.visible = persistentSettings.customDecorations;
}
- function closeWallet() {
+ function closeWallet(callback) {
// Disconnect all listeners
if (typeof currentWallet !== "undefined" && currentWallet !== null) {
@@ -306,8 +306,17 @@ ApplicationWindow {
}
currentWallet = undefined;
- walletManager.closeWallet();
+ appWindow.showProcessingSplash(qsTr("Closing wallet..."));
+ if (callback) {
+ walletManager.closeWalletAsync(function() {
+ hideProcessingSplash();
+ callback();
+ });
+ } else {
+ walletManager.closeWallet();
+ hideProcessingSplash();
+ }
}
function connectWallet(wallet) {
@@ -558,11 +567,6 @@ ApplicationWindow {
}
}
- function onWalletClosed(walletAddress) {
- hideProcessingSplash();
- console.log(">>> wallet closed: " + walletAddress)
- }
-
function onWalletPassphraseNeeded(){
if(rootItem.state !== "normal") return;
@@ -1115,17 +1119,18 @@ ApplicationWindow {
function showWizard(){
clearMoneroCardLabelText();
walletInitialized = false;
- closeWallet();
- currentWallet = undefined;
- wizard.restart();
- wizard.wizardState = "wizardHome";
- rootItem.state = "wizard"
- // reset balance
- leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0);
- fiatApiUpdateBalance(0, 0);
- // disable timers
- userInActivityTimer.running = false;
- simpleModeConnectionTimer.running = false;
+ closeWallet(function() {
+ currentWallet = undefined;
+ wizard.restart();
+ wizard.wizardState = "wizardHome";
+ rootItem.state = "wizard"
+ // reset balance
+ leftPanel.balanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(0);
+ fiatApiUpdateBalance(0, 0);
+ // disable timers
+ userInActivityTimer.running = false;
+ simpleModeConnectionTimer.running = false;
+ });
}
function hideMenu() {
@@ -1289,7 +1294,6 @@ ApplicationWindow {
y = (Screen.height - maxWindowHeight) / 2
//
walletManager.walletOpened.connect(onWalletOpened);
- walletManager.walletClosed.connect(onWalletClosed);
walletManager.deviceButtonRequest.connect(onDeviceButtonRequest);
walletManager.deviceButtonPressed.connect(onDeviceButtonPressed);
walletManager.checkUpdatesComplete.connect(onWalletCheckUpdatesComplete);
@@ -2131,8 +2135,8 @@ ApplicationWindow {
console.log("close accepted");
// Close wallet non async on exit
daemonManager.exit();
- walletManager.closeWallet();
- Qt.quit();
+
+ closeWallet(Qt.quit);
}
function onWalletCheckUpdatesComplete(update) {
diff --git a/pages/settings/SettingsInfo.qml b/pages/settings/SettingsInfo.qml
index b329c068..938bd122 100644
--- a/pages/settings/SettingsInfo.qml
+++ b/pages/settings/SettingsInfo.qml
@@ -208,10 +208,11 @@ Rectangle {
confirmationDialog.icon = StandardIcon.Question
confirmationDialog.cancelText = qsTr("Cancel")
confirmationDialog.onAcceptedCallback = function() {
- walletManager.closeWallet();
- walletManager.clearWalletCache(persistentSettings.wallet_path);
- walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
- persistentSettings.nettype, persistentSettings.kdfRounds);
+ appWindow.closeWallet(function() {
+ walletManager.clearWalletCache(persistentSettings.wallet_path);
+ walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
+ persistentSettings.nettype, persistentSettings.kdfRounds);
+ });
}
confirmationDialog.onRejectedCallback = null;
diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp
index 22a810b9..9b53ad6e 100644
--- a/src/libwalletqt/WalletManager.cpp
+++ b/src/libwalletqt/WalletManager.cpp
@@ -228,11 +228,11 @@ QString WalletManager::closeWallet()
return result;
}
-void WalletManager::closeWalletAsync()
+void WalletManager::closeWalletAsync(const QJSValue& callback)
{
m_scheduler.run([this] {
- emit walletClosed(closeWallet());
- });
+ return QJSValueList({closeWallet()});
+ }, callback);
}
bool WalletManager::walletExists(const QString &path) const
diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h
index 18256b1c..54d2a29f 100644
--- a/src/libwalletqt/WalletManager.h
+++ b/src/libwalletqt/WalletManager.h
@@ -117,7 +117,7 @@ public:
/*!
* \brief closeWalletAsync - asynchronous version of "closeWallet"
*/
- Q_INVOKABLE void closeWalletAsync();
+ Q_INVOKABLE void closeWalletAsync(const QJSValue& callback);
//! checks is given filename is a wallet;
Q_INVOKABLE bool walletExists(const QString &path) const;
@@ -192,7 +192,6 @@ signals:
void walletPassphraseNeeded();
void deviceButtonRequest(quint64 buttonCode);
void deviceButtonPressed();
- void walletClosed(const QString &walletAddress);
void checkUpdatesComplete(const QString &result) const;
void miningStatus(bool isMining) const;