qt: Masternode Tab should work with nowallet (#4318)

Make Masternode Tab accessible even when there is no wallet.

WalletFrame now owns a MasternodeList that will be shown when there are
no wallets to display.
This commit is contained in:
linuxsh2 2021-08-10 15:37:06 -04:00 committed by GitHub
parent fc8952aa19
commit 6af4a22556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View File

@ -583,6 +583,7 @@ void BitcoinGUI::createToolBars()
masternodeButton->setStatusTip(tr("Browse masternodes"));
tabGroup->addButton(masternodeButton);
connect(masternodeButton, SIGNAL(clicked()), this, SLOT(gotoMasternodePage()));
masternodeButton->setEnabled(true);
}
connect(overviewButton, SIGNAL(clicked()), this, SLOT(gotoOverviewPage()));
@ -805,10 +806,6 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
coinJoinCoinsButton->setEnabled(enabled && clientModel->coinJoinOptions().isEnabled());
receiveCoinsButton->setEnabled(enabled);
historyButton->setEnabled(enabled);
if (masternodeButton != nullptr) {
QSettings settings;
masternodeButton->setEnabled(enabled && settings.value("fShowMasternodesTab").toBool());
}
}
#endif // ENABLE_WALLET

View File

@ -91,6 +91,7 @@ MasternodeList::MasternodeList(QWidget* parent) :
ui->tableWidgetMasternodesDIP3->setContextMenuPolicy(Qt::CustomContextMenu);
ui->filterLineEditDIP3->setPlaceholderText(tr("Filter by any property (e.g. address or protx hash)"));
ui->checkBoxMyMasternodesOnly->setEnabled(false);
QAction* copyProTxHashAction = new QAction(tr("Copy ProTx Hash"), this);
QAction* copyCollateralOutpointAction = new QAction(tr("Copy Collateral Outpoint"), this);
@ -126,6 +127,7 @@ void MasternodeList::setClientModel(ClientModel* model)
void MasternodeList::setWalletModel(WalletModel* model)
{
this->walletModel = model;
ui->checkBoxMyMasternodesOnly->setEnabled(model != nullptr);
}
void MasternodeList::showContextMenuDIP3(const QPoint& point)

View File

@ -6,6 +6,7 @@
#include <qt/walletmodel.h>
#include <qt/bitcoingui.h>
#include <qt/masternodelist.h>
#include <qt/walletview.h>
#include <cassert>
@ -28,6 +29,9 @@ WalletFrame::WalletFrame(BitcoinGUI* _gui) :
QLabel *noWallet = new QLabel(tr("No wallet has been loaded."));
noWallet->setAlignment(Qt::AlignCenter);
walletStack->addWidget(noWallet);
masternodeListPage = new MasternodeList();
walletStack->addWidget(masternodeListPage);
}
WalletFrame::~WalletFrame()
@ -38,6 +42,8 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
masternodeListPage->setClientModel(_clientModel);
for (auto i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) {
i.value()->setClientModel(_clientModel);
}
@ -144,6 +150,12 @@ void WalletFrame::gotoHistoryPage()
void WalletFrame::gotoMasternodePage()
{
QMap<WalletModel*, WalletView*>::const_iterator i;
if (mapWalletViews.empty()) {
walletStack->setCurrentWidget(masternodeListPage);
return;
}
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
i.value()->gotoMasternodePage();
}

View File

@ -13,6 +13,7 @@ class ClientModel;
class SendCoinsRecipient;
class WalletModel;
class WalletView;
class MasternodeList;
QT_BEGIN_NAMESPACE
class QStackedWidget;
@ -53,6 +54,7 @@ private:
BitcoinGUI *gui;
ClientModel *clientModel;
QMap<WalletModel*, WalletView*> mapWalletViews;
MasternodeList* masternodeListPage;
bool bOutOfSync;