Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletframe.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/walletframe.h> | #include <qt/walletframe.h> | ||||
#include <qt/bitcoingui.h> | #include <qt/bitcoingui.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <qt/walletview.h> | #include <qt/walletview.h> | ||||
Show All 24 Lines | void WalletFrame::setClientModel(ClientModel *_clientModel) { | ||||
this->clientModel = _clientModel; | this->clientModel = _clientModel; | ||||
} | } | ||||
bool WalletFrame::addWallet(WalletModel *walletModel) { | bool WalletFrame::addWallet(WalletModel *walletModel) { | ||||
if (!gui || !clientModel || !walletModel) { | if (!gui || !clientModel || !walletModel) { | ||||
return false; | return false; | ||||
} | } | ||||
const QString name = walletModel->getWalletName(); | if (mapWalletViews.count(walletModel) > 0) { | ||||
if (mapWalletViews.count(name) > 0) { | |||||
return false; | return false; | ||||
} | } | ||||
WalletView *walletView = new WalletView(platformStyle, walletModel, this); | WalletView *walletView = new WalletView(platformStyle, walletModel, this); | ||||
walletView->setBitcoinGUI(gui); | walletView->setBitcoinGUI(gui); | ||||
walletView->setClientModel(clientModel); | walletView->setClientModel(clientModel); | ||||
walletView->showOutOfSyncWarning(bOutOfSync); | walletView->showOutOfSyncWarning(bOutOfSync); | ||||
WalletView *current_wallet_view = currentWalletView(); | WalletView *current_wallet_view = currentWalletView(); | ||||
if (current_wallet_view) { | if (current_wallet_view) { | ||||
walletView->setCurrentIndex(current_wallet_view->currentIndex()); | walletView->setCurrentIndex(current_wallet_view->currentIndex()); | ||||
} else { | } else { | ||||
walletView->gotoOverviewPage(); | walletView->gotoOverviewPage(); | ||||
} | } | ||||
walletStack->addWidget(walletView); | walletStack->addWidget(walletView); | ||||
mapWalletViews[name] = walletView; | mapWalletViews[walletModel] = walletView; | ||||
// Ensure a walletView is able to show the main window | // Ensure a walletView is able to show the main window | ||||
connect(walletView, &WalletView::showNormalIfMinimized, | connect(walletView, &WalletView::showNormalIfMinimized, | ||||
[this] { gui->showNormalIfMinimized(); }); | [this] { gui->showNormalIfMinimized(); }); | ||||
connect(walletView, &WalletView::outOfSyncWarningClicked, this, | connect(walletView, &WalletView::outOfSyncWarningClicked, this, | ||||
&WalletFrame::outOfSyncWarningClicked); | &WalletFrame::outOfSyncWarningClicked); | ||||
return true; | return true; | ||||
} | } | ||||
bool WalletFrame::setCurrentWallet(const QString &name) { | bool WalletFrame::setCurrentWallet(WalletModel *wallet_model) { | ||||
if (mapWalletViews.count(name) == 0) { | if (mapWalletViews.count(wallet_model) == 0) { | ||||
return false; | return false; | ||||
} | } | ||||
WalletView *walletView = mapWalletViews.value(name); | WalletView *walletView = mapWalletViews.value(wallet_model); | ||||
walletStack->setCurrentWidget(walletView); | walletStack->setCurrentWidget(walletView); | ||||
assert(walletView); | assert(walletView); | ||||
walletView->updateEncryptionStatus(); | walletView->updateEncryptionStatus(); | ||||
return true; | return true; | ||||
} | } | ||||
bool WalletFrame::removeWallet(const QString &name) { | bool WalletFrame::removeWallet(WalletModel *wallet_model) { | ||||
if (mapWalletViews.count(name) == 0) { | if (mapWalletViews.count(wallet_model) == 0) { | ||||
return false; | return false; | ||||
} | } | ||||
WalletView *walletView = mapWalletViews.take(name); | WalletView *walletView = mapWalletViews.take(wallet_model); | ||||
walletStack->removeWidget(walletView); | walletStack->removeWidget(walletView); | ||||
delete walletView; | delete walletView; | ||||
return true; | return true; | ||||
} | } | ||||
void WalletFrame::removeAllWallets() { | void WalletFrame::removeAllWallets() { | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
walletStack->removeWidget(i.value()); | walletStack->removeWidget(i.value()); | ||||
} | } | ||||
mapWalletViews.clear(); | mapWalletViews.clear(); | ||||
} | } | ||||
bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient) { | bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient) { | ||||
WalletView *walletView = currentWalletView(); | WalletView *walletView = currentWalletView(); | ||||
if (!walletView) { | if (!walletView) { | ||||
return false; | return false; | ||||
} | } | ||||
return walletView->handlePaymentRequest(recipient); | return walletView->handlePaymentRequest(recipient); | ||||
} | } | ||||
void WalletFrame::showOutOfSyncWarning(bool fShow) { | void WalletFrame::showOutOfSyncWarning(bool fShow) { | ||||
bOutOfSync = fShow; | bOutOfSync = fShow; | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
i.value()->showOutOfSyncWarning(fShow); | i.value()->showOutOfSyncWarning(fShow); | ||||
} | } | ||||
} | } | ||||
void WalletFrame::gotoOverviewPage() { | void WalletFrame::gotoOverviewPage() { | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
i.value()->gotoOverviewPage(); | i.value()->gotoOverviewPage(); | ||||
} | } | ||||
} | } | ||||
void WalletFrame::gotoHistoryPage() { | void WalletFrame::gotoHistoryPage() { | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
i.value()->gotoHistoryPage(); | i.value()->gotoHistoryPage(); | ||||
} | } | ||||
} | } | ||||
void WalletFrame::gotoReceiveCoinsPage() { | void WalletFrame::gotoReceiveCoinsPage() { | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
i.value()->gotoReceiveCoinsPage(); | i.value()->gotoReceiveCoinsPage(); | ||||
} | } | ||||
} | } | ||||
void WalletFrame::gotoSendCoinsPage(QString addr) { | void WalletFrame::gotoSendCoinsPage(QString addr) { | ||||
QMap<QString, WalletView *>::const_iterator i; | QMap<WalletModel *, WalletView *>::const_iterator i; | ||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { | ||||
i.value()->gotoSendCoinsPage(addr); | i.value()->gotoSendCoinsPage(addr); | ||||
} | } | ||||
} | } | ||||
void WalletFrame::gotoSignMessageTab(QString addr) { | void WalletFrame::gotoSignMessageTab(QString addr) { | ||||
WalletView *walletView = currentWalletView(); | WalletView *walletView = currentWalletView(); | ||||
if (walletView) { | if (walletView) { | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |