diff --git a/client/DigiDoc.cpp b/client/DigiDoc.cpp index 8288d8027..8a99ddd5f 100644 --- a/client/DigiDoc.cpp +++ b/client/DigiDoc.cpp @@ -588,9 +588,11 @@ void DigiDoc::removeSignature( unsigned int num ) { if( !checkDoc( num >= b->signatures().size(), tr("Missing signature") ) ) return; - try { - b->removeSignature( num ); - modified = true; + try { + waitFor([this, num] { + b->removeSignature(num); + modified = true; + }); } catch( const Exception &e ) { setLastError( tr("Failed remove signature from container"), e ); } } diff --git a/client/MainWindow.cpp b/client/MainWindow.cpp index c9a428e64..5ea8260c1 100644 --- a/client/MainWindow.cpp +++ b/client/MainWindow.cpp @@ -29,6 +29,7 @@ #include "QPCSC.h" #include "QSigner.h" #include "Styles.h" +#include "sslConnect.h" #include "TokenData.h" #include "effects/ButtonHoverFilter.h" #include "effects/FadeInNotification.h" @@ -47,7 +48,6 @@ #include "widgets/WarningItem.h" #include "widgets/WarningList.h" -#include #include #include #include @@ -61,8 +61,6 @@ using namespace ria::qdigidoc4; using namespace ria::qdigidoc4::colors; -Q_LOGGING_CATEGORY(MLog, "qdigidoc4.MainWindow") - MainWindow::MainWindow( QWidget *parent ) : QWidget( parent ) , ui( new Ui::MainWindow ) @@ -219,23 +217,16 @@ void MainWindow::pageSelected(PageIcon *page) } Pages toPage = page->getType(); - if(toPage == SignIntro) + if(toPage == SignIntro && digiDoc) { - if(digiDoc) - { - navigate = false; - selectPage(SignDetails); - } + selectPage(SignDetails); + return; } - else if(toPage == CryptoIntro) + if(toPage == CryptoIntro && cryptoDoc) { - if(cryptoDoc) - { - navigate = false; - selectPage(CryptoDetails); - } + selectPage(CryptoDetails); + return; } - if(navigate) navigateToPage(toPage); } @@ -919,7 +910,8 @@ void MainWindow::showSettings(int page) dlg.exec(); } -void MainWindow::sign(const std::function &sign) +template +void MainWindow::sign(F &&sign) { if(!CheckConnection().check(QStringLiteral("https://id.eesti.ee/config.json"))) { @@ -1028,22 +1020,13 @@ bool MainWindow::removeFile(DocumentModel *model, int index) } } - bool hasEmptyFile = false; - for (auto i = 0; i < model->rowCount(); ++i) { - const auto fileSize = model->fileSize(i).trimmed(); - if (fileSize.startsWith(QLatin1String("0 "), Qt::CaseInsensitive)) - { - hasEmptyFile = true; - } - } - - if (false == hasEmptyFile) - { + for(auto i = 0; i < model->rowCount(); ++i) { + if(!model->fileSize(i).trimmed().startsWith(QLatin1String("0 "))) + continue; warnings->closeWarning(EmptyFileWarning); - if (digiDoc) - { - this->ui->signContainerPage->transition(digiDoc); - } + if(digiDoc) + ui->signContainerPage->transition(digiDoc); + break; } return false; @@ -1051,13 +1034,13 @@ bool MainWindow::removeFile(DocumentModel *model, int index) void MainWindow::removeSignature(int index) { - if(digiDoc) - { - digiDoc->removeSignature(index); - save(); - ui->signContainerPage->transition(digiDoc); - adjustDrops(); - } + if(!digiDoc) + return; + WaitDialogHolder waitDialog(this, tr("Removing signature")); + digiDoc->removeSignature(index); + save(); + ui->signContainerPage->transition(digiDoc); + adjustDrops(); } void MainWindow::removeSignatureFile(int index) diff --git a/client/MainWindow.h b/client/MainWindow.h index 2944951af..90be15363 100644 --- a/client/MainWindow.h +++ b/client/MainWindow.h @@ -23,9 +23,6 @@ #include "common_enums.h" #include "QSmartCard.h" -#include "sslConnect.h" - -#include namespace Ui { class MainWindow; @@ -104,7 +101,8 @@ private Q_SLOTS: void selectPageIcon( PageIcon* page ); void showCardMenu( bool show ); void showNotification( const QString &msg, bool isSuccess = false ); - void sign(const std::function &sign); + template + void sign(F &&sign); void updateCardWarnings(const QSmartCardData &data); bool validateCardError(QSmartCardData::PinType type, QSmartCardData::PinType t, QSmartCard::ErrorType err); bool validateFiles(const QString &container, const QStringList &files); @@ -116,7 +114,7 @@ private Q_SLOTS: bool wrap(const QString& wrappedFile, bool enclose); bool wrapContainer(bool signing); void containerSummary(); - + CryptoDoc* cryptoDoc = nullptr; DigiDoc* digiDoc = nullptr; Ui::MainWindow *ui; diff --git a/client/translations/en.ts b/client/translations/en.ts index b79ac7f10..34240ea37 100644 --- a/client/translations/en.ts +++ b/client/translations/en.ts @@ -1590,6 +1590,10 @@ ID-CARD CANCEL CANCEL + + Removing signature + Removing signature + Files can not be added to the signed container. The system will create a new container which shall contain the signed document and the files you wish to add. Files can not be added to the signed container. The system will create a new container which shall contain the signed document and the files you wish to add. diff --git a/client/translations/et.ts b/client/translations/et.ts index 25a674e6b..3bb7fce35 100644 --- a/client/translations/et.ts +++ b/client/translations/et.ts @@ -1590,6 +1590,10 @@ ID-KAARDIGA CANCEL KATKESTA + + Removing signature + Allkirja eemaldamine + Files can not be added to the signed container. The system will create a new container which shall contain the signed document and the files you wish to add. Allkirjastatud ümbrikusse ei saa faile lisada. Süsteem loob uue ümbriku, kuhu lisatakse allkirjastatud dokument ja Sinu valitud failid. diff --git a/client/translations/ru.ts b/client/translations/ru.ts index 7b4d8c60f..40d7d1e06 100644 --- a/client/translations/ru.ts +++ b/client/translations/ru.ts @@ -1592,6 +1592,10 @@ ID-КАРТОЙ CANCEL ОТМЕНА + + Removing signature + Удаление подписи + Files can not be added to the signed container. The system will create a new container which shall contain the signed document and the files you wish to add. Файлы не могут быть добавлены в подписанный контейнер. Система создаст новый контейнер, в который будет добавлен подписанный документ и выбранные вами файлы.