diff --git a/PdfForQtViewer/pdfviewermainwindow.cpp b/PdfForQtViewer/pdfviewermainwindow.cpp
index 17bddb0..bce0167 100644
--- a/PdfForQtViewer/pdfviewermainwindow.cpp
+++ b/PdfForQtViewer/pdfviewermainwindow.cpp
@@ -456,8 +456,11 @@ void PDFViewerMainWindow::on_actionGenerateCMAPrepository_triggered()
void PDFViewerMainWindow::on_actionOptions_triggered()
{
- PDFViewerSettingsDialog dialog(this);
- dialog.exec();
+ PDFViewerSettingsDialog dialog(m_settings->getSettings(), this);
+ if (dialog.exec() == QDialog::Accepted)
+ {
+ m_settings->setSettings(dialog.getSettings());
+ }
}
} // namespace pdfviewer
diff --git a/PdfForQtViewer/pdfviewermainwindow.ui b/PdfForQtViewer/pdfviewermainwindow.ui
index 4068a73..a9f0e39 100644
--- a/PdfForQtViewer/pdfviewermainwindow.ui
+++ b/PdfForQtViewer/pdfviewermainwindow.ui
@@ -214,6 +214,9 @@
Options...
+
+ Ctrl+K
+
diff --git a/PdfForQtViewer/pdfviewersettings.cpp b/PdfForQtViewer/pdfviewersettings.cpp
index 0d4693d..c8377f6 100644
--- a/PdfForQtViewer/pdfviewersettings.cpp
+++ b/PdfForQtViewer/pdfviewersettings.cpp
@@ -3,6 +3,12 @@
namespace pdfviewer
{
+void PDFViewerSettings::setSettings(const PDFViewerSettings::Settings& settings)
+{
+ m_settings = settings;
+ emit settingsChanged();
+}
+
void PDFViewerSettings::readSettings(QSettings& settings)
{
settings.beginGroup("ViewerSettings");
diff --git a/PdfForQtViewer/pdfviewersettings.h b/PdfForQtViewer/pdfviewersettings.h
index 1d02828..3a3457d 100644
--- a/PdfForQtViewer/pdfviewersettings.h
+++ b/PdfForQtViewer/pdfviewersettings.h
@@ -19,6 +19,27 @@ public:
}
+ struct Settings
+ {
+ Settings() :
+ m_features(pdf::PDFRenderer::getDefaultFeatures()),
+ m_rendererEngine(pdf::RendererEngine::OpenGL),
+ m_multisampleAntialiasing(true),
+ m_rendererSamples(16)
+ {
+
+ }
+
+ pdf::PDFRenderer::Features m_features;
+ QString m_directory;
+ pdf::RendererEngine m_rendererEngine;
+ bool m_multisampleAntialiasing;
+ int m_rendererSamples;
+ };
+
+ const Settings& getSettings() const { return m_settings; }
+ void setSettings(const Settings& settings);
+
void readSettings(QSettings& settings);
void writeSettings(QSettings& settings);
@@ -38,22 +59,6 @@ signals:
void settingsChanged();
private:
- struct Settings
- {
- Settings() :
- m_features(pdf::PDFRenderer::getDefaultFeatures()),
- m_rendererEngine(pdf::RendererEngine::OpenGL),
- m_rendererSamples(16)
- {
-
- }
-
- pdf::PDFRenderer::Features m_features;
- QString m_directory;
- pdf::RendererEngine m_rendererEngine;
- int m_rendererSamples;
- };
-
Settings m_settings;
};
diff --git a/PdfForQtViewer/pdfviewersettingsdialog.cpp b/PdfForQtViewer/pdfviewersettingsdialog.cpp
index 9506103..b4b4dc4 100644
--- a/PdfForQtViewer/pdfviewersettingsdialog.cpp
+++ b/PdfForQtViewer/pdfviewersettingsdialog.cpp
@@ -1,14 +1,19 @@
#include "pdfviewersettingsdialog.h"
#include "ui_pdfviewersettingsdialog.h"
+#include "pdfglobal.h"
+#include "pdfutils.h"
+
#include
namespace pdfviewer
{
-PDFViewerSettingsDialog::PDFViewerSettingsDialog(QWidget *parent) :
+PDFViewerSettingsDialog::PDFViewerSettingsDialog(const PDFViewerSettings::Settings& settings, QWidget *parent) :
QDialog(parent),
- ui(new Ui::PDFViewerSettingsDialog)
+ ui(new Ui::PDFViewerSettingsDialog),
+ m_settings(settings),
+ m_isLoadingData(false)
{
ui->setupUi(this);
@@ -21,8 +26,26 @@ PDFViewerSettingsDialog::PDFViewerSettingsDialog(QWidget *parent) :
for (int i : { 1, 2, 4, 8, 16 })
{
- ui->multisampleAntialiasingSamplesCountComboBox->addItem(QString::number(i));
+ ui->multisampleAntialiasingSamplesCountComboBox->addItem(QString::number(i), i);
}
+
+ for (QWidget* widget : { ui->engineInfoLabel, ui->renderingInfoLabel })
+ {
+ widget->setMinimumWidth(widget->sizeHint().width());
+ }
+
+ for (QCheckBox* checkBox : { ui->multisampleAntialiasingCheckBox, ui->antialiasingCheckBox, ui->textAntialiasingCheckBox, ui->smoothPicturesCheckBox, ui->ignoreOptionalContentCheckBox, ui->clipToCropBoxCheckBox })
+ {
+ connect(checkBox, &QCheckBox::clicked, this, &PDFViewerSettingsDialog::saveData);
+ }
+ for (QComboBox* comboBox : { ui->renderingEngineComboBox, ui->multisampleAntialiasingSamplesCountComboBox })
+ {
+ connect(comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &PDFViewerSettingsDialog::saveData);
+ }
+
+ ui->optionsPagesWidget->setCurrentRow(0);
+ adjustSize();
+ loadData();
}
PDFViewerSettingsDialog::~PDFViewerSettingsDialog()
@@ -54,4 +77,76 @@ void PDFViewerSettingsDialog::on_optionsPagesWidget_currentItemChanged(QListWidg
}
}
+void PDFViewerSettingsDialog::loadData()
+{
+ pdf::PDFTemporaryValueChange guard(&m_isLoadingData, true);
+ ui->renderingEngineComboBox->setCurrentIndex(ui->renderingEngineComboBox->findData(static_cast(m_settings.m_rendererEngine)));
+
+ if (m_settings.m_rendererEngine == pdf::RendererEngine::OpenGL)
+ {
+ ui->multisampleAntialiasingCheckBox->setEnabled(true);
+ ui->multisampleAntialiasingCheckBox->setChecked(m_settings.m_multisampleAntialiasing);
+ ui->multisampleAntialiasingSamplesCountComboBox->setEnabled(true);
+ ui->multisampleAntialiasingSamplesCountComboBox->setCurrentIndex(ui->multisampleAntialiasingSamplesCountComboBox->findData(m_settings.m_rendererSamples));
+ }
+ else
+ {
+ ui->multisampleAntialiasingCheckBox->setEnabled(false);
+ ui->multisampleAntialiasingCheckBox->setChecked(false);
+ ui->multisampleAntialiasingSamplesCountComboBox->setEnabled(false);
+ ui->multisampleAntialiasingSamplesCountComboBox->setCurrentIndex(-1);
+ }
+
+ ui->antialiasingCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::Antialiasing));
+ ui->textAntialiasingCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::TextAntialiasing));
+ ui->smoothPicturesCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::SmoothImages));
+ ui->ignoreOptionalContentCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::IgnoreOptionalContent));
+ ui->clipToCropBoxCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::ClipToCropBox));
+}
+
+void PDFViewerSettingsDialog::saveData()
+{
+ if (m_isLoadingData)
+ {
+ return;
+ }
+
+ QObject* sender = this->sender();
+
+ if (sender == ui->renderingEngineComboBox)
+ {
+ m_settings.m_rendererEngine = static_cast(ui->renderingEngineComboBox->currentData().toInt());
+ }
+ else if (sender == ui->multisampleAntialiasingCheckBox)
+ {
+ m_settings.m_multisampleAntialiasing = ui->multisampleAntialiasingCheckBox->isChecked();
+ }
+ else if (sender == ui->multisampleAntialiasingSamplesCountComboBox)
+ {
+ m_settings.m_rendererSamples = ui->multisampleAntialiasingSamplesCountComboBox->currentData().toInt();
+ }
+ else if (sender == ui->antialiasingCheckBox)
+ {
+ m_settings.m_features.setFlag(pdf::PDFRenderer::Antialiasing, ui->antialiasingCheckBox->isChecked());
+ }
+ else if (sender == ui->textAntialiasingCheckBox)
+ {
+ m_settings.m_features.setFlag(pdf::PDFRenderer::TextAntialiasing, ui->textAntialiasingCheckBox->isChecked());
+ }
+ else if (sender == ui->smoothPicturesCheckBox)
+ {
+ m_settings.m_features.setFlag(pdf::PDFRenderer::SmoothImages, ui->smoothPicturesCheckBox->isChecked());
+ }
+ else if (sender == ui->ignoreOptionalContentCheckBox)
+ {
+ m_settings.m_features.setFlag(pdf::PDFRenderer::IgnoreOptionalContent, ui->ignoreOptionalContentCheckBox->isChecked());
+ }
+ else if (sender == ui->clipToCropBoxCheckBox)
+ {
+ m_settings.m_features.setFlag(pdf::PDFRenderer::ClipToCropBox, ui->clipToCropBoxCheckBox->isChecked());
+ }
+
+ loadData();
+}
+
} // namespace pdfviewer
diff --git a/PdfForQtViewer/pdfviewersettingsdialog.h b/PdfForQtViewer/pdfviewersettingsdialog.h
index 9a1199c..4d926fe 100644
--- a/PdfForQtViewer/pdfviewersettingsdialog.h
+++ b/PdfForQtViewer/pdfviewersettingsdialog.h
@@ -20,7 +20,7 @@ class PDFViewerSettingsDialog : public QDialog
Q_OBJECT
public:
- explicit PDFViewerSettingsDialog(QWidget* parent);
+ explicit PDFViewerSettingsDialog(const PDFViewerSettings::Settings& settings, QWidget* parent);
virtual ~PDFViewerSettingsDialog() override;
enum Page : int
@@ -30,11 +30,18 @@ public:
ShadingSettings
};
+ const PDFViewerSettings::Settings& getSettings() const { return m_settings; }
+
private slots:
void on_optionsPagesWidget_currentItemChanged(QListWidgetItem* current, QListWidgetItem* previous);
private:
+ void loadData();
+ void saveData();
+
Ui::PDFViewerSettingsDialog* ui;
+ PDFViewerSettings::Settings m_settings;
+ bool m_isLoadingData;
};
} // namespace pdfviewer
diff --git a/PdfForQtViewer/pdfviewersettingsdialog.ui b/PdfForQtViewer/pdfviewersettingsdialog.ui
index ee9696e..393dfa8 100644
--- a/PdfForQtViewer/pdfviewersettingsdialog.ui
+++ b/PdfForQtViewer/pdfviewersettingsdialog.ui
@@ -26,7 +26,7 @@
-
- 1
+ 0