Merge pull request #2872 from Diapolo/GUI_wallet
Bitcoin-Qt: tweak Qt walletXXX.cpp/h code
This commit is contained in:
commit
b60012f2b6
6 changed files with 42 additions and 24 deletions
|
@ -12,15 +12,13 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
|
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
|
||||||
QFrame(_gui),
|
QFrame(_gui)
|
||||||
gui(_gui),
|
|
||||||
clientModel(0)
|
|
||||||
{
|
{
|
||||||
// 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 WalletStack(this);
|
||||||
walletStack->setBitcoinGUI(gui);
|
walletStack->setBitcoinGUI(_gui);
|
||||||
walletFrameLayout->setContentsMargins(0,0,0,0);
|
walletFrameLayout->setContentsMargins(0,0,0,0);
|
||||||
walletFrameLayout->addWidget(walletStack);
|
walletFrameLayout->addWidget(walletStack);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +29,7 @@ WalletFrame::~WalletFrame()
|
||||||
|
|
||||||
void WalletFrame::setClientModel(ClientModel *clientModel)
|
void WalletFrame::setClientModel(ClientModel *clientModel)
|
||||||
{
|
{
|
||||||
this->clientModel = clientModel;
|
if (clientModel)
|
||||||
walletStack->setClientModel(clientModel);
|
walletStack->setClientModel(clientModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +41,7 @@ bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
|
||||||
bool WalletFrame::setCurrentWallet(const QString& name)
|
bool WalletFrame::setCurrentWallet(const QString& name)
|
||||||
{
|
{
|
||||||
// TODO: Check if valid name
|
// TODO: Check if valid name
|
||||||
walletStack->setCurrentWallet(name);
|
return walletStack->setCurrentWallet(name);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::removeAllWallets()
|
void WalletFrame::removeAllWallets()
|
||||||
|
|
|
@ -35,8 +35,6 @@ public:
|
||||||
void showOutOfSyncWarning(bool fShow);
|
void showOutOfSyncWarning(bool fShow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BitcoinGUI *gui;
|
|
||||||
ClientModel *clientModel;
|
|
||||||
WalletStack *walletStack;
|
WalletStack *walletStack;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
WalletStack::WalletStack(QWidget *parent) :
|
WalletStack::WalletStack(QWidget *parent) :
|
||||||
QStackedWidget(parent),
|
QStackedWidget(parent),
|
||||||
|
gui(0),
|
||||||
clientModel(0),
|
clientModel(0),
|
||||||
bOutOfSync(true)
|
bOutOfSync(true)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +26,7 @@ WalletStack::~WalletStack()
|
||||||
|
|
||||||
bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
|
bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
|
||||||
{
|
{
|
||||||
if (!gui || !clientModel || mapWalletViews.count(name) > 0)
|
if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
WalletView *walletView = new WalletView(this, gui);
|
WalletView *walletView = new WalletView(this, gui);
|
||||||
|
@ -35,12 +36,18 @@ bool WalletStack::addWallet(const QString& name, WalletModel *walletModel)
|
||||||
walletView->showOutOfSyncWarning(bOutOfSync);
|
walletView->showOutOfSyncWarning(bOutOfSync);
|
||||||
addWidget(walletView);
|
addWidget(walletView);
|
||||||
mapWalletViews[name] = walletView;
|
mapWalletViews[name] = walletView;
|
||||||
|
|
||||||
|
// Ensure a walletView is able to show the main window
|
||||||
|
connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletStack::removeWallet(const QString& name)
|
bool WalletStack::removeWallet(const QString& name)
|
||||||
{
|
{
|
||||||
if (mapWalletViews.count(name) == 0) return false;
|
if (mapWalletViews.count(name) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.take(name);
|
WalletView *walletView = mapWalletViews.take(name);
|
||||||
removeWidget(walletView);
|
removeWidget(walletView);
|
||||||
return true;
|
return true;
|
||||||
|
@ -57,7 +64,8 @@ void WalletStack::removeAllWallets()
|
||||||
bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (!walletView) return false;
|
if (!walletView)
|
||||||
|
return false;
|
||||||
|
|
||||||
return walletView->handlePaymentRequest(recipient);
|
return walletView->handlePaymentRequest(recipient);
|
||||||
}
|
}
|
||||||
|
@ -108,49 +116,59 @@ void WalletStack::gotoSendCoinsPage(QString addr)
|
||||||
void WalletStack::gotoSignMessageTab(QString addr)
|
void WalletStack::gotoSignMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->gotoSignMessageTab(addr);
|
if (walletView)
|
||||||
|
walletView->gotoSignMessageTab(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::gotoVerifyMessageTab(QString addr)
|
void WalletStack::gotoVerifyMessageTab(QString addr)
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->gotoVerifyMessageTab(addr);
|
if (walletView)
|
||||||
|
walletView->gotoVerifyMessageTab(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::encryptWallet(bool status)
|
void WalletStack::encryptWallet(bool status)
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->encryptWallet(status);
|
if (walletView)
|
||||||
|
walletView->encryptWallet(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::backupWallet()
|
void WalletStack::backupWallet()
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->backupWallet();
|
if (walletView)
|
||||||
|
walletView->backupWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::changePassphrase()
|
void WalletStack::changePassphrase()
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->changePassphrase();
|
if (walletView)
|
||||||
|
walletView->changePassphrase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::unlockWallet()
|
void WalletStack::unlockWallet()
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->unlockWallet();
|
if (walletView)
|
||||||
|
walletView->unlockWallet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::setEncryptionStatus()
|
void WalletStack::setEncryptionStatus()
|
||||||
{
|
{
|
||||||
WalletView *walletView = (WalletView*)currentWidget();
|
WalletView *walletView = (WalletView*)currentWidget();
|
||||||
if (walletView) walletView->setEncryptionStatus();
|
if (walletView)
|
||||||
|
walletView->setEncryptionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletStack::setCurrentWallet(const QString& name)
|
bool WalletStack::setCurrentWallet(const QString& name)
|
||||||
{
|
{
|
||||||
if (mapWalletViews.count(name) == 0) return;
|
if (mapWalletViews.count(name) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.value(name);
|
WalletView *walletView = mapWalletViews.value(name);
|
||||||
setCurrentWidget(walletView);
|
setCurrentWidget(walletView);
|
||||||
walletView->setEncryptionStatus();
|
walletView->setEncryptionStatus();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ private:
|
||||||
bool bOutOfSync;
|
bool bOutOfSync;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentWallet(const QString& name);
|
bool setCurrentWallet(const QString& name);
|
||||||
|
|
||||||
/** Switch to overview (home) page */
|
/** Switch to overview (home) page */
|
||||||
void gotoOverviewPage();
|
void gotoOverviewPage();
|
||||||
|
|
|
@ -207,6 +207,7 @@ bool WalletView::handlePaymentRequest(const SendCoinsRecipient& recipient)
|
||||||
if (sendCoinsPage->handlePaymentRequest(recipient))
|
if (sendCoinsPage->handlePaymentRequest(recipient))
|
||||||
{
|
{
|
||||||
gotoSendCoinsPage();
|
gotoSendCoinsPage();
|
||||||
|
emit showNormalIfMinimized();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -100,6 +100,10 @@ public slots:
|
||||||
void unlockWallet();
|
void unlockWallet();
|
||||||
|
|
||||||
void setEncryptionStatus();
|
void setEncryptionStatus();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/** Signal that we want to show the main window */
|
||||||
|
void showNormalIfMinimized();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WALLETVIEW_H
|
#endif // WALLETVIEW_H
|
||||||
|
|
Loading…
Reference in a new issue