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 Sep 3, 2024
1 parent 847ba67 commit 284c880
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* SOFTWARE.
*/

#include "utils/erasedata.hpp"

#include "webeiddialog.hpp"
#include "application.hpp"
#include "punycode.hpp"
Expand Down Expand Up @@ -465,7 +463,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 +479,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 +679,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 +694,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 284c880

Please sign in to comment.