diff --git a/src/qt/pivx/forms/topbar.ui b/src/qt/pivx/forms/topbar.ui index 23d90556bf21d..2c931da3d813f 100644 --- a/src/qt/pivx/forms/topbar.ui +++ b/src/qt/pivx/forms/topbar.ui @@ -1,837 +1,800 @@ - TopBar - - - - 0 - 0 - 734 - 200 - - - - - 0 - 200 - - - - - 16777215 - 200 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 65 - - - - - 0 - - - 14 - - - 0 - - - 14 - - - 0 - - - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 36 - - - - padding:0px;margin:0px; - - - 480.0685 SAPP - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 1 - 30 - - - - - 1 - 30 - - - - + TopBar + + + + 0 + 0 + 929 + 200 + + + + + 0 + 200 + + + + + 16777215 + 200 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 65 + + + + + 0 + + + 14 + + + 0 + + + 14 + + + 0 + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 36 + + + + padding:0px;margin:0px; + + + 480.0685 SAPP + + + + + + + + 1 + 30 + + + + + 1 + 30 + + + + background-color:white; padding:0px; border:none; - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 36 - - - - 1,000 zSAPP - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 12 - - - 0 - - - - - - 0 - 36 - - - - - 16777215 - 36 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 36 - 36 - - - - - 16777215 - 36 - - - - - - - - - - - - 36 - 36 - - - - - - - - - 36 - 36 - - - - - - - - - - 36 - 36 - - - - - - - - - 36 - 36 - - - - - - - - - 36 - 36 - - - - - - - - - 36 - 36 - - - - - - - - - 36 - 36 - - - - - - - - - 0 - 0 - - - - - 36 - 0 - - - - - - - - - 36 - 36 - - - - - - - - - - - - - - 0 - 135 - - - - - 10 - - - 0 - - - 10 - - - 10 - - - - - 9 - - - - - 0 - - - 0 - - - 30 - - - - - 0 - - - - - - - Balance - - - - - - - 480.0685 SAPP - - - - - - - - - - - 0 - - - - - - - Available - - - - - - - 480.0685 SAPP - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - Pending - - - - - - - 6.943 SAPP - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - Immature - - - - - - - 10 SAPP - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - Locked - - - - - - - 10 SAPP - - - - - - - - - - - - - - 1 - 100 - - - - - 1 - 16777215 - - - - + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 36 + + + + 1,000 zSAPP + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 12 + + + 0 + + + + + + 0 + 36 + + + + + 16777215 + 36 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 36 + 36 + + + + + 16777215 + 36 + + + + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 36 + 36 + + + + + + + + + 0 + 0 + + + + + 36 + 0 + + + + + + + + + 36 + 36 + + + + + + + + + + + + + + 0 + 135 + + + + + 10 + + + 0 + + + 10 + + + 10 + + + + + 9 + + + + + 0 + + + 0 + + + 30 + + + + + 0 + + + + + + + Balance + + + + + + + 480.0685 SAPP + + + + + + + + + + + 0 + + + + + + + Available + + + + + + + 480.0685 SAPP + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + Pending + + + + + + + 6.943 SAPP + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + Immature + + + + + + + 10 SAPP + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + + Locked + + + + + + + 10 SAPP + + + + + + + + + + + + + + 1 + 100 + + + + + 1 + 16777215 + + + + background-color:white; padding:0px; border:none; - - - - - - - - - - - 0 - - - 30 - - - 0 - - - 0 - - - 0 - - - - - - - Available - - - - - - - 1,000 zSAPP - - - - - - - - - 0 - - - - - - - Pending - - - - - - - 60 zSAPP - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - - - Immature - - - - - - - 10 zSAPP - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 90 - 110 - - - - - 90 - 110 - - - - - 0 - - - 5 - - - 10 - - - 5 - - - 0 - - - - - - 70 - 70 - - - - - 16777215 - 70 - - - - Qt::NoFocus - - - - - - - 70 - 70 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 36 - 36 - - - - - 36 - 36 - - - - Qt::NoFocus - - - - - - - - - - - - - - - - - - - - ExpandableButton - QWidget -
qt/pivx/expandablebutton.h
- 1 -
- - PFBorderImage - QFrame -
qt/pivx/pfborderimage.h
- 1 -
-
- - + + + + +
+
+ + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + + + 30 + + + 0 + + + 0 + + + 0 + + + + + + + New Protocol! + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + 0 + + + + + + + Protocol + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + +
+
+ + + + + 0 + 0 + + + + + 90 + 110 + + + + + 90 + 110 + + + + + 0 + + + 5 + + + 10 + + + 5 + + + 0 + + + + + + 70 + 70 + + + + + 16777215 + 70 + + + + Qt::NoFocus + + + + + + + 70 + 70 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + 36 + 36 + + + + + 36 + 36 + + + + Qt::NoFocus + + + + + + + + + +
+
+ + + + + + + + + PFBorderImage + QFrame +
qt/pivx/pfborderimage.h
+ 1 +
+ + ExpandableButton + QWidget +
qt/pivx/expandablebutton.h
+ 1 +
+
+ +
diff --git a/src/qt/pivx/topbar.cpp b/src/qt/pivx/topbar.cpp index cda7bdace713e..6a7707febd778 100644 --- a/src/qt/pivx/topbar.cpp +++ b/src/qt/pivx/topbar.cpp @@ -22,6 +22,8 @@ #include "masternode-sync.h" #include "wallet/wallet.h" +#include "masternode.h" +#include "masternodeman.h" #include @@ -44,7 +46,7 @@ TopBar::TopBar(PIVXGUI* _mainWindow, QWidget *parent) : ui->containerTop->setProperty("cssClass", "container-top"); #endif - std::initializer_list lblTitles = {ui->labelTitle1, ui->labelTitle5, ui->labelTitle6, ui->labelTitleAvailablezPiv, ui->labelTitle3, ui->labelTitle4, ui->labelTitlePendingzPiv, ui->labelTitleImmaturezPiv}; + std::initializer_list lblTitles = {ui->labelTitle1, ui->labelTitle5, ui->labelTitle6, ui->labelTitleCurrentProtocol, ui->labelTitle3, ui->labelTitle4, ui->labelTitleNewProtocol}; setCssProperty(lblTitles, "text-title-topbar"); QFont font; font.setWeight(QFont::Light); @@ -52,9 +54,9 @@ TopBar::TopBar(PIVXGUI* _mainWindow, QWidget *parent) : // Amount information top ui->widgetTopAmount->setVisible(false); - setCssProperty({ui->labelAmountTopPiv, ui->labelAmountTopzPiv}, "amount-small-topbar"); - setCssProperty({ui->labelAvailablezPiv, ui->labelTotalPiv}, "amount-topbar"); - setCssProperty({ui->labelAmountPiv, ui->labelPendingPiv, ui->labelPendingzPiv, ui->labelImmaturePiv, ui->labelImmaturezPiv, ui->labelLockedPiv}, "amount-small-topbar"); + setCssProperty({ui->labelAmountTopPiv, ui->labelAlertNewProtocol}, "amount-small-topbar"); + setCssProperty({ui->labelNewProtocol, ui->labelTotalPiv}, "amount-topbar"); + setCssProperty({ui->labelAmountPiv, ui->labelPendingPiv, ui->labelCurrentProtocol, ui->labelImmaturePiv, ui->labelLockedPiv}, "amount-small-topbar"); // Progress Sync progressBar = new QProgressBar(ui->layoutSync); @@ -595,6 +597,7 @@ void TopBar::loadWalletModel() } connect(walletModel, &WalletModel::balanceChanged, this, &TopBar::updateBalances); + connect(walletModel, &WalletModel::balanceChanged, this, &TopBar::checkNewProtocol); connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &TopBar::updateDisplayUnit); connect(walletModel, &WalletModel::encryptionStatusChanged, this, &TopBar::refreshStatus); // Ask for passphrase if needed @@ -603,6 +606,7 @@ void TopBar::loadWalletModel() updateDisplayUnit(); refreshStatus(); + checkNewProtocol(); onColdStakingClicked(); isInitializing = false; @@ -671,6 +675,54 @@ void TopBar::updateDisplayUnit() } } +void TopBar::checkNewProtocol() +{ + std::string strFilter = ""; + + int nHeight; + { + LOCK(cs_main); + CBlockIndex* pindex = chainActive.Tip(); + if(!pindex) return; + nHeight = pindex->nHeight; + } + std::vector> vMasternodeRanks = mnodeman.GetMasternodeRanks(nHeight); + int newProtocolVersion = 0; + + for (PAIRTYPE(int, CMasternode) & s : vMasternodeRanks) { + std::string strVin = s.second.vin.prevout.ToStringShort(); + std::string strTxHash = s.second.vin.prevout.hash.ToString(); + + CMasternode* mn = mnodeman.Find(s.second.vin); + + if (mn != NULL) { + if (strFilter != "" && strTxHash.find(strFilter) == std::string::npos && + mn->Status().find(strFilter) == std::string::npos && + CBitcoinAddress(mn->pubKeyCollateralAddress.GetID()).ToString().find(strFilter) == std::string::npos) continue; + + if (mn->protocolVersion > PROTOCOL_VERSION) { + newProtocolVersion = mn->protocolVersion; + break; + } + } + } + + QString currentProtocolVersion = QString::number(PROTOCOL_VERSION); + QString latestProtocolVersion = QString::number(newProtocolVersion); + + ui->labelCurrentProtocol->setText(currentProtocolVersion); + + if (newProtocolVersion) { + ui->labelTitleNewProtocol->setText("New Protocol!"); + ui->labelNewProtocol->setText(latestProtocolVersion); + ui->labelAlertNewProtocol->setText("New Protocol! " + latestProtocolVersion); + } else { + ui->labelTitleNewProtocol->setText(""); + ui->labelNewProtocol->setText(""); + ui->labelAlertNewProtocol->setText(""); + } +} + void TopBar::updateBalances(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& zerocoinBalance, const CAmount& unconfirmedZerocoinBalance, const CAmount& immatureZerocoinBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance, @@ -687,9 +739,6 @@ void TopBar::updateBalances(const CAmount& balance, const CAmount& unconfirmedBa // zSAPP Balance CAmount matureZerocoinBalance = zerocoinBalance - unconfirmedZerocoinBalance - immatureZerocoinBalance; - // Set - QString totalzPiv = GUIUtil::formatBalance(matureZerocoinBalance, nDisplayUnit, true); - // SAPP // Top ui->labelAmountTopPiv->setText(GUIUtil::formatBalance(pivAvailableBalance, nDisplayUnit)); @@ -699,22 +748,6 @@ void TopBar::updateBalances(const CAmount& balance, const CAmount& unconfirmedBa ui->labelPendingPiv->setText(GUIUtil::formatBalance(unconfirmedBalance, nDisplayUnit)); ui->labelImmaturePiv->setText(GUIUtil::formatBalance(immatureBalance, nDisplayUnit)); ui->labelLockedPiv->setText(GUIUtil::formatBalance(nLockedBalance, nDisplayUnit)); - - // Update display state and/or values for zSAPP balances as necessary - bool fHaveZerocoins = zerocoinBalance > 0; - - // Set visibility of zSAPP label titles/values - ui->typeSpacerTop->setVisible(fHaveZerocoins); - ui->typeSpacerExpanded->setVisible(fHaveZerocoins); - ui->labelAmountTopzPiv->setVisible(fHaveZerocoins); - ui->zerocoinBalances->setVisible(fHaveZerocoins); - - // Top - ui->labelAmountTopzPiv->setText(totalzPiv); - // Expanded - ui->labelAvailablezPiv->setText(totalzPiv); - ui->labelPendingzPiv->setText(GUIUtil::formatBalance(unconfirmedZerocoinBalance, nDisplayUnit, true)); - ui->labelImmaturezPiv->setText(GUIUtil::formatBalance(immatureZerocoinBalance, nDisplayUnit, true)); } void TopBar::resizeEvent(QResizeEvent *event) diff --git a/src/qt/pivx/topbar.h b/src/qt/pivx/topbar.h index 3d981457fb615..5f3a204b05723 100644 --- a/src/qt/pivx/topbar.h +++ b/src/qt/pivx/topbar.h @@ -79,6 +79,7 @@ private Q_SLOTS: void onColdStakingClicked(); void refreshProgressBarSize(); void expandSync(); + void checkNewProtocol(); private: Ui::TopBar *ui; LockUnlock *lockUnlockWidget = nullptr;