mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
qt: merge walletstack and walletframe
There were too many levels of indirection here, and the functionality of walletframe and walletstack can easily be merged. This commit merges the two which cuts a lot of lines of boilerplate code.
This commit is contained in:
parent
81cab378cc
commit
26702e6930
7 changed files with 106 additions and 324 deletions
|
@ -51,7 +51,7 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
|
||||||
moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \
|
moc_signverifymessagedialog.cpp moc_splashscreen.cpp moc_trafficgraphwidget.cpp moc_transactiondesc.cpp \
|
||||||
moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \
|
moc_transactiondescdialog.cpp moc_transactionfilterproxy.cpp \
|
||||||
moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \
|
moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \
|
||||||
moc_walletmodel.cpp moc_walletstack.cpp moc_walletview.cpp
|
moc_walletmodel.cpp moc_walletview.cpp
|
||||||
|
|
||||||
BITCOIN_MM = macdockiconhandler.mm macnotificationhandler.mm
|
BITCOIN_MM = macdockiconhandler.mm macnotificationhandler.mm
|
||||||
QR_CPP = qrcodedialog.cpp
|
QR_CPP = qrcodedialog.cpp
|
||||||
|
@ -75,7 +75,7 @@ BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
|
||||||
sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \
|
sendcoinsdialog.h sendcoinsentry.h signverifymessagedialog.h splashscreen.h \
|
||||||
trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \
|
trafficgraphwidget.h transactiondescdialog.h transactiondesc.h transactionfilterproxy.h \
|
||||||
transactionrecord.h transactiontablemodel.h transactionview.h walletframe.h \
|
transactionrecord.h transactiontablemodel.h transactionview.h walletframe.h \
|
||||||
walletmodel.h walletmodeltransaction.h walletstack.h walletview.h
|
walletmodel.h walletmodeltransaction.h walletview.h
|
||||||
|
|
||||||
RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
|
RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
|
||||||
res/icons/quit.png res/icons/send.png res/icons/toolbar.png \
|
res/icons/quit.png res/icons/send.png res/icons/toolbar.png \
|
||||||
|
@ -105,7 +105,7 @@ BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
|
||||||
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \
|
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \
|
||||||
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
|
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
|
||||||
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \
|
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \
|
||||||
walletmodel.cpp walletmodeltransaction.cpp walletstack.cpp walletview.cpp
|
walletmodel.cpp walletmodeltransaction.cpp walletview.cpp
|
||||||
|
|
||||||
RES_IMAGES = res/images/about.png res/images/splash.png \
|
RES_IMAGES = res/images/about.png res/images/splash.png \
|
||||||
res/images/splash_testnet.png
|
res/images/splash_testnet.png
|
||||||
|
|
|
@ -5,20 +5,21 @@
|
||||||
* The Bitcoin Developers 2011-2013
|
* The Bitcoin Developers 2011-2013
|
||||||
*/
|
*/
|
||||||
#include "walletframe.h"
|
#include "walletframe.h"
|
||||||
|
#include "walletview.h"
|
||||||
#include "bitcoingui.h"
|
#include "bitcoingui.h"
|
||||||
#include "walletstack.h"
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QStackedWidget>
|
||||||
|
|
||||||
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
|
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
|
||||||
QFrame(_gui)
|
QFrame(_gui),
|
||||||
|
gui(_gui)
|
||||||
{
|
{
|
||||||
// Leave HBox hook for adding a list view later
|
// Leave HBox hook for adding a list view later
|
||||||
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
|
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
walletStack = new WalletStack(this);
|
walletStack = new QStackedWidget(this);
|
||||||
walletStack->setBitcoinGUI(_gui);
|
|
||||||
walletFrameLayout->setContentsMargins(0,0,0,0);
|
walletFrameLayout->setContentsMargins(0,0,0,0);
|
||||||
walletFrameLayout->addWidget(walletStack);
|
walletFrameLayout->addWidget(walletStack);
|
||||||
}
|
}
|
||||||
|
@ -29,95 +30,146 @@ WalletFrame::~WalletFrame()
|
||||||
|
|
||||||
void WalletFrame::setClientModel(ClientModel *clientModel)
|
void WalletFrame::setClientModel(ClientModel *clientModel)
|
||||||
{
|
{
|
||||||
if (clientModel)
|
this->clientModel = clientModel;
|
||||||
walletStack->setClientModel(clientModel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
|
bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
|
||||||
{
|
{
|
||||||
return walletStack->addWallet(name, walletModel);
|
if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WalletView *walletView = new WalletView(this);
|
||||||
|
walletView->setBitcoinGUI(gui);
|
||||||
|
walletView->setClientModel(clientModel);
|
||||||
|
walletView->setWalletModel(walletModel);
|
||||||
|
walletView->showOutOfSyncWarning(bOutOfSync);
|
||||||
|
|
||||||
|
walletView->gotoOverviewPage(); /* XXX we should go to the currently selected page */
|
||||||
|
walletStack->addWidget(walletView);
|
||||||
|
mapWalletViews[name] = walletView;
|
||||||
|
|
||||||
|
// Ensure a walletView is able to show the main window
|
||||||
|
connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletFrame::setCurrentWallet(const QString& name)
|
bool WalletFrame::setCurrentWallet(const QString& name)
|
||||||
{
|
{
|
||||||
// TODO: Check if valid name
|
if (mapWalletViews.count(name) == 0)
|
||||||
return walletStack->setCurrentWallet(name);
|
return false;
|
||||||
|
|
||||||
|
WalletView *walletView = mapWalletViews.value(name);
|
||||||
|
walletStack->setCurrentWidget(walletView);
|
||||||
|
walletView->setEncryptionStatus();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::removeAllWallets()
|
void WalletFrame::removeAllWallets()
|
||||||
{
|
{
|
||||||
walletStack->removeAllWallets();
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
walletStack->removeWidget(i.value());
|
||||||
|
mapWalletViews.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
||||||
{
|
{
|
||||||
return walletStack->handlePaymentRequest(recipient);
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (!walletView)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return walletView->handlePaymentRequest(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::showOutOfSyncWarning(bool fShow)
|
void WalletFrame::showOutOfSyncWarning(bool fShow)
|
||||||
{
|
{
|
||||||
if (!walletStack)
|
bOutOfSync = fShow;
|
||||||
return;
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
walletStack->showOutOfSyncWarning(fShow);
|
i.value()->showOutOfSyncWarning(fShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoOverviewPage()
|
void WalletFrame::gotoOverviewPage()
|
||||||
{
|
{
|
||||||
walletStack->gotoOverviewPage();
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
i.value()->gotoOverviewPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoHistoryPage()
|
void WalletFrame::gotoHistoryPage()
|
||||||
{
|
{
|
||||||
walletStack->gotoHistoryPage();
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
i.value()->gotoHistoryPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoAddressBookPage()
|
void WalletFrame::gotoAddressBookPage()
|
||||||
{
|
{
|
||||||
walletStack->gotoAddressBookPage();
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
i.value()->gotoAddressBookPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoReceiveCoinsPage()
|
void WalletFrame::gotoReceiveCoinsPage()
|
||||||
{
|
{
|
||||||
walletStack->gotoReceiveCoinsPage();
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
i.value()->gotoReceiveCoinsPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoSendCoinsPage(QString addr)
|
void WalletFrame::gotoSendCoinsPage(QString addr)
|
||||||
{
|
{
|
||||||
walletStack->gotoSendCoinsPage(addr);
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
|
i.value()->gotoSendCoinsPage(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoSignMessageTab(QString addr)
|
void WalletFrame::gotoSignMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
walletStack->gotoSignMessageTab(addr);
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->gotoSignMessageTab(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoVerifyMessageTab(QString addr)
|
void WalletFrame::gotoVerifyMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
walletStack->gotoSignMessageTab(addr);
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->gotoVerifyMessageTab(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::encryptWallet(bool status)
|
void WalletFrame::encryptWallet(bool status)
|
||||||
{
|
{
|
||||||
walletStack->encryptWallet(status);
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->encryptWallet(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::backupWallet()
|
void WalletFrame::backupWallet()
|
||||||
{
|
{
|
||||||
walletStack->backupWallet();
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->backupWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::changePassphrase()
|
void WalletFrame::changePassphrase()
|
||||||
{
|
{
|
||||||
walletStack->changePassphrase();
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->changePassphrase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::unlockWallet()
|
void WalletFrame::unlockWallet()
|
||||||
{
|
{
|
||||||
walletStack->unlockWallet();
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->unlockWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::setEncryptionStatus()
|
void WalletFrame::setEncryptionStatus()
|
||||||
{
|
{
|
||||||
walletStack->setEncryptionStatus();
|
WalletView *walletView = (WalletView*)walletStack->currentWidget();
|
||||||
|
if (walletView)
|
||||||
|
walletView->setEncryptionStatus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,17 @@
|
||||||
#define WALLETFRAME_H
|
#define WALLETFRAME_H
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
class BitcoinGUI;
|
class BitcoinGUI;
|
||||||
class ClientModel;
|
class ClientModel;
|
||||||
class SendCoinsRecipient;
|
class SendCoinsRecipient;
|
||||||
class WalletModel;
|
class WalletModel;
|
||||||
class WalletStack;
|
class WalletView;
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QStackedWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class WalletFrame : public QFrame
|
class WalletFrame : public QFrame
|
||||||
{
|
{
|
||||||
|
@ -35,7 +40,12 @@ public:
|
||||||
void showOutOfSyncWarning(bool fShow);
|
void showOutOfSyncWarning(bool fShow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WalletStack *walletStack;
|
QStackedWidget *walletStack;
|
||||||
|
BitcoinGUI *gui;
|
||||||
|
ClientModel *clientModel;
|
||||||
|
QMap<QString, WalletView*> mapWalletViews;
|
||||||
|
|
||||||
|
bool bOutOfSync;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** Switch to overview (home) page */
|
/** Switch to overview (home) page */
|
||||||
|
|
|
@ -1,174 +0,0 @@
|
||||||
/*
|
|
||||||
* Qt4 bitcoin GUI.
|
|
||||||
*
|
|
||||||
* W.J. van der Laan 2011-2012
|
|
||||||
* The Bitcoin Developers 2011-2013
|
|
||||||
*/
|
|
||||||
#include "walletstack.h"
|
|
||||||
#include "walletview.h"
|
|
||||||
#include "bitcoingui.h"
|
|
||||||
|
|
||||||
#include <QMap>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
WalletStack::WalletStack(QWidget *parent) :
|
|
||||||
QStackedWidget(parent),
|
|
||||||
gui(0),
|
|
||||||
clientModel(0),
|
|
||||||
bOutOfSync(true)
|
|
||||||
{
|
|
||||||
setContentsMargins(0,0,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
WalletStack::~WalletStack()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
|
|
||||||
{
|
|
||||||
if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
WalletView *walletView = new WalletView(this, gui);
|
|
||||||
walletView->setBitcoinGUI(gui);
|
|
||||||
walletView->setClientModel(clientModel);
|
|
||||||
walletView->setWalletModel(walletModel);
|
|
||||||
walletView->showOutOfSyncWarning(bOutOfSync);
|
|
||||||
addWidget(walletView);
|
|
||||||
mapWalletViews[name] = walletView;
|
|
||||||
|
|
||||||
// Ensure a walletView is able to show the main window
|
|
||||||
connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WalletStack::removeWallet(const QString& name)
|
|
||||||
{
|
|
||||||
if (mapWalletViews.count(name) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.take(name);
|
|
||||||
removeWidget(walletView);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::removeAllWallets()
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
removeWidget(i.value());
|
|
||||||
mapWalletViews.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (!walletView)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return walletView->handlePaymentRequest(recipient);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::showOutOfSyncWarning(bool fShow)
|
|
||||||
{
|
|
||||||
bOutOfSync = fShow;
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->showOutOfSyncWarning(fShow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoOverviewPage()
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->gotoOverviewPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoHistoryPage()
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->gotoHistoryPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoAddressBookPage()
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->gotoAddressBookPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoReceiveCoinsPage()
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->gotoReceiveCoinsPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoSendCoinsPage(QString addr)
|
|
||||||
{
|
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
|
||||||
i.value()->gotoSendCoinsPage(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoSignMessageTab(QString addr)
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->gotoSignMessageTab(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::gotoVerifyMessageTab(QString addr)
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->gotoVerifyMessageTab(addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::encryptWallet(bool status)
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->encryptWallet(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::backupWallet()
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->backupWallet();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::changePassphrase()
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->changePassphrase();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::unlockWallet()
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->unlockWallet();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WalletStack::setEncryptionStatus()
|
|
||||||
{
|
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
|
||||||
if (walletView)
|
|
||||||
walletView->setEncryptionStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WalletStack::setCurrentWallet(const QString& name)
|
|
||||||
{
|
|
||||||
if (mapWalletViews.count(name) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.value(name);
|
|
||||||
setCurrentWidget(walletView);
|
|
||||||
walletView->setEncryptionStatus();
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* Qt4 bitcoin GUI.
|
|
||||||
*
|
|
||||||
* W.J. van der Laan 2011-2012
|
|
||||||
* The Bitcoin Developers 2011-2013
|
|
||||||
*/
|
|
||||||
#ifndef WALLETSTACK_H
|
|
||||||
#define WALLETSTACK_H
|
|
||||||
|
|
||||||
#include <QStackedWidget>
|
|
||||||
#include <QMap>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
class BitcoinGUI;
|
|
||||||
class TransactionTableModel;
|
|
||||||
class ClientModel;
|
|
||||||
class WalletModel;
|
|
||||||
class WalletView;
|
|
||||||
class TransactionView;
|
|
||||||
class OverviewPage;
|
|
||||||
class AddressBookPage;
|
|
||||||
class SendCoinsDialog;
|
|
||||||
class SendCoinsRecipient;
|
|
||||||
class SignVerifyMessageDialog;
|
|
||||||
class Notificator;
|
|
||||||
class RPCConsole;
|
|
||||||
|
|
||||||
class CWalletManager;
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QLabel;
|
|
||||||
class QModelIndex;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
/*
|
|
||||||
WalletStack class. This class is a container for WalletView instances. It takes the place of centralWidget.
|
|
||||||
It was added to support multiple wallet functionality. It communicates with both the client and the
|
|
||||||
wallet models to give the user an up-to-date view of the current core state. It manages all the wallet views
|
|
||||||
it contains and updates them accordingly.
|
|
||||||
*/
|
|
||||||
class WalletStack : public QStackedWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit WalletStack(QWidget *parent = 0);
|
|
||||||
~WalletStack();
|
|
||||||
|
|
||||||
void setBitcoinGUI(BitcoinGUI *gui) { this->gui = gui; }
|
|
||||||
|
|
||||||
void setClientModel(ClientModel *clientModel) { this->clientModel = clientModel; }
|
|
||||||
|
|
||||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
|
||||||
bool removeWallet(const QString& name);
|
|
||||||
|
|
||||||
void removeAllWallets();
|
|
||||||
|
|
||||||
bool handlePaymentRequest(const SendCoinsRecipient &recipient);
|
|
||||||
|
|
||||||
void showOutOfSyncWarning(bool fShow);
|
|
||||||
|
|
||||||
private:
|
|
||||||
BitcoinGUI *gui;
|
|
||||||
ClientModel *clientModel;
|
|
||||||
QMap<QString, WalletView*> mapWalletViews;
|
|
||||||
|
|
||||||
bool bOutOfSync;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
bool setCurrentWallet(const QString& name);
|
|
||||||
|
|
||||||
/** Switch to overview (home) page */
|
|
||||||
void gotoOverviewPage();
|
|
||||||
/** Switch to history (transactions) page */
|
|
||||||
void gotoHistoryPage();
|
|
||||||
/** Switch to address book page */
|
|
||||||
void gotoAddressBookPage();
|
|
||||||
/** Switch to receive coins page */
|
|
||||||
void gotoReceiveCoinsPage();
|
|
||||||
/** Switch to send coins page */
|
|
||||||
void gotoSendCoinsPage(QString addr = "");
|
|
||||||
|
|
||||||
/** Show Sign/Verify Message dialog and switch to sign message tab */
|
|
||||||
void gotoSignMessageTab(QString addr = "");
|
|
||||||
/** Show Sign/Verify Message dialog and switch to verify message tab */
|
|
||||||
void gotoVerifyMessageTab(QString addr = "");
|
|
||||||
|
|
||||||
/** Encrypt the wallet */
|
|
||||||
void encryptWallet(bool status);
|
|
||||||
/** Backup the wallet */
|
|
||||||
void backupWallet();
|
|
||||||
/** Change encrypted wallet passphrase */
|
|
||||||
void changePassphrase();
|
|
||||||
/** Ask for passphrase to unlock wallet temporarily */
|
|
||||||
void unlockWallet();
|
|
||||||
|
|
||||||
/** Set the encryption status as shown in the UI.
|
|
||||||
@param[in] status current encryption status
|
|
||||||
@see WalletModel::EncryptionStatus
|
|
||||||
*/
|
|
||||||
void setEncryptionStatus();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // WALLETSTACK_H
|
|
|
@ -29,9 +29,9 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
|
WalletView::WalletView(QWidget *parent):
|
||||||
QStackedWidget(parent),
|
QStackedWidget(parent),
|
||||||
gui(_gui),
|
gui(0),
|
||||||
clientModel(0),
|
clientModel(0),
|
||||||
walletModel(0)
|
walletModel(0)
|
||||||
{
|
{
|
||||||
|
@ -54,12 +54,8 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
|
||||||
transactionsPage->setLayout(vbox);
|
transactionsPage->setLayout(vbox);
|
||||||
|
|
||||||
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
|
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
|
||||||
|
|
||||||
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
|
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
|
||||||
|
sendCoinsPage = new SendCoinsDialog();
|
||||||
sendCoinsPage = new SendCoinsDialog(gui);
|
|
||||||
|
|
||||||
signVerifyMessageDialog = new SignVerifyMessageDialog(gui);
|
|
||||||
|
|
||||||
addWidget(overviewPage);
|
addWidget(overviewPage);
|
||||||
addWidget(transactionsPage);
|
addWidget(transactionsPage);
|
||||||
|
@ -82,8 +78,6 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
|
||||||
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
|
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
|
||||||
// Clicking on "Export" allows to export the transaction list
|
// Clicking on "Export" allows to export the transaction list
|
||||||
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));
|
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));
|
||||||
|
|
||||||
gotoOverviewPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletView::~WalletView()
|
WalletView::~WalletView()
|
||||||
|
@ -120,7 +114,6 @@ void WalletView::setWalletModel(WalletModel *walletModel)
|
||||||
addressBookPage->setModel(walletModel->getAddressTableModel());
|
addressBookPage->setModel(walletModel->getAddressTableModel());
|
||||||
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
|
receiveCoinsPage->setModel(walletModel->getAddressTableModel());
|
||||||
sendCoinsPage->setModel(walletModel);
|
sendCoinsPage->setModel(walletModel);
|
||||||
signVerifyMessageDialog->setModel(walletModel);
|
|
||||||
|
|
||||||
setEncryptionStatus();
|
setEncryptionStatus();
|
||||||
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int)));
|
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int)));
|
||||||
|
@ -185,7 +178,10 @@ void WalletView::gotoSendCoinsPage(QString addr)
|
||||||
|
|
||||||
void WalletView::gotoSignMessageTab(QString addr)
|
void WalletView::gotoSignMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
// call show() in showTab_SM()
|
// calls show() in showTab_SM()
|
||||||
|
SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this);
|
||||||
|
signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
signVerifyMessageDialog->setModel(walletModel);
|
||||||
signVerifyMessageDialog->showTab_SM(true);
|
signVerifyMessageDialog->showTab_SM(true);
|
||||||
|
|
||||||
if (!addr.isEmpty())
|
if (!addr.isEmpty())
|
||||||
|
@ -194,7 +190,10 @@ void WalletView::gotoSignMessageTab(QString addr)
|
||||||
|
|
||||||
void WalletView::gotoVerifyMessageTab(QString addr)
|
void WalletView::gotoVerifyMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
// call show() in showTab_VM()
|
// calls show() in showTab_VM()
|
||||||
|
SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this);
|
||||||
|
signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
signVerifyMessageDialog->setModel(walletModel);
|
||||||
signVerifyMessageDialog->showTab_VM(true);
|
signVerifyMessageDialog->showTab_VM(true);
|
||||||
|
|
||||||
if (!addr.isEmpty())
|
if (!addr.isEmpty())
|
||||||
|
|
|
@ -36,7 +36,7 @@ class WalletView : public QStackedWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WalletView(QWidget *parent, BitcoinGUI *_gui);
|
explicit WalletView(QWidget *parent);
|
||||||
~WalletView();
|
~WalletView();
|
||||||
|
|
||||||
void setBitcoinGUI(BitcoinGUI *gui);
|
void setBitcoinGUI(BitcoinGUI *gui);
|
||||||
|
@ -64,7 +64,6 @@ private:
|
||||||
AddressBookPage *addressBookPage;
|
AddressBookPage *addressBookPage;
|
||||||
AddressBookPage *receiveCoinsPage;
|
AddressBookPage *receiveCoinsPage;
|
||||||
SendCoinsDialog *sendCoinsPage;
|
SendCoinsDialog *sendCoinsPage;
|
||||||
SignVerifyMessageDialog *signVerifyMessageDialog;
|
|
||||||
|
|
||||||
TransactionView *transactionView;
|
TransactionView *transactionView;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue