@@ -103,7 +103,7 @@ MainWindow::MainWindow( QWidget *parent )
103103 separator->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
104104 separator->setStyleSheet (QStringLiteral (" background-color: #D9D9D9;" ));
105105 separator->resize (8000 , 1 );
106- separator->move (110 , 0 );
106+ separator->move (mapToGlobal (ui-> topBar -> pos ()) );
107107 separator->show ();
108108#endif
109109
@@ -119,8 +119,6 @@ MainWindow::MainWindow( QWidget *parent )
119119 updateSelectorData (token);
120120 updateMyEID (token);
121121 ui->cryptoContainerPage ->cardChanged (token.cert ());
122- if (cryptoDoc)
123- ui->cryptoContainerPage ->update (cryptoDoc, token.cert ());
124122 });
125123 QPCSC::instance ().start ();
126124
@@ -146,8 +144,6 @@ MainWindow::MainWindow( QWidget *parent )
146144 connect (ui->cryptoContainerPage , &ContainerPage::action, this , &MainWindow::onCryptoAction);
147145 connect (ui->cryptoContainerPage , &ContainerPage::addFiles, this , [this ](const QStringList &files) { openFiles (files, true ); } );
148146 connect (ui->cryptoContainerPage , &ContainerPage::fileRemoved, this , &MainWindow::removeCryptoFile);
149- connect (ui->cryptoContainerPage , &ContainerPage::keysSelected, this , &MainWindow::updateKeys);
150- connect (ui->cryptoContainerPage , &ContainerPage::removed, this , &MainWindow::removeAddress);
151147 connect (ui->cryptoContainerPage , &ContainerPage::warning, this , [this ](WarningText warningText) {
152148 ui->warnings ->showWarning (warningText);
153149 ui->crypto ->warningIcon (true );
@@ -334,19 +330,15 @@ void MainWindow::navigateToPage( Pages page, const QStringList &files, bool crea
334330 if (!filename.isNull ())
335331 {
336332 signatureContainer->create (filename);
337- bool filesAdded = false ;
338333 for (const auto &file: files)
339334 {
340335 if (signatureContainer->documentModel ()->addFile (file))
341- filesAdded = true ;
336+ navigate = true ;
342337 }
343- navigate = filesAdded;
344338 }
345339 }
346- else if (signatureContainer->open (files[0 ]))
347- {
348- navigate = true ;
349- }
340+ else
341+ navigate = signatureContainer->open (files[0 ]);
350342 if (navigate)
351343 {
352344 resetDigiDoc (signatureContainer.release ());
@@ -356,31 +348,27 @@ void MainWindow::navigateToPage( Pages page, const QStringList &files, bool crea
356348 else if (page == CryptoDetails)
357349 {
358350 navigate = false ;
359- std::unique_ptr <CryptoDoc> cryptoContainer ( new CryptoDoc ( this ) );
351+ auto cryptoContainer = std::make_unique <CryptoDoc>( this );
360352
361353 if (create)
362354 {
363355 QString filename = FileDialog::createNewFileName (files[0 ], false , this );
364356 if (!filename.isNull ())
365357 {
366358 cryptoContainer->clear (filename);
367- bool filesAdded = false ;
368359 for (const auto &file: files)
369360 {
370361 if (cryptoContainer->documentModel ()->addFile (file))
371- filesAdded = true ;
362+ navigate = true ;
372363 }
373- navigate = filesAdded;
374364 }
375365 }
376- else if (cryptoContainer->open (files[0 ]))
377- {
378- navigate = true ;
379- }
366+ else
367+ navigate = cryptoContainer->open (files[0 ]);
380368 if (navigate)
381369 {
382- resetCryptoDoc (cryptoContainer. release ( ));
383- ui->cryptoContainerPage ->transition (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
370+ resetCryptoDoc (std::move (cryptoContainer ));
371+ ui->cryptoContainerPage ->transition (cryptoDoc. get () , qApp->signer ()->tokenauth ().cert ());
384372 }
385373 }
386374
@@ -464,7 +452,7 @@ void MainWindow::convertToCDoc()
464452 if (filename.isNull ())
465453 return ;
466454
467- std::unique_ptr <CryptoDoc> cryptoContainer ( new CryptoDoc ( this ) );
455+ auto cryptoContainer = std::make_unique <CryptoDoc>( this );
468456 cryptoContainer->clear (filename);
469457
470458 // If signed, add whole signed document to cryptocontainer; otherwise content only
@@ -477,9 +465,9 @@ void MainWindow::convertToCDoc()
477465 if (!cardData.cert ().isNull ())
478466 cryptoContainer->addKey (CKey (cardData.cert ()));
479467
480- resetCryptoDoc (cryptoContainer. release ( ));
468+ resetCryptoDoc (std::move (cryptoContainer ));
481469 resetDigiDoc (nullptr , false );
482- ui->cryptoContainerPage ->transition (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
470+ ui->cryptoContainerPage ->transition (cryptoDoc. get () , qApp->signer ()->tokenauth ().cert ());
483471 selectPage (CryptoDetails);
484472
485473 FadeInNotification::success (ui->topBar , tr (" Converted to crypto container!" ));
@@ -515,14 +503,14 @@ void MainWindow::onCryptoAction(int action, const QString &/*id*/, const QString
515503 case DecryptToken:
516504 if (decrypt ())
517505 {
518- ui->cryptoContainerPage ->transition (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
506+ ui->cryptoContainerPage ->transition (cryptoDoc. get () , qApp->signer ()->tokenauth ().cert ());
519507 FadeInNotification::success (ui->topBar , tr (" Decryption succeeded!" ));
520508 }
521509 break ;
522510 case EncryptContainer:
523511 if (encrypt ())
524512 {
525- ui->cryptoContainerPage ->transition (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
513+ ui->cryptoContainerPage ->transition (cryptoDoc. get () , qApp->signer ()->tokenauth ().cert ());
526514 FadeInNotification::success (ui->topBar , tr (" Encryption succeeded!" ));
527515 }
528516 break ;
@@ -683,12 +671,10 @@ void MainWindow::openContainer(bool signature)
683671 openFiles (files);
684672}
685673
686- void MainWindow::resetCryptoDoc (CryptoDoc * doc)
674+ void MainWindow::resetCryptoDoc (std::unique_ptr< CryptoDoc> && doc)
687675{
688676 ui->crypto ->warningIcon (false );
689- ui->cryptoContainerPage ->clear ();
690- delete cryptoDoc;
691- cryptoDoc = doc;
677+ cryptoDoc = std::move (doc);
692678}
693679
694680void MainWindow::resetDigiDoc (DigiDoc *doc, bool warnOnChange)
@@ -881,15 +867,6 @@ void MainWindow::sign(F &&sign)
881867 adjustDrops ();
882868}
883869
884- void MainWindow::removeAddress (int index)
885- {
886- if (cryptoDoc)
887- {
888- cryptoDoc->removeKey (index);
889- ui->cryptoContainerPage ->update (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
890- }
891- }
892-
893870void MainWindow::removeCryptoFile (int index)
894871{
895872 if (!cryptoDoc)
@@ -1072,18 +1049,6 @@ void MainWindow::updateSelectorData(TokenData data)
10721049 showCardMenu (false );
10731050}
10741051
1075- void MainWindow::updateKeys (const QList<CKey> &keys)
1076- {
1077- if (!cryptoDoc)
1078- return ;
1079-
1080- for (auto i = cryptoDoc->keys ().size () - 1 ; i >= 0 ; i--)
1081- cryptoDoc->removeKey (i);
1082- for (const auto &key: keys)
1083- cryptoDoc->addKey (key);
1084- ui->cryptoContainerPage ->update (cryptoDoc, qApp->signer ()->tokenauth ().cert ());
1085- }
1086-
10871052void MainWindow::containerSummary ()
10881053{
10891054#ifdef Q_OS_WIN
0 commit comments