From 8ffc4f918942ebf00a7e6e2ba3f11e11e068155e Mon Sep 17 00:00:00 2001 From: Jakub Melka Date: Sun, 11 Sep 2022 17:54:11 +0200 Subject: [PATCH] Issue #25: MinGW compilation fix --- CMakeLists.txt | 6 ++- CodeGenerator/codegenerator.cpp | 3 +- Pdf4QtDocDiff/main.cpp | 1 - Pdf4QtDocPageOrganizer/main.cpp | 1 - Pdf4QtLib/CMakeLists.txt | 4 ++ Pdf4QtLib/sources/pdfcertificatemanager.cpp | 9 ++++ Pdf4QtLib/sources/pdfdiff.cpp | 3 +- Pdf4QtLib/sources/pdfdrawwidget.cpp | 3 +- Pdf4QtLib/sources/pdfencoding.cpp | 4 +- Pdf4QtLib/sources/pdfparser.cpp | 12 ++--- Pdf4QtLib/sources/pdfsecurityhandler.cpp | 10 +++++ Pdf4QtLib/sources/pdfsignaturehandler.cpp | 11 ++++- Pdf4QtLib/sources/pdfxfaengine.cpp | 20 ++++----- Pdf4QtViewer/pdfdocumentpropertiesdialog.cpp | 2 +- Pdf4QtViewer/pdfencryptionsettingsdialog.cpp | 44 ++++++++++-------- Pdf4QtViewer/pdfencryptionsettingsdialog.h | 4 ++ Pdf4QtViewer/pdfencryptionsettingsdialog.ui | 45 ++++++------------- Pdf4QtViewer/pdfrecentfilemanager.cpp | 2 +- Pdf4QtViewer/pdfsendmail.cpp | 3 ++ Pdf4QtViewerLite/main.cpp | 1 - .../AudioBookPlugin/CMakeLists.txt | 4 ++ .../objectinspectordialog.cpp | 20 +++++---- .../objectinspectordialog.h | 2 + .../objectinspectordialog.ui | 14 +----- .../objectstatisticsdialog.cpp | 7 ++- .../objectstatisticsdialog.h | 2 + .../objectstatisticsdialog.ui | 13 +----- .../outputpreviewdialog.cpp | 23 +++++----- .../OutputPreviewPlugin/outputpreviewdialog.h | 1 + .../outputpreviewdialog.ui | 13 +----- Pdf4QtViewerProfi/main.cpp | 1 - PdfTool/CMakeLists.txt | 4 ++ PdfTool/pdftoolfetchimages.cpp | 3 +- PdfTool/pdftoolinfo.cpp | 2 +- PdfTool/pdftoolrender.cpp | 3 +- 35 files changed, 160 insertions(+), 140 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e040bc..cf36cf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,11 @@ set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC_OPTIONS "--threshold;0;--compress;9") if (MSVC) - add_compile_options(/bigobj) + add_compile_options(/bigobj) +endif() + +if (MINGW) + add_compile_options("-Wa,-mbig-obj") endif() add_subdirectory(Pdf4QtLib) diff --git a/CodeGenerator/codegenerator.cpp b/CodeGenerator/codegenerator.cpp index ea7329d..5500b3e 100644 --- a/CodeGenerator/codegenerator.cpp +++ b/CodeGenerator/codegenerator.cpp @@ -86,8 +86,7 @@ void GeneratedCodeStorage::generateCode(QTextStream& stream, CodeGeneratorParame QObject* Serializer::load(const QDomElement& element, QObject* parent) { QString className = element.attribute("class"); - const int metaTypeId = QMetaType::type(className.toLatin1()); - const QMetaObject* metaObject = QMetaType::metaObjectForType(metaTypeId); + const QMetaObject* metaObject = QMetaType::fromName(QByteArrayView(className.toLatin1())).metaObject(); if (metaObject) { diff --git a/Pdf4QtDocDiff/main.cpp b/Pdf4QtDocDiff/main.cpp index ad0f7aa..1726712 100644 --- a/Pdf4QtDocDiff/main.cpp +++ b/Pdf4QtDocDiff/main.cpp @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true); - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity, true); QApplication application(argc, argv); diff --git a/Pdf4QtDocPageOrganizer/main.cpp b/Pdf4QtDocPageOrganizer/main.cpp index 1c740f0..9992c16 100644 --- a/Pdf4QtDocPageOrganizer/main.cpp +++ b/Pdf4QtDocPageOrganizer/main.cpp @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true); - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity, true); QApplication application(argc, argv); diff --git a/Pdf4QtLib/CMakeLists.txt b/Pdf4QtLib/CMakeLists.txt index cff1563..42ea6cb 100644 --- a/Pdf4QtLib/CMakeLists.txt +++ b/Pdf4QtLib/CMakeLists.txt @@ -116,6 +116,10 @@ target_link_libraries(Pdf4QtLib PRIVATE freetype) target_link_libraries(Pdf4QtLib PRIVATE openjp2) target_link_libraries(Pdf4QtLib PRIVATE JPEG::JPEG) +if(MINGW) + target_link_libraries(Pdf4QtLib PRIVATE Secur32 Mscms Gdi32 User32 crypt32) +endif() + target_include_directories(Pdf4QtLib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/sources) target_include_directories(Pdf4QtLib PUBLIC ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}) diff --git a/Pdf4QtLib/sources/pdfcertificatemanager.cpp b/Pdf4QtLib/sources/pdfcertificatemanager.cpp index 9304621..263010a 100644 --- a/Pdf4QtLib/sources/pdfcertificatemanager.cpp +++ b/Pdf4QtLib/sources/pdfcertificatemanager.cpp @@ -21,6 +21,11 @@ #include #include +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + #include #include #include @@ -249,3 +254,7 @@ bool PDFSignatureFactory::sign(QString certificateName, QString password, QByteA } } // namespace pdf + +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic pop +#endif diff --git a/Pdf4QtLib/sources/pdfdiff.cpp b/Pdf4QtLib/sources/pdfdiff.cpp index b5903b2..fd72345 100644 --- a/Pdf4QtLib/sources/pdfdiff.cpp +++ b/Pdf4QtLib/sources/pdfdiff.cpp @@ -883,7 +883,8 @@ void PDFDiff::finalizeGraphicsPieces(PDFDiffPageContext& context) continue; } - hasher.addData(reinterpret_cast(info.hash.data()), int(info.hash.size())); + QByteArrayView view(reinterpret_cast(info.hash.data()), info.hash.size()); + hasher.addData(view); } QByteArray hash = hasher.result(); diff --git a/Pdf4QtLib/sources/pdfdrawwidget.cpp b/Pdf4QtLib/sources/pdfdrawwidget.cpp index b145652..42ff232 100644 --- a/Pdf4QtLib/sources/pdfdrawwidget.cpp +++ b/Pdf4QtLib/sources/pdfdrawwidget.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace pdf { @@ -566,7 +567,7 @@ PDFOpenGLDrawWidget::PDFOpenGLDrawWidget(PDFWidget* widget, int samplesCount, QW QSurfaceFormat format = this->format(); format.setProfile(QSurfaceFormat::CoreProfile); format.setSamples(samplesCount); - format.setColorSpace(QSurfaceFormat::sRGBColorSpace); + format.setColorSpace(QColorSpace(QColorSpace::SRgb)); format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); setFormat(format); } diff --git a/Pdf4QtLib/sources/pdfencoding.cpp b/Pdf4QtLib/sources/pdfencoding.cpp index 09048d3..18b4683 100644 --- a/Pdf4QtLib/sources/pdfencoding.cpp +++ b/Pdf4QtLib/sources/pdfencoding.cpp @@ -2233,9 +2233,9 @@ QString PDFEncoding::convertTextString(const QByteArray& stream) QString PDFEncoding::convertFromUnicode(const QByteArray& stream) { - const ushort* bytes = reinterpret_cast(stream.data()); + const char16_t* bytes = reinterpret_cast(stream.data()); const int sizeInChars = stream.size(); - const int sizeSizeInUShorts = sizeInChars / sizeof(const ushort) * sizeof(char); + const size_t sizeSizeInUShorts = sizeInChars / sizeof(const ushort) * sizeof(char); return QString::fromUtf16(bytes, sizeSizeInUShorts); } diff --git a/Pdf4QtLib/sources/pdfparser.cpp b/Pdf4QtLib/sources/pdfparser.cpp index 99f772e..78c8221 100644 --- a/Pdf4QtLib/sources/pdfparser.cpp +++ b/Pdf4QtLib/sources/pdfparser.cpp @@ -705,7 +705,7 @@ PDFObject PDFParser::getObject() { case PDFLexicalAnalyzer::TokenType::Boolean: { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::Bool); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::Bool); const bool value = m_lookAhead1.data.toBool(); shift(); return PDFObject::createBool(value); @@ -713,7 +713,7 @@ PDFObject PDFParser::getObject() case PDFLexicalAnalyzer::TokenType::Integer: { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::LongLong); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::LongLong); const PDFInteger value = m_lookAhead1.data.toLongLong(); shift(); @@ -723,7 +723,7 @@ PDFObject PDFParser::getObject() m_lookAhead2.type == PDFLexicalAnalyzer::TokenType::Command && m_lookAhead2.data.toByteArray() == PDF_REFERENCE_COMMAND) { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::LongLong); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::LongLong); const PDFInteger generation = m_lookAhead1.data.toLongLong(); shift(); shift(); @@ -738,7 +738,7 @@ PDFObject PDFParser::getObject() case PDFLexicalAnalyzer::TokenType::Real: { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::Double); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::Double); const PDFReal value = m_lookAhead1.data.toDouble(); shift(); return PDFObject::createReal(value); @@ -746,7 +746,7 @@ PDFObject PDFParser::getObject() case PDFLexicalAnalyzer::TokenType::String: { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::ByteArray); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::ByteArray); QByteArray array = m_lookAhead1.data.toByteArray(); array.shrink_to_fit(); shift(); @@ -755,7 +755,7 @@ PDFObject PDFParser::getObject() case PDFLexicalAnalyzer::TokenType::Name: { - Q_ASSERT(m_lookAhead1.data.type() == QVariant::ByteArray); + Q_ASSERT(m_lookAhead1.data.typeId() == QVariant::ByteArray); QByteArray array = m_lookAhead1.data.toByteArray(); array.shrink_to_fit(); shift(); diff --git a/Pdf4QtLib/sources/pdfsecurityhandler.cpp b/Pdf4QtLib/sources/pdfsecurityhandler.cpp index 460e0f2..a6df1b9 100644 --- a/Pdf4QtLib/sources/pdfsecurityhandler.cpp +++ b/Pdf4QtLib/sources/pdfsecurityhandler.cpp @@ -26,6 +26,11 @@ #include +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + #include #include #include @@ -2612,3 +2617,8 @@ PDFObject PDFPublicKeySecurityHandler::createEncryptionDictionaryObject() const } } // namespace pdf + +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic pop +#endif + diff --git a/Pdf4QtLib/sources/pdfsignaturehandler.cpp b/Pdf4QtLib/sources/pdfsignaturehandler.cpp index 2d9c68a..f4ce77c 100644 --- a/Pdf4QtLib/sources/pdfsignaturehandler.cpp +++ b/Pdf4QtLib/sources/pdfsignaturehandler.cpp @@ -1,4 +1,4 @@ - // Copyright (C) 2020-2022 Jakub Melka +// Copyright (C) 2020-2022 Jakub Melka // // This file is part of PDF4QT. // @@ -23,6 +23,11 @@ #include "pdfdbgheap.h" #include "pdfsignaturehandler_impl.h" +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + #include #include #include @@ -2100,3 +2105,7 @@ pdf::PDFCertificateStore::CertificateEntries pdf::PDFCertificateStore::getSystem return result; } + +#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC) +#pragma GCC diagnostic pop +#endif diff --git a/Pdf4QtLib/sources/pdfxfaengine.cpp b/Pdf4QtLib/sources/pdfxfaengine.cpp index 7ce6545..6d22694 100644 --- a/Pdf4QtLib/sources/pdfxfaengine.cpp +++ b/Pdf4QtLib/sources/pdfxfaengine.cpp @@ -12134,19 +12134,19 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui, passwordEdit || signature || textEdit; const bool isDefaultUi = !isNonDefaultUi || defaultUi; - if (textEdit || (isDefaultUi && value.value.type() == QVariant::String)) + if (textEdit || (isDefaultUi && value.value.typeId() == QVariant::String)) { drawUiTextEdit(textEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter); } - else if (checkButton || (isDefaultUi && value.value.type() == QVariant::Bool)) + else if (checkButton || (isDefaultUi && value.value.typeId() == QVariant::Bool)) { drawUiCheckButton(checkButton, value, nominalExtentArea, painter); } - else if (imageEdit || (isDefaultUi && value.value.type() == QVariant::Image)) + else if (imageEdit || (isDefaultUi && value.value.typeId() == QVariant::Image)) { drawUiImageEdit(imageEdit, value, errors, nominalExtentArea, painter); } - else if (numericEdit || (isDefaultUi && value.value.type() == QVariant::Double)) + else if (numericEdit || (isDefaultUi && value.value.typeId() == QVariant::Double)) { drawUiNumericEdit(numericEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter); } @@ -12166,9 +12166,9 @@ void PDFXFAEngineImpl::drawUi(const xfa::XFA_ui* ui, { errors << PDFRenderError(RenderErrorType::NotImplemented, PDFTranslationContext::tr("XFA: Buttons not implemented.")); } - else if (dateTimeEdit || (isDefaultUi && (value.value.type() == QVariant::DateTime || - value.value.type() == QVariant::Date || - value.value.type() == QVariant::Time))) + else if (dateTimeEdit || (isDefaultUi && (value.value.typeId() == QVariant::DateTime || + value.value.typeId() == QVariant::Date || + value.value.typeId() == QVariant::Time))) { drawUiDateTimeEdit(dateTimeEdit, value, errors, nominalExtentArea, paragraphSettingsIndex, painter); } @@ -12391,15 +12391,15 @@ void PDFXFAEngineImpl::drawUiDateTimeEdit(const xfa::XFA_dateTimeEdit* dateTimeE QString text; - if (value.value.type() == QVariant::DateTime) + if (value.value.typeId() == QVariant::DateTime) { text = value.value.toDateTime().toString(); } - else if (value.value.type() == QVariant::Time) + else if (value.value.typeId() == QVariant::Time) { text = value.value.toTime().toString(); } - else if (value.value.type() == QVariant::Date) + else if (value.value.typeId() == QVariant::Date) { text = value.value.toDate().toString(); } diff --git a/Pdf4QtViewer/pdfdocumentpropertiesdialog.cpp b/Pdf4QtViewer/pdfdocumentpropertiesdialog.cpp index 750b93f..071917e 100644 --- a/Pdf4QtViewer/pdfdocumentpropertiesdialog.cpp +++ b/Pdf4QtViewer/pdfdocumentpropertiesdialog.cpp @@ -130,7 +130,7 @@ void PDFDocumentPropertiesDialog::initializeProperties(const pdf::PDFDocument* d { QString key = QString::fromLatin1(item.first); QVariant valueVariant = item.second; - QString value = (valueVariant.type() == QVariant::DateTime) ? locale.toString(valueVariant.toDateTime()) : valueVariant.toString(); + QString value = (valueVariant.typeId() == QVariant::DateTime) ? locale.toString(valueVariant.toDateTime()) : valueVariant.toString(); new QTreeWidgetItem(customRoot, { key, value }); } ui->propertiesTreeWidget->addTopLevelItem(customRoot); diff --git a/Pdf4QtViewer/pdfencryptionsettingsdialog.cpp b/Pdf4QtViewer/pdfencryptionsettingsdialog.cpp index 1d43191..b5c32c7 100644 --- a/Pdf4QtViewer/pdfencryptionsettingsdialog.cpp +++ b/Pdf4QtViewer/pdfencryptionsettingsdialog.cpp @@ -17,6 +17,7 @@ #include "pdfencryptionsettingsdialog.h" #include "ui_pdfencryptionsettingsdialog.h" +#include "pdfencryptionstrengthhintwidget.h" #include "pdfutils.h" #include "pdfwidgetutils.h" @@ -33,7 +34,10 @@ PDFEncryptionSettingsDialog::PDFEncryptionSettingsDialog(QByteArray documentId, QDialog(parent), ui(new Ui::PDFEncryptionSettingsDialog), m_isUpdatingUi(false), - m_documentId(documentId) + m_documentId(documentId), + m_userPasswordStrengthHintWidget(new PDFEncryptionStrengthHintWidget(this)), + m_ownerPasswordStrengthHintWidget(new PDFEncryptionStrengthHintWidget(this)), + m_algorithmHintWidget(new PDFEncryptionStrengthHintWidget(this)) { ui->setupUi(this); @@ -45,20 +49,24 @@ PDFEncryptionSettingsDialog::PDFEncryptionSettingsDialog(QByteArray documentId, ui->algorithmComboBox->setCurrentIndex(0); - ui->algorithmHintWidget->setFixedSize(ui->algorithmHintWidget->minimumSizeHint()); - ui->userPasswordStrengthHintWidget->setFixedSize(ui->userPasswordStrengthHintWidget->minimumSizeHint()); - ui->ownerPasswordStrengthHintWidget->setFixedSize(ui->ownerPasswordStrengthHintWidget->minimumSizeHint()); + m_algorithmHintWidget->setFixedSize(m_algorithmHintWidget->minimumSizeHint()); + m_userPasswordStrengthHintWidget->setFixedSize(m_userPasswordStrengthHintWidget->minimumSizeHint()); + m_ownerPasswordStrengthHintWidget->setFixedSize(m_userPasswordStrengthHintWidget->minimumSizeHint()); - ui->algorithmHintWidget->setMinValue(1); - ui->algorithmHintWidget->setMaxValue(5); + ui->passwordsGroupBoxLayout->addWidget(m_userPasswordStrengthHintWidget, 0, 2); + ui->passwordsGroupBoxLayout->addWidget(m_ownerPasswordStrengthHintWidget, 1, 2); + ui->methodGroupBoxLayout->addWidget(m_algorithmHintWidget, 0, 2); + + m_algorithmHintWidget->setMinValue(1); + m_algorithmHintWidget->setMaxValue(5); const int passwordOptimalEntropy = pdf::PDFSecurityHandlerFactory::getPasswordOptimalEntropy(); - ui->userPasswordStrengthHintWidget->setMinValue(0); - ui->userPasswordStrengthHintWidget->setMaxValue(passwordOptimalEntropy); + m_userPasswordStrengthHintWidget->setMinValue(0); + m_userPasswordStrengthHintWidget->setMaxValue(passwordOptimalEntropy); - ui->ownerPasswordStrengthHintWidget->setMinValue(0); - ui->ownerPasswordStrengthHintWidget->setMaxValue(passwordOptimalEntropy); + m_ownerPasswordStrengthHintWidget->setMinValue(0); + m_ownerPasswordStrengthHintWidget->setMaxValue(passwordOptimalEntropy); connect(ui->algorithmComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &PDFEncryptionSettingsDialog::updateUi); connect(ui->userPasswordEnableCheckBox, &QCheckBox::clicked, this, &PDFEncryptionSettingsDialog::updateUi); @@ -103,17 +111,17 @@ void PDFEncryptionSettingsDialog::updateUi() switch (algorithm) { case pdf::PDFSecurityHandlerFactory::None: - ui->algorithmHintWidget->setCurrentValue(1); + m_algorithmHintWidget->setCurrentValue(1); break; case pdf::PDFSecurityHandlerFactory::RC4: - ui->algorithmHintWidget->setCurrentValue(2); + m_algorithmHintWidget->setCurrentValue(2); break; case pdf::PDFSecurityHandlerFactory::AES_128: - ui->algorithmHintWidget->setCurrentValue(4); + m_algorithmHintWidget->setCurrentValue(4); break; case pdf::PDFSecurityHandlerFactory::AES_256: case pdf::PDFSecurityHandlerFactory::Certificate: - ui->algorithmHintWidget->setCurrentValue(5); + m_algorithmHintWidget->setCurrentValue(5); break; default: @@ -170,8 +178,8 @@ void PDFEncryptionSettingsDialog::updateUi() ui->ownerPasswordEdit->clear(); } - ui->userPasswordStrengthHintWidget->setEnabled(ui->userPasswordEnableCheckBox->isChecked()); - ui->ownerPasswordStrengthHintWidget->setEnabled(ui->ownerPasswordEnableCheckBox->isChecked()); + m_userPasswordStrengthHintWidget->setEnabled(ui->userPasswordEnableCheckBox->isChecked()); + m_ownerPasswordStrengthHintWidget->setEnabled(ui->ownerPasswordEnableCheckBox->isChecked()); ui->encryptAllRadioButton->setEnabled(encrypted); ui->encryptAllExceptMetadataRadioButton->setEnabled(encrypted); @@ -204,8 +212,8 @@ void PDFEncryptionSettingsDialog::updatePasswordScore() const int userPasswordScore = pdf::PDFSecurityHandlerFactory::getPasswordEntropy(ui->userPasswordEdit->text(), algorithm); const int ownerPasswordScore = pdf::PDFSecurityHandlerFactory::getPasswordEntropy(ui->ownerPasswordEdit->text(), algorithm); - ui->userPasswordStrengthHintWidget->setCurrentValue(userPasswordScore); - ui->ownerPasswordStrengthHintWidget->setCurrentValue(ownerPasswordScore); + m_userPasswordStrengthHintWidget->setCurrentValue(userPasswordScore); + m_ownerPasswordStrengthHintWidget->setCurrentValue(ownerPasswordScore); } void PDFEncryptionSettingsDialog::accept() diff --git a/Pdf4QtViewer/pdfencryptionsettingsdialog.h b/Pdf4QtViewer/pdfencryptionsettingsdialog.h index 9923b75..0870d3f 100644 --- a/Pdf4QtViewer/pdfencryptionsettingsdialog.h +++ b/Pdf4QtViewer/pdfencryptionsettingsdialog.h @@ -32,6 +32,7 @@ class QCheckBox; namespace pdfviewer { +class PDFEncryptionStrengthHintWidget; class PDFEncryptionSettingsDialog : public QDialog { @@ -57,6 +58,9 @@ private: std::map m_checkBoxToPermission; pdf::PDFSecurityHandlerPointer m_updatedSecurityHandler; QByteArray m_documentId; + PDFEncryptionStrengthHintWidget* m_userPasswordStrengthHintWidget; + PDFEncryptionStrengthHintWidget* m_ownerPasswordStrengthHintWidget; + PDFEncryptionStrengthHintWidget* m_algorithmHintWidget; }; } // namespace pdfviewer diff --git a/Pdf4QtViewer/pdfencryptionsettingsdialog.ui b/Pdf4QtViewer/pdfencryptionsettingsdialog.ui index 7f335db..d1a3ac6 100644 --- a/Pdf4QtViewer/pdfencryptionsettingsdialog.ui +++ b/Pdf4QtViewer/pdfencryptionsettingsdialog.ui @@ -20,9 +20,6 @@ Encryption Method - - - @@ -62,13 +59,6 @@ Passwords - - - - Password (owner access) - - - @@ -76,6 +66,16 @@ + + + + QLineEdit::Password + + + true + + + @@ -86,22 +86,13 @@ - - - - - - - QLineEdit::Password - - - true + + + + Password (owner access) - - - @@ -215,14 +206,6 @@ - - - pdfviewer::PDFEncryptionStrengthHintWidget - QWidget -
pdfencryptionstrengthhintwidget.h
- 1 -
-
diff --git a/Pdf4QtViewer/pdfrecentfilemanager.cpp b/Pdf4QtViewer/pdfrecentfilemanager.cpp index 039ac48..c85bc99 100644 --- a/Pdf4QtViewer/pdfrecentfilemanager.cpp +++ b/Pdf4QtViewer/pdfrecentfilemanager.cpp @@ -97,7 +97,7 @@ void PDFRecentFileManager::onRecentFileActionTriggered() Q_ASSERT(action); QVariant data = action->data(); - if (data.type() == QVariant::String) + if (data.typeId() == QVariant::String) { emit fileOpenRequest(data.toString()); } diff --git a/Pdf4QtViewer/pdfsendmail.cpp b/Pdf4QtViewer/pdfsendmail.cpp index 8f348ea..82eec4e 100644 --- a/Pdf4QtViewer/pdfsendmail.cpp +++ b/Pdf4QtViewer/pdfsendmail.cpp @@ -34,6 +34,8 @@ namespace pdfviewer bool PDFSendMail::sendMail(QWidget* parent, QString subject, QString fileName) { #ifdef Q_OS_WIN + +#if !defined(PDF4QT_COMPILER_MINGW) QFileInfo fileInfo(fileName); std::wstring subjectString = subject.toStdWString(); std::wstring fileNameString = fileInfo.fileName().toStdWString(); @@ -84,6 +86,7 @@ bool PDFSendMail::sendMail(QWidget* parent, QString subject, QString fileName) default: return false; } +#endif return false; #elif defined(Q_OS_UNIX) diff --git a/Pdf4QtViewerLite/main.cpp b/Pdf4QtViewerLite/main.cpp index 231fbe8..6074ff6 100644 --- a/Pdf4QtViewerLite/main.cpp +++ b/Pdf4QtViewerLite/main.cpp @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true); - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity, true); QApplication application(argc, argv); diff --git a/Pdf4QtViewerPlugins/AudioBookPlugin/CMakeLists.txt b/Pdf4QtViewerPlugins/AudioBookPlugin/CMakeLists.txt index 57a1a15..393f0c1 100644 --- a/Pdf4QtViewerPlugins/AudioBookPlugin/CMakeLists.txt +++ b/Pdf4QtViewerPlugins/AudioBookPlugin/CMakeLists.txt @@ -25,6 +25,10 @@ add_library(AudioBookPlugin SHARED target_link_libraries(AudioBookPlugin PRIVATE Pdf4QtLib Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGLWidgets) +if(MINGW) + target_link_libraries(AudioBookPlugin PRIVATE ole32 sapi) +endif() + set_target_properties(AudioBookPlugin PROPERTIES VERSION ${PDF4QT_VERSION} SOVERSION ${PDF4QT_VERSION} diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.cpp b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.cpp index b199dc6..0714475 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.cpp +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.cpp @@ -31,14 +31,16 @@ ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFCMS* cms, const pdf:: ui(new Ui::ObjectInspectorDialog), m_cms(cms), m_document(document), - m_model(nullptr) + m_model(nullptr), + m_viewerWidget(new ObjectViewerWidget(this)) { ui->setupUi(this); m_objectClassifier.classify(document); - ui->currentObjectWidget->setCms(cms); - ui->currentObjectWidget->setDocument(document); + m_viewerWidget->setCms(cms); + m_viewerWidget->setDocument(document); + ui->currentObjectTabLayout->addWidget(m_viewerWidget); ui->modeComboBox->addItem(tr("Document"), int(PDFObjectInspectorTreeItemModel::Document)); ui->modeComboBox->addItem(tr("Pages"), int(PDFObjectInspectorTreeItemModel::Page)); @@ -103,8 +105,8 @@ ObjectInspectorDialog::ObjectInspectorDialog(const pdf::PDFCMS* cms, const pdf:: ui->splitter->setSizes(QList() << pdf::PDFWidgetUtils::scaleDPI_x(this, 300) << pdf::PDFWidgetUtils::scaleDPI_x(this, 200)); connect(ui->objectTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ObjectInspectorDialog::onCurrentIndexChanged); - connect(ui->currentObjectWidget, &ObjectViewerWidget::pinRequest, this, &ObjectInspectorDialog::onPinRequest); - connect(ui->currentObjectWidget, &ObjectViewerWidget::unpinRequest, this, &ObjectInspectorDialog::onUnpinRequest); + connect(m_viewerWidget, &ObjectViewerWidget::pinRequest, this, &ObjectInspectorDialog::onPinRequest); + connect(m_viewerWidget, &ObjectViewerWidget::unpinRequest, this, &ObjectInspectorDialog::onUnpinRequest); ui->objectTreeView->setMinimumWidth(pdf::PDFWidgetUtils::scaleDPI_x(this, 200)); setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(800, 600))); @@ -126,12 +128,12 @@ void ObjectInspectorDialog::onPinRequest() { ObjectViewerWidget* source = qobject_cast(sender()); - if (!source || source != ui->currentObjectWidget) + if (!source || source != m_viewerWidget) { return; } - ObjectViewerWidget* cloned = ui->currentObjectWidget->clone(true, this); + ObjectViewerWidget* cloned = m_viewerWidget->clone(true, this); connect(cloned, &ObjectViewerWidget::pinRequest, this, &ObjectInspectorDialog::onPinRequest); connect(cloned, &ObjectViewerWidget::unpinRequest, this, &ObjectInspectorDialog::onUnpinRequest); ui->tabWidget->addTab(cloned, cloned->getTitleText()); @@ -141,7 +143,7 @@ void ObjectInspectorDialog::onUnpinRequest() { ObjectViewerWidget* source = qobject_cast(sender()); - if (!source || source == ui->currentObjectWidget) + if (!source || source == m_viewerWidget) { return; } @@ -165,7 +167,7 @@ void ObjectInspectorDialog::onCurrentIndexChanged(const QModelIndex& current, co isRoot = true; } - ui->currentObjectWidget->setData(reference, qMove(object), isRoot); + m_viewerWidget->setData(reference, qMove(object), isRoot); } } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.h b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.h index d5220e3..b20444f 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.h +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.h @@ -21,6 +21,7 @@ #include "pdfdocument.h" #include "pdfobjectutils.h" #include "pdfcms.h" +#include "objectviewerwidget.h" #include @@ -52,6 +53,7 @@ private: const pdf::PDFDocument* m_document; pdf::PDFObjectClassifier m_objectClassifier; PDFObjectInspectorTreeItemModel* m_model; + ObjectViewerWidget* m_viewerWidget; }; } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui index 1ddaf26..fa12e36 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectinspectordialog.ui @@ -47,11 +47,7 @@ Current Object - - - - - + @@ -68,14 +64,6 @@ - - - pdfplugin::ObjectViewerWidget - QWidget -
objectviewerwidget.h
- 1 -
-
diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp index ace1117..339bfd6 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.cpp @@ -26,10 +26,13 @@ namespace pdfplugin ObjectStatisticsDialog::ObjectStatisticsDialog(const pdf::PDFDocument* document, QWidget *parent) : QDialog(parent, Qt::Dialog | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint), ui(new Ui::ObjectStatisticsDialog), - m_document(document) + m_document(document), + m_statisticsGraphWidget(new StatisticsGraphWidget(this)) { ui->setupUi(this); + ui->dialogLayout->addWidget(m_statisticsGraphWidget); + ui->comboBox->addItem(tr("Statistics by Object Function"), int(ByObjectClass)); ui->comboBox->addItem(tr("Statistics by Object Type"), int(ByObjectType)); ui->comboBox->setCurrentIndex(ui->comboBox->findData(int(ByObjectClass), Qt::UserRole, Qt::MatchExactly)); @@ -163,7 +166,7 @@ void ObjectStatisticsDialog::updateStatisticsWidget() break; } - ui->graphWidget->setStatistics(qMove(statistics)); + m_statisticsGraphWidget->setStatistics(qMove(statistics)); } } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.h b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.h index 9926f3c..76c2c14 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.h +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.h @@ -20,6 +20,7 @@ #include "pdfdocument.h" #include "pdfobjectutils.h" +#include "statisticsgraphwidget.h" #include @@ -52,6 +53,7 @@ private: const pdf::PDFDocument* m_document; pdf::PDFObjectClassifier::Statistics m_statistics; + StatisticsGraphWidget* m_statisticsGraphWidget; }; } // namespace pdfplugin diff --git a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.ui b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.ui index 992f597..aa2be1c 100644 --- a/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.ui +++ b/Pdf4QtViewerPlugins/ObjectInspectorPlugin/objectstatisticsdialog.ui @@ -13,23 +13,12 @@ Object Statistics - + - - - - - - pdfplugin::StatisticsGraphWidget - QWidget -
StatisticsGraphWidget.h
- 1 -
-
diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp index 7d54635..953546d 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.cpp @@ -38,6 +38,7 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf:: m_document(document), m_widget(widget), m_needUpdateImage(false), + m_outputPreviewWidget(new OutputPreviewWidget(this)), m_futureWatcher(nullptr) { ui->setupUi(this); @@ -46,6 +47,8 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf:: ui->pageIndexScrollBar->setValue(1); ui->pageIndexScrollBar->setMaximum(int(document->getCatalog()->getPageCount())); + ui->frameViewLayout->insertWidget(0, m_outputPreviewWidget); + ui->displayModeComboBox->addItem(tr("Separations"), OutputPreviewWidget::Separations); ui->displayModeComboBox->addItem(tr("Color Warnings | Ink Coverage"), OutputPreviewWidget::ColorWarningInkCoverage); ui->displayModeComboBox->addItem(tr("Color Warnings | Rich Black"), OutputPreviewWidget::ColorWarningRichBlack); @@ -54,7 +57,7 @@ OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf:: ui->displayModeComboBox->addItem(tr("Opacity Channel"), OutputPreviewWidget::OpacityChannel); ui->displayModeComboBox->setCurrentIndex(0); - ui->imageWidget->setInkMapper(&m_inkMapper); + m_outputPreviewWidget->setInkMapper(&m_inkMapper); ui->inksTreeWidget->setMinimumHeight(pdf::PDFWidgetUtils::scaleDPI_y(ui->inksTreeWidget, 150)); m_inkMapper.createSpotColors(ui->simulateSeparationsCheckBox->isChecked()); @@ -191,7 +194,7 @@ void OutputPreviewDialog::updateAlarmColorButtonIcon() { QSize iconSize = ui->alarmColorButton->iconSize(); QPixmap pixmap(iconSize); - pixmap.fill(ui->imageWidget->getAlarmColor()); + pixmap.fill(m_outputPreviewWidget->getAlarmColor()); ui->alarmColorButton->setIcon(QIcon(pixmap)); } @@ -206,10 +209,10 @@ void OutputPreviewDialog::onPaperColorChanged() void OutputPreviewDialog::onAlarmColorButtonClicked() { - QColorDialog colorDialog(ui->imageWidget->getAlarmColor(), this); + QColorDialog colorDialog(m_outputPreviewWidget->getAlarmColor(), this); if (colorDialog.exec() == QColorDialog::Accepted) { - ui->imageWidget->setAlarmColor(colorDialog.currentColor()); + m_outputPreviewWidget->setAlarmColor(colorDialog.currentColor()); updateAlarmColorButtonIcon(); } } @@ -231,7 +234,7 @@ void OutputPreviewDialog::onSimulatePaperColorChecked(bool checked) void OutputPreviewDialog::onDisplayModeChanged() { - ui->imageWidget->setDisplayMode(OutputPreviewWidget::DisplayMode(ui->displayModeComboBox->currentData().toInt())); + m_outputPreviewWidget->setDisplayMode(OutputPreviewWidget::DisplayMode(ui->displayModeComboBox->currentData().toInt())); } void OutputPreviewDialog::onInksChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector& roles) @@ -247,12 +250,12 @@ void OutputPreviewDialog::onInksChanged(const QModelIndex& topLeft, const QModel void OutputPreviewDialog::onInkCoverageLimitChanged(double value) { - ui->imageWidget->setInkCoverageLimit(value / 100.0); + m_outputPreviewWidget->setInkCoverageLimit(value / 100.0); } void OutputPreviewDialog::onRichBlackLimtiChanged(double value) { - ui->imageWidget->setRichBlackLimit(value / 100.0); + m_outputPreviewWidget->setRichBlackLimit(value / 100.0); } void OutputPreviewDialog::updatePageImage() @@ -268,7 +271,7 @@ void OutputPreviewDialog::updatePageImage() const pdf::PDFPage* page = m_document->getCatalog()->getPage(ui->pageIndexScrollBar->value() - 1); if (!page) { - ui->imageWidget->clear(); + m_outputPreviewWidget->clear(); return; } @@ -318,7 +321,7 @@ void OutputPreviewDialog::updatePageImage() flags.setFlag(pdf::PDFTransparencyRendererSettings::SaveOriginalProcessImage, true); m_inkMapperForRendering = m_inkMapper; - QSize renderSize = ui->imageWidget->getPageImageSizeHint(); + QSize renderSize = m_outputPreviewWidget->getPageImageSizeHint(); auto renderImage = [this, page, renderSize, paperColor, activeColorMask, flags]() -> RenderedImage { return renderPage(page, renderSize, paperColor, activeColorMask, flags); @@ -389,7 +392,7 @@ void OutputPreviewDialog::onPageImageRendered() m_futureWatcher->deleteLater(); m_futureWatcher = nullptr; - ui->imageWidget->setPageImage(qMove(result.image), qMove(result.originalProcessImage), result.pageSize); + m_outputPreviewWidget->setPageImage(qMove(result.image), qMove(result.originalProcessImage), result.pageSize); if (m_needUpdateImage) { diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h index 28e4dac..4e6037c 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h @@ -87,6 +87,7 @@ private: const pdf::PDFDocument* m_document; pdf::PDFWidget* m_widget; bool m_needUpdateImage; + OutputPreviewWidget* m_outputPreviewWidget; QFuture m_future; QFutureWatcher* m_futureWatcher; diff --git a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui index 18fb8b4..bc78f9d 100644 --- a/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui +++ b/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.ui @@ -7,7 +7,7 @@ 0 0 955 - 677 + 686 @@ -40,9 +40,6 @@ 0 - - - @@ -316,14 +313,6 @@
- - - pdfplugin::OutputPreviewWidget - QWidget -
outputpreviewwidget.h
- 1 -
-
diff --git a/Pdf4QtViewerProfi/main.cpp b/Pdf4QtViewerProfi/main.cpp index be1b5bf..30967a1 100644 --- a/Pdf4QtViewerProfi/main.cpp +++ b/Pdf4QtViewerProfi/main.cpp @@ -29,7 +29,6 @@ int main(int argc, char *argv[]) #endif QApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true); - QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity, true); QApplication application(argc, argv); diff --git a/PdfTool/CMakeLists.txt b/PdfTool/CMakeLists.txt index d4e2d88..0a3ef59 100644 --- a/PdfTool/CMakeLists.txt +++ b/PdfTool/CMakeLists.txt @@ -48,4 +48,8 @@ add_executable(PdfTool target_link_libraries(PdfTool PRIVATE Pdf4QtLib Qt6::Core Qt6::Gui Qt6::Xml) +if(MINGW) + target_link_libraries(PdfTool PRIVATE ole32 sapi) +endif() + install(TARGETS PdfTool) diff --git a/PdfTool/pdftoolfetchimages.cpp b/PdfTool/pdftoolfetchimages.cpp index 163b043..e0a88b8 100644 --- a/PdfTool/pdftoolfetchimages.cpp +++ b/PdfTool/pdftoolfetchimages.cpp @@ -258,7 +258,8 @@ PDFToolAbstractApplication::Options PDFToolFetchImages::getOptionsFlags() const void PDFToolFetchImages::onImageExtracted(pdf::PDFInteger pageIndex, pdf::PDFInteger order, const QImage& image) { QCryptographicHash hasher(QCryptographicHash::Sha512); - hasher.addData(reinterpret_cast(image.bits()), image.sizeInBytes()); + QByteArrayView imageData(image.bits(), image.sizeInBytes()); + hasher.addData(imageData); QByteArray hash = hasher.result(); QMutexLocker lock(&m_mutex); diff --git a/PdfTool/pdftoolinfo.cpp b/PdfTool/pdftoolinfo.cpp index b42fd55..a028852 100644 --- a/PdfTool/pdftoolinfo.cpp +++ b/PdfTool/pdftoolinfo.cpp @@ -155,7 +155,7 @@ int PDFToolInfoApplication::execute(const PDFToolOptions& options) { QString key = QString::fromLatin1(item.first); QVariant valueVariant = item.second; - QString value = (valueVariant.type() == QVariant::DateTime) ? convertDateTimeToString(valueVariant.toDateTime().toLocalTime(), options.outputDateFormat) : valueVariant.toString(); + QString value = (valueVariant.typeId() == QVariant::DateTime) ? convertDateTimeToString(valueVariant.toDateTime().toLocalTime(), options.outputDateFormat) : valueVariant.toString(); writeProperty("custom-property", key, value); } } diff --git a/PdfTool/pdftoolrender.cpp b/PdfTool/pdftoolrender.cpp index 3159d4f..3e0cd26 100644 --- a/PdfTool/pdftoolrender.cpp +++ b/PdfTool/pdftoolrender.cpp @@ -19,6 +19,7 @@ #include "pdffont.h" #include "pdfconstants.h" +#include #include namespace pdftool @@ -185,7 +186,7 @@ int PDFToolRenderBase::execute(const PDFToolOptions& options) surfaceFormat = QSurfaceFormat::defaultFormat(); surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); surfaceFormat.setSamples(options.renderMSAAsamples); - surfaceFormat.setColorSpace(QSurfaceFormat::sRGBColorSpace); + surfaceFormat.setColorSpace(QColorSpace(QColorSpace::SRgb)); surfaceFormat.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); }