mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-17 15:21:30 +02:00
wizard: fix lookahead validation
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
#include "ui_PageSetSubaddressLookahead.h"
|
||||
#include "WalletWizard.h"
|
||||
|
||||
#include <QIntValidator>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
#include "Icons.h"
|
||||
|
||||
PageSetSubaddressLookahead::PageSetSubaddressLookahead(WizardFields *fields, QWidget *parent)
|
||||
: QWizardPage(parent)
|
||||
@@ -14,11 +16,19 @@ PageSetSubaddressLookahead::PageSetSubaddressLookahead(WizardFields *fields, QWi
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// uint32_t can go up to 4294967294, but this isn't realistic
|
||||
auto indexValidator = new QIntValidator(1, 2147483647, this);
|
||||
auto *indexValidator = new QRegularExpressionValidator{QRegularExpression("[0-9]{0,5}")};
|
||||
|
||||
ui->line_major->setValidator(indexValidator);
|
||||
connect(ui->line_major, &QLineEdit::textChanged, [this]{
|
||||
this->completeChanged();
|
||||
});
|
||||
|
||||
ui->line_minor->setValidator(indexValidator);
|
||||
connect(ui->line_major, &QLineEdit::textChanged, [this]{
|
||||
this->completeChanged();
|
||||
});
|
||||
|
||||
ui->infoFrame->setInfo(icons()->icon("warning"), "Lookahead must be non-zero.");
|
||||
|
||||
this->setTitle("Subaddress Lookahead");
|
||||
}
|
||||
@@ -31,6 +41,7 @@ void PageSetSubaddressLookahead::initializePage() {
|
||||
ui->line_major->setText("50");
|
||||
ui->line_minor->setText("200");
|
||||
}
|
||||
ui->infoFrame->hide();
|
||||
}
|
||||
|
||||
bool PageSetSubaddressLookahead::validatePage() {
|
||||
@@ -40,4 +51,19 @@ bool PageSetSubaddressLookahead::validatePage() {
|
||||
|
||||
int PageSetSubaddressLookahead::nextId() const {
|
||||
return WalletWizard::Page_WalletFile;
|
||||
}
|
||||
}
|
||||
|
||||
bool PageSetSubaddressLookahead::isComplete() const {
|
||||
ui->infoFrame->hide();
|
||||
|
||||
if (ui->line_major->text().isEmpty() || ui->line_major->text().toInt() == 0) {
|
||||
ui->infoFrame->show();
|
||||
return false;
|
||||
}
|
||||
if (ui->line_minor->text().isEmpty() || ui->line_minor->text().toInt() == 0) {
|
||||
ui->infoFrame->show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
void initializePage() override;
|
||||
bool validatePage() override;
|
||||
int nextId() const override;
|
||||
bool isComplete() const override;
|
||||
|
||||
private:
|
||||
Ui::PageSetSubaddressLookahead *ui;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="line_major"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
@@ -30,16 +33,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="line_major"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="line_minor"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="InfoFrame" name="infoFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>InfoFrame</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>components.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user