diff --git a/client/Application.cpp b/client/Application.cpp index 320198bf0..84ea6fe46 100644 --- a/client/Application.cpp +++ b/client/Application.cpp @@ -38,6 +38,7 @@ class MacMenuBar {}; #include "dialogs/SettingsDialog.h" #include "dialogs/WaitDialog.h" #include "dialogs/WarningDialog.h" +#include "effects/Overlay.h" #include @@ -336,7 +337,7 @@ Application::Application( int &argc, char **argv ) QTimer::singleShot(0, this, [this] { auto lessThanVersion = [](QLatin1String key) { return QVersionNumber::fromString(applicationVersion()) < - QVersionNumber::fromString(confValue(key).toString()); + QVersionNumber::fromString(confValue(key).toString()); }; WarningDialog *dlg{}; if(lessThanVersion(QLatin1String("QDIGIDOC4-UNSUPPORTED"))) @@ -357,13 +358,17 @@ Application::Application( int &argc, char **argv ) "macOS users can download the latest ID-software version from the " "Mac App Store.")); } - connect(d->conf, &Configuration::finished, this, [&](bool changed, const QString &){ + connect(d->conf, &Configuration::finished, this, [lessThanVersion](bool changed, const QString &){ if(changed && lessThanVersion(QLatin1String("QDIGIDOC4-LATEST"))) - dlg = WarningDialog::show(tr( + { + auto dlg = new WarningDialog(tr( "An ID-software update has been found. To download the update, go to the " "id.ee website. " "macOS users can download the update from the " - "Mac App Store.")); + "Mac App Store."), activeWindow()); + new Overlay(dlg, activeWindow()); + dlg->exec(); + } }); #ifdef Q_OS_WIN if(dlg) @@ -430,22 +435,7 @@ Application::Application( int &argc, char **argv ) { digidoc::Conf::init( new DigidocConf ); d->signer = new QSigner(this); - QString cache = confValue(TSLCache).toString(); - QDir().mkpath( cache ); - QDateTime tslTime = QDateTime::currentDateTimeUtc().addDays(-7); - for(const QString &file: QDir(QStringLiteral(":/TSL/")).entryList()) - { - QFile tl(cache + "/" + file); - if(!tl.exists() || - readTSLVersion(":/TSL/" + file) > readTSLVersion(tl.fileName())) - { - tl.remove(); - QFile::copy(":/TSL/" + file, tl.fileName()); - tl.setPermissions(QFile::Permissions(0x6444)); - if(tl.open(QFile::Append)) - tl.setFileTime(tslTime, QFileDevice::FileModificationTime); - } - } + updateTSLCache(QDateTime::currentDateTimeUtc().addDays(-7)); digidoc::initialize(applicationName().toUtf8().constData(), QStringLiteral("%1/%2 (%3)") .arg(applicationName(), applicationVersion(), applicationOs()).toUtf8().constData(), @@ -956,6 +946,27 @@ void Application::showWarning( const QString &msg, const digidoc::Exception &e ) QSigner* Application::signer() const { return d->signer; } +void Application::updateTSLCache(const QDateTime &tslTime) +{ + QString cache = confValue(Application::TSLCache).toString(); + QDir().mkpath(cache); + const QStringList tsllist = QDir(QStringLiteral(":/TSL/")).entryList(); + for(const QString &file: tsllist) + { + if(QFile tl(cache + "/" + file); + Application::readTSLVersion(":/TSL/" + file) > Application::readTSLVersion(tl.fileName())) + { + const QStringList cleanup = QDir(cache, file + QStringLiteral("*")).entryList(); + for(const QString &rm: cleanup) + QFile::remove(cache + "/" + rm); + QFile::copy(":/TSL/" + file, tl.fileName()); + tl.setPermissions(QFile::Permissions(0x6444)); + if(tslTime.isValid() && tl.open(QFile::Append)) + tl.setFileTime(tslTime, QFileDevice::FileModificationTime); + } + } +} + void Application::waitForTSL( const QString &file ) { if(!CONTAINER_EXT.contains(QFileInfo(file).suffix(), Qt::CaseInsensitive)) diff --git a/client/Application.h b/client/Application.h index 373805c18..8c3adaf2d 100644 --- a/client/Application.h +++ b/client/Application.h @@ -75,6 +75,7 @@ class Application final: public Common static uint readTSLVersion(const QString &path); static void setConfValue( ConfParameter parameter, const QVariant &value ); static void showClient(const QStringList ¶ms = {}, bool crypto = false, bool sign = false, bool newWindow = false); + static void updateTSLCache(const QDateTime &tslTime); private Q_SLOTS: static void browse(const QUrl &url); diff --git a/client/dialogs/AddRecipients.cpp b/client/dialogs/AddRecipients.cpp index cc9bb1a91..19a5d2896 100644 --- a/client/dialogs/AddRecipients.cpp +++ b/client/dialogs/AddRecipients.cpp @@ -57,7 +57,7 @@ AddRecipients::AddRecipients(ItemList* itemList, QWidget *parent) ui->actionLayout->setDirection(QBoxLayout::RightToLeft); #endif setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint ); - new Overlay(this, parent); + new Overlay(this); ui->leftPane->init(ria::qdigidoc4::ToAddAdresses, QT_TRANSLATE_NOOP("ItemList", "Add recipients")); ui->leftPane->setFont(Styles::font(Styles::Regular, 20)); diff --git a/client/dialogs/CertificateDetails.cpp b/client/dialogs/CertificateDetails.cpp index 4f4a01fcb..daf595f64 100644 --- a/client/dialogs/CertificateDetails.cpp +++ b/client/dialogs/CertificateDetails.cpp @@ -46,7 +46,7 @@ CertificateDetails::CertificateDetails(const SslCertificate &cert, QWidget *pare #else setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); #endif - new Overlay(this, parent); + new Overlay(this); QFont headerFont = Styles::font( Styles::Regular, 18 ); QFont regularFont = Styles::font( Styles::Regular, 14 ); diff --git a/client/dialogs/KeyDialog.cpp b/client/dialogs/KeyDialog.cpp index 41f93d0ff..b9b662ca3 100644 --- a/client/dialogs/KeyDialog.cpp +++ b/client/dialogs/KeyDialog.cpp @@ -38,7 +38,7 @@ KeyDialog::KeyDialog( const CKey &k, QWidget *parent ) #endif setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint); setAttribute(Qt::WA_DeleteOnClose); - new Overlay(this, parent); + new Overlay(this); QFont condensed = Styles::font(Styles::Condensed, 12); QFont regular = Styles::font(Styles::Regular, 14); diff --git a/client/dialogs/MobileDialog.cpp b/client/dialogs/MobileDialog.cpp index 2c42fc2c5..00dc68c6a 100644 --- a/client/dialogs/MobileDialog.cpp +++ b/client/dialogs/MobileDialog.cpp @@ -30,7 +30,7 @@ MobileDialog::MobileDialog(QWidget *parent) : ui(new Ui::MobileDialog) { static const QStringList countryCodes {QStringLiteral("372"), QStringLiteral("370")}; - new Overlay(this, parent); + new Overlay(this); ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); setFixedSize(size()); diff --git a/client/dialogs/PinPopup.cpp b/client/dialogs/PinPopup.cpp index aef78c9ba..a869ffb17 100644 --- a/client/dialogs/PinPopup.cpp +++ b/client/dialogs/PinPopup.cpp @@ -50,7 +50,7 @@ PinPopup::PinPopup(PinFlags flags, const QString &title, TokenFlags count, QWidg setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); for(QLineEdit *w: findChildren()) w->setAttribute(Qt::WA_MacShowFocusRect, false); - new Overlay(this, parent); + new Overlay(this); ui->labelNameId->setFont(Styles::font(Styles::Regular, 20, QFont::DemiBold)); ui->label->setFont(Styles::font(Styles::Regular, 14)); diff --git a/client/dialogs/PinUnblock.cpp b/client/dialogs/PinUnblock.cpp index 6ca01cba0..cb3d5f448 100644 --- a/client/dialogs/PinUnblock.cpp +++ b/client/dialogs/PinUnblock.cpp @@ -40,7 +40,7 @@ PinUnblock::PinUnblock(WorkMode mode, QWidget *parent, QSmartCardData::PinType t list.first()->setFocus(); for(QLineEdit *w: list) w->setAttribute(Qt::WA_MacShowFocusRect, false); - new Overlay(this, parent); + new Overlay(this); QFont condensed14 = Styles::font(Styles::Condensed, 14); QFont condensed12 = Styles::font(Styles::Condensed, 12); diff --git a/client/dialogs/RoleAddressDialog.cpp b/client/dialogs/RoleAddressDialog.cpp index f8c5a469b..3c23882ab 100644 --- a/client/dialogs/RoleAddressDialog.cpp +++ b/client/dialogs/RoleAddressDialog.cpp @@ -90,7 +90,7 @@ int RoleAddressDialog::get(QString &city, QString &country, QString &state, QStr { if(!Settings::SHOW_ROLE_ADDRESS_INFO) return QDialog::Accepted; - new Overlay(this, parentWidget()); + new Overlay(this); int result = QDialog::exec(); if(result == QDialog::Rejected) return result; diff --git a/client/dialogs/SettingsDialog.cpp b/client/dialogs/SettingsDialog.cpp index ca8eb0dde..17ef5262d 100644 --- a/client/dialogs/SettingsDialog.cpp +++ b/client/dialogs/SettingsDialog.cpp @@ -60,7 +60,7 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent) : QDialog(parent) , ui(new Ui::SettingsDialog) { - new Overlay(this, parent); + new Overlay(this); ui->setupUi(this); setWindowFlag(Qt::FramelessWindowHint); @@ -196,7 +196,8 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent) WarningDialog::show(this, tr("Checking updates has failed.") + "
" + tr("Please try again."), error); return; } - WarningDialog::show(this, tr("DigiDoc4 Client configuration update was successful.")); + auto dlg = WarningDialog::show(this, tr("DigiDoc4 Client configuration update was successful.")); + new Overlay(dlg); #ifdef Q_OS_WIN QString path = QApplication::applicationDirPath() + QLatin1String("/id-updater.exe"); if (QFile::exists(path)) @@ -210,7 +211,7 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent) connect(ui->btnCheckConnection, &QPushButton::clicked, this, &SettingsDialog::checkConnection); connect(ui->btnFirstRun, &QPushButton::clicked, this, [this] { - FirstRun *dlg = new FirstRun(this); + auto *dlg = new FirstRun(this); connect(dlg, &FirstRun::langChanged, this, [this](const QString &lang) { retranslate(lang); selectLanguage(); @@ -221,21 +222,7 @@ SettingsDialog::SettingsDialog(int page, QWidget *parent) #ifdef CONFIG_URL qApp->conf()->update(true); #endif - QString cache = Application::confValue(Application::TSLCache).toString(); - const QStringList tsllist = QDir(QStringLiteral(":/TSL/")).entryList(); - for(const QString &file: tsllist) - { - if(const QString target = cache + "/" + file; - !QFile::exists(target) || - Application::readTSLVersion(":/TSL/" + file) > Application::readTSLVersion(target)) - { - const QStringList cleanup = QDir(cache, file + QStringLiteral("*")).entryList(); - for(const QString &rm: cleanup) - QFile::remove(cache + "/" + rm); - QFile::copy(":/TSL/" + file, target); - QFile::setPermissions(target, QFile::Permissions(0x6444)); - } - } + Application::updateTSLCache({}); }); connect( ui->btnNavUseByDefault, &QPushButton::clicked, this, &SettingsDialog::useDefaultSettings ); connect( ui->btnNavSaveReport, &QPushButton::clicked, this, [=]{ diff --git a/client/dialogs/SignatureDialog.cpp b/client/dialogs/SignatureDialog.cpp index aaa2ece5b..e0bb8efc5 100644 --- a/client/dialogs/SignatureDialog.cpp +++ b/client/dialogs/SignatureDialog.cpp @@ -46,7 +46,7 @@ SignatureDialog::SignatureDialog(const DigiDocSignature &signature, QWidget *par connect(d->showRole, &AccordionTitle::opened, d->showErrors, &AccordionTitle::openSection); connect(d->showRole, &AccordionTitle::closed, this, [this] { d->showErrors->setSectionOpen(); }); - new Overlay(this, parent); + new Overlay(this); SslCertificate c = signature.cert(); QString style = QStringLiteral(""); diff --git a/client/dialogs/SmartIDDialog.cpp b/client/dialogs/SmartIDDialog.cpp index 0ed5a220f..8ea8aec9a 100644 --- a/client/dialogs/SmartIDDialog.cpp +++ b/client/dialogs/SmartIDDialog.cpp @@ -30,7 +30,7 @@ SmartIDDialog::SmartIDDialog(QWidget *parent) , ui(new Ui::SmartIDDialog) { static const QString &EE = Settings::SMARTID_COUNTRY_LIST.first(); - new Overlay(this, parent); + new Overlay(this); ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint); diff --git a/client/dialogs/WaitDialog.cpp b/client/dialogs/WaitDialog.cpp index aaccf4630..ffbcadda4 100644 --- a/client/dialogs/WaitDialog.cpp +++ b/client/dialogs/WaitDialog.cpp @@ -32,7 +32,7 @@ WaitDialog::WaitDialog(QWidget *parent) : QDialog(parent) , ui(new Ui::WaitDialog) { - new Overlay(this, parent); + new Overlay(this); setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint); ui->setupUi(this); ui->movie->load(QStringLiteral(":/images/wait.svg")); diff --git a/client/effects/Overlay.cpp b/client/effects/Overlay.cpp index c4c910bb8..ddbbce491 100644 --- a/client/effects/Overlay.cpp +++ b/client/effects/Overlay.cpp @@ -22,6 +22,10 @@ #include #include +Overlay::Overlay(QWidget *runner) + : Overlay(runner, runner->parentWidget()) +{} + Overlay::Overlay(QWidget *runner, QWidget *parent) : QWidget(parent->topLevelWidget()) { diff --git a/client/effects/Overlay.h b/client/effects/Overlay.h index ff63607b9..7650b019f 100644 --- a/client/effects/Overlay.h +++ b/client/effects/Overlay.h @@ -25,6 +25,7 @@ class Overlay final : public QWidget { Q_OBJECT public: + Overlay(QWidget *runner); Overlay(QWidget *runner, QWidget *parent); ~Overlay() final;