Issue #25: MinGW compilation fix

This commit is contained in:
Jakub Melka 2022-09-11 17:54:11 +02:00
parent 825fe59420
commit 8ffc4f9189
35 changed files with 160 additions and 140 deletions

View File

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

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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})

View File

@ -21,6 +21,11 @@
#include <QFile>
#include <QStandardPaths>
#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <openssl/bio.h>
#include <openssl/rsa.h>
#include <openssl/rsaerr.h>
@ -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

View File

@ -883,7 +883,8 @@ void PDFDiff::finalizeGraphicsPieces(PDFDiffPageContext& context)
continue;
}
hasher.addData(reinterpret_cast<const char*>(info.hash.data()), int(info.hash.size()));
QByteArrayView view(reinterpret_cast<const char*>(info.hash.data()), info.hash.size());
hasher.addData(view);
}
QByteArray hash = hasher.result();

View File

@ -28,6 +28,7 @@
#include <QKeyEvent>
#include <QApplication>
#include <QPixmapCache>
#include <QColorSpace>
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);
}

View File

@ -2233,9 +2233,9 @@ QString PDFEncoding::convertTextString(const QByteArray& stream)
QString PDFEncoding::convertFromUnicode(const QByteArray& stream)
{
const ushort* bytes = reinterpret_cast<const ushort*>(stream.data());
const char16_t* bytes = reinterpret_cast<const char16_t*>(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);
}

View File

@ -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();

View File

@ -26,6 +26,11 @@
#include <QRandomGenerator>
#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <openssl/rc4.h>
#include <openssl/md5.h>
#include <openssl/aes.h>
@ -2612,3 +2617,8 @@ PDFObject PDFPublicKeySecurityHandler::createEncryptionDictionaryObject() const
}
} // namespace pdf
#if defined(PDF4QT_COMPILER_MINGW) || defined(PDF4QT_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif

View File

@ -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 <openssl/err.h>
#include <openssl/sha.h>
#include <openssl/rsa.h>
@ -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

View File

@ -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();
}

View File

@ -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);

View File

@ -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<int>::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()

View File

@ -32,6 +32,7 @@ class QCheckBox;
namespace pdfviewer
{
class PDFEncryptionStrengthHintWidget;
class PDFEncryptionSettingsDialog : public QDialog
{
@ -57,6 +58,9 @@ private:
std::map<QCheckBox*, pdf::PDFSecurityHandler::Permission> m_checkBoxToPermission;
pdf::PDFSecurityHandlerPointer m_updatedSecurityHandler;
QByteArray m_documentId;
PDFEncryptionStrengthHintWidget* m_userPasswordStrengthHintWidget;
PDFEncryptionStrengthHintWidget* m_ownerPasswordStrengthHintWidget;
PDFEncryptionStrengthHintWidget* m_algorithmHintWidget;
};
} // namespace pdfviewer

View File

@ -20,9 +20,6 @@
<string>Encryption Method</string>
</property>
<layout class="QGridLayout" name="methodGroupBoxLayout">
<item row="0" column="2">
<widget class="pdfviewer::PDFEncryptionStrengthHintWidget" name="algorithmHintWidget" native="true"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="encryptionAlgorithm">
<property name="text">
@ -62,13 +59,6 @@
<string>Passwords</string>
</property>
<layout class="QGridLayout" name="passwordsGroupBoxLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="ownerPasswordEnableCheckBox">
<property name="text">
<string>Password (owner access)</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="userPasswordEnableCheckBox">
<property name="text">
@ -76,6 +66,16 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ownerPasswordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="userPasswordEdit">
<property name="echoMode">
@ -86,22 +86,13 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="pdfviewer::PDFEncryptionStrengthHintWidget" name="userPasswordStrengthHintWidget" native="true"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="ownerPasswordEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
<item row="1" column="0">
<widget class="QCheckBox" name="ownerPasswordEnableCheckBox">
<property name="text">
<string>Password (owner access)</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="pdfviewer::PDFEncryptionStrengthHintWidget" name="ownerPasswordStrengthHintWidget" native="true"/>
</item>
</layout>
</widget>
</item>
@ -215,14 +206,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfviewer::PDFEncryptionStrengthHintWidget</class>
<extends>QWidget</extends>
<header>pdfencryptionstrengthhintwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -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());
}

View File

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

View File

@ -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);

View File

@ -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}

View File

@ -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<int>() << 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<ObjectViewerWidget*>(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<ObjectViewerWidget*>(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

View File

@ -21,6 +21,7 @@
#include "pdfdocument.h"
#include "pdfobjectutils.h"
#include "pdfcms.h"
#include "objectviewerwidget.h"
#include <QDialog>
@ -52,6 +53,7 @@ private:
const pdf::PDFDocument* m_document;
pdf::PDFObjectClassifier m_objectClassifier;
PDFObjectInspectorTreeItemModel* m_model;
ObjectViewerWidget* m_viewerWidget;
};
} // namespace pdfplugin

View File

@ -47,11 +47,7 @@
<attribute name="title">
<string>Current Object</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="pdfplugin::ObjectViewerWidget" name="currentObjectWidget" native="true"/>
</item>
</layout>
<layout class="QVBoxLayout" name="currentObjectTabLayout"/>
</widget>
</widget>
</widget>
@ -68,14 +64,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfplugin::ObjectViewerWidget</class>
<extends>QWidget</extends>
<header>objectviewerwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -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

View File

@ -20,6 +20,7 @@
#include "pdfdocument.h"
#include "pdfobjectutils.h"
#include "statisticsgraphwidget.h"
#include <QDialog>
@ -52,6 +53,7 @@ private:
const pdf::PDFDocument* m_document;
pdf::PDFObjectClassifier::Statistics m_statistics;
StatisticsGraphWidget* m_statisticsGraphWidget;
};
} // namespace pdfplugin

View File

@ -13,23 +13,12 @@
<property name="windowTitle">
<string>Object Statistics</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="dialogLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="pdfplugin::StatisticsGraphWidget" name="graphWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfplugin::StatisticsGraphWidget</class>
<extends>QWidget</extends>
<header>StatisticsGraphWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -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<int>& 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)
{

View File

@ -87,6 +87,7 @@ private:
const pdf::PDFDocument* m_document;
pdf::PDFWidget* m_widget;
bool m_needUpdateImage;
OutputPreviewWidget* m_outputPreviewWidget;
QFuture<RenderedImage> m_future;
QFutureWatcher<RenderedImage>* m_futureWatcher;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>955</width>
<height>677</height>
<height>686</height>
</rect>
</property>
<property name="windowTitle">
@ -40,9 +40,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="pdfplugin::OutputPreviewWidget" name="imageWidget" native="true"/>
</item>
<item>
<widget class="QScrollBar" name="pageIndexScrollBar">
<property name="orientation">
@ -316,14 +313,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>pdfplugin::OutputPreviewWidget</class>
<extends>QWidget</extends>
<header>outputpreviewwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -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);

View File

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

View File

@ -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<const char*>(image.bits()), image.sizeInBytes());
QByteArrayView imageData(image.bits(), image.sizeInBytes());
hasher.addData(imageData);
QByteArray hash = hasher.result();
QMutexLocker lock(&m_mutex);

View File

@ -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);
}
}

View File

@ -19,6 +19,7 @@
#include "pdffont.h"
#include "pdfconstants.h"
#include <QColorSpace>
#include <QElapsedTimer>
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);
}