mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-13 13:20:40 +02:00
qt, wallet: Add LoadWalletsActivity class
Also this commit moves wallets loading out from the main GUI thread.
This commit is contained in:
parent
4a024fc310
commit
f6991cb906
@ -659,9 +659,8 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
|
|||||||
GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
|
GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
|
||||||
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
|
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
|
||||||
|
|
||||||
for (WalletModel* wallet_model : m_wallet_controller->getOpenWallets()) {
|
auto activity = new LoadWalletsActivity(m_wallet_controller, this);
|
||||||
addWallet(wallet_model);
|
activity->load();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletController* BitcoinGUI::getWalletController()
|
WalletController* BitcoinGUI::getWalletController()
|
||||||
|
@ -41,10 +41,6 @@ WalletController::WalletController(ClientModel& client_model, const PlatformStyl
|
|||||||
getOrCreateWallet(std::move(wallet));
|
getOrCreateWallet(std::move(wallet));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (std::unique_ptr<interfaces::Wallet>& wallet : m_node.walletClient().getWallets()) {
|
|
||||||
getOrCreateWallet(std::move(wallet));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_activity_worker->moveToThread(m_activity_thread);
|
m_activity_worker->moveToThread(m_activity_thread);
|
||||||
m_activity_thread->start();
|
m_activity_thread->start();
|
||||||
QTimer::singleShot(0, m_activity_worker, []() {
|
QTimer::singleShot(0, m_activity_worker, []() {
|
||||||
@ -342,3 +338,21 @@ void OpenWalletActivity::open(const std::string& path)
|
|||||||
QTimer::singleShot(0, this, &OpenWalletActivity::finish);
|
QTimer::singleShot(0, this, &OpenWalletActivity::finish);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadWalletsActivity::LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget)
|
||||||
|
: WalletControllerActivity(wallet_controller, parent_widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadWalletsActivity::load()
|
||||||
|
{
|
||||||
|
showProgressDialog(tr("Loading wallets…"));
|
||||||
|
|
||||||
|
QTimer::singleShot(0, worker(), [this] {
|
||||||
|
for (auto& wallet : node().walletClient().getWallets()) {
|
||||||
|
m_wallet_controller->getOrCreateWallet(std::move(wallet));
|
||||||
|
}
|
||||||
|
|
||||||
|
QTimer::singleShot(0, this, [this] { Q_EMIT finished(); });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -148,4 +148,14 @@ private:
|
|||||||
void finish();
|
void finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LoadWalletsActivity : public WalletControllerActivity
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
LoadWalletsActivity(WalletController* wallet_controller, QWidget* parent_widget);
|
||||||
|
|
||||||
|
void load();
|
||||||
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_WALLETCONTROLLER_H
|
#endif // BITCOIN_QT_WALLETCONTROLLER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user