Skip to content

Commit 6825fab

Browse files
committed
[GUI] Master nodes wizard input validations + code cleanup.
1 parent 639d14d commit 6825fab

File tree

3 files changed

+46
-28
lines changed

3 files changed

+46
-28
lines changed

src/qt/pivx/dashboardwidget.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,16 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :
117117

118118
ui->labelEmpty->setText(tr("No transactions yet"));
119119
setCssProperty(ui->labelEmpty, "text-empty");
120-
121120
setCssProperty(ui->chartContainer, "container-chart");
122-
123121
setCssProperty(ui->pushImgEmptyChart, "img-empty-staking-on");
124122

125123
ui->btnHowTo->setText(tr("How to get PIV or zPIV"));
126124
setCssBtnSecondary(ui->btnHowTo);
127125

128-
ui->labelEmptyChart->setText(tr("Staking off"));
126+
ui->labelEmptyChart->setText(tr("You have no staking rewards"));
129127
setCssProperty(ui->labelEmptyChart, "text-empty");
130128

131-
ui->labelMessageEmpty->setText(tr("You can activate and deactivate the Staking mode in the status bar at the top right of the wallet"));
129+
ui->labelMessageEmpty->setText(tr("You can verify the staking activity in the status bar at the top right of the wallet.\nIt will start alone as soon as the wallet has some balance."));
132130
setCssSubtitleScreen(ui->labelMessageEmpty);
133131

134132
// Chart State

src/qt/pivx/forms/masternodewizarddialog.ui

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@
842842
</layout>
843843
</widget>
844844
<widget class="QWidget" name="page_4">
845-
<layout class="QVBoxLayout" name="verticalLayout_10" stretch="0,0,0,0,0,0,0,0,0,0">
845+
<layout class="QVBoxLayout" name="verticalLayout_10" stretch="0,0,0,0,0,0,0,0,0,0,0">
846846
<property name="spacing">
847847
<number>6</number>
848848
</property>
@@ -877,6 +877,19 @@
877877
</property>
878878
</widget>
879879
</item>
880+
<item alignment="Qt::AlignHCenter">
881+
<widget class="QLabel" name="labelSubtitleAddressIp">
882+
<property name="text">
883+
<string>Address of the node that must always be online running the actual master node.</string>
884+
</property>
885+
<property name="alignment">
886+
<set>Qt::AlignCenter</set>
887+
</property>
888+
<property name="wordWrap">
889+
<bool>true</bool>
890+
</property>
891+
</widget>
892+
</item>
880893
<item>
881894
<spacer name="verticalSpacer_2">
882895
<property name="orientation">
@@ -888,7 +901,7 @@
888901
<property name="sizeHint" stdset="0">
889902
<size>
890903
<width>20</width>
891-
<height>40</height>
904+
<height>20</height>
892905
</size>
893906
</property>
894907
</spacer>
@@ -933,7 +946,7 @@
933946
<property name="sizeHint" stdset="0">
934947
<size>
935948
<width>20</width>
936-
<height>40</height>
949+
<height>30</height>
937950
</size>
938951
</property>
939952
</spacer>

src/qt/pivx/masternodewizarddialog.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "qt/pivx/qtutils.h"
44
#include "optionsmodel.h"
55
#include <QFile>
6+
#include <QIntValidator>
67

78
MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *parent) :
89
QDialog(parent),
@@ -15,7 +16,7 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
1516
ui->setupUi(this);
1617

1718
this->setStyleSheet(parent->styleSheet());
18-
ui->frame->setProperty("cssClass", "container-dialog");
19+
setCssProperty(ui->frame, "container-dialog");
1920
ui->frame->setContentsMargins(10,10,10,10);
2021

2122
setCssProperty({ui->labelLine1, ui->labelLine3}, "line-purple");
@@ -31,27 +32,29 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
3132
ui->pushName4->setEnabled(false);
3233

3334
// Frame 1
34-
ui->labelTitle1->setProperty("cssClass", "text-title-dialog");
35-
ui->labelMessage1a->setProperty("cssClass", "text-main-grey");
36-
ui->labelMessage1b->setProperty("cssClass", "text-main-purple");
35+
setCssProperty(ui->labelTitle1, "text-title-dialog");
36+
setCssProperty(ui->labelMessage1a, "text-main-grey");
37+
setCssProperty(ui->labelMessage1b, "text-main-purple");
3738

3839
// Frame 3
39-
ui->labelTitle3->setProperty("cssClass", "text-title-dialog");
40-
ui->labelMessage3->setProperty("cssClass", "text-main-grey");
40+
setCssProperty(ui->labelTitle3, "text-title-dialog");
41+
setCssProperty(ui->labelMessage3, "text-main-grey");
4142

4243
ui->lineEditName->setPlaceholderText(tr("e.g user_masternode"));
4344
initCssEditLine(ui->lineEditName);
4445

4546
// Frame 4
46-
ui->labelTitle4->setProperty("cssClass", "text-title-dialog");
47-
ui->labelSubtitleIp->setProperty("cssClass", "text-title");
48-
ui->labelSubtitlePort->setProperty("cssClass", "text-title");
47+
setCssProperty(ui->labelTitle4, "text-title-dialog");
48+
setCssProperty(ui->labelSubtitleIp, "text-title");
49+
setCssProperty(ui->labelSubtitlePort, "text-title");
50+
setCssSubtitleScreen(ui->labelSubtitleAddressIp);
4951

5052
ui->lineEditIpAddress->setPlaceholderText("e.g 18.255.255.255");
5153
ui->lineEditPort->setPlaceholderText("e.g 51472");
5254
initCssEditLine(ui->lineEditIpAddress);
5355
initCssEditLine(ui->lineEditPort);
5456
ui->stackedWidget->setCurrentIndex(pos);
57+
ui->lineEditPort->setValidator(new QIntValidator(0, 9999999, ui->lineEditPort));
5558

5659
// Confirm icons
5760
ui->stackedIcon1->addWidget(icConfirm1);
@@ -73,7 +76,7 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
7376
icConfirm3->show();
7477
icConfirm3->raise();
7578
icConfirm3->setVisible(false);
76-
icConfirm4->setProperty("cssClass", "ic-step-confirm");
79+
setCssProperty(icConfirm4, "ic-step-confirm");
7780
icConfirm4->setMinimumSize(BUTTON_SIZE);
7881
icConfirm4->setMaximumSize(BUTTON_SIZE);
7982
icConfirm4->move(posX, posY);
@@ -85,11 +88,11 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
8588
// Connect btns
8689
setCssBtnPrimary(ui->btnNext);
8790
ui->btnNext->setText(tr("NEXT"));
88-
ui->btnBack->setProperty("cssClass" , "btn-dialog-cancel");
91+
setCssProperty(ui->btnBack , "btn-dialog-cancel");
8992
ui->btnBack->setVisible(false);
9093
ui->btnBack->setText(tr("BACK"));
9194

92-
ui->pushButtonSkip->setProperty("cssClass", "ic-close");
95+
setCssProperty(ui->pushButtonSkip, "ic-close");
9396

9497
connect(ui->pushButtonSkip, SIGNAL(clicked()), this, SLOT(close()));
9598
connect(ui->btnNext, SIGNAL(clicked()), this, SLOT(onNextClicked()));
@@ -100,32 +103,38 @@ void MasterNodeWizardDialog::onNextClicked(){
100103
switch(pos){
101104
case 0:{
102105
ui->stackedWidget->setCurrentIndex(1);
103-
104106
ui->pushName4->setChecked(false);
105107
ui->pushName3->setChecked(true);
106108
ui->pushName1->setChecked(true);
107-
108109
icConfirm1->setVisible(true);
109-
110110
ui->pushNumber3->setChecked(true);
111111

112112
ui->btnBack->setVisible(true);
113113
break;
114114
}
115115
case 1:{
116-
ui->stackedWidget->setCurrentIndex(2);
117116

117+
// No empty names accepted.
118+
if (ui->lineEditName->text().isEmpty()) {
119+
return;
120+
}
121+
122+
ui->stackedWidget->setCurrentIndex(2);
118123
ui->pushName4->setChecked(false);
119124
ui->pushName3->setChecked(true);
120125
ui->pushName1->setChecked(true);
121-
122126
icConfirm3->setVisible(true);
123127
ui->pushNumber4->setChecked(true);
124-
125128
ui->btnBack->setVisible(true);
126129
break;
127130
}
128131
case 2:{
132+
133+
// No empty address accepted
134+
if (ui->lineEditIpAddress->text().isEmpty()) {
135+
return;
136+
}
137+
129138
icConfirm4->setVisible(true);
130139
ui->btnBack->setVisible(true);
131140
ui->btnBack->setVisible(true);
@@ -318,13 +327,10 @@ void MasterNodeWizardDialog::onBackClicked(){
318327
}
319328
case 1:{
320329
ui->stackedWidget->setCurrentIndex(1);
321-
322330
ui->pushNumber4->setChecked(false);
323331
ui->pushNumber3->setChecked(true);
324-
325332
ui->pushName4->setChecked(false);
326333
ui->pushName3->setChecked(true);
327-
328334
icConfirm3->setVisible(false);
329335

330336
break;
@@ -405,6 +411,7 @@ void MasterNodeWizardDialog::inform(QString text){
405411
snackBar->setText(text);
406412
snackBar->resize(this->width(), snackBar->height());
407413
openDialog(snackBar, this);
414+
snackBar->deleteLater();
408415
}
409416

410417
MasterNodeWizardDialog::~MasterNodeWizardDialog()

0 commit comments

Comments
 (0)