Skip to content

Commit fdbffe9

Browse files
committed
[Qt] Add Generate Address to CreateProposal
1 parent e4634a5 commit fdbffe9

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/qt/pivx/createproposaldialog.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ CreateProposalDialog::CreateProposalDialog(PIVXGUI* parent, GovernanceModel* _go
5656
initPageIndexBtn(icConfirm3);
5757

5858
// Connect btns
59-
setCssProperty(ui->btnNext, "btn-primary");
59+
setCssProperty({ui->btnNext, ui->btnGenAddr}, "btn-primary");
60+
ui->btnGenAddr->setVisible(false);
61+
ui->btnGenAddr->setText(tr("GENERATE ADDRESS"));
6062
ui->btnNext->setText(tr("NEXT"));
6163
setCssProperty(ui->btnBack, "btn-dialog-cancel");
6264
ui->btnBack->setVisible(false);
@@ -66,6 +68,7 @@ CreateProposalDialog::CreateProposalDialog(PIVXGUI* parent, GovernanceModel* _go
6668
connect(ui->pushButtonSkip, &QPushButton::clicked, this, &CreateProposalDialog::close);
6769
connect(ui->btnNext, &QPushButton::clicked, this, &CreateProposalDialog::onNextClicked);
6870
connect(ui->btnBack, &QPushButton::clicked, this, &CreateProposalDialog::onBackClicked);
71+
connect(ui->btnGenAddr, &QPushButton::clicked, this, &CreateProposalDialog::onGenAddressClicked);
6972
}
7073

7174
void setEditBoxStyle(QLabel* label, QLineEdit* lineEdit, const QString& placeholderText)
@@ -270,6 +273,7 @@ void CreateProposalDialog::onNextClicked()
270273
ui->pushName1->setChecked(true);
271274
icConfirm1->setVisible(true);
272275
ui->btnBack->setVisible(true);
276+
ui->btnGenAddr->setVisible(true);
273277
break;
274278
}
275279
case 1: {
@@ -306,6 +310,7 @@ void CreateProposalDialog::onBackClicked()
306310
ui->pushName1->setChecked(true);
307311
icConfirm1->setVisible(false);
308312
ui->btnBack->setVisible(false);
313+
ui->btnGenAddr->setVisible(false);
309314
break;
310315
}
311316
case 1: {
@@ -368,6 +373,14 @@ void CreateProposalDialog::onAddrListClicked()
368373
menuContacts->show();
369374
}
370375

376+
void CreateProposalDialog::onGenAddressClicked()
377+
{
378+
std::string addrLabel = ui->lineEditPropName->text().toStdString();
379+
CallResult<Destination> addr = !addrLabel.empty() ? walletModel->getNewAddress(addrLabel) : walletModel->getNewAddress("");
380+
QString newAddr = QString::fromStdString(addr.getObjResult()->ToString());
381+
ui->lineEditAddress->setText(newAddr);
382+
}
383+
371384
void CreateProposalDialog::keyPressEvent(QKeyEvent *e)
372385
{
373386
if (e->type() == QEvent::KeyPress) {

src/qt/pivx/createproposaldialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public Q_SLOTS:
3636
void propAmountChanged(const QString& newText);
3737
bool propaddressChanged(const QString& newText);
3838
void onAddrListClicked();
39+
void onGenAddressClicked();
3940
void monthsEditDeselect(int i);
4041

4142
private:

src/qt/pivx/forms/createproposaldialog.ui

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
</size>
353353
</property>
354354
<property name="currentIndex">
355-
<number>0</number>
355+
<number>1</number>
356356
</property>
357357
<widget class="QWidget" name="pageIcon3">
358358
<property name="minimumSize">
@@ -670,6 +670,9 @@
670670
<height>350</height>
671671
</size>
672672
</property>
673+
<property name="currentIndex">
674+
<number>1</number>
675+
</property>
673676
<widget class="QWidget" name="page_1">
674677
<layout class="QVBoxLayout" name="verticalLayout_7" stretch="1,3,0">
675678
<property name="spacing">
@@ -1270,15 +1273,40 @@
12701273
</widget>
12711274
</item>
12721275
<item>
1273-
<layout class="QHBoxLayout" name="horizontalLayout1" stretch="1,2,2">
1276+
<layout class="QHBoxLayout" name="horizontalLayout1" stretch="0,0,0,2">
1277+
<item>
1278+
<widget class="QPushButton" name="btnGenAddr">
1279+
<property name="minimumSize">
1280+
<size>
1281+
<width>180</width>
1282+
<height>50</height>
1283+
</size>
1284+
</property>
1285+
<property name="maximumSize">
1286+
<size>
1287+
<width>250</width>
1288+
<height>16777215</height>
1289+
</size>
1290+
</property>
1291+
<property name="focusPolicy">
1292+
<enum>Qt::NoFocus</enum>
1293+
</property>
1294+
<property name="text">
1295+
<string notr="true">N/A</string>
1296+
</property>
1297+
</widget>
1298+
</item>
12741299
<item>
12751300
<spacer name="horizontalSpacer">
12761301
<property name="orientation">
12771302
<enum>Qt::Horizontal</enum>
12781303
</property>
1304+
<property name="sizeType">
1305+
<enum>QSizePolicy::Fixed</enum>
1306+
</property>
12791307
<property name="sizeHint" stdset="0">
12801308
<size>
1281-
<width>40</width>
1309+
<width>180</width>
12821310
<height>20</height>
12831311
</size>
12841312
</property>

0 commit comments

Comments
 (0)