PDF4QT/PdfForQtViewer/pdfviewersettings.h

131 lines
4.6 KiB
C
Raw Normal View History

2020-01-18 11:38:54 +01:00
// Copyright (C) 2019-2020 Jakub Melka
2019-12-07 17:59:03 +01:00
//
// This file is part of PdfForQt.
//
// PdfForQt 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.
//
// PdfForQt 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 PDFForQt. If not, see <https://www.gnu.org/licenses/>.
2019-09-06 19:07:52 +02:00
#ifndef PDFVIEWERSETTINGS_H
#define PDFVIEWERSETTINGS_H
#include "pdfrenderer.h"
#include "pdfcms.h"
2020-01-18 14:55:26 +01:00
#include "pdfexecutionpolicy.h"
2019-09-06 19:07:52 +02:00
#include <QObject>
namespace pdfviewer
{
class PDFViewerSettings : public QObject
{
Q_OBJECT
public:
inline explicit PDFViewerSettings(QObject* parent) :
QObject(parent)
{
}
2019-09-07 19:01:54 +02:00
struct Settings
{
2019-12-15 19:28:25 +01:00
Settings();
2019-09-07 19:01:54 +02:00
bool operator==(const Settings&) const = default;
bool operator!=(const Settings&) const = default;
2019-09-07 19:01:54 +02:00
pdf::PDFRenderer::Features m_features;
QString m_directory;
pdf::RendererEngine m_rendererEngine;
bool m_multisampleAntialiasing;
int m_rendererSamples;
2019-12-15 17:46:58 +01:00
bool m_prefetchPages;
2019-09-28 18:26:31 +02:00
pdf::PDFReal m_preferredMeshResolutionRatio;
pdf::PDFReal m_minimalMeshResolutionRatio;
pdf::PDFReal m_colorTolerance;
2019-11-30 16:26:32 +01:00
bool m_allowLaunchApplications;
bool m_allowLaunchURI;
2020-01-18 14:55:26 +01:00
pdf::PDFExecutionPolicy::Strategy m_multithreadingStrategy = pdf::PDFExecutionPolicy::Strategy::PageMultithreaded;
2019-12-15 19:28:25 +01:00
// Cache settings
int m_compiledPageCacheLimit;
int m_thumbnailsCacheLimit;
int m_fontCacheLimit;
int m_instancedFontCacheLimit;
2020-02-13 18:31:00 +01:00
// Speech settings
QString m_speechEngine;
QString m_speechLocale;
QString m_speechVoice;
double m_speechRate;
double m_speechPitch;
double m_speechVolume;
2020-02-22 18:27:33 +01:00
// Magnifier tool settings
int m_magnifierSize;
double m_magnifierZoom;
2019-09-07 19:01:54 +02:00
};
const Settings& getSettings() const { return m_settings; }
void setSettings(const Settings& settings);
void readSettings(QSettings& settings, const pdf::PDFCMSSettings& defaultCMSSettings);
2019-09-06 19:07:52 +02:00
void writeSettings(QSettings& settings);
QString getDirectory() const;
void setDirectory(const QString& directory);
pdf::PDFRenderer::Features getFeatures() const;
void setFeatures(const pdf::PDFRenderer::Features& features);
pdf::RendererEngine getRendererEngine() const;
void setRendererEngine(pdf::RendererEngine rendererEngine);
int getRendererSamples() const;
void setRendererSamples(int rendererSamples);
2019-12-15 17:46:58 +01:00
bool isPagePrefetchingEnabled() const { return m_settings.m_prefetchPages; }
2019-09-08 11:13:59 +02:00
bool isMultisampleAntialiasingEnabled() const { return m_settings.m_multisampleAntialiasing; }
2019-09-28 18:26:31 +02:00
pdf::PDFReal getPreferredMeshResolutionRatio() const { return m_settings.m_preferredMeshResolutionRatio; }
void setPreferredMeshResolutionRatio(pdf::PDFReal preferredMeshResolutionRatio);
pdf::PDFReal getMinimalMeshResolutionRatio() const { return m_settings.m_minimalMeshResolutionRatio; }
void setMinimalMeshResolutionRatio(pdf::PDFReal minimalMeshResolutionRatio);
pdf::PDFReal getColorTolerance() const { return m_settings.m_colorTolerance; }
void setColorTolerance(pdf::PDFReal colorTolerance);
2019-12-15 19:28:25 +01:00
int getCompiledPageCacheLimit() const { return m_settings.m_compiledPageCacheLimit; }
int getThumbnailsCacheLimit() const { return m_settings.m_thumbnailsCacheLimit; }
int getFontCacheLimit() const { return m_settings.m_fontCacheLimit; }
int getInstancedFontCacheLimit() const { return m_settings.m_instancedFontCacheLimit; }
const pdf::PDFCMSSettings& getColorManagementSystemSettings() const { return m_colorManagementSystemSettings; }
void setColorManagementSystemSettings(const pdf::PDFCMSSettings& settings) { m_colorManagementSystemSettings = settings; }
2020-01-18 14:55:26 +01:00
pdf::PDFExecutionPolicy::Strategy getMultithreadingStrategy() const { return m_settings.m_multithreadingStrategy; }
2019-09-06 19:07:52 +02:00
signals:
void settingsChanged();
private:
Settings m_settings;
pdf::PDFCMSSettings m_colorManagementSystemSettings;
2019-09-06 19:07:52 +02:00
};
} // namespace pdfviewer
#endif // PDFVIEWERSETTINGS_H