wizard: fix lookahead validation
Some checks failed
ci/gh-actions/build / build-ubuntu-without-scanner (push) Has been cancelled
ci/gh-actions/guix / cache-sources (push) Has been cancelled
ci/gh-actions/guix / aarch64-linux-gnu (push) Has been cancelled
ci/gh-actions/guix / arm-linux-gnueabihf (push) Has been cancelled
ci/gh-actions/guix / arm64-apple-darwin (push) Has been cancelled
ci/gh-actions/guix / i686-linux-gnu (push) Has been cancelled
ci/gh-actions/guix / riscv64-linux-gnu (push) Has been cancelled
ci/gh-actions/guix / x86_64-apple-darwin (push) Has been cancelled
ci/gh-actions/guix / x86_64-linux-gnu.no-tor-bundle (push) Has been cancelled
ci/gh-actions/guix / x86_64-linux-gnu.pack (push) Has been cancelled
ci/gh-actions/guix / x86_64-linux-gnu (push) Has been cancelled
ci/gh-actions/guix / x86_64-w64-mingw32.installer (push) Has been cancelled
ci/gh-actions/guix / x86_64-w64-mingw32 (push) Has been cancelled
ci/gh-actions/guix / bundle-logs (push) Has been cancelled

This commit is contained in:
tobtoht 2024-09-29 21:58:40 +02:00
parent b64089091c
commit 23208d98a6
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
3 changed files with 52 additions and 7 deletions

View file

@ -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() {
@ -41,3 +52,18 @@ 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;
}

View file

@ -22,6 +22,7 @@ public:
void initializePage() override;
bool validatePage() override;
int nextId() const override;
bool isComplete() const override;
private:
Ui::PageSetSubaddressLookahead *ui;

View file

@ -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>