mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-02 10:14:31 +00:00
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.
This commit is contained in:
parent
26702e6930
commit
163145938c
@ -4,7 +4,7 @@ Multiwallet Qt Development and Integration Strategy
|
|||||||
In order to support loading of multiple wallets in bitcoin-qt, a few changes in the UI architecture will be needed.
|
In order to support loading of multiple wallets in bitcoin-qt, a few changes in the UI architecture will be needed.
|
||||||
Fortunately, only four of the files in the existing project are affected by this change.
|
Fortunately, only four of the files in the existing project are affected by this change.
|
||||||
|
|
||||||
Three new classes have been implemented in three new .h/.cpp file pairs, with much of the functionality that was previously
|
Two new classes have been implemented in two new .h/.cpp file pairs, with much of the functionality that was previously
|
||||||
implemented in the BitcoinGUI class moved over to these new classes.
|
implemented in the BitcoinGUI class moved over to these new classes.
|
||||||
|
|
||||||
The two existing files most affected, by far, are bitcoingui.h and bitcoingui.cpp, as the BitcoinGUI class will require
|
The two existing files most affected, by far, are bitcoingui.h and bitcoingui.cpp, as the BitcoinGUI class will require
|
||||||
@ -12,7 +12,7 @@ some major retrofitting.
|
|||||||
|
|
||||||
Only requiring some minor changes is bitcoin.cpp.
|
Only requiring some minor changes is bitcoin.cpp.
|
||||||
|
|
||||||
Finally, three new headers and source files will have to be added to bitcoin-qt.pro.
|
Finally, two new headers and source files will have to be added to bitcoin-qt.pro.
|
||||||
|
|
||||||
Changes to class BitcoinGUI
|
Changes to class BitcoinGUI
|
||||||
---------------------------
|
---------------------------
|
||||||
@ -23,13 +23,9 @@ A new class called *WalletView* inheriting from QStackedWidget has been written
|
|||||||
these page views. In addition to owning these five page views, a WalletView also has a pointer to a WalletModel instance.
|
these page views. In addition to owning these five page views, a WalletView also has a pointer to a WalletModel instance.
|
||||||
This allows the construction of multiple WalletView objects, each rendering a distinct wallet.
|
This allows the construction of multiple WalletView objects, each rendering a distinct wallet.
|
||||||
|
|
||||||
A second class called *WalletStack*, also inheriting from QStackedWidget, has been written to handle switching focus between
|
A second class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
|
||||||
different loaded wallets. In its current implementation, as a QStackedWidget, only one wallet can be viewed at a time -
|
controls into BitcoinGUI. At present it contains the WalletView instances for the wallets and does little more than passing on messages
|
||||||
but this can be changed later.
|
from BitcoinGUI to the currently selected WalletView. It is a WalletFrame instance
|
||||||
|
|
||||||
A third class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
|
|
||||||
controls into BitcoinGUI. At present it just contains a WalletStack instance and does little more than passing on messages
|
|
||||||
from BitcoinGUI to the WalletStack, which in turn passes them to the individual WalletViews. It is a WalletFrame instance
|
|
||||||
that takes the place of what used to be centralWidget in BitcoinGUI. The purpose of this class is to allow future
|
that takes the place of what used to be centralWidget in BitcoinGUI. The purpose of this class is to allow future
|
||||||
refinements of the wallet controls with minimal need for further modifications to BitcoinGUI, thus greatly simplifying
|
refinements of the wallet controls with minimal need for further modifications to BitcoinGUI, thus greatly simplifying
|
||||||
merges while reducing the risk of breaking top-level stuff.
|
merges while reducing the risk of breaking top-level stuff.
|
||||||
|
@ -447,26 +447,31 @@ void BitcoinGUI::aboutClicked()
|
|||||||
|
|
||||||
void BitcoinGUI::gotoOverviewPage()
|
void BitcoinGUI::gotoOverviewPage()
|
||||||
{
|
{
|
||||||
|
overviewAction->setChecked(true);
|
||||||
if (walletFrame) walletFrame->gotoOverviewPage();
|
if (walletFrame) walletFrame->gotoOverviewPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::gotoHistoryPage()
|
void BitcoinGUI::gotoHistoryPage()
|
||||||
{
|
{
|
||||||
|
historyAction->setChecked(true);
|
||||||
if (walletFrame) walletFrame->gotoHistoryPage();
|
if (walletFrame) walletFrame->gotoHistoryPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::gotoAddressBookPage()
|
void BitcoinGUI::gotoAddressBookPage()
|
||||||
{
|
{
|
||||||
|
addressBookAction->setChecked(true);
|
||||||
if (walletFrame) walletFrame->gotoAddressBookPage();
|
if (walletFrame) walletFrame->gotoAddressBookPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::gotoReceiveCoinsPage()
|
void BitcoinGUI::gotoReceiveCoinsPage()
|
||||||
{
|
{
|
||||||
|
receiveCoinsAction->setChecked(true);
|
||||||
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
|
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::gotoSendCoinsPage(QString addr)
|
void BitcoinGUI::gotoSendCoinsPage(QString addr)
|
||||||
{
|
{
|
||||||
|
sendCoinsAction->setChecked(true);
|
||||||
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
|
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +61,6 @@ public:
|
|||||||
|
|
||||||
void removeAllWallets();
|
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:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
@ -44,7 +44,8 @@ bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
|
|||||||
walletView->setWalletModel(walletModel);
|
walletView->setWalletModel(walletModel);
|
||||||
walletView->showOutOfSyncWarning(bOutOfSync);
|
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);
|
walletStack->addWidget(walletView);
|
||||||
mapWalletViews[name] = walletView;
|
mapWalletViews[name] = walletView;
|
||||||
|
|
||||||
@ -65,6 +66,16 @@ bool WalletFrame::setCurrentWallet(const QString& name)
|
|||||||
return true;
|
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()
|
void WalletFrame::removeAllWallets()
|
||||||
{
|
{
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<QString, WalletView*>::const_iterator i;
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
bool addWallet(const QString& name, WalletModel *walletModel);
|
||||||
bool setCurrentWallet(const QString& name);
|
bool setCurrentWallet(const QString& name);
|
||||||
|
bool removeWallet(const QString &name);
|
||||||
void removeAllWallets();
|
void removeAllWallets();
|
||||||
|
|
||||||
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
||||||
|
@ -64,7 +64,6 @@ WalletView::WalletView(QWidget *parent):
|
|||||||
addWidget(sendCoinsPage);
|
addWidget(sendCoinsPage);
|
||||||
|
|
||||||
// Clicking on a transaction on the overview page simply sends you to transaction history page
|
// 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)));
|
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
|
||||||
|
|
||||||
// Double-clicking on a transaction on the transaction history page shows details
|
// Double-clicking on a transaction on the transaction history page shows details
|
||||||
@ -87,6 +86,10 @@ WalletView::~WalletView()
|
|||||||
void WalletView::setBitcoinGUI(BitcoinGUI *gui)
|
void WalletView::setBitcoinGUI(BitcoinGUI *gui)
|
||||||
{
|
{
|
||||||
this->gui = gui;
|
this->gui = gui;
|
||||||
|
if(gui)
|
||||||
|
{
|
||||||
|
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, SLOT(gotoHistoryPage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::setClientModel(ClientModel *clientModel)
|
void WalletView::setClientModel(ClientModel *clientModel)
|
||||||
@ -103,7 +106,7 @@ void WalletView::setClientModel(ClientModel *clientModel)
|
|||||||
void WalletView::setWalletModel(WalletModel *walletModel)
|
void WalletView::setWalletModel(WalletModel *walletModel)
|
||||||
{
|
{
|
||||||
this->walletModel = walletModel;
|
this->walletModel = walletModel;
|
||||||
if (walletModel)
|
if (walletModel && gui)
|
||||||
{
|
{
|
||||||
// Receive and report messages from wallet thread
|
// Receive and report messages from wallet thread
|
||||||
connect(walletModel, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int)));
|
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()
|
void WalletView::gotoOverviewPage()
|
||||||
{
|
{
|
||||||
gui->getOverviewAction()->setChecked(true);
|
|
||||||
setCurrentWidget(overviewPage);
|
setCurrentWidget(overviewPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::gotoHistoryPage()
|
void WalletView::gotoHistoryPage()
|
||||||
{
|
{
|
||||||
gui->getHistoryAction()->setChecked(true);
|
|
||||||
setCurrentWidget(transactionsPage);
|
setCurrentWidget(transactionsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::gotoAddressBookPage()
|
void WalletView::gotoAddressBookPage()
|
||||||
{
|
{
|
||||||
gui->getAddressBookAction()->setChecked(true);
|
|
||||||
setCurrentWidget(addressBookPage);
|
setCurrentWidget(addressBookPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::gotoReceiveCoinsPage()
|
void WalletView::gotoReceiveCoinsPage()
|
||||||
{
|
{
|
||||||
gui->getReceiveCoinsAction()->setChecked(true);
|
|
||||||
setCurrentWidget(receiveCoinsPage);
|
setCurrentWidget(receiveCoinsPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletView::gotoSendCoinsPage(QString addr)
|
void WalletView::gotoSendCoinsPage(QString addr)
|
||||||
{
|
{
|
||||||
gui->getSendCoinsAction()->setChecked(true);
|
|
||||||
setCurrentWidget(sendCoinsPage);
|
setCurrentWidget(sendCoinsPage);
|
||||||
|
|
||||||
if (!addr.isEmpty())
|
if (!addr.isEmpty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user