aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-10-18 18:43:07 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2013-10-19 17:51:26 +0200
commit163145938ca2ff52e633136ca49e89f880f8e89b (patch)
tree7216657535e1d2666ef26cd701c7999daec73e55 /src/qt
parent26702e6930519c7d063796f2572a5b4ef5f29b06 (diff)
qt: remove awkward way of setting GUI pages
Selecting the button for a pages was going through bitcoingui->walletframe->walletview->bitcoingui. Because of this, the actions for the pages had to be exposed on the BitcoinGUI object.
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/bitcoingui.cpp5
-rw-r--r--src/qt/bitcoingui.h8
-rw-r--r--src/qt/walletframe.cpp13
-rw-r--r--src/qt/walletframe.h2
-rw-r--r--src/qt/walletview.cpp12
5 files changed, 23 insertions, 17 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 23a221120f..3336a8afd3 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -447,26 +447,31 @@ void BitcoinGUI::aboutClicked()
void BitcoinGUI::gotoOverviewPage()
{
+ overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
+ historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
void BitcoinGUI::gotoAddressBookPage()
{
+ addressBookAction->setChecked(true);
if (walletFrame) walletFrame->gotoAddressBookPage();
}
void BitcoinGUI::gotoReceiveCoinsPage()
{
+ receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
+ sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index e2dd5dc6bc..e5a92fed93 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -61,14 +61,6 @@ public:
void removeAllWallets();
- /** Used by WalletView to allow access to needed QActions */
- // Todo: Use Qt signals for these
- QAction * getOverviewAction() { return overviewAction; }
- QAction * getHistoryAction() { return historyAction; }
- QAction * getAddressBookAction() { return addressBookAction; }
- QAction * getReceiveCoinsAction() { return receiveCoinsAction; }
- QAction * getSendCoinsAction() { return sendCoinsAction; }
-
protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp
index 56b081170a..f754bd5e71 100644
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -44,7 +44,8 @@ bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
walletView->setWalletModel(walletModel);
walletView->showOutOfSyncWarning(bOutOfSync);
- walletView->gotoOverviewPage(); /* XXX we should go to the currently selected page */
+ /* TODO we should goto the currently selected page once dynamically adding wallets is supported */
+ walletView->gotoOverviewPage();
walletStack->addWidget(walletView);
mapWalletViews[name] = walletView;
@@ -65,6 +66,16 @@ bool WalletFrame::setCurrentWallet(const QString& name)
return true;
}
+bool WalletFrame::removeWallet(const QString &name)
+{
+ if (mapWalletViews.count(name) == 0)
+ return false;
+
+ WalletView *walletView = mapWalletViews.take(name);
+ walletStack->removeWidget(walletView);
+ return true;
+}
+
void WalletFrame::removeAllWallets()
{
QMap<QString, WalletView*>::const_iterator i;
diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h
index 4cc6d14e41..5011987963 100644
--- a/src/qt/walletframe.h
+++ b/src/qt/walletframe.h
@@ -32,7 +32,7 @@ public:
bool addWallet(const QString& name, WalletModel *walletModel);
bool setCurrentWallet(const QString& name);
-
+ bool removeWallet(const QString &name);
void removeAllWallets();
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index 39678690ce..d7cef971ed 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -64,7 +64,6 @@ WalletView::WalletView(QWidget *parent):
addWidget(sendCoinsPage);
// Clicking on a transaction on the overview page simply sends you to transaction history page
- connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
// Double-clicking on a transaction on the transaction history page shows details
@@ -87,6 +86,10 @@ WalletView::~WalletView()
void WalletView::setBitcoinGUI(BitcoinGUI *gui)
{
this->gui = gui;
+ if(gui)
+ {
+ connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage()));
+ }
}
void WalletView::setClientModel(ClientModel *clientModel)
@@ -103,7 +106,7 @@ void WalletView::setClientModel(ClientModel *clientModel)
void WalletView::setWalletModel(WalletModel *walletModel)
{
this->walletModel = walletModel;
- if (walletModel)
+ if (walletModel && gui)
{
// Receive and report messages from wallet thread
connect(walletModel, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
@@ -145,31 +148,26 @@ void WalletView::incomingTransaction(const QModelIndex& parent, int start, int /
void WalletView::gotoOverviewPage()
{
- gui->getOverviewAction()->setChecked(true);
setCurrentWidget(overviewPage);
}
void WalletView::gotoHistoryPage()
{
- gui->getHistoryAction()->setChecked(true);
setCurrentWidget(transactionsPage);
}
void WalletView::gotoAddressBookPage()
{
- gui->getAddressBookAction()->setChecked(true);
setCurrentWidget(addressBookPage);
}
void WalletView::gotoReceiveCoinsPage()
{
- gui->getReceiveCoinsAction()->setChecked(true);
setCurrentWidget(receiveCoinsPage);
}
void WalletView::gotoSendCoinsPage(QString addr)
{
- gui->getSendCoinsAction()->setChecked(true);
setCurrentWidget(sendCoinsPage);
if (!addr.isEmpty())