6 #include "ui_createproposaldialog.h"
16 QSize BUTTON_SIZE = QSize(22, 22);
18 btn->setMinimumSize(BUTTON_SIZE);
19 btn->setMaximumSize(BUTTON_SIZE);
23 btn->setVisible(
false);
30 walletModel(_walletModel),
31 icConfirm1(new QPushButton(this)),
32 icConfirm2(new QPushButton(this)),
33 icConfirm3(new QPushButton(this))
36 this->setStyleSheet(parent->styleSheet());
39 ui->frame->setContentsMargins(10,10,10,10);
60 ui->btnGenAddr->setVisible(
false);
61 ui->btnGenAddr->setText(tr(
"GENERATE ADDRESS"));
62 ui->btnNext->setText(tr(
"NEXT"));
64 ui->btnBack->setVisible(
false);
65 ui->btnBack->setText(tr(
"BACK"));
68 connect(
ui->pushButtonSkip, &QPushButton::clicked,
this, &CreateProposalDialog::close);
74 void setEditBoxStyle(QLabel* label, QLineEdit* lineEdit,
const QString& placeholderText)
77 lineEdit->setPlaceholderText(placeholderText);
79 lineEdit->setAttribute(Qt::WA_MacShowFocusRect,
false);
88 setEditBoxStyle(
ui->labelURL,
ui->lineEditURL,
"e.g https://forum.pivx/proposals/best_proposal_ever");
102 actAddrList =
ui->lineEditAddress->addAction(QIcon(
"://ic-contact-arrow-down"), QLineEdit::TrailingPosition);
106 ui->lineEditMonths->setAttribute(Qt::WA_MacShowFocusRect,
false);
107 connect(
ui->lineEditMonths,
static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
109 connect(
ui->lineEditMonths->findChild<QLineEdit*>(), &QLineEdit::cursorPositionChanged,
119 ui->lineEditMonths->findChild<QLineEdit*>()->deselect();
120 ui->lineEditMonths->clearFocus();
126 ui->stackedWidget->setCurrentIndex(
pos);
128 ui->labelResultAmountTitle,
129 ui->labelResultAddressTitle,
130 ui->labelResultMonthsTitle,
131 ui->labelResultUrlTitle},
135 ui->labelResultAmount,
136 ui->labelResultAddress,
137 ui->labelResultMonths,
138 ui->labelResultUrl},
"text-body1-dialog");
154 if (newText.isEmpty()) {
158 auto amount = GUIUtil::parseValue(newText);
160 ui->lineEditAmount->setText(newText.left(newText.size() - 1));
168 if (!str.isEmpty()) {
169 QString trimmedStr = str.trimmed();
170 bool isShielded =
false;
181 QString propName =
ui->lineEditPropName->text();
182 if (propName.isEmpty()) {
184 inform(tr(
"Proposal name cannot be empty"));
190 inform(QString::fromStdString(res.getError()));
197 inform(tr(
"Proposal name cannot contain non UTF-8 characters"));
202 if (!res)
inform(QString::fromStdString(res.getError()));
209 auto amount = GUIUtil::parseValue(
ui->lineEditAmount->text());
211 inform(tr(
"Invalid amount"));
216 inform(QString::fromStdString(opRes.getError()));
223 inform(QString::fromStdString(opRes.getError()));
228 inform(tr(
"Invalid payment address"));
237 ui->labelResultName->setText(
ui->lineEditPropName->text());
238 ui->labelResultUrl->setText(
ui->lineEditURL->text());
240 ui->labelResultMonths->setText(QString::number(
ui->lineEditMonths->value()));
241 ui->labelResultAddress->setText(
ui->lineEditAddress->text());
242 ui->labelResultUrl->setText(
ui->lineEditURL->text());
247 int months =
ui->lineEditMonths->value();
248 CAmount amount = GUIUtil::parseValue(
ui->lineEditAmount->text());
250 ui->lineEditPropName->text().toStdString(),
251 ui->lineEditURL->text().toStdString(),
254 ui->lineEditAddress->text().toStdString()
257 inform(QString::fromStdString(opRes.getError()));
265 int nextPos =
pos + 1;
269 ui->stackedWidget->setCurrentIndex(nextPos);
270 ui->pushNumber2->setChecked(
true);
271 ui->pushName3->setChecked(
false);
272 ui->pushName2->setChecked(
true);
273 ui->pushName1->setChecked(
true);
275 ui->btnBack->setVisible(
true);
276 ui->btnGenAddr->setVisible(
true);
282 ui->stackedWidget->setCurrentIndex(nextPos);
283 ui->pushNumber3->setChecked(
true);
284 ui->pushName3->setChecked(
true);
285 ui->pushName2->setChecked(
true);
286 ui->pushName1->setChecked(
true);
288 ui->btnNext->setText(tr(
"Send"));
300 if (
pos == 0)
return;
304 ui->stackedWidget->setCurrentIndex(
pos);
305 ui->pushNumber1->setChecked(
true);
306 ui->pushNumber3->setChecked(
false);
307 ui->pushNumber2->setChecked(
false);
308 ui->pushName3->setChecked(
false);
309 ui->pushName2->setChecked(
false);
310 ui->pushName1->setChecked(
true);
312 ui->btnBack->setVisible(
false);
313 ui->btnGenAddr->setVisible(
false);
317 ui->stackedWidget->setCurrentIndex(
pos);
318 ui->pushNumber2->setChecked(
true);
319 ui->pushNumber3->setChecked(
false);
320 ui->pushName3->setChecked(
false);
321 ui->pushName2->setChecked(
true);
322 ui->pushName1->setChecked(
true);
324 ui->btnNext->setText(tr(
"Next"));
335 inform(tr(
"No contacts available, you can go to the contacts screen and add some there!"));
339 int rowHeight =
ui->lineEditAddress->height();
340 int height = 70 * 2 + 1;
341 int width =
ui->lineEditAddress->width();
350 dynamic_cast<PIVXGUI*
>(parent()),
355 ui->lineEditAddress->setText(address);
369 QPoint position =
ui->containerPage2->rect().bottomLeft();
370 position.setY(position.y() + rowHeight * 2 - 20);
371 position.setX(position.x() + 74);
378 std::string addrLabel =
ui->lineEditPropName->text().toStdString();
380 QString newAddr = QString::fromStdString(addr.
getObjResult()->ToString());
381 ui->lineEditAddress->setText(newAddr);
386 if (e->type() == QEvent::KeyPress) {
387 QKeyEvent* ke =
static_cast<QKeyEvent*
>(e);
388 if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return)
onNextClicked();
389 if (ke->key() == Qt::Key_Escape) reject();
397 if (
ui->lineEditPropName)
ui->lineEditPropName->setFocus();
400 if (
ui->lineEditAddress)
ui->lineEditAddress->setFocus();
403 if (
ui->btnNext)
ui->btnNext->setFocus();
int64_t CAmount
Amount in PIV (Can be negative)
static const QString Send
Specifies send address.
static const QString Receive
Specifies receive address.
const Optional< T > & getObjResult() const
void showEvent(QShowEvent *e) override
Ui::CreateProposalDialog * ui
void propUrlChanged(const QString &newText)
void onGenAddressClicked()
void monthsEditDeselect(int i)
void propAmountChanged(const QString &newText)
bool propaddressChanged(const QString &newText)
WalletModel * walletModel
GovernanceModel * govModel
void propNameChanged(const QString &newText)
CreateProposalDialog(PIVXGUI *parent, GovernanceModel *_govModel, WalletModel *_walletModel)
void keyPressEvent(QKeyEvent *e) override
void inform(const QString &text)
~CreateProposalDialog() override
ContactsDropdown * menuContacts
OperationResult validatePropPaymentCount(int paymentCount) const
OperationResult validatePropURL(const QString &url) const
OperationResult validatePropName(const QString &name) const
OperationResult validatePropAmount(CAmount amount) const
OperationResult createProposal(const std::string &strProposalName, const std::string &strURL, int nPaymentCount, CAmount nAmount, const std::string &strPaymentAddr)
CAmount getMaxAvailableBudgetAmount() const
void setText(const QString &text)
Interface to PIVX wallet from Qt view code.
bool validateAddress(const QString &address)
CallResult< Destination > getNewAddress(const std::string &label="") const
AddressTableModel * getAddressTableModel()
void setEditBoxStyle(QLabel *label, QLineEdit *lineEdit, const QString &placeholderText)
void initPageIndexBtn(QPushButton *btn)
void setupAmountWidget(QLineEdit *widget, QWidget *parent)
QString formatBalance(CAmount amount, int nDisplayUnit, bool isZpiv)
void setShadow(QWidget *edit)
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
bool openDialog(QDialog *widget, QWidget *gui)
void setCssEditLine(QLineEdit *edit, bool isValid, bool forceUpdate)
bool IsValidUTF8(const std::string &str)
Checks for valid 4-byte UTF-8 encoding in a string.