@@ -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
128127QString 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
313312void 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-
336327void 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
370361void 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
407397void WebEidDialog::setupOK (const std::function<void ()>& func, const QString& label, bool enabled)
0 commit comments