aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-08-23 01:31:25 -0700
committerWladimir J. van der Laan <laanwj@gmail.com>2013-08-23 01:31:25 -0700
commitb60012f2b6770105557db2af40dc34947e884330 (patch)
tree88a2ba112bc8c6fb3353327c5579c830f7868ff4
parente62f8d72f349aec0865268c089ae99fedd314af1 (diff)
parentdbc0a6aba2cf94aa1b167145a18e0b9c671aef5b (diff)
Merge pull request #2872 from Diapolo/GUI_wallet
Bitcoin-Qt: tweak Qt walletXXX.cpp/h code
-rw-r--r--src/qt/walletframe.cpp13
-rw-r--r--src/qt/walletframe.h2
-rw-r--r--src/qt/walletstack.cpp42
-rw-r--r--src/qt/walletstack.h2
-rw-r--r--src/qt/walletview.cpp3
-rw-r--r--src/qt/walletview.h4
6 files changed, 42 insertions, 24 deletions
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp
index ed2723a0f7..99a6647a65 100644
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -12,15 +12,13 @@
#include <QMessageBox>
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
- QFrame(_gui),
- gui(_gui),
- clientModel(0)
+ QFrame(_gui)
{
// Leave HBox hook for adding a list view later
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
setContentsMargins(0,0,0,0);
walletStack = new WalletStack(this);
- walletStack->setBitcoinGUI(gui);
+ walletStack->setBitcoinGUI(_gui);
walletFrameLayout->setContentsMargins(0,0,0,0);
walletFrameLayout->addWidget(walletStack);
}
@@ -31,8 +29,8 @@ WalletFrame::~WalletFrame()
void WalletFrame::setClientModel(ClientModel *clientModel)
{
- this->clientModel = clientModel;
- walletStack->setClientModel(clientModel);
+ if (clientModel)
+ walletStack->setClientModel(clientModel);
}
bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
@@ -43,8 +41,7 @@ bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
bool WalletFrame::setCurrentWallet(const QString& name)
{
// TODO: Check if valid name
- walletStack->setCurrentWallet(name);
- return true;
+ return walletStack->setCurrentWallet(name);
}
void WalletFrame::removeAllWallets()
diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h
index d5aeb6d859..eaae053ccd 100644
--- a/src/qt/walletframe.h
+++ b/src/qt/walletframe.h
@@ -35,8 +35,6 @@ public:
void showOutOfSyncWarning(bool fShow);
private:
- BitcoinGUI *gui;
- ClientModel *clientModel;
WalletStack *walletStack;
public slots:
diff --git a/src/qt/walletstack.cpp b/src/qt/walletstack.cpp
index 6cc73358a4..4ef87aed52 100644
--- a/src/qt/walletstack.cpp
+++ b/src/qt/walletstack.cpp
@@ -13,6 +13,7 @@
WalletStack::WalletStack(QWidget *parent) :
QStackedWidget(parent),
+ gui(0),
clientModel(0),
bOutOfSync(true)
{
@@ -25,7 +26,7 @@ WalletStack::~WalletStack()
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;
WalletView *walletView = new WalletView(this, gui);
@@ -35,12 +36,18 @@ bool WalletStack::addWallet(const QString& name, WalletModel *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;
+ if (mapWalletViews.count(name) == 0)
+ return false;
+
WalletView *walletView = mapWalletViews.take(name);
removeWidget(walletView);
return true;
@@ -57,7 +64,8 @@ void WalletStack::removeAllWallets()
bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient)
{
WalletView *walletView = (WalletView*)currentWidget();
- if (!walletView) return false;
+ if (!walletView)
+ return false;
return walletView->handlePaymentRequest(recipient);
}
@@ -108,49 +116,59 @@ void WalletStack::gotoSendCoinsPage(QString addr)
void WalletStack::gotoSignMessageTab(QString addr)
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->gotoSignMessageTab(addr);
+ if (walletView)
+ walletView->gotoSignMessageTab(addr);
}
void WalletStack::gotoVerifyMessageTab(QString addr)
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->gotoVerifyMessageTab(addr);
+ if (walletView)
+ walletView->gotoVerifyMessageTab(addr);
}
void WalletStack::encryptWallet(bool status)
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->encryptWallet(status);
+ if (walletView)
+ walletView->encryptWallet(status);
}
void WalletStack::backupWallet()
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->backupWallet();
+ if (walletView)
+ walletView->backupWallet();
}
void WalletStack::changePassphrase()
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->changePassphrase();
+ if (walletView)
+ walletView->changePassphrase();
}
void WalletStack::unlockWallet()
{
WalletView *walletView = (WalletView*)currentWidget();
- if (walletView) walletView->unlockWallet();
+ if (walletView)
+ walletView->unlockWallet();
}
void WalletStack::setEncryptionStatus()
{
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);
setCurrentWidget(walletView);
walletView->setEncryptionStatus();
+ return true;
}
diff --git a/src/qt/walletstack.h b/src/qt/walletstack.h
index 5c84cb6e1e..74b9f09081 100644
--- a/src/qt/walletstack.h
+++ b/src/qt/walletstack.h
@@ -67,7 +67,7 @@ private:
bool bOutOfSync;
public slots:
- void setCurrentWallet(const QString& name);
+ bool setCurrentWallet(const QString& name);
/** Switch to overview (home) page */
void gotoOverviewPage();
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index 0a6a4028a0..efb74efaa0 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -137,7 +137,7 @@ void WalletView::setWalletModel(WalletModel *walletModel)
void WalletView::incomingTransaction(const QModelIndex& parent, int start, int /*end*/)
{
// Prevent balloon-spam when initial block download is in progress
- if(!walletModel || !clientModel || clientModel->inInitialBlockDownload())
+ if (!walletModel || !clientModel || clientModel->inInitialBlockDownload())
return;
TransactionTableModel *ttm = walletModel->getTransactionTableModel();
@@ -207,6 +207,7 @@ bool WalletView::handlePaymentRequest(const SendCoinsRecipient& recipient)
if (sendCoinsPage->handlePaymentRequest(recipient))
{
gotoSendCoinsPage();
+ emit showNormalIfMinimized();
return true;
}
else
diff --git a/src/qt/walletview.h b/src/qt/walletview.h
index 97e8f93df9..ce4e051098 100644
--- a/src/qt/walletview.h
+++ b/src/qt/walletview.h
@@ -100,6 +100,10 @@ public slots:
void unlockWallet();
void setEncryptionStatus();
+
+signals:
+ /** Signal that we want to show the main window */
+ void showNormalIfMinimized();
};
#endif // WALLETVIEW_H