mirror of https://github.com/JakubMelka/PDF4QT.git
Issue #108: Add accessibility options in pdf reader [enhancement] - settings in ui, finish work
This commit is contained in:
parent
6f6ddaab04
commit
65fd88aa71
|
@ -1457,7 +1457,14 @@ void PDFCMSManager::setSettings(const PDFCMSSettings& settings)
|
|||
|
||||
PDFColorConvertor PDFCMSManager::getColorConvertor() const
|
||||
{
|
||||
return PDFColorConvertor();
|
||||
QMutexLocker lock(&m_mutex);
|
||||
|
||||
PDFColorConvertor colorConvertor;
|
||||
colorConvertor.setBackgroundColor(m_settings.backgroundColor);
|
||||
colorConvertor.setForegroundColor(m_settings.foregroundColor);
|
||||
colorConvertor.setHighContrastBrightnessFactor(m_settings.sigmoidSlopeFactor);
|
||||
colorConvertor.setBitonalThreshold(m_settings.bitonalThreshold);
|
||||
return colorConvertor;
|
||||
}
|
||||
|
||||
const PDFColorProfileIdentifiers& PDFCMSManager::getOutputProfiles() const
|
||||
|
|
|
@ -84,6 +84,12 @@ struct PDFCMSSettings
|
|||
QString deviceCMYK; ///< Identifiers for color space (device CMYK)
|
||||
QString softProofingProfile; ///< Identifiers for soft proofing profile
|
||||
QString profileDirectory; ///< Directory containing color profiles
|
||||
|
||||
// Postprocessing
|
||||
QColor foregroundColor = Qt::green;
|
||||
QColor backgroundColor = Qt::black;
|
||||
int bitonalThreshold = 128;
|
||||
double sigmoidSlopeFactor = 10.0;
|
||||
};
|
||||
|
||||
/// Color management system base class. It contains functions to transform
|
||||
|
|
|
@ -197,6 +197,26 @@ void PDFColorConvertor::calculateSigmoidParams()
|
|||
m_sigmoidParamC_Range = sigmoidParamC_Range();
|
||||
}
|
||||
|
||||
QColor PDFColorConvertor::getForegroundColor() const
|
||||
{
|
||||
return m_foregroundColor;
|
||||
}
|
||||
|
||||
QColor PDFColorConvertor::getBackgroundColor() const
|
||||
{
|
||||
return m_backgroundColor;
|
||||
}
|
||||
|
||||
void PDFColorConvertor::setForegroundColor(const QColor& newForegroundColor)
|
||||
{
|
||||
m_foregroundColor = newForegroundColor;
|
||||
}
|
||||
|
||||
void PDFColorConvertor::setBackgroundColor(const QColor& newBackgroundColor)
|
||||
{
|
||||
m_backgroundColor = newBackgroundColor;
|
||||
}
|
||||
|
||||
int PDFColorConvertor::getBitonalThreshold() const
|
||||
{
|
||||
return m_bitonalThreshold;
|
||||
|
|
|
@ -92,6 +92,17 @@ public:
|
|||
/// to ensure accurate differentiation between light and dark areas in images.
|
||||
void setBitonalThreshold(int newBitonalThreshold);
|
||||
|
||||
/// Set background color
|
||||
/// \param newBackgroundColor Background color
|
||||
void setBackgroundColor(const QColor& newBackgroundColor);
|
||||
|
||||
/// Set foreground color
|
||||
/// \param newForegroundColor Foreground color
|
||||
void setForegroundColor(const QColor& newForegroundColor);
|
||||
|
||||
QColor getBackgroundColor() const;
|
||||
QColor getForegroundColor() const;
|
||||
|
||||
private:
|
||||
/// Correct lightness using sigmoid function
|
||||
/// \return Adjusted lightness normalized in range [0.0, 1.0]
|
||||
|
|
|
@ -120,7 +120,11 @@ PDFViewerMainWindowLite::PDFViewerMainWindowLite(QWidget* parent) :
|
|||
m_actionManager->setAction(PDFActionManager::RenderOptionSmoothPictures, ui->actionRenderOptionSmoothPictures);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionIgnoreOptionalContentSettings, ui->actionRenderOptionIgnoreOptionalContentSettings);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionDisplayAnnotations, ui->actionRenderOptionDisplayAnnotations);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionInvertColors, ui->actionInvertColors);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionInvertColors, ui->actionColorInvert);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionGrayscale, ui->actionColorGrayscale);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionHighContrast, ui->actionColorHighContrast);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionBitonal, ui->actionColorBitonal);
|
||||
m_actionManager->setAction(PDFActionManager::RenderOptionCustomColors, ui->actionColorCustom);
|
||||
m_actionManager->setAction(PDFActionManager::Properties, ui->actionProperties);
|
||||
m_actionManager->setAction(PDFActionManager::Options, ui->actionOptions);
|
||||
m_actionManager->setAction(PDFActionManager::ResetToFactorySettings, ui->actionResetToFactorySettings);
|
||||
|
|
|
@ -87,7 +87,11 @@
|
|||
<addaction name="actionFitWidth"/>
|
||||
<addaction name="actionFitHeight"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionInvertColors"/>
|
||||
<addaction name="actionColorInvert"/>
|
||||
<addaction name="actionColorGrayscale"/>
|
||||
<addaction name="actionColorHighContrast"/>
|
||||
<addaction name="actionColorBitonal"/>
|
||||
<addaction name="actionColorCustom"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
|
@ -349,7 +353,7 @@
|
|||
<string>Send by E-Mail...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInvertColors">
|
||||
<action name="actionColorInvert">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -358,7 +362,55 @@
|
|||
<normaloff>:/resources/invert-colors.svg</normaloff>:/resources/invert-colors.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Invert Colors</string>
|
||||
<string>Color | Inverted</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColorGrayscale">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
<normaloff>:/resources/invert-colors.svg</normaloff>:/resources/invert-colors.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color | Grayscale</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColorHighContrast">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
<normaloff>:/resources/invert-colors.svg</normaloff>:/resources/invert-colors.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color | High Contrast</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColorBitonal">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
<normaloff>:/resources/invert-colors.svg</normaloff>:/resources/invert-colors.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color | Monochromatic</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColorCustom">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="pdf4qtviewer.qrc">
|
||||
<normaloff>:/resources/invert-colors.svg</normaloff>:/resources/invert-colors.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Color | Custom</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRotateRight">
|
||||
|
|
|
@ -78,6 +78,10 @@ void PDFViewerSettings::readSettings(QSettings& settings, const pdf::PDFCMSSetti
|
|||
m_colorManagementSystemSettings.proofingIntent = static_cast<pdf::RenderingIntent>(settings.value("proofingIntent", int(defaultCMSSettings.proofingIntent)).toInt());
|
||||
m_colorManagementSystemSettings.outOfGamutColor = settings.value("outOfGamutColor", defaultCMSSettings.outOfGamutColor).value<QColor>();
|
||||
m_colorManagementSystemSettings.profileDirectory = settings.value("profileDirectory", defaultCMSSettings.profileDirectory).toString();
|
||||
m_colorManagementSystemSettings.foregroundColor = settings.value("foregroundColor", defaultCMSSettings.foregroundColor).value<QColor>();
|
||||
m_colorManagementSystemSettings.backgroundColor = settings.value("backgroundColor", defaultCMSSettings.backgroundColor).value<QColor>();
|
||||
m_colorManagementSystemSettings.sigmoidSlopeFactor = settings.value("sigmoidSlopeFactor", defaultCMSSettings.sigmoidSlopeFactor).toDouble();
|
||||
m_colorManagementSystemSettings.bitonalThreshold = settings.value("bitonalThreshold",defaultCMSSettings.bitonalThreshold).toInt();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("SpeechSettings");
|
||||
|
@ -145,6 +149,10 @@ void PDFViewerSettings::writeSettings(QSettings& settings)
|
|||
settings.setValue("proofingIntent", int(m_colorManagementSystemSettings.proofingIntent));
|
||||
settings.setValue("outOfGamutColor", m_colorManagementSystemSettings.outOfGamutColor);
|
||||
settings.setValue("profileDirectory", m_colorManagementSystemSettings.profileDirectory);
|
||||
settings.setValue("foregroundColor", m_colorManagementSystemSettings.foregroundColor);
|
||||
settings.setValue("backgroundColor", m_colorManagementSystemSettings.backgroundColor);
|
||||
settings.setValue("sigmoidSlopeFactor", m_colorManagementSystemSettings.sigmoidSlopeFactor);
|
||||
settings.setValue("bitonalThreshold", m_colorManagementSystemSettings.bitonalThreshold);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("SpeechSettings");
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "pdfutils.h"
|
||||
#include "pdfwidgetutils.h"
|
||||
#include "pdfrecentfilemanager.h"
|
||||
#include "pdfcolorconvertor.h"
|
||||
#include "pdfdbgheap.h"
|
||||
|
||||
#include <QAction>
|
||||
|
@ -82,7 +83,8 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
|||
new QListWidgetItem(QIcon(":/resources/shading.svg"), tr("Shading"), ui->optionsPagesWidget, ShadingSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/cache.svg"), tr("Cache"), ui->optionsPagesWidget, CacheSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/shortcuts.svg"), tr("Shortcuts"), ui->optionsPagesWidget, ShortcutSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/cms.svg"), tr("Colors"), ui->optionsPagesWidget, ColorManagementSystemSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/cms.svg"), tr("Colors | CMS"), ui->optionsPagesWidget, ColorManagementSystemSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/cms.svg"), tr("Colors | Postprocessing"), ui->optionsPagesWidget, ColorPostprocessingSettings);
|
||||
new QListWidgetItem(QIcon(":/resources/security.svg"), tr("Security"), ui->optionsPagesWidget, SecuritySettings);
|
||||
new QListWidgetItem(QIcon(":/resources/ui.svg"), tr("UI"), ui->optionsPagesWidget, UISettings);
|
||||
new QListWidgetItem(QIcon(":/resources/speech.svg"), tr("Speech"), ui->optionsPagesWidget, SpeechSettings);
|
||||
|
@ -146,7 +148,7 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settin
|
|||
fillColorProfileList(ui->cmsDeviceRGBColorProfileComboBox, cmsManager->getRGBProfiles());
|
||||
fillColorProfileList(ui->cmsDeviceCMYKColorProfileComboBox, cmsManager->getCMYKProfiles());
|
||||
|
||||
for (QWidget* widget : { ui->engineInfoLabel, ui->renderingInfoLabel, ui->securityInfoLabel, ui->cmsInfoLabel })
|
||||
for (QWidget* widget : { ui->engineInfoLabel, ui->renderingInfoLabel, ui->securityInfoLabel, ui->cmsInfoLabel, ui->colorPostProcessingInfoLabel })
|
||||
{
|
||||
widget->setMinimumWidth(widget->sizeHint().width());
|
||||
}
|
||||
|
@ -236,6 +238,10 @@ void PDFViewerSettingsDialog::on_optionsPagesWidget_currentItemChanged(QListWidg
|
|||
ui->stackedWidget->setCurrentWidget(ui->cmsPage);
|
||||
break;
|
||||
|
||||
case ColorPostprocessingSettings:
|
||||
ui->stackedWidget->setCurrentWidget(ui->cmsPostprocessingPage);
|
||||
break;
|
||||
|
||||
case SecuritySettings:
|
||||
ui->stackedWidget->setCurrentWidget(ui->securityPage);
|
||||
break;
|
||||
|
@ -386,6 +392,12 @@ void PDFViewerSettingsDialog::loadData()
|
|||
ui->cmsProfileDirectoryEdit->setText(QString());
|
||||
}
|
||||
|
||||
// Color postprocessing
|
||||
ui->foregroundColorEdit->setText(m_cmsSettings.foregroundColor.name(QColor::HexRgb));
|
||||
ui->backgroundColorEdit->setText(m_cmsSettings.backgroundColor.name(QColor::HexRgb));
|
||||
ui->sigmoidFunctionSlopeEdit->setValue(m_cmsSettings.sigmoidSlopeFactor);
|
||||
ui->bitonalThresholdEdit->setValue(m_cmsSettings.bitonalThreshold);
|
||||
|
||||
// Text-to-speech
|
||||
ui->speechEnginesComboBox->setCurrentIndex(ui->speechEnginesComboBox->findData(m_settings.m_speechEngine));
|
||||
setSpeechEngine(m_settings.m_speechEngine, m_settings.m_speechLocale);
|
||||
|
@ -587,6 +599,32 @@ void PDFViewerSettingsDialog::saveData()
|
|||
{
|
||||
m_settings.m_magnifierZoom = ui->magnifierZoomEdit->value();
|
||||
}
|
||||
else if (sender == ui->foregroundColorEdit)
|
||||
{
|
||||
m_cmsSettings.foregroundColor.setNamedColor(ui->foregroundColorEdit->text());
|
||||
if (!m_cmsSettings.foregroundColor.isValid())
|
||||
{
|
||||
pdf::PDFColorConvertor colorConvertor;
|
||||
m_cmsSettings.foregroundColor = colorConvertor.getForegroundColor();
|
||||
}
|
||||
}
|
||||
else if (sender == ui->backgroundColorEdit)
|
||||
{
|
||||
m_cmsSettings.backgroundColor.setNamedColor(ui->backgroundColorEdit->text());
|
||||
if (!m_cmsSettings.backgroundColor.isValid())
|
||||
{
|
||||
pdf::PDFColorConvertor colorConvertor;
|
||||
m_cmsSettings.backgroundColor = colorConvertor.getBackgroundColor();
|
||||
}
|
||||
}
|
||||
else if (sender == ui->sigmoidFunctionSlopeEdit)
|
||||
{
|
||||
m_cmsSettings.sigmoidSlopeFactor = ui->sigmoidFunctionSlopeEdit->value();
|
||||
}
|
||||
else if (sender == ui->bitonalThresholdEdit)
|
||||
{
|
||||
m_cmsSettings.bitonalThreshold = ui->bitonalThresholdEdit->value();
|
||||
}
|
||||
else if (sender == ui->formHighlightFieldsCheckBox)
|
||||
{
|
||||
m_settings.m_formAppearanceFlags.setFlag(pdf::PDFFormManager::HighlightFields, ui->formHighlightFieldsCheckBox->isChecked());
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
CacheSettings,
|
||||
ShortcutSettings,
|
||||
ColorManagementSystemSettings,
|
||||
ColorPostprocessingSettings,
|
||||
SecuritySettings,
|
||||
UISettings,
|
||||
SpeechSettings,
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>7</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="enginePage">
|
||||
<layout class="QVBoxLayout" name="enginePageLayout">
|
||||
|
@ -792,6 +792,97 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="cmsPostprocessingPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Color Postprocessing</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="backgroundColorEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="sigmoidParamLabel">
|
||||
<property name="text">
|
||||
<string>Sigmoid function slope parameter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="foregroundColorLabel">
|
||||
<property name="text">
|
||||
<string>Foreground color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="foregroundColorEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="backgroundColorLabel">
|
||||
<property name="text">
|
||||
<string>Background color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="sigmoidFunctionSlopeEdit">
|
||||
<property name="minimum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="bitonalThresholdLabel">
|
||||
<property name="text">
|
||||
<string>Bitonal threshold</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="bitonalThresholdEdit">
|
||||
<property name="maximum">
|
||||
<number>255</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="colorPostProcessingInfoLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:700;">Foreground</span> and <span style=" font-weight:700;">background</span> colors refer to a custom colors rendering mode, where two colors are used - the paper is drawn with the background color, and the foreground color is used for text and graphics. By default, the background is black and the foreground is green, which is easy on the eyes. </p><p><span style=" font-weight:700;">Sigmoid function slope parameter</span> is a parameter in high contrast color rendering. This rendering mode displays all graphics in high contrast. This parameter affects the degree of contrast. Set the value from 1 to 5 for a small contrast change, from 5 to 10 for a medium contrast change, and more than 10 for very high contrast rendering. </p><p><span style=" font-weight:700;">Bitonal threshold</span> is used in the bitonal rendering color mode. It distinguishes between black and white colors. However, the threshold for images is determined automatically. </p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="securityPage">
|
||||
<layout class="QVBoxLayout" name="securityPageLayout">
|
||||
<property name="leftMargin">
|
||||
|
|
Loading…
Reference in New Issue