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 9
9
10
10
#include < algorithm>
11
11
12
+ #include < QMessageBox>
12
13
#include < QMutexLocker>
13
14
#include < QThread>
14
15
@@ -37,6 +38,30 @@ std::vector<WalletModel*> WalletController::getWallets() const
37
38
return m_wallets;
38
39
}
39
40
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
+
40
65
WalletModel* WalletController::getOrCreateWallet (std::unique_ptr<interfaces::Wallet> wallet)
41
66
{
42
67
QMutexLocker locker (&m_mutex);
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ class WalletController : public QObject
37
37
~WalletController ();
38
38
39
39
std::vector<WalletModel*> getWallets () const ;
40
+ std::vector<std::string> getWalletsAvailableToOpen () const ;
41
+
42
+ WalletModel* openWallet (const std::string& name, QWidget* parent = nullptr );
40
43
41
44
private Q_SLOTS:
42
45
void addWallet (WalletModel* wallet_model);
You can’t perform that action at this time.
0 commit comments