Issue #108: Add accessibility options in pdf reader [enhancement] - settings in ui, finish work

This commit is contained in:
Jakub Melka
2023-11-19 14:28:23 +01:00
parent 6f6ddaab04
commit 65fd88aa71
10 changed files with 256 additions and 18 deletions

View File

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