Plugin for soft-proofing

This commit is contained in:
Jakub Melka
2020-12-25 19:01:08 +01:00
parent 05db7a1d30
commit 468a492e19
18 changed files with 881 additions and 9 deletions

View File

@@ -0,0 +1,7 @@
{
"Name" : "SoftProofing",
"Author" : "Jakub Melka",
"Version" : "1.0.0",
"License" : "LGPL v3",
"Description" : "Perform soft-proofing / gamut checking with CMYK profiles on a document."
}

View File

@@ -0,0 +1,52 @@
# Copyright (C) 2020 Jakub Melka
#
# This file is part of Pdf4Qt.
#
# Pdf4Qt is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pdf4Qt is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
TEMPLATE = lib
DEFINES += SOFTPROOFINGPLUGIN_LIBRARY
QT += gui widgets
LIBS += -L$$OUT_PWD/../..
LIBS += -lPdf4QtLib
QMAKE_CXXFLAGS += /std:c++latest /utf-8
INCLUDEPATH += $$PWD/../../Pdf4QtLib/Sources
DESTDIR = $$OUT_PWD/../../pdfplugins
CONFIG += c++11
SOURCES += \
softproofingplugin.cpp \
settingsdialog.cpp
HEADERS += \
softproofingplugin.h \
settingsdialog.h
CONFIG += force_debug_info
DISTFILES += \
SoftProofingPlugin.json
RESOURCES += \
icons.qrc
FORMS += \
settingsdialog.ui

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/pdfplugins/softproofing">
<file>gamut-checking.svg</file>
<file>soft-proofing.svg</file>
<file>settings.svg</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,58 @@
// Copyright (C) 2020 Jakub Melka
//
// This file is part of Pdf4Qt.
//
// Pdf4Qt is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pdf4Qt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "pdfwidgetutils.h"
SettingsDialog::SettingsDialog(QWidget* parent, const pdf::PDFCMSSettings& settings, const pdf::PDFCMSManager* manager) :
QDialog(parent),
ui(new Ui::SettingsDialog),
m_settings(settings)
{
ui->setupUi(this);
ui->cmsProofingIntentComboBox->addItem(tr("Auto"), int(pdf::RenderingIntent::Auto));
ui->cmsProofingIntentComboBox->addItem(tr("Perceptual"), int(pdf::RenderingIntent::Perceptual));
ui->cmsProofingIntentComboBox->addItem(tr("Relative colorimetric"), int(pdf::RenderingIntent::RelativeColorimetric));
ui->cmsProofingIntentComboBox->addItem(tr("Absolute colorimetric"), int(pdf::RenderingIntent::AbsoluteColorimetric));
ui->cmsProofingIntentComboBox->addItem(tr("Saturation"), int(pdf::RenderingIntent::Saturation));
for (const pdf::PDFColorProfileIdentifier& identifier : manager->getCMYKProfiles())
{
ui->cmsProofingColorProfileComboBox->addItem(identifier.name, identifier.id);
}
ui->cmsProofingIntentComboBox->setCurrentIndex(ui->cmsProofingIntentComboBox->findData(int(m_settings.proofingIntent)));
ui->cmsProofingColorProfileComboBox->setCurrentIndex(ui->cmsProofingColorProfileComboBox->findData(m_settings.softProofingProfile));
setMinimumSize(pdf::PDFWidgetUtils::scaleDPI(this, QSize(320, 160)));
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::accept()
{
m_settings.proofingIntent = static_cast<pdf::RenderingIntent>(ui->cmsProofingIntentComboBox->currentData().toInt());
m_settings.softProofingProfile = ui->cmsProofingColorProfileComboBox->currentData().toString();
QDialog::accept();
}

View File

@@ -0,0 +1,51 @@
// Copyright (C) 2020 Jakub Melka
//
// This file is part of Pdf4Qt.
//
// Pdf4Qt is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pdf4Qt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include "softproofingplugin.h"
#include "pdfcms.h"
#include <QDialog>
class QComboBox;
namespace Ui
{
class SettingsDialog;
}
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget* parent, const pdf::PDFCMSSettings& settings, const pdf::PDFCMSManager* manager);
virtual ~SettingsDialog() override;
virtual void accept() override;
const pdf::PDFCMSSettings& getSettings() const { return m_settings; }
private:
Ui::SettingsDialog* ui;
pdf::PDFCMSSettings m_settings;
};
#endif // SETTINGSDIALOG_H

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<height>165</height>
</rect>
</property>
<property name="windowTitle">
<string>Soft Proofing Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="softProofingGroupBox">
<property name="title">
<string>Soft Proofing Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="cmsOutputProfileLabel">
<property name="text">
<string>Proofing profile</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cmsProofingColorProfileComboBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="cmsProofingIntentLabel">
<property name="text">
<string>Proofing intent</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmsProofingIntentComboBox"/>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@@ -0,0 +1,141 @@
// Copyright (C) 2020 Jakub Melka
//
// This file is part of Pdf4Qt.
//
// Pdf4Qt is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pdf4Qt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
#include "softproofingplugin.h"
#include "settingsdialog.h"
#include "pdfcms.h"
#include "pdfutils.h"
#include "pdfdrawwidget.h"
#include <QAction>
namespace pdfplugin
{
SoftProofingPlugin::SoftProofingPlugin() :
pdf::PDFPlugin(nullptr),
m_enableSoftProofingAction(nullptr),
m_enableGamutCheckingAction(nullptr),
m_showSettingsAction(nullptr),
m_isLoadingGUI(false)
{
}
void SoftProofingPlugin::setWidget(pdf::PDFWidget* widget)
{
Q_ASSERT(!m_widget);
BaseClass::setWidget(widget);
m_enableSoftProofingAction = new QAction(QIcon(":/pdfplugins/softproofing/soft-proofing.svg"), tr("Soft Proofing"), this);
m_enableGamutCheckingAction = new QAction(QIcon(":/pdfplugins/softproofing/gamut-checking.svg"), tr("Gamut Checking"), this);
m_showSettingsAction = new QAction(QIcon(":/pdfplugins/softproofing/settings.svg"), tr("Soft Proofing Settings"), this);
m_enableSoftProofingAction->setCheckable(true);
m_enableGamutCheckingAction->setCheckable(true);
m_enableSoftProofingAction->setObjectName("actionSoftProofing_EnableSoftProofing");
m_enableGamutCheckingAction->setObjectName("actionSoftProofing_EnableGamutChecking");
m_showSettingsAction->setObjectName("actionSoftProofing_ShowSettings");
connect(m_enableSoftProofingAction, &QAction::triggered, this, &SoftProofingPlugin::onSoftProofingTriggered);
connect(m_enableGamutCheckingAction, &QAction::triggered, this, &SoftProofingPlugin::onGamutCheckingTriggered);
connect(m_showSettingsAction, &QAction::triggered, this, &SoftProofingPlugin::onSettingsTriggered);
updateActions();
}
void SoftProofingPlugin::setCMSManager(pdf::PDFCMSManager* manager)
{
BaseClass::setCMSManager(manager);
connect(manager, &pdf::PDFCMSManager::colorManagementSystemChanged, this, &SoftProofingPlugin::updateActions);
}
void SoftProofingPlugin::setDocument(const pdf::PDFModifiedDocument& document)
{
BaseClass::setDocument(document);
if (document.hasReset())
{
updateActions();
}
}
std::vector<QAction*> SoftProofingPlugin::getActions() const
{
return { m_enableSoftProofingAction, m_enableGamutCheckingAction, m_showSettingsAction };
}
void SoftProofingPlugin::onSoftProofingTriggered()
{
if (m_isLoadingGUI)
{
// We are just updating gui, do nothing
return;
}
pdf::PDFCMSSettings settings = m_cmsManager->getSettings();
settings.isSoftProofing = m_enableSoftProofingAction->isChecked();
m_cmsManager->setSettings(settings);
}
void SoftProofingPlugin::onGamutCheckingTriggered()
{
if (m_isLoadingGUI)
{
// We are just updating gui, do nothing
return;
}
pdf::PDFCMSSettings settings = m_cmsManager->getSettings();
settings.isGamutChecking = m_enableGamutCheckingAction->isChecked();
m_cmsManager->setSettings(settings);
}
void SoftProofingPlugin::onSettingsTriggered()
{
SettingsDialog settingsDialog(m_widget, m_cmsManager->getSettings(), m_cmsManager);
if (settingsDialog.exec() == SettingsDialog::Accepted)
{
m_cmsManager->setSettings(settingsDialog.getSettings());
}
}
void SoftProofingPlugin::updateActions()
{
pdf::PDFTemporaryValueChange guard(&m_isLoadingGUI, true);
if (m_enableSoftProofingAction)
{
m_enableSoftProofingAction->setEnabled(m_widget);
m_enableSoftProofingAction->setChecked(m_cmsManager && m_cmsManager->getSettings().isSoftProofing);
}
if (m_enableGamutCheckingAction)
{
m_enableGamutCheckingAction->setEnabled(m_widget);
m_enableGamutCheckingAction->setChecked(m_cmsManager && m_cmsManager->getSettings().isGamutChecking);
}
if (m_showSettingsAction)
{
m_showSettingsAction->setEnabled(m_widget);
}
}
}

View File

@@ -0,0 +1,60 @@
// Copyright (C) 2020 Jakub Melka
//
// This file is part of Pdf4Qt.
//
// Pdf4Qt is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pdf4Qt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
#ifndef SOFTPROOFINGPLUGIN_H
#define SOFTPROOFINGPLUGIN_H
#include "pdfplugin.h"
#include <QObject>
namespace pdfplugin
{
class SoftProofingPlugin : public pdf::PDFPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "Pdf4Qt.SoftProofingPlugin" FILE "SoftProofingPlugin.json")
private:
using BaseClass = pdf::PDFPlugin;
public:
SoftProofingPlugin();
virtual void setWidget(pdf::PDFWidget* widget) override;
virtual void setCMSManager(pdf::PDFCMSManager* manager) override;
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
virtual std::vector<QAction*> getActions() const override;
private:
void onSoftProofingTriggered();
void onGamutCheckingTriggered();
void onSettingsTriggered();
void updateActions();
QAction* m_enableSoftProofingAction;
QAction* m_enableGamutCheckingAction;
QAction* m_showSettingsAction;
bool m_isLoadingGUI;
};
} // namespace pdfplugin
#endif // SOFTPROOFINGPLUGIN_H