Merge #6403: feat(qt): Governance Tab should respect selected units and settings

90923ae7c7 feat(qt): Governance Tab should respect selected units and settings (UdjinM6)

Pull request description:

  ## Issue being fixed or feature implemented
  Governance Tab ignores selected units and settings atm. Let's fix this.

  Display settings:
  <img width="607" alt="Screenshot 2024-11-19 at 00 49 35" src="https://github.com/user-attachments/assets/4ee777b4-8104-4e82-801a-c412573aa505">

  develop:
  <img width="965" alt="Screenshot 2024-11-19 at 00 47 35" src="https://github.com/user-attachments/assets/8aa69db0-c8a7-4e31-b733-e765e7f7f510">
  <img width="956" alt="Screenshot 2024-11-19 at 00 48 02" src="https://github.com/user-attachments/assets/1213fd66-24a2-40b8-bb32-87f3310f0086">

  this PR:

  <img width="956" alt="Screenshot 2024-11-19 at 00 49 04" src="https://github.com/user-attachments/assets/a09f8134-eddd-4e9c-ab86-1b5c4afeb994">
  <img width="958" alt="Screenshot 2024-11-19 at 00 49 17" src="https://github.com/user-attachments/assets/f9c34938-c56f-4198-8613-26f6e8c08c71">

  ## What was done?

  ## How Has This Been Tested?

  ## Breaking Changes

  ## Checklist:
  - [ ] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  PastaPastaPasta:
    ACK 90923ae7c7
  knst:
    utACK 90923ae7c7

Tree-SHA512: 90887821674ff989156718f39ffccda4d30bcf3126627443cb3dab9ce00869d436606eb8a6cd2fc498bd6d8107f6697863bf7df1e41200505c2d7c3081d2b21a
This commit is contained in:
pasta 2024-11-20 11:37:54 -06:00
commit 3c80dfc3f5
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
2 changed files with 23 additions and 2 deletions

View File

@ -12,6 +12,7 @@
#include <netbase.h>
#include <qt/clientmodel.h>
#include <qt/guiutil.h>
#include <qt/optionsmodel.h>
#include <univalue.h>
@ -135,8 +136,10 @@ QVariant ProposalModel::data(const QModelIndex& index, int role) const
return proposal->startDate().date();
case Column::END_DATE:
return proposal->endDate().date();
case Column::PAYMENT_AMOUNT:
return proposal->paymentAmount();
case Column::PAYMENT_AMOUNT: {
return BitcoinUnits::floorWithUnit(m_display_unit, proposal->paymentAmount() * COIN, false,
BitcoinUnits::SeparatorStyle::ALWAYS);
}
case Column::IS_ACTIVE:
return proposal->isActive() ? tr("Yes") : tr("No");
case Column::VOTING_STATUS:
@ -283,6 +286,8 @@ const Proposal* ProposalModel::getProposalAt(const QModelIndex& index) const
return m_data[index.row()];
}
void ProposalModel::setDisplayUnit(int display_unit) { this->m_display_unit = display_unit; }
//
// Governance Tab main widget.
//
@ -340,6 +345,17 @@ void GovernanceList::setClientModel(ClientModel* model)
{
this->clientModel = model;
updateProposalList();
if (model != nullptr) {
connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, this, &GovernanceList::updateDisplayUnit);
}
}
void GovernanceList::updateDisplayUnit()
{
if (this->clientModel) {
proposalModel->setDisplayUnit(this->clientModel->getOptionsModel()->getDisplayUnit());
ui->govTableView->update();
}
}
void GovernanceList::updateProposalList()

View File

@ -7,6 +7,7 @@
#include <governance/object.h>
#include <primitives/transaction.h>
#include <qt/bitcoinunits.h>
#include <sync.h>
#include <util/system.h>
@ -48,6 +49,7 @@ private:
QTimer* timer;
private Q_SLOTS:
void updateDisplayUnit();
void updateProposalList();
void updateProposalCount() const;
void showProposalContextMenu(const QPoint& pos);
@ -92,6 +94,7 @@ class ProposalModel : public QAbstractTableModel
private:
QList<const Proposal*> m_data;
int nAbsVoteReq = 0;
int m_display_unit{BitcoinUnits::DASH};
public:
explicit ProposalModel(QObject* parent = nullptr) :
@ -119,6 +122,8 @@ public:
void setVotingParams(int nAbsVoteReq);
const Proposal* getProposalAt(const QModelIndex& index) const;
void setDisplayUnit(int display_unit);
};
#endif // BITCOIN_QT_GOVERNANCELIST_H