@@ -87,7 +87,7 @@ using namespace std::chrono;
8787const QStringList Application::CONTAINER_EXT {
8888 QStringLiteral (" asice" ), QStringLiteral (" sce" ),
8989 QStringLiteral (" asics" ), QStringLiteral (" scs" ),
90- QStringLiteral (" bdoc" ), QStringLiteral (" edoc" ),
90+ QStringLiteral (" bdoc" ), QStringLiteral (" edoc" ), QStringLiteral ( " adoc " ),
9191};
9292
9393class DigidocConf final : public digidoc::XmlConfCurrent
@@ -623,7 +623,7 @@ bool Application::event(QEvent *event)
623623 {
624624 case REOpenEvent::Type:
625625 if ( !activeWindow () )
626- parseArgs ();
626+ showClient ();
627627 return true ;
628628 case QEvent::FileOpen:
629629 {
@@ -841,7 +841,7 @@ void Application::parseArgs(QStringList args)
841841 suffix.endsWith (QLatin1String (" .cdoc" ), Qt::CaseInsensitive) ||
842842 suffix.endsWith (QLatin1String (" .cdoc2" ), Qt::CaseInsensitive))
843843 crypto = true ;
844- showClient (args, crypto, sign, newWindow);
844+ showClient (std::move ( args) , crypto, sign, newWindow);
845845}
846846
847847uint Application::readTSLVersion (const QString &path)
@@ -869,19 +869,28 @@ int Application::run()
869869 return exec ();
870870}
871871
872- void Application::showClient (const QStringList ¶ms , bool crypto, bool sign, bool newWindow)
872+ void Application::showClient (QStringList files , bool crypto, bool sign, bool newWindow)
873873{
874+ // Make sure all parameters are files
875+ for (auto i = files.begin (); i != files.end (); )
876+ {
877+ if (QFileInfo (*i).isFile ())
878+ ++i;
879+ else
880+ i = files.erase (i);
881+ }
882+
874883 if (sign)
875- sign = params.size () != 1 || !CONTAINER_EXT.contains (QFileInfo (params.value (0 )).suffix (), Qt::CaseInsensitive);
884+ sign = files.size () != 1 || !CONTAINER_EXT.contains (QFileInfo (files.value (0 )).suffix (), Qt::CaseInsensitive);
885+
876886 MainWindow *w = nullptr ;
877- if (! newWindow && params. isEmpty () )
878- {
879- // If no files selected (e.g. restoring minimized window), select first
887+ if (newWindow)
888+ w = nullptr ;
889+ else if (files. isEmpty ()) // If no files selected (e.g. restoring minimized window), select first
880890 w = qobject_cast<MainWindow*>(mainWindow ());
881- }
882- else if (!newWindow)
891+ else
883892 {
884- // else select first window with no open files
893+ // select first window with no open files
885894 for (auto *widget : topLevelWidgets ())
886895 {
887896 if (auto *main = qobject_cast<MainWindow*>(widget);
@@ -923,12 +932,13 @@ void Application::showClient(const QStringList ¶ms, bool crypto, bool sign,
923932 w->show ();
924933 w->activateWindow ();
925934 w->raise ();
926- if (!params.isEmpty ())
927- #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
928- QMetaObject::invokeMethod (w, [&] { w->open (params, crypto, sign); });
929- #else
930- QMetaObject::invokeMethod (w, &MainWindow::open, params, crypto, sign);
931- #endif
935+ if (files.isEmpty ())
936+ return ;
937+ QMetaObject::invokeMethod (w, [&] {
938+ using enum ria::qdigidoc4::Pages;
939+ w->selectPage (crypto && !sign ? CryptoIntro : SignIntro);
940+ w->openFiles (files, false , sign);
941+ });
932942}
933943
934944void Application::showWarning ( const QString &msg, const digidoc::Exception &e )
0 commit comments