mirror of
				https://github.com/JakubMelka/PDF4QT.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	Issue #182: PDF4QT Document Diff command line cmd line arguments ignored
This commit is contained in:
		| @@ -16,6 +16,7 @@ | |||||||
| //    along with PDF4QT.  If not, see <https://www.gnu.org/licenses/>. | //    along with PDF4QT.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| #include "pdfconstants.h" | #include "pdfconstants.h" | ||||||
|  | #include "pdfdocumentreader.h" | ||||||
| #include "mainwindow.h" | #include "mainwindow.h" | ||||||
|  |  | ||||||
| #include <QApplication> | #include <QApplication> | ||||||
| @@ -44,5 +45,40 @@ int main(int argc, char *argv[]) | |||||||
|     pdfdiff::MainWindow mainWindow(nullptr); |     pdfdiff::MainWindow mainWindow(nullptr); | ||||||
|     mainWindow.show(); |     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(); |     return application.exec(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -458,22 +458,7 @@ void MainWindow::performOperation(Operation operation) | |||||||
|             if (document) |             if (document) | ||||||
|             { |             { | ||||||
|                 clear(true, false); |                 clear(true, false); | ||||||
|                 m_leftDocument = std::move(*document); |                 setLeftDocument(std::move(*document)); | ||||||
|  |  | ||||||
|                 const size_t pageCount = m_leftDocument.getCatalog()->getPageCount(); |  | ||||||
|                 if (pageCount > 1) |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getLeftPageSelectionEdit()->setText(QString("1-%2").arg(pageCount)); |  | ||||||
|                 } |  | ||||||
|                 else if (pageCount == 1) |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getLeftPageSelectionEdit()->setText("1"); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getLeftPageSelectionEdit()->clear(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 updateViewDocument(); |                 updateViewDocument(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -489,22 +474,7 @@ void MainWindow::performOperation(Operation operation) | |||||||
|             if (document) |             if (document) | ||||||
|             { |             { | ||||||
|                 clear(false, true); |                 clear(false, true); | ||||||
|                 m_rightDocument = std::move(*document); |                 setRightDocument(std::move(*document)); | ||||||
|  |  | ||||||
|                 const size_t pageCount = m_rightDocument.getCatalog()->getPageCount(); |  | ||||||
|                 if (pageCount > 1) |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getRightPageSelectionEdit()->setText(QString("1-%2").arg(pageCount)); |  | ||||||
|                 } |  | ||||||
|                 else if (pageCount == 1) |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getRightPageSelectionEdit()->setText("1"); |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     m_settingsDockWidget->getRightPageSelectionEdit()->clear(); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 updateViewDocument(); |                 updateViewDocument(); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -863,6 +833,44 @@ std::optional<pdf::PDFDocument> MainWindow::openDocument() | |||||||
|     return pdf::PDFDocument(); |     return pdf::PDFDocument(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void MainWindow::setRightDocument(pdf::PDFDocument&& newRightDocument) | ||||||
|  | { | ||||||
|  |     m_rightDocument = newRightDocument; | ||||||
|  |  | ||||||
|  |     const size_t pageCount = m_rightDocument.getCatalog()->getPageCount(); | ||||||
|  |     if (pageCount > 1) | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getRightPageSelectionEdit()->setText(QString("1-%2").arg(pageCount)); | ||||||
|  |     } | ||||||
|  |     else if (pageCount == 1) | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getRightPageSelectionEdit()->setText("1"); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getRightPageSelectionEdit()->clear(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void MainWindow::setLeftDocument(pdf::PDFDocument&& newLeftDocument) | ||||||
|  | { | ||||||
|  |     m_leftDocument = newLeftDocument; | ||||||
|  |  | ||||||
|  |     const size_t pageCount = m_leftDocument.getCatalog()->getPageCount(); | ||||||
|  |     if (pageCount > 1) | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getLeftPageSelectionEdit()->setText(QString("1-%2").arg(pageCount)); | ||||||
|  |     } | ||||||
|  |     else if (pageCount == 1) | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getLeftPageSelectionEdit()->setText("1"); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         m_settingsDockWidget->getLeftPageSelectionEdit()->clear(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| void MainWindow::onProgressStarted(pdf::ProgressStartupInfo info) | void MainWindow::onProgressStarted(pdf::ProgressStartupInfo info) | ||||||
| { | { | ||||||
| #ifdef WIN_TASKBAR_BUTTON | #ifdef WIN_TASKBAR_BUTTON | ||||||
|   | |||||||
| @@ -84,6 +84,14 @@ public: | |||||||
|     virtual void showEvent(QShowEvent* event) override; |     virtual void showEvent(QShowEvent* event) override; | ||||||
|     virtual void closeEvent(QCloseEvent* event) override; |     virtual void closeEvent(QCloseEvent* event) override; | ||||||
|  |  | ||||||
|  |     void setLeftDocument(pdf::PDFDocument&& newLeftDocument); | ||||||
|  |     void setRightDocument(pdf::PDFDocument&& newRightDocument); | ||||||
|  |  | ||||||
|  |     void updateViewDocument(); | ||||||
|  |  | ||||||
|  |     bool canPerformOperation(Operation operation) const; | ||||||
|  |     void performOperation(Operation operation); | ||||||
|  |  | ||||||
| private slots: | private slots: | ||||||
|     void updateActions(); |     void updateActions(); | ||||||
|     void onSelectionChanged(size_t currentIndex); |     void onSelectionChanged(size_t currentIndex); | ||||||
| @@ -100,9 +108,6 @@ private: | |||||||
|     void loadSettings(); |     void loadSettings(); | ||||||
|     void saveSettings(); |     void saveSettings(); | ||||||
|  |  | ||||||
|     bool canPerformOperation(Operation operation) const; |  | ||||||
|     void performOperation(Operation operation); |  | ||||||
|  |  | ||||||
|     void setViewDocument(pdf::PDFDocument* document, bool updateCustomPageLayout); |     void setViewDocument(pdf::PDFDocument* document, bool updateCustomPageLayout); | ||||||
|  |  | ||||||
|     ComparedDocumentMapper::Mode getDocumentViewMode() const; |     ComparedDocumentMapper::Mode getDocumentViewMode() const; | ||||||
| @@ -115,7 +120,6 @@ private: | |||||||
|  |  | ||||||
|     void updateAll(bool resetFilters); |     void updateAll(bool resetFilters); | ||||||
|     void updateFilteredResult(); |     void updateFilteredResult(); | ||||||
|     void updateViewDocument(); |  | ||||||
|     void updateCustomPageLayout(); |     void updateCustomPageLayout(); | ||||||
|     void updateOverlayTransparency(); |     void updateOverlayTransparency(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,12 +1,16 @@ | |||||||
| CURRENT: | CURRENT: | ||||||
|  |  - Issue #182: PDF4QT Document Diff command line cmd line arguments ignored | ||||||
|  - Issue #173: errors loading file Echoplex.pdf |  - Issue #173: errors loading file Echoplex.pdf | ||||||
|  - Issue #172: access keys are missing from most menu items/action text strings |  - Issue #172: access keys are missing from most menu items/action text strings | ||||||
|  - Issue #168: When opening a PDF file or merging some PDF files, stamp will disappear. |  - Issue #168: When opening a PDF file or merging some PDF files, stamp will disappear. | ||||||
|  |  - Issue #166: Adding images to PDF?  | ||||||
|  - Issue #164: Taskbar icon not shown in linux mint. |  - Issue #164: Taskbar icon not shown in linux mint. | ||||||
|  - Issue #163: Unable to render probably valid PDF |  - Issue #163: Unable to render probably valid PDF | ||||||
|  - Issue #161: Can it be possible to trust a certificate like in acrobat?  |  - Issue #161: Can it be possible to trust a certificate like in acrobat?  | ||||||
|  - Issue #159: Offer 4 AppImage one for each App [enhancement]  |  - Issue #159: Offer 4 AppImage one for each App [enhancement]  | ||||||
|  - Issue #123: Alternative software rendering backend (Blend2D) |  - Issue #123: Alternative software rendering backend (Blend2D) | ||||||
|  |  - Issue #42: Is REAL pdf text editing planned ? | ||||||
|  |  - Issue #26: Add pictures in PDF files  | ||||||
|  |  | ||||||
| V: 1.3.7 10.1.2024 | V: 1.3.7 10.1.2024 | ||||||
|  - Issue #142: Cannot reach the top |  - Issue #142: Cannot reach the top | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user