Skip to content

Commit

Permalink
Return only MainWindow and QDialog parent windows
Browse files Browse the repository at this point in the history
IB-8091, IB-8092

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Jun 3, 2024
1 parent 7bdd13f commit 405f475
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
37 changes: 18 additions & 19 deletions client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ class DigidocConf final: public digidoc::XmlConfCurrent
static bool isAllowed = false;
if(!isAllowed)
{
QEventLoop e;
QMetaObject::invokeMethod( qApp, "showTSLWarning", Q_ARG(QEventLoop*,&e) );
e.exec();
dispatchToMain([] {
WarningDialog::show(Application::tr(
"The renewal of Trust Service status List, used for digital signature validation, has failed. "
"Please check your internet connection and make sure you have the latest ID-software version "
"installed. An expired Trust Service List (TSL) will be used for signature validation. "
"<a href=\"https://www.id.ee/en/article/digidoc4-message-updating-the-list-of-trusted-certificates-was-unsuccessful/\">Additional information</a>"), QString());
});
isAllowed = true;
}
return isAllowed;
Expand Down Expand Up @@ -435,9 +439,8 @@ Application::Application( int &argc, char **argv )
qDebug() << "TSL loading finished";
Q_EMIT qApp->TSLLoadingFinished();
qApp->d->ready = true;
if(ex) {
if(ex)
dispatchToMain(showWarning, tr("Failed to initalize."), *ex);
}
}
);
}
Expand Down Expand Up @@ -472,10 +475,10 @@ Application::Application( int &argc, char **argv )
{
Settings::SHOW_INTRO = false;
auto *dlg = new FirstRun(mainWindow());
connect(dlg, &FirstRun::langChanged, this, [this](const QString& lang) { loadTranslation( lang ); });
connect(dlg, &FirstRun::langChanged, this, &Application::loadTranslation);
dlg->open();
}
});
}, Qt::QueuedConnection);

if( !args.isEmpty() || topLevelWindows().isEmpty() )
parseArgs(std::move(args));
Expand Down Expand Up @@ -740,15 +743,21 @@ void Application::mailTo( const QUrl &url )

QWidget* Application::mainWindow()
{
if(QWidget *win = qobject_cast<MainWindow*>(activeWindow()))
if(auto *win = qobject_cast<MainWindow*>(activeWindow()))
return win;
if(auto *win = qobject_cast<QDialog*>(activeWindow()))
return win;
auto list = topLevelWidgets();
// Prefer main window; on Mac also the menu is top level window
if(auto i = std::find_if(list.cbegin(), list.cend(),
[](QWidget *widget) { return qobject_cast<MainWindow*>(widget); });
i != list.cend())
return *i;
return list.value(0);
if(auto i = std::find_if(list.cbegin(), list.cend(),
[](QWidget *widget) { return qobject_cast<QDialog*>(widget); });
i != list.cend())
return *i;
return nullptr;
}

bool Application::notify(QObject *object, QEvent *event)
Expand Down Expand Up @@ -915,16 +924,6 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
QMetaObject::invokeMethod(w, "open", Q_ARG(QStringList,params), Q_ARG(bool,crypto), Q_ARG(bool,sign));
}

void Application::showTSLWarning(QEventLoop *e)
{
auto *dlg = WarningDialog::show(tr(
"The renewal of Trust Service status List, used for digital signature validation, has failed. "
"Please check your internet connection and make sure you have the latest ID-software version "
"installed. An expired Trust Service List (TSL) will be used for signature validation. "
"<a href=\"https://www.id.ee/en/article/digidoc4-message-updating-the-list-of-trusted-certificates-was-unsuccessful/\">Additional information</a>"));
connect(dlg, &WarningDialog::finished, e, &QEventLoop::quit);
}

void Application::showWarning( const QString &msg, const digidoc::Exception &e )
{
digidoc::Exception::ExceptionCode code = digidoc::Exception::General;
Expand Down
1 change: 0 additions & 1 deletion client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class Application final: public Common
private Q_SLOTS:
static void browse(const QUrl &url);
static void mailTo(const QUrl &url);
static void showTSLWarning( QEventLoop *e );

Q_SIGNALS:
void TSLLoadingFinished();
Expand Down

0 comments on commit 405f475

Please sign in to comment.