Skip to content

Commit

Permalink
[GUI] Master nodes wizard input validations + code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Sep 6, 2019
1 parent 639d14d commit 6825fab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 28 deletions.
6 changes: 2 additions & 4 deletions src/qt/pivx/dashboardwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,16 @@ DashboardWidget::DashboardWidget(PIVXGUI* parent) :

ui->labelEmpty->setText(tr("No transactions yet"));
setCssProperty(ui->labelEmpty, "text-empty");

setCssProperty(ui->chartContainer, "container-chart");

setCssProperty(ui->pushImgEmptyChart, "img-empty-staking-on");

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

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

ui->labelMessageEmpty->setText(tr("You can activate and deactivate the Staking mode in the status bar at the top right of the wallet"));
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."));
setCssSubtitleScreen(ui->labelMessageEmpty);

// Chart State
Expand Down
19 changes: 16 additions & 3 deletions src/qt/pivx/forms/masternodewizarddialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QVBoxLayout" name="verticalLayout_10" stretch="0,0,0,0,0,0,0,0,0,0">
<layout class="QVBoxLayout" name="verticalLayout_10" stretch="0,0,0,0,0,0,0,0,0,0,0">
<property name="spacing">
<number>6</number>
</property>
Expand Down Expand Up @@ -877,6 +877,19 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="labelSubtitleAddressIp">
<property name="text">
<string>Address of the node that must always be online running the actual master node.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand All @@ -888,7 +901,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>20</height>
</size>
</property>
</spacer>
Expand Down Expand Up @@ -933,7 +946,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<height>30</height>
</size>
</property>
</spacer>
Expand Down
49 changes: 28 additions & 21 deletions src/qt/pivx/masternodewizarddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "qt/pivx/qtutils.h"
#include "optionsmodel.h"
#include <QFile>
#include <QIntValidator>

MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *parent) :
QDialog(parent),
Expand All @@ -15,7 +16,7 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
ui->setupUi(this);

this->setStyleSheet(parent->styleSheet());
ui->frame->setProperty("cssClass", "container-dialog");
setCssProperty(ui->frame, "container-dialog");
ui->frame->setContentsMargins(10,10,10,10);

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

// Frame 1
ui->labelTitle1->setProperty("cssClass", "text-title-dialog");
ui->labelMessage1a->setProperty("cssClass", "text-main-grey");
ui->labelMessage1b->setProperty("cssClass", "text-main-purple");
setCssProperty(ui->labelTitle1, "text-title-dialog");
setCssProperty(ui->labelMessage1a, "text-main-grey");
setCssProperty(ui->labelMessage1b, "text-main-purple");

// Frame 3
ui->labelTitle3->setProperty("cssClass", "text-title-dialog");
ui->labelMessage3->setProperty("cssClass", "text-main-grey");
setCssProperty(ui->labelTitle3, "text-title-dialog");
setCssProperty(ui->labelMessage3, "text-main-grey");

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

// Frame 4
ui->labelTitle4->setProperty("cssClass", "text-title-dialog");
ui->labelSubtitleIp->setProperty("cssClass", "text-title");
ui->labelSubtitlePort->setProperty("cssClass", "text-title");
setCssProperty(ui->labelTitle4, "text-title-dialog");
setCssProperty(ui->labelSubtitleIp, "text-title");
setCssProperty(ui->labelSubtitlePort, "text-title");
setCssSubtitleScreen(ui->labelSubtitleAddressIp);

ui->lineEditIpAddress->setPlaceholderText("e.g 18.255.255.255");
ui->lineEditPort->setPlaceholderText("e.g 51472");
initCssEditLine(ui->lineEditIpAddress);
initCssEditLine(ui->lineEditPort);
ui->stackedWidget->setCurrentIndex(pos);
ui->lineEditPort->setValidator(new QIntValidator(0, 9999999, ui->lineEditPort));

// Confirm icons
ui->stackedIcon1->addWidget(icConfirm1);
Expand All @@ -73,7 +76,7 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
icConfirm3->show();
icConfirm3->raise();
icConfirm3->setVisible(false);
icConfirm4->setProperty("cssClass", "ic-step-confirm");
setCssProperty(icConfirm4, "ic-step-confirm");
icConfirm4->setMinimumSize(BUTTON_SIZE);
icConfirm4->setMaximumSize(BUTTON_SIZE);
icConfirm4->move(posX, posY);
Expand All @@ -85,11 +88,11 @@ MasterNodeWizardDialog::MasterNodeWizardDialog(WalletModel *model, QWidget *pare
// Connect btns
setCssBtnPrimary(ui->btnNext);
ui->btnNext->setText(tr("NEXT"));
ui->btnBack->setProperty("cssClass" , "btn-dialog-cancel");
setCssProperty(ui->btnBack , "btn-dialog-cancel");
ui->btnBack->setVisible(false);
ui->btnBack->setText(tr("BACK"));

ui->pushButtonSkip->setProperty("cssClass", "ic-close");
setCssProperty(ui->pushButtonSkip, "ic-close");

connect(ui->pushButtonSkip, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->btnNext, SIGNAL(clicked()), this, SLOT(onNextClicked()));
Expand All @@ -100,32 +103,38 @@ void MasterNodeWizardDialog::onNextClicked(){
switch(pos){
case 0:{
ui->stackedWidget->setCurrentIndex(1);

ui->pushName4->setChecked(false);
ui->pushName3->setChecked(true);
ui->pushName1->setChecked(true);

icConfirm1->setVisible(true);

ui->pushNumber3->setChecked(true);

ui->btnBack->setVisible(true);
break;
}
case 1:{
ui->stackedWidget->setCurrentIndex(2);

// No empty names accepted.
if (ui->lineEditName->text().isEmpty()) {
return;
}

ui->stackedWidget->setCurrentIndex(2);
ui->pushName4->setChecked(false);
ui->pushName3->setChecked(true);
ui->pushName1->setChecked(true);

icConfirm3->setVisible(true);
ui->pushNumber4->setChecked(true);

ui->btnBack->setVisible(true);
break;
}
case 2:{

// No empty address accepted
if (ui->lineEditIpAddress->text().isEmpty()) {
return;
}

icConfirm4->setVisible(true);
ui->btnBack->setVisible(true);
ui->btnBack->setVisible(true);
Expand Down Expand Up @@ -318,13 +327,10 @@ void MasterNodeWizardDialog::onBackClicked(){
}
case 1:{
ui->stackedWidget->setCurrentIndex(1);

ui->pushNumber4->setChecked(false);
ui->pushNumber3->setChecked(true);

ui->pushName4->setChecked(false);
ui->pushName3->setChecked(true);

icConfirm3->setVisible(false);

break;
Expand Down Expand Up @@ -405,6 +411,7 @@ void MasterNodeWizardDialog::inform(QString text){
snackBar->setText(text);
snackBar->resize(this->width(), snackBar->height());
openDialog(snackBar, this);
snackBar->deleteLater();
}

MasterNodeWizardDialog::~MasterNodeWizardDialog()
Expand Down

0 comments on commit 6825fab

Please sign in to comment.