Skip to content

Commit a1fa042

Browse files
committed
Fix command line arguments parsing
IB-8576, Fixes #1350 Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent 5a135a7 commit a1fa042

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

client/Application.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,7 @@ 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+
QMetaObject::invokeMethod(this, qOverload<QStringList>(&Application::parseArgs), QStringList(fileName));
634632
return true;
635633
}
636634
#ifdef Q_OS_MAC
@@ -871,7 +869,7 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
871869
{
872870
if(sign)
873871
sign = params.size() != 1 || !CONTAINER_EXT.contains(QFileInfo(params.value(0)).suffix(), Qt::CaseInsensitive);
874-
QWidget *w = nullptr;
872+
MainWindow *w = nullptr;
875873
if(!newWindow && params.isEmpty())
876874
{
877875
// If no files selected (e.g. restoring minimized window), select first
@@ -921,8 +919,8 @@ void Application::showClient(const QStringList &params, bool crypto, bool sign,
921919
w->show();
922920
w->activateWindow();
923921
w->raise();
924-
if( !params.isEmpty() )
925-
QMetaObject::invokeMethod(w, "open", Q_ARG(QStringList,params), Q_ARG(bool,crypto), Q_ARG(bool,sign));
922+
if(!params.isEmpty())
923+
QMetaObject::invokeMethod(w, &MainWindow::open, params, crypto, sign);
926924
}
927925

928926
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)