Skip to content

Commit

Permalink
gui: Add closeAllWallets to WalletController
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed May 31, 2020
1 parent a65b55f commit f30960a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
removeAndDeleteWallet(wallet_model);
}

void WalletController::closeAllWallets(QWidget* parent)
{
QMessageBox::StandardButton button = QMessageBox::question(parent, tr("Close all wallets"),
tr("Are you sure you wish to close all wallets?"),
QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Yes);
if (button != QMessageBox::Yes) return;

QMutexLocker locker(&m_mutex);
for (WalletModel* wallet_model : m_wallets) {
wallet_model->wallet().remove();
Q_EMIT walletRemoved(wallet_model);
delete wallet_model;
}
m_wallets.clear();
}

WalletModel* WalletController::getOrCreateWallet(std::unique_ptr<interfaces::Wallet> wallet)
{
QMutexLocker locker(&m_mutex);
Expand Down
1 change: 1 addition & 0 deletions src/qt/walletcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class WalletController : public QObject
std::map<std::string, bool> listWalletDir() const;

void closeWallet(WalletModel* wallet_model, QWidget* parent = nullptr);
void closeAllWallets(QWidget* parent = nullptr);

Q_SIGNALS:
void walletAdded(WalletModel* wallet_model);
Expand Down

0 comments on commit f30960a

Please sign in to comment.