@@ -52,7 +52,7 @@ using namespace std::chrono;
5252
5353MainWindow::MainWindow ( QWidget *parent )
5454 : QWidget( parent )
55- , ui( new Ui::MainWindow )
55+ , ui(std::make_unique< Ui::MainWindow>() )
5656{
5757 setAttribute (Qt::WA_DeleteOnClose, true );
5858 setAcceptDrops ( true );
@@ -127,12 +127,7 @@ MainWindow::MainWindow( QWidget *parent )
127127 updateMyEid (qApp->signer ()->smartcard ()->data ());
128128}
129129
130- MainWindow::~MainWindow ()
131- {
132- digiDoc.reset ();
133- cryptoDoc.reset ();
134- delete ui;
135- }
130+ MainWindow::~MainWindow () noexcept = default ;
136131
137132void MainWindow::adjustDrops ()
138133{
@@ -675,27 +670,34 @@ void MainWindow::updateMyEid(const QSmartCardData &data)
675670 return ;
676671 bool pin1Blocked = data.retryCount (QSmartCardData::Pin1Type) == 0 ;
677672 bool pin2Blocked = data.retryCount (QSmartCardData::Pin2Type) == 0 ;
673+ bool pin1Locked = data.pinLocked (QSmartCardData::Pin1Type);
678674 bool pin2Locked = data.pinLocked (QSmartCardData::Pin2Type);
679675 ui->myEid ->warningIcon (
680- pin1Blocked ||
676+ pin1Blocked || pin1Locked ||
681677 pin2Blocked || pin2Locked ||
682678 data.retryCount (QSmartCardData::PukType) == 0 );
683679 ui->signContainerPage ->cardChanged (data.signCert (), pin2Blocked || pin2Locked);
684- ui->cryptoContainerPage ->cardChanged (data.authCert (), pin1Blocked);
685-
686- if (pin1Blocked)
687- ui->warnings ->showWarning ({WarningType::UnblockPin1Warning, 0 ,
688- [this ]{ changePinClicked (QSmartCardData::Pin1Type, QSmartCard::UnblockWithPuk); }});
689-
690- if (pin2Locked && pin2Blocked)
691- ui->warnings ->showWarning ({WarningType::ActivatePin2WithPUKWarning, 0 ,
692- [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::ActivateWithPuk); }});
693- else if (pin2Blocked)
694- ui->warnings ->showWarning ({WarningType::UnblockPin2Warning, 0 ,
695- [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::UnblockWithPuk); }});
696- else if (pin2Locked)
697- ui->warnings ->showWarning ({WarningType::ActivatePin2Warning, 0 ,
698- [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::ActivateWithPin); }});
680+ ui->cryptoContainerPage ->cardChanged (data.authCert (), pin1Blocked || pin1Locked);
681+
682+ using enum WarningText::WarningType;
683+ if (pin1Locked)
684+ ui->warnings ->showWarning ({LockedCardWarning});
685+ else
686+ {
687+ if (pin1Blocked)
688+ ui->warnings ->showWarning ({UnblockPin1Warning, 0 ,
689+ [this ]{ changePinClicked (QSmartCardData::Pin1Type, QSmartCard::UnblockWithPuk); }});
690+
691+ if (pin2Locked && pin2Blocked)
692+ ui->warnings ->showWarning ({ActivatePin2WithPUKWarning, 0 ,
693+ [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::ActivateWithPuk); }});
694+ else if (pin2Blocked)
695+ ui->warnings ->showWarning ({UnblockPin2Warning, 0 ,
696+ [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::UnblockWithPuk); }});
697+ else if (pin2Locked)
698+ ui->warnings ->showWarning ({ActivatePin2Warning, 0 ,
699+ [this ]{ changePinClicked (QSmartCardData::Pin2Type, QSmartCard::ActivateWithPin); }});
700+ }
699701
700702 const qint64 DAY = 24 * 60 * 60 ;
701703 qint64 expiresIn = 106 * DAY;
@@ -707,12 +709,12 @@ void MainWindow::updateMyEid(const QSmartCardData &data)
707709 if (expiresIn <= 0 )
708710 {
709711 ui->myEid ->invalidIcon (true );
710- ui->warnings ->showWarning ({WarningType:: CertExpiredError});
712+ ui->warnings ->showWarning ({CertExpiredError});
711713 }
712714 else if (expiresIn <= 105 * DAY)
713715 {
714716 ui->myEid ->warningIcon (true );
715- ui->warnings ->showWarning ({WarningType:: CertExpiryWarning});
717+ ui->warnings ->showWarning ({CertExpiryWarning});
716718 }
717719}
718720
0 commit comments