6 #include "ui_votedialog.h"
19 this->setStyleSheet(parent->styleSheet());
27 ui->labelAmount->setAlignment(Qt::AlignCenter);
29 ui->labelTime->setAlignment(Qt::AlignCenter);
31 ui->labelMessage->setAlignment(Qt::AlignCenter);
50 connect(
ui->btnEsc, &QPushButton::clicked,
this, &VoteDialog::close);
51 connect(
ui->btnCancel, &QPushButton::clicked,
this, &VoteDialog::close);
57 proposal = std::make_unique<ProposalInfo>(prop);
58 ui->labelTitleVote->setText(QString::fromStdString(prop.
name));
62 double percentageNo = (totalVotes == 0) ? 0 : (prop.
votesNo / totalVotes) * 100;
63 double percentageYes = (totalVotes == 0) ? 0 : (prop.
votesYes / totalVotes) * 100;
66 checkBoxNo->setText(QString::number(prop.
votesNo) +
" / " + QString::number(percentageNo) +
"% " + tr(
"No"));
67 checkBoxYes->setText(tr(
"Yes") +
" " + QString::number(prop.
votesYes) +
" / " + QString::number(percentageYes) +
"%");
77 if (!isPositive && !isNegative) {
78 inform(tr(
"Select a vote direction"));
83 inform(tr(
"Missing voting masternodes selection"));
88 for (
const auto& vote :
votes) {
101 inform(QString::fromStdString(res.getError()));
138 void VoteDialog::initVoteCheck(QWidget* container, QCheckBox* checkBox, QProgressBar* progressBar,
const QString& text, Qt::LayoutDirection direction,
bool isVoteYes)
140 QGridLayout* gridLayout =
dynamic_cast<QGridLayout*
>(container->layout());
141 progressBar->setMaximum(100);
142 progressBar->setMinimum(0);
143 progressBar->setLayoutDirection(direction);
144 progressBar->setTextVisible(
false);
145 progressBar->setAlignment(Qt::AlignCenter);
146 progressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
147 progressBar->setOrientation(Qt::Horizontal);
148 progressBar->setContentsMargins(0,0,0,0);
150 gridLayout->addWidget(progressBar, 0, 0, 1, 1);
151 progressBar->setAttribute(Qt::WA_LayoutUsesWidgetRect);
153 checkBox->setText(text);
154 checkBox->setLayoutDirection(direction);
156 gridLayout->addWidget(checkBox, 0, 0, 1, 1);
158 gridLayout->setMargin(0);
159 container->setContentsMargins(0,0,0,0);
160 connect(checkBox, &QCheckBox::clicked, [
this, checkBox, progressBar, isVoteYes](){
onCheckBoxClicked(checkBox, progressBar, isVoteYes); });
161 checkBox->setAttribute(Qt::WA_LayoutUsesWidgetRect);
169 text = !
votes.empty() ? tr(
"You have voted with %1 Masternodes for this proposal\nChange votes").arg(
votes.size()) :
170 tr(
"Select Voting Masternodes");
172 text = tr(
"%1 Masternodes selected to vote").arg(
vecSelectedMn.size());
174 ui->btnSelectMasternodes->setText(text);
int getProposalVoteUpdateMinTime() const
OperationResult voteForProposal(const ProposalInfo &prop, bool isVotePositive, const std::vector< std::string > &mnVotingAlias)
std::vector< VoteInfo > getLocalMNsVotesForProposal(const ProposalInfo &propInfo)
std::vector< std::string > getSelectedMnAlias()
void setMnVoters(const std::vector< VoteInfo > &_votes)
void setModel(MNModel *_mnModel, int minVoteUpdateTimeInSecs)
void setText(const QString &text)
std::unique_ptr< ProposalInfo > proposal
void showEvent(QShowEvent *event) override
void onMnSelectionClicked()
GovernanceModel * govModel
void updateMnSelectionNum()
std::vector< VoteInfo > votes
QProgressBar * progressBarYes
QProgressBar * progressBarNo
MnSelectionDialog * mnSelectionDialog
void setProposal(const ProposalInfo &prop)
std::vector< std::string > vecSelectedMn
void initVoteCheck(QWidget *container, QCheckBox *checkBox, QProgressBar *progressBar, const QString &text, Qt::LayoutDirection direction, bool isVoteYes)
void inform(const QString &text)
void onCheckBoxClicked(QCheckBox *checkBox, QProgressBar *progressBar, bool isVoteYes)
VoteDialog(QWidget *parent, GovernanceModel *_govModel, MNModel *_mnModel)
QString formatBalance(CAmount amount, int nDisplayUnit, bool isZpiv)
bool openDialogWithOpaqueBackgroundY(QDialog *widget, PIVXGUI *gui, double posX, int posY, bool hideOpaqueBackground)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
bool openDialog(QDialog *widget, QWidget *gui)
int remainingPayments
Amount of times that the proposal was paid already.
CAmount amount
Amount of PIV paid per month.
int64_t GetAdjustedTime()