mirror of
https://github.com/monero-project/monero-gui
synced 2024-12-01 08:11:54 +01:00
WalletManager: async close with splash screen
This commit is contained in:
parent
c4b3fbae1d
commit
ab9e31e7cc
46
main.qml
46
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) {
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user