Skip to content

Commit

Permalink
Show Wait dialog on signature removal (open-eid#1085)
Browse files Browse the repository at this point in the history
IB-7365

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Aug 2, 2022
1 parent 27e3de4 commit 77a14fa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 47 deletions.
8 changes: 5 additions & 3 deletions client/DigiDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
}
Expand Down
61 changes: 22 additions & 39 deletions client/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -47,7 +48,6 @@
#include "widgets/WarningItem.h"
#include "widgets/WarningList.h"

#include <QtCore/QLoggingCategory>
#include <QtCore/QMimeData>
#include <QtCore/QSettings>
#include <QtCore/QStandardPaths>
Expand All @@ -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 )
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -919,7 +910,8 @@ void MainWindow::showSettings(int page)
dlg.exec();
}

void MainWindow::sign(const std::function<bool(const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role)> &sign)
template<typename F>
void MainWindow::sign(F &&sign)
{
if(!CheckConnection().check(QStringLiteral("https://id.eesti.ee/config.json")))
{
Expand Down Expand Up @@ -1028,36 +1020,27 @@ 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;
}

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)
Expand Down
8 changes: 3 additions & 5 deletions client/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

#include "common_enums.h"
#include "QSmartCard.h"
#include "sslConnect.h"

#include <functional>

namespace Ui {
class MainWindow;
Expand Down Expand Up @@ -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<bool(const QString &city, const QString &state, const QString &zip, const QString &country, const QString &role)> &sign);
template <typename F>
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);
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions client/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,10 @@ ID-CARD</translation>
<source>CANCEL</source>
<translation>CANCEL</translation>
</message>
<message>
<source>Removing signature</source>
<translation>Removing signature</translation>
</message>
<message>
<source>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.</source>
<translation>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.</translation>
Expand Down
4 changes: 4 additions & 0 deletions client/translations/et.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,10 @@ ID-KAARDIGA</translation>
<source>CANCEL</source>
<translation>KATKESTA</translation>
</message>
<message>
<source>Removing signature</source>
<translation>Allkirja eemaldamine</translation>
</message>
<message>
<source>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.</source>
<translation>Allkirjastatud ümbrikusse ei saa faile lisada. Süsteem loob uue ümbriku, kuhu lisatakse allkirjastatud dokument ja Sinu valitud failid.</translation>
Expand Down
4 changes: 4 additions & 0 deletions client/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,10 @@ ID-КАРТОЙ</translation>
<source>CANCEL</source>
<translation>ОТМЕНА</translation>
</message>
<message>
<source>Removing signature</source>
<translation>Удаление подписи</translation>
</message>
<message>
<source>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.</source>
<translation>Файлы не могут быть добавлены в подписанный контейнер. Система создаст новый контейнер, в который будет добавлен подписанный документ и выбранные вами файлы.</translation>
Expand Down

0 comments on commit 77a14fa

Please sign in to comment.