From c726db96f5c0acc06a4d44c16d45601b93619d18 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Thu, 16 Nov 2023 11:21:11 +0200 Subject: [PATCH] Build dialog before showing IB-7840 Signed-off-by: Raul Metsma --- client/Application.cpp | 5 +++-- client/DocumentModel.cpp | 18 ++++++++--------- client/MainWindow.cpp | 10 ++++++---- client/common_enums.h | 11 +---------- client/widgets/AddressItem.cpp | 2 +- client/widgets/FileItem.cpp | 4 ++-- client/widgets/FileList.cpp | 2 +- client/widgets/ItemList.cpp | 2 +- client/widgets/LabelButton.h | 2 +- client/widgets/SignatureItem.cpp | 33 +++++++++++++++----------------- client/widgets/SignatureItem.h | 1 - debian/control | 3 +++ 12 files changed, 42 insertions(+), 51 deletions(-) diff --git a/client/Application.cpp b/client/Application.cpp index cee87c11a..32fcd5393 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -462,8 +462,8 @@ Application::Application( int &argc, char **argv ) #ifdef Q_OS_MAC if(!Settings::PLUGINS.isSet()) { - auto *dlg = WarningDialog::show(tr( - "In order to authenticate and sign in e-services with an ID-card you need to install the web browser components.")); + auto *dlg = new WarningDialog(tr( + "In order to authenticate and sign in e-services with an ID-card you need to install the web browser components."), mainWindow()); dlg->setCancelText(tr("Ignore forever").toUpper()); dlg->addButton(tr("Remind later").toUpper(), QMessageBox::Ignore); dlg->addButton(tr("Install").toUpper(), QMessageBox::Open); @@ -475,6 +475,7 @@ Application::Application( int &argc, char **argv ) default: Settings::PLUGINS = QStringLiteral("ignore"); } }); + dlg->open(); } #endif if(Settings::SHOW_INTRO) diff --git a/client/DocumentModel.cpp b/client/DocumentModel.cpp index 6e74c28b3..0920c0815 100644 --- a/client/DocumentModel.cpp +++ b/client/DocumentModel.cpp @@ -39,11 +39,9 @@ void DocumentModel::addTempFiles(const QStringList &files) QStringList DocumentModel::tempFiles() const { QStringList copied; - int rows = rowCount(); - for(int i = 0; i < rows; ++i) + for(int i = 0, rows = rowCount(); i < rows; ++i) { - QFileInfo f(save(i, FileDialog::tempPath(data(i)))); - if(f.exists()) + if(QFileInfo f(save(i, FileDialog::tempPath(data(i)))); f.exists()) copied.append(f.absoluteFilePath()); } return copied; @@ -59,10 +57,10 @@ bool DocumentModel::verifyFile(const QString &f) QStringLiteral("gif"), QStringLiteral("ico"), QStringLiteral("ps"), QStringLiteral("psd"), QStringLiteral("tif"), QStringLiteral("tiff"), QStringLiteral("csv")}; QJsonArray allowedExts = Application::confValue(QLatin1String("ALLOWED-EXTENSIONS")).toArray(defaultArray); - if(!allowedExts.contains(QJsonValue(QFileInfo(f).suffix().toLower()))){ - WarningDialog::show(tr("A file with this extension cannot be opened in the DigiDoc4 Client. Download the file to view it."))->setCancelText(WarningDialog::OK); - return false; - } - - return true; + if(allowedExts.contains(QJsonValue(QFileInfo(f).suffix().toLower()))) + return true; + auto *dlg = new WarningDialog(tr("A file with this extension cannot be opened in the DigiDoc4 Client. Download the file to view it.")); + dlg->setCancelText(WarningDialog::OK); + dlg->open(); + return false; } diff --git a/client/MainWindow.cpp b/client/MainWindow.cpp index ec47cae6a..44ea2b404 100644 --- a/client/MainWindow.cpp +++ b/client/MainWindow.cpp @@ -990,7 +990,7 @@ void MainWindow::removeSignature(int index) if(!digiDoc) return; WaitDialogHolder waitDialog(this, tr("Removing signature")); - digiDoc->removeSignature(index); + digiDoc->removeSignature(unsigned(index)); save(); ui->signContainerPage->transition(digiDoc); adjustDrops(); @@ -1030,15 +1030,17 @@ bool MainWindow::validateFiles(const QString &container, const QStringList &file if(std::none_of(files.cbegin(), files.cend(), [containerInfo] (const QString &file) { return containerInfo == QFileInfo(file); })) return true; - WarningDialog::show(this, tr("Cannot add container to same container\n%1") - .arg(FileDialog::normalized(container)))->setCancelText(WarningDialog::Cancel); + auto *dlg = WarningDialog::show(this, tr("Cannot add container to same container\n%1") + .arg(FileDialog::normalized(container))); + dlg->setCancelText(WarningDialog::Cancel); + dlg->open(); return false; } void MainWindow::warningClicked(const QString &link) { if(link == QLatin1String("#unblock-PIN1")) - ui->accordion->changePin1Clicked (false, true); + ui->accordion->changePin1Clicked(false, true); else if(link == QLatin1String("#unblock-PIN2")) ui->accordion->changePin2Clicked (false, true); else if(link.startsWith(QLatin1String("http"))) diff --git a/client/common_enums.h b/client/common_enums.h index b37184c2f..8ca88841b 100644 --- a/client/common_enums.h +++ b/client/common_enums.h @@ -19,8 +19,7 @@ #pragma once -namespace ria { -namespace qdigidoc4 { +namespace ria::qdigidoc4 { enum ContainerState { Uninitialized = (1 << 0), @@ -37,8 +36,6 @@ enum ContainerState { }; enum Actions { - AddressAdd, - ContainerCancel, ContainerConvert, ContainerEncrypt, @@ -53,15 +50,10 @@ enum Actions { DecryptContainer, DecryptToken, - FileAdd, - FileRemove, - SignatureAdd, SignatureMobile, SignatureSmartID, SignatureToken, - SignatureRemove, - SignatureWarning, ClearSignatureWarning }; @@ -101,4 +93,3 @@ enum WarningType { }; } -} diff --git a/client/widgets/AddressItem.cpp b/client/widgets/AddressItem.cpp index 08d231d3e..b472cbe1a 100644 --- a/client/widgets/AddressItem.cpp +++ b/client/widgets/AddressItem.cpp @@ -53,7 +53,7 @@ AddressItem::AddressItem(CKey k, QWidget *parent, bool showIcon) ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); connect(ui->add, &QToolButton::clicked, this, [this]{ emit add(this);}); connect(ui->remove, &LabelButton::clicked, this, [this]{ emit remove(this);}); diff --git a/client/widgets/FileItem.cpp b/client/widgets/FileItem.cpp index f29694ee4..0b1a5473d 100644 --- a/client/widgets/FileItem.cpp +++ b/client/widgets/FileItem.cpp @@ -31,9 +31,9 @@ FileItem::FileItem(QString file, ContainerState state, QWidget *parent) ui->setupUi(this); ui->fileName->setFont(Styles::font(Styles::Regular, 14)); ui->download->setIcons(QStringLiteral("/images/icon_download.svg"), QStringLiteral("/images/icon_download_hover.svg"), QStringLiteral("/images/icon_download_pressed.svg"), 17, 17); - ui->download->init(LabelButton::White, {}, 0); + ui->download->init(LabelButton::White); ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); stateChange(state); diff --git a/client/widgets/FileList.cpp b/client/widgets/FileList.cpp index a1cc5c7aa..0fd246a80 100644 --- a/client/widgets/FileList.cpp +++ b/client/widgets/FileList.cpp @@ -41,7 +41,7 @@ FileList::FileList(QWidget *parent) { ui->download->setIcons(QStringLiteral("/images/icon_download.svg"), QStringLiteral("/images/icon_download_hover.svg"), QStringLiteral("/images/icon_download_pressed.svg"), 17, 17); - ui->download->init(LabelButton::White, QString(), 0); + ui->download->init(LabelButton::White); ui->download->installEventFilter( new ButtonHoverFilter(QStringLiteral(":/images/icon_download.svg"), QStringLiteral(":/images/icon_download_hover.svg"), this)); connect(ui->add, &LabelButton::clicked, this, &FileList::selectFile); diff --git a/client/widgets/ItemList.cpp b/client/widgets/ItemList.cpp index f99528d05..0252cf891 100644 --- a/client/widgets/ItemList.cpp +++ b/client/widgets/ItemList.cpp @@ -203,7 +203,7 @@ void ItemList::init(ItemType item, const char *header) } else { - ui->add->init(LabelButton::DeepCeruleanWithLochmara, addLabel(), itemType == ItemFile ? FileAdd : AddressAdd); + ui->add->init(LabelButton::DeepCeruleanWithLochmara, addLabel()); ui->add->setFont(Styles::font(Styles::Condensed, 12)); } diff --git a/client/widgets/LabelButton.h b/client/widgets/LabelButton.h index 59da02a6b..b17c9d641 100644 --- a/client/widgets/LabelButton.h +++ b/client/widgets/LabelButton.h @@ -39,7 +39,7 @@ class LabelButton : public QToolButton explicit LabelButton(QWidget *parent = nullptr); - void init( Style style, const QString &label, int code ); + void init(Style style, const QString &label = {}, int code = 0); void setIcons(const QString &normalIcon, const QString &hoverIcon, const QString &pressedIcon, int w, int h); signals: diff --git a/client/widgets/SignatureItem.cpp b/client/widgets/SignatureItem.cpp index cad1a904e..596aac8e8 100644 --- a/client/widgets/SignatureItem.cpp +++ b/client/widgets/SignatureItem.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include using namespace ria::qdigidoc4; @@ -62,9 +63,21 @@ SignatureItem::SignatureItem(DigiDocSignature s, ContainerState /*state*/, QWidg ui->role->installEventFilter(this); ui->remove->setIcons(QStringLiteral("/images/icon_remove.svg"), QStringLiteral("/images/icon_remove_hover.svg"), QStringLiteral("/images/icon_remove_pressed.svg"), 17, 17); - ui->remove->init(LabelButton::White, {}, 0); + ui->remove->init(LabelButton::White); ui->remove->setVisible(ui->signature.container()->isSupported()); - connect(ui->remove, &LabelButton::clicked, this, &SignatureItem::removeSignature); + connect(ui->remove, &LabelButton::clicked, this, [this]{ + const SslCertificate c = ui->signature.cert(); + auto *dlg = new WarningDialog(tr("Remove signature %1?") + .arg(c.toString(c.showCN() ? QStringLiteral("CN serialNumber") : QStringLiteral("GN SN serialNumber"))), this); + dlg->setCancelText(WarningDialog::Cancel); + dlg->resetCancelStyle(); + dlg->addButton(WarningDialog::OK, QMessageBox::Ok, true); + connect(dlg, &WarningDialog::finished, this, [this](int result) { + if(result == QMessageBox::Ok) + emit remove(this); + }); + dlg->open(); + }); init(); } @@ -194,22 +207,6 @@ QWidget* SignatureItem::lastTabWidget() return ui->remove; } -void SignatureItem::removeSignature() -{ - const SslCertificate c = ui->signature.cert(); - QString msg = tr("Remove signature %1?") - .arg(c.toString(c.showCN() ? QStringLiteral("CN serialNumber") : QStringLiteral("GN SN serialNumber"))); - - auto *dlg = WarningDialog::show(this, msg); - dlg->setCancelText(WarningDialog::Cancel); - dlg->resetCancelStyle(); - dlg->addButton(WarningDialog::OK, SignatureRemove, true); - connect(dlg, &WarningDialog::finished, this, [this](int result) { - if(result == SignatureRemove) - emit remove(this); - }); -} - void SignatureItem::updateNameField() { QTextDocument doc; diff --git a/client/widgets/SignatureItem.h b/client/widgets/SignatureItem.h index 3aa4b7974..7fe02678e 100644 --- a/client/widgets/SignatureItem.h +++ b/client/widgets/SignatureItem.h @@ -41,7 +41,6 @@ class SignatureItem final : public Item bool event(QEvent *event) final; bool eventFilter(QObject *o, QEvent *e) final; void init(); - void removeSignature(); void updateNameField(); class Private; diff --git a/debian/control b/debian/control index 45701ae71..b11f7aeca 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,9 @@ Build-Depends: libldap2-dev, libpcsclite-dev, libssl-dev, + libflatbuffers-dev, + flatbuffers-compiler-dev, + zlib1g-dev, qt6-tools-dev | qttools5-dev, qt6-l10n-tools | qttools5-dev-tools, libqt6svg6-dev | libqt5svg5-dev