Skip to content

Commit 284c880

Browse files
committed
Remove code duplication by implementing displayPinBlockedError() via displayFatalError()
WE2-479 Signed-off-by: Mart Somermaa <[email protected]>
1 parent 847ba67 commit 284c880

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/ui/webeiddialog.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
* SOFTWARE.
2121
*/
2222

23-
#include "utils/erasedata.hpp"
24-
2523
#include "webeiddialog.hpp"
2624
#include "application.hpp"
2725
#include "punycode.hpp"
@@ -465,7 +463,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
465463
break;
466464
case Status::PIN_BLOCKED:
467465
displayPinBlockedError();
468-
resizeHeight();
469466
return;
470467
case Status::INVALID_PIN_LENGTH:
471468
message = [] { return tr("Invalid PIN length"); };
@@ -482,7 +479,7 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
482479
case Status::UNKNOWN_ERROR:
483480
message = [] { return tr("Technical error"); };
484481
displayFatalError(message);
485-
break;
482+
return;
486483
}
487484

488485
ui->pinErrorLabel->setVisible(bool(message));
@@ -682,17 +679,7 @@ void WebEidDialog::setupOK(Func func, const char* text, bool enabled)
682679

683680
void WebEidDialog::displayPinBlockedError()
684681
{
685-
ui->pinTitleLabel->hide();
686-
ui->pinInput->hide();
687-
ui->pinTimeoutTimer->stop();
688-
ui->pinTimeRemaining->hide();
689-
ui->pinEntryTimeoutProgressBar->hide();
690-
setTrText(ui->pinErrorLabel, QT_TR_NOOP("PIN is locked. Unblock and try again."));
691-
ui->pinErrorLabel->show();
692-
ui->okButton->hide();
693-
ui->cancelButton->setEnabled(true);
694-
ui->cancelButton->show();
695-
ui->helpButton->show();
682+
displayFatalError([] { return tr("PIN is locked. Unblock and try again."); });
696683
}
697684

698685
void WebEidDialog::displayFatalError(std::function<QString()> message)
@@ -707,6 +694,8 @@ void WebEidDialog::displayFatalError(std::function<QString()> message)
707694
ui->okButton->hide();
708695
ui->cancelButton->setEnabled(true);
709696
ui->cancelButton->show();
697+
ui->helpButton->show();
698+
resizeHeight();
710699
}
711700

712701
void WebEidDialog::showPinInputWarning(bool show)

0 commit comments

Comments
 (0)