6 #include "ui_governancewidget.h"
15 #include <QDesktopServices>
16 #include <QGraphicsDropShadowEffect>
20 void initComboView(
PWidget* parent, QComboBox* comboBox,
const QString& filterHint,
const QList<QString>& values)
22 auto* modelFilter =
new QStandardItemModel(parent);
24 for (
int i = 0; i < values.size(); ++i) {
25 auto item =
new QStandardItem(QString(filterHint+
": %1").arg(values.value(i)));
27 modelFilter->appendRow(item);
30 comboBox->setModel(modelFilter);
31 comboBox->setItemDelegate(delegateFilter);
32 comboBox->setCurrentIndex(0);
37 ui(new
Ui::governancewidget)
40 this->setStyleSheet(parent->styleSheet());
43 ui->left->setContentsMargins(0,20,0,0);
45 ui->right->setContentsMargins(20,10,20,20);
49 ui->labelTitle->setText(tr(
"Governance"));
51 ui->labelSubtitle1->setText(tr(
"View, follow, vote and submit network budget proposals.\nBe part of the DAO."));
58 font.setPointSize(14);
62 lineEdit->setFont(font);
63 lineEdit->setAlignment(Qt::AlignRight);
65 QList<QString> values{tr(
"Date"), tr(
"Amount"), tr(
"Name")};
67 ui->comboBoxSort->setVisible(
false);
71 lineEditFilter->setFont(font);
72 initComboBox(
ui->comboBoxFilter, lineEditFilter,
"btn-filter",
false);
73 QList<QString> valuesFilter{tr(
"All"), tr(
"Passing"), tr(
"Not Passing"), tr(
"Waiting")};
75 connect(
ui->comboBoxFilter,
static_cast<void (QComboBox::*)(
const QString&)
>(&QComboBox::currentTextChanged),
89 ui->layoutWarning->setVisible(
true);
90 ui->lblWarning->setText(tr(
"Please wait until the node is fully synced to see the correct information"));
95 ui->btnCreateProposal->setTitleClassAndText(
"btn-title-grey",
"Create Proposal");
96 ui->btnCreateProposal->setSubTitleClassAndText(
"text-subtitle", tr(
"Prepare and submit a new proposal."));
98 ui->emptyContainer->setVisible(
false);
108 int filterByType =
ui->comboBoxFilter->currentIndex();
109 switch (filterByType) {
117 statusFilter = ProposalInfo::Status::WAITING_FOR_APPROVAL;
129 inform(tr(
"Please wait until the node is fully synced"));
133 if (proposalInfo.
status == ProposalInfo::Status::WAITING_FOR_APPROVAL) {
134 inform(tr(
"Cannot vote for the proposal yet, wait until it's confirmed by the network"));
143 inform(tr(
"Vote emitted successfully!"));
145 dialog->deleteLater();
153 inform(tr(
"Please wait until the node is fully synced"));
163 if (nextSuperblock - acceptedRange < chainHeight) {
164 inform(tr(
"Cannot create proposal, superblock is too close. Need to wait %1 blocks").arg(nextSuperblock - chainHeight));
169 if (!ptrUnlockedContext->isValid()) {
170 inform(tr(
"Cannot create proposal, wallet locked"));
176 inform(tr(
"Cannot create proposal, need to have at least %1 to pay for the proposal fee").arg(
186 inform(tr(
"Proposal transaction fee broadcasted!"));
188 dialog->deleteLater();
208 QRect rect = card->geometry();
209 QPoint pos = rect.topRight();
210 pos.setX(pos.x() - 22);
211 pos.setY(pos.y() + (
isSync ? 100 : 140) -
ui->scrollArea->verticalScrollBar()->value());
220 inform(tr(
"Proposal URL copied to clipboard"));
226 if (
ask(tr(
"Open Proposal URL"),
227 tr(
"The following URL will be opened in the default browser") +
"\n\n" +
229 tr(
"Are you sure?\n(Always verify the URL validity before opening it)\n"))) {
231 inform(tr(
"Failed to open proposal URL"));
242 dialog->deleteLater();
254 int remainingDays = remainingBlocks / 1440;
255 QString text = remainingDays == 0 ? tr(
"Next superblock today!\n%2 blocks to go.").arg(remainingBlocks) :
256 tr(
"Next superblock in %1 days.\n%2 blocks to go.").arg(remainingDays).arg(remainingBlocks);
257 ui->labelNextSuperblock->setText(text);
301 if (!isVisible())
return;
319 static void setCardShadow(QWidget* edit)
321 QGraphicsDropShadowEffect* shadowEffect =
new QGraphicsDropShadowEffect();
322 shadowEffect->setColor(QColor(77, 77, 77, 30));
323 shadowEffect->setXOffset(0);
324 shadowEffect->setYOffset(4);
325 shadowEffect->setBlurRadius(6);
326 edit->setGraphicsEffect(shadowEffect);
335 setCardShadow(propCard);
341 if (
ui->emptyContainer->isVisible() != show) {
342 ui->emptyContainer->setVisible(show);
343 ui->mainContainer->setVisible(!show);
361 ui->scrollArea->setWidgetResizable(
true);
372 card->setNeedsUpdate(
true);
378 for (
const auto& prop : props) {
379 QLayoutItem* item =
gridLayout->itemAtPosition(row, column);
386 cards.emplace_back(card);
387 gridLayout->addWidget(card, row, column, 1, 1);
389 card->setProposal(prop);
398 auto it =
cards.begin();
399 while (it !=
cards.end()) {
406 it =
cards.erase(it);
414 int widgetWidth =
ui->left->width();
415 if (widgetWidth < 785) {
417 }
else if (widgetWidth < 1100){
428 ui->layoutWarning->setVisible(!
isSync);
429 if (!isVisible())
return;
void startMasternodesTimer()
void numBlocksChanged(int count)
void stopMasternodesTimer()
int getLastBlockProcessedHeight() const
bool inInitialBlockDownload() const
Return true if core is doing initial block download.
void setValues(QList< QString > _values)
int getNextSuperblockHeight() const
CAmount getBudgetAvailableAmount() const
CAmount getProposalFeeAmount() const
CAmount getBudgetAllocatedAmount() const
void setWalletModel(WalletModel *_walletModel)
std::list< ProposalInfo > getProposals(const ProposalInfo::Status *filterByStatus=nullptr, bool filterFinished=true)
void setNeedsUpdate(bool _update)
void inform(const QString &text)
void voteClicked(const ProposalInfo &proposalInfo)
ProposalInfo getProposal()
void onMenuClicked(ProposalCard *card)
bool isUpdateNeeded() const
void setProposal(const ProposalInfo &info)
void setProposal(const ProposalInfo &prop)
bool isTestNetwork() const
interfaces::WalletBalances GetWalletBalances()
UnlockContext requestUnlock()
bool isRegTestNetwork() const
QString formatBalance(CAmount amount, int nDisplayUnit, bool isZpiv)
void setClipboard(const QString &str)
void initComboBox(QComboBox *combo, QLineEdit *lineEdit, QString cssClass, bool setView)
bool openDialogWithOpaqueBackgroundY(QDialog *widget, PIVXGUI *gui, double posX, int posY, bool hideOpaqueBackground)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
Status status
Proposal state.