Skip to content

Commit ff73fc0

Browse files
metsmamrts
authored andcommitted
Disable OK button on pin retry and hide on pin blocked
WE2-441 Signed-off-by: Raul Metsma <[email protected]>
1 parent 5ac3a3f commit ff73fc0

File tree

6 files changed

+13
-40
lines changed

6 files changed

+13
-40
lines changed

src/ui/translations/en.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<source>No readers attached. Please connect a smart card reader.</source>
3131
<translation>No readers attached. Please connect a smart card reader.</translation>
3232
</message>
33-
<message>
34-
<source>PIN blocked</source>
35-
<translation>PIN blocked</translation>
36-
</message>
3733
<message>
3834
<source>Wrong PIN length</source>
3935
<translation>Wrong PIN length</translation>

src/ui/translations/et.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<source>No readers attached. Please connect a smart card reader.</source>
3131
<translation type="unfinished"></translation>
3232
</message>
33-
<message>
34-
<source>PIN blocked</source>
35-
<translation>PIN blokeeritud</translation>
36-
</message>
3733
<message>
3834
<source>Wrong PIN length</source>
3935
<translation>Valie PIN koodi pikkus</translation>

src/ui/translations/fi.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<source>No readers attached. Please connect a smart card reader.</source>
3131
<translation type="unfinished"></translation>
3232
</message>
33-
<message>
34-
<source>PIN blocked</source>
35-
<translation type="unfinished"></translation>
36-
</message>
3733
<message>
3834
<source>Wrong PIN length</source>
3935
<translation type="unfinished"></translation>

src/ui/translations/ru.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
<source>No readers attached. Please connect a smart card reader.</source>
3131
<translation type="unfinished"></translation>
3232
</message>
33-
<message>
34-
<source>PIN blocked</source>
35-
<translation type="unfinished"></translation>
36-
</message>
3733
<message>
3834
<source>Wrong PIN length</source>
3935
<translation type="unfinished"></translation>

src/ui/webeiddialog.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private)
8181
ui->waitingSpinner->load(QStringLiteral(":/images/wait.svg"));
8282
ui->waitingPageLayout->setAlignment(ui->waitingSpinner, Qt::AlignCenter);
8383

84+
connect(ui->pageStack, &QStackedWidget::currentChanged, this, &WebEidDialog::resizeHeight);
8485
connect(ui->selectCertificateInfo, &CertificateListWidget::currentItemChanged, this,
8586
[this] { ui->okButton->setEnabled(true); });
8687
connect(ui->cancelButton, &QPushButton::clicked, this, &WebEidDialog::rejected);
@@ -119,10 +120,8 @@ void WebEidDialog::showWaitingForCardPage(const CommandType commandType)
119120
// Don't show OK button while waiting for card operation or connect card.
120121
ui->okButton->hide();
121122

122-
const auto pageIndex =
123-
commandType == CommandType::INSERT_CARD ? int(Page::MESSAGE) : int(Page::WAITING);
124-
ui->pageStack->setCurrentIndex(pageIndex);
125-
resizeHeight();
123+
ui->pageStack->setCurrentIndex(
124+
int(commandType == CommandType::INSERT_CARD ? Page::MESSAGE : Page::WAITING));
126125
}
127126

128127
QString WebEidDialog::getPin()
@@ -144,7 +143,7 @@ void WebEidDialog::onSmartCardStatusUpdate(const RetriableError status)
144143
ui->helpButton->show();
145144
ui->cancelButton->show();
146145
ui->okButton->hide();
147-
showPage(Page::MESSAGE);
146+
ui->pageStack->setCurrentIndex(int(Page::MESSAGE));
148147
}
149148

150149
/** This slot is used by the get certificate and authenticate commands in case there are multiple
@@ -184,7 +183,7 @@ void WebEidDialog::onMultipleCertificatesReady(
184183
THROW(ProgrammingError, "Command " + std::string(currentCommand) + " not allowed here");
185184
}
186185

187-
showPage(Page::SELECT_CERTIFICATE);
186+
ui->pageStack->setCurrentIndex(int(Page::SELECT_CERTIFICATE));
188187
}
189188
CATCH_AND_EMIT_FAILURE_AND_RETURN()
190189
}
@@ -246,7 +245,7 @@ void WebEidDialog::onSingleCertificateReady(const QUrl& origin,
246245
displayPinRetriesRemaining(certAndPin.pinInfo.pinRetriesCount);
247246
}
248247

249-
showPage(page);
248+
ui->pageStack->setCurrentIndex(int(page));
250249
}
251250
CATCH_AND_EMIT_FAILURE_AND_RETURN()
252251
}
@@ -270,7 +269,7 @@ void WebEidDialog::onVerifyPinFailed(const electronic_id::VerifyPinFailed::Statu
270269

271270
QString message;
272271

273-
// FIXME: don't allow retry in case of PIN_BLOCKED, UNKNOWN_ERROR
272+
// FIXME: don't allow retry in case of UNKNOWN_ERROR
274273
switch (status) {
275274
case Status::RETRY_ALLOWED:
276275
message = tr("Incorrect PIN, %n retries left", nullptr, retriesLeft);
@@ -279,8 +278,9 @@ void WebEidDialog::onVerifyPinFailed(const electronic_id::VerifyPinFailed::Statu
279278
style()->polish(ui->pinInput);
280279
break;
281280
case Status::PIN_BLOCKED:
282-
message = tr("PIN blocked");
283-
break;
281+
displayPinBlockedError();
282+
resizeHeight();
283+
return;
284284
case Status::INVALID_PIN_LENGTH:
285285
message = tr("Wrong PIN length");
286286
break;
@@ -303,11 +303,10 @@ void WebEidDialog::onVerifyPinFailed(const electronic_id::VerifyPinFailed::Statu
303303
} else {
304304
ui->pinInput->show();
305305
ui->pinTitleLabel->show();
306-
ui->okButton->setEnabled(true);
306+
ui->okButton->setDisabled(true);
307307
ui->cancelButton->setEnabled(true);
308+
resizeHeight();
308309
}
309-
310-
resizeHeight();
311310
}
312311

313312
void WebEidDialog::reject()
@@ -325,14 +324,6 @@ bool WebEidDialog::event(QEvent* event)
325324
return WebEidUI::event(event);
326325
}
327326

328-
void WebEidDialog::showPage(const WebEidDialog::Page page)
329-
{
330-
if (ui->pageStack->currentIndex() != int(page)) {
331-
ui->pageStack->setCurrentIndex(int(page));
332-
resizeHeight();
333-
}
334-
}
335-
336327
void WebEidDialog::connectOkToCachePinAndEmitSelectedCertificate(
337328
const CardCertificateAndPinInfo& certAndPin)
338329
{
@@ -363,8 +354,8 @@ void WebEidDialog::onRetryImpl(const QString& error)
363354
ui->connectCardLabel->setText(error);
364355
ui->messagePageTitleLabel->setText(tr("Error occurred"));
365356
ui->cardChipIcon->setPixmap(QStringLiteral(":/images/id-card.svg"));
366-
showPage(Page::MESSAGE);
367357
setupOK([this] { emit retry(); }, tr("Retry"), true);
358+
ui->pageStack->setCurrentIndex(int(Page::MESSAGE));
368359
}
369360

370361
void WebEidDialog::setupPinPadProgressBarAndEmitWait(const CardCertificateAndPinInfo& certAndPin)
@@ -401,7 +392,6 @@ void WebEidDialog::setupPinInputValidator(const PinInfo::PinMinMaxLength& pinMin
401392
ui->pinInput->setMaxLength(int(pinMinMaxLength.second));
402393
ui->pinInput->show();
403394
ui->pinInput->setFocus();
404-
resizeHeight();
405395
}
406396

407397
void WebEidDialog::setupOK(const std::function<void()>& func, const QString& label, bool enabled)

src/ui/webeiddialog.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class WebEidDialog : public WebEidUI
6868
private:
6969
bool event(QEvent* event) override;
7070
void reject() override;
71-
void showPage(const WebEidDialog::Page page);
7271

7372
void connectOkToCachePinAndEmitSelectedCertificate(const CardCertificateAndPinInfo& certAndPin);
7473

0 commit comments

Comments
 (0)