From: tobtoht Date: Sun, 29 Sep 2024 19:58:40 +0000 (+0200) Subject: wizard: fix lookahead validation X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=23208d98a6f71f4846a1be0ba99c7a9f1a32df1f;p=gamesguru%2Ffeather.git wizard: fix lookahead validation --- diff --git a/src/wizard/PageSetSubaddressLookahead.cpp b/src/wizard/PageSetSubaddressLookahead.cpp index c6c896a9..6d9e05b4 100644 --- a/src/wizard/PageSetSubaddressLookahead.cpp +++ b/src/wizard/PageSetSubaddressLookahead.cpp @@ -5,7 +5,9 @@ #include "ui_PageSetSubaddressLookahead.h" #include "WalletWizard.h" -#include +#include + +#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; -} \ No newline at end of file +} + +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; +} diff --git a/src/wizard/PageSetSubaddressLookahead.h b/src/wizard/PageSetSubaddressLookahead.h index 04fb4c39..fc7a6d38 100644 --- a/src/wizard/PageSetSubaddressLookahead.h +++ b/src/wizard/PageSetSubaddressLookahead.h @@ -22,6 +22,7 @@ public: void initializePage() override; bool validatePage() override; int nextId() const override; + bool isComplete() const override; private: Ui::PageSetSubaddressLookahead *ui; diff --git a/src/wizard/PageSetSubaddressLookahead.ui b/src/wizard/PageSetSubaddressLookahead.ui index 6fd4d8f4..b724fe32 100644 --- a/src/wizard/PageSetSubaddressLookahead.ui +++ b/src/wizard/PageSetSubaddressLookahead.ui @@ -23,6 +23,9 @@ + + + @@ -30,16 +33,31 @@ - - - + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + InfoFrame + QFrame +
components.h
+ 1 +
+