Skip to content

Commit

Permalink
Remove code duplication by implementing displayPinBlockedError() via …
Browse files Browse the repository at this point in the history
…displayFatalError()

WE2-479

Signed-off-by: Mart Somermaa <[email protected]>
  • Loading branch information
mrts committed Aug 30, 2024
1 parent 4f11b50 commit 355ac18
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
break;
case Status::PIN_BLOCKED:
displayPinBlockedError();
resizeHeight();
return;
case Status::INVALID_PIN_LENGTH:
message = [] { return tr("Invalid PIN length"); };
Expand All @@ -482,7 +481,7 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
case Status::UNKNOWN_ERROR:
message = [] { return tr("Technical error"); };
displayFatalError(message);
break;
return;
}

ui->pinErrorLabel->setVisible(bool(message));
Expand Down Expand Up @@ -682,17 +681,7 @@ void WebEidDialog::setupOK(Func func, const char* text, bool enabled)

void WebEidDialog::displayPinBlockedError()
{
ui->pinTitleLabel->hide();
ui->pinInput->hide();
ui->pinTimeoutTimer->stop();
ui->pinTimeRemaining->hide();
ui->pinEntryTimeoutProgressBar->hide();
setTrText(ui->pinErrorLabel, QT_TR_NOOP("PIN is locked. Unblock and try again."));
ui->pinErrorLabel->show();
ui->okButton->hide();
ui->cancelButton->setEnabled(true);
ui->cancelButton->show();
ui->helpButton->show();
displayFatalError([] { return tr("PIN is locked. Unblock and try again."); });
}

void WebEidDialog::displayFatalError(std::function<QString()> message)
Expand All @@ -707,6 +696,8 @@ void WebEidDialog::displayFatalError(std::function<QString()> message)
ui->okButton->hide();
ui->cancelButton->setEnabled(true);
ui->cancelButton->show();
ui->helpButton->show();
resizeHeight();
}

void WebEidDialog::showPinInputWarning(bool show)
Expand Down

0 comments on commit 355ac18

Please sign in to comment.