File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 99
1010#include < algorithm>
1111
12+ #include < QMessageBox>
1213#include < QMutexLocker>
1314#include < QThread>
1415
@@ -37,6 +38,30 @@ std::vector<WalletModel*> WalletController::getWallets() const
3738 return m_wallets;
3839}
3940
41+ std::vector<std::string> WalletController::getWalletsAvailableToOpen () const
42+ {
43+ QMutexLocker locker (&m_mutex);
44+ std::vector<std::string> wallets = m_node.listWalletDir ();
45+ for (WalletModel* wallet_model : m_wallets) {
46+ auto it = std::remove (wallets.begin (), wallets.end (), wallet_model->wallet ().getWalletName ());
47+ if (it != wallets.end ()) wallets.erase (it);
48+ }
49+ return wallets;
50+ }
51+
52+ WalletModel* WalletController::openWallet (const std::string& name, QWidget* parent)
53+ {
54+ std::string error, warning;
55+ WalletModel* wallet_model = getOrCreateWallet (m_node.loadWallet (name, error, warning));
56+ if (!wallet_model) {
57+ QMessageBox::warning (parent, tr (" Open Wallet" ), QString::fromStdString (error));
58+ }
59+ if (!warning.empty ()) {
60+ QMessageBox::information (parent, tr (" Open Wallet" ), QString::fromStdString (warning));
61+ }
62+ return wallet_model;
63+ }
64+
4065WalletModel* WalletController::getOrCreateWallet (std::unique_ptr<interfaces::Wallet> wallet)
4166{
4267 QMutexLocker locker (&m_mutex);
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ class WalletController : public QObject
3737 ~WalletController ();
3838
3939 std::vector<WalletModel*> getWallets () const ;
40+ std::vector<std::string> getWalletsAvailableToOpen () const ;
41+
42+ WalletModel* openWallet (const std::string& name, QWidget* parent = nullptr );
4043
4144private Q_SLOTS:
4245 void addWallet (WalletModel* wallet_model);
You can’t perform that action at this time.
0 commit comments