From d3234bb91564ee8327b111e0acf2a83153929c25 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Thu, 18 Aug 2016 21:55:34 +0300 Subject: WalletManager::openWalletAsync in progress --- src/libwalletqt/WalletManager.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/libwalletqt/WalletManager.cpp') diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index a7742bca..50a61553 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -6,6 +6,7 @@ #include #include #include +#include @@ -42,6 +43,20 @@ Wallet *WalletManager::openWallet(const QString &path, const QString &password, return wallet; } +void WalletManager::openWalletAsync(const QString &path, const QString &password, bool testnet) +{ + QFuture future = QtConcurrent::run(this, &WalletManager::openWallet, + path, password, testnet); + QFutureWatcher * watcher = new QFutureWatcher(); + watcher->setFuture(future); + connect(watcher, &QFutureWatcher::finished, + this, [this, watcher]() { + QFuture future = watcher->future(); + watcher->deleteLater(); + emit walletOpened(future.result()); + }); +} + Wallet *WalletManager::recoveryWallet(const QString &path, const QString &memo, bool testnet) { @@ -51,9 +66,26 @@ Wallet *WalletManager::recoveryWallet(const QString &path, const QString &memo, } -void WalletManager::closeWallet(Wallet *wallet) +QString WalletManager::closeWallet(Wallet *wallet) { + QString result = wallet->address(); delete wallet; + return result; +} + +void WalletManager::closeWalletAsync(Wallet *wallet) +{ + QFuture future = QtConcurrent::run(this, &WalletManager::closeWallet, + wallet); + QFutureWatcher * watcher = new QFutureWatcher(); + watcher->setFuture(future); + + connect(watcher, &QFutureWatcher::finished, + this, [this, watcher]() { + QFuture future = watcher->future(); + watcher->deleteLater(); + emit future.result(); + }); } bool WalletManager::walletExists(const QString &path) const -- cgit v1.2.3