Skip to content

Commit 2b48d57

Browse files
authored
Fix command line arguments parsing (#1351)
IB-8576, Fixes #1350 Signed-off-by: Raul Metsma <[email protected]>
1 parent 5a135a7 commit 2b48d57

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

client/Application.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,11 @@ bool Application::event(QEvent *event)
628628
case QEvent::FileOpen:
629629
{
630630
QString fileName = static_cast<QFileOpenEvent*>(event)->file().normalized(QString::NormalizationForm_C);
631-
QMetaObject::invokeMethod(this, [fileName = std::move(fileName)] {
632-
parseArgs({ fileName });
633-
});
631+
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
632+
QMetaObject::invokeMethod(this, [&fileName] { parseArgs({fileName}); });
633+
#else
634+
QMetaObject::invokeMethod(this, qOverload<QStringList>(&Application::parseArgs), QStringList(fileName));
635+
#endif
634636
return true;
635637
}
636638
#ifdef Q_OS_MAC
@@ -871,7 +873,7 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
871873
{
872874
if(sign)
873875
sign = params.size() != 1 || !CONTAINER_EXT.contains(QFileInfo(params.value(0)).suffix(), Qt::CaseInsensitive);
874-
QWidget *w = nullptr;
876+
MainWindow *w = nullptr;
875877
if(!newWindow && params.isEmpty())
876878
{
877879
// If no files selected (e.g. restoring minimized window), select first
@@ -921,8 +923,12 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
921923
w->show();
922924
w->activateWindow();
923925
w->raise();
924-
if( !params.isEmpty() )
925-
QMetaObject::invokeMethod(w, "open", Q_ARG(QStringList,params), Q_ARG(bool,crypto), Q_ARG(bool,sign));
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
926932
}
927933

928934
void Application::showWarning( const QString &msg, const digidoc::Exception &e )

client/MainWindow.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,12 @@ void MainWindow::openFiles(const QStringList &files, bool addFile, bool forceCre
614614
navigateToPage(page, content, create);
615615
}
616616

617-
void MainWindow::open(const QStringList &params, bool crypto, bool sign)
617+
void MainWindow::open(const QStringList &files, bool crypto, bool sign)
618618
{
619619
if (crypto && !sign)
620620
selectPage(Pages::CryptoIntro);
621621
else
622622
selectPage(Pages::SignIntro);
623-
624-
QStringList files;
625-
for(const auto &param: params)
626-
{
627-
if(QFileInfo(param).isFile())
628-
files << param;
629-
}
630-
631623
if(!files.isEmpty())
632624
openFiles(files, false, sign);
633625
}

client/MainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class MainWindow final : public QWidget
4444
explicit MainWindow(QWidget *parent = nullptr);
4545
~MainWindow() final;
4646

47+
void open(const QStringList &files, bool crypto, bool sign);
4748
void showSettings(int page);
4849

4950
protected:
@@ -71,7 +72,6 @@ class MainWindow final : public QWidget
7172
void navigateToPage( ria::qdigidoc4::Pages page, const QStringList &files = QStringList(), bool create = true );
7273
void onCryptoAction(int action, const QString &id, const QString &phone);
7374
void onSignAction(int action, const QString &info1, const QString &info2);
74-
void open(const QStringList &params, bool crypto, bool sign);
7575
void openContainer(bool signature);
7676
void openFiles(const QStringList &files, bool addFile = false, bool forceCreate = false);
7777
void pageSelected(int page, bool checked = true);

0 commit comments

Comments
 (0)