From 014a31fa3cfee6a7b051ffc90e059e6a7c86848e Mon Sep 17 00:00:00 2001
From: Albert S <mail@quitesimple.org>
Date: Mon, 19 Aug 2019 20:02:28 +0200
Subject: [PATCH] gui: fix passing args to pdfviewer (paths with spaces work
 now)

---
 gui/mainwindow.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 644cfc8..8e0b33a 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -129,13 +129,14 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview)
 					QString command = settings.value("pdfviewer").toString();
 					if(command != "" && command.contains("%p") && command.contains("%f"))
 					{
-						command = command.replace("%f", preview.documentPath);
-						command = command.replace("%p", QString::number(preview.page));
 						QStringList splitted = command.split(" ");
 						if(splitted.size() > 1)
 						{
 							QString cmd = splitted[0];
 							QStringList args = splitted.mid(1);
+							args.replaceInStrings("%f", preview.documentPath);
+							args.replaceInStrings("%p", QString::number(preview.page));
+
 							QProcess::startDetached(cmd, args);
 						}
 					}