Issue #182: PDF4QT Document Diff command line cmd line arguments ignored

This commit is contained in:
Jakub Melka
2024-06-26 18:49:31 +02:00
parent 1e79871b9b
commit 625a4307d0
4 changed files with 88 additions and 36 deletions

View File

@ -16,6 +16,7 @@
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
#include "pdfconstants.h"
#include "pdfdocumentreader.h"
#include "mainwindow.h"
#include <QApplication>
@ -44,5 +45,40 @@ int main(int argc, char *argv[])
pdfdiff::MainWindow mainWindow(nullptr);
mainWindow.show();
QStringList positionalArguments = parser.positionalArguments();
if (positionalArguments.size() >= 1)
{
bool leftDocumentIsOK = false;
bool rightDocumentIsOk = false;
pdf::PDFDocumentReader reader(nullptr, [](bool* ok) { *ok = false; return QString(); }, true, false);
pdf::PDFDocument documentLeft = reader.readFromFile(positionalArguments.front());
if (reader.getReadingResult() == pdf::PDFDocumentReader::Result::OK)
{
leftDocumentIsOK = true;
mainWindow.setLeftDocument(std::move(documentLeft));
}
if (positionalArguments.size() >= 2)
{
pdf::PDFDocument documentRight = reader.readFromFile(positionalArguments[1]);
if (reader.getReadingResult() == pdf::PDFDocumentReader::Result::OK)
{
rightDocumentIsOk = true;
mainWindow.setRightDocument(std::move(documentRight));
}
}
mainWindow.updateViewDocument();
if (leftDocumentIsOK && rightDocumentIsOk && mainWindow.canPerformOperation(pdfdiff::MainWindow::Operation::Compare))
{
mainWindow.performOperation(pdfdiff::MainWindow::Operation::Compare);
}
}
return application.exec();
}