mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Issue #25: MinGW compilation fix
This commit is contained in:
@@ -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);
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
|
@@ -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>
|
||||
|
@@ -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());
|
||||
}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user