mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Issue #59: Use optionally logical pixels when zooming
This commit is contained in:
@ -29,6 +29,8 @@
|
||||
#include <QTimer>
|
||||
#include <QPainter>
|
||||
#include <QFontMetrics>
|
||||
#include <QScreen>
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace pdf
|
||||
{
|
||||
@ -535,10 +537,23 @@ void PDFDrawWidgetProxy::update()
|
||||
Q_ASSERT(m_verticalScrollbar);
|
||||
|
||||
QWidget* widget = m_widget->getDrawWidget()->getWidget();
|
||||
QScreen* primaryScreen = QGuiApplication::primaryScreen();
|
||||
|
||||
// First, we must calculate pixel per mm ratio to obtain DPMM (device pixel per mm),
|
||||
// we also assume, that zoom is correctly set.
|
||||
m_pixelPerMM = static_cast<PDFReal>(widget->width()) / static_cast<PDFReal>(widget->widthMM());
|
||||
QSizeF physicalSize = primaryScreen->physicalSize();
|
||||
QSizeF pixelSize = primaryScreen->size();
|
||||
|
||||
m_pixelPerMM = pixelSize.width() / physicalSize.width();
|
||||
|
||||
// Are we using logical pixels instead of physical ones?
|
||||
if (m_features.testFlag(PDFRenderer::LogicalSizeZooming))
|
||||
{
|
||||
qreal ldpi = primaryScreen->logicalDotsPerInch();
|
||||
qreal pdpi = primaryScreen->physicalDotsPerInch();
|
||||
qreal ratioLogicalToPhysical = ldpi / pdpi;
|
||||
m_pixelPerMM *= ratioLogicalToPhysical;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_zoom > 0.0);
|
||||
Q_ASSERT(m_pixelPerMM > 0.0);
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
InvertColors = 0x0100, ///< Invert colors
|
||||
DenyExtraGraphics = 0x0200, ///< Do not display additional graphics, for example from tools
|
||||
DisplayAnnotations = 0x0400, ///< Display annotations
|
||||
LogicalSizeZooming = 0x0800, ///< Use logical pixel resolution instead of physical one when zooming
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Features, Feature)
|
||||
|
@ -329,6 +329,7 @@ void PDFViewerSettingsDialog::loadData()
|
||||
ui->maximumUndoStepsEdit->setValue(m_settings.m_maximumUndoSteps);
|
||||
ui->maximumRedoStepsEdit->setValue(m_settings.m_maximumRedoSteps);
|
||||
ui->developerModeCheckBox->setChecked(m_settings.m_allowDeveloperMode);
|
||||
ui->logicalPixelZoomCheckBox->setChecked(m_settings.m_features.testFlag(pdf::PDFRenderer::LogicalSizeZooming));
|
||||
|
||||
// CMS
|
||||
ui->cmsTypeComboBox->setCurrentIndex(ui->cmsTypeComboBox->findData(int(m_cmsSettings.system)));
|
||||
@ -602,6 +603,10 @@ void PDFViewerSettingsDialog::saveData()
|
||||
{
|
||||
m_settings.m_maximumRedoSteps = ui->maximumRedoStepsEdit->value();
|
||||
}
|
||||
else if (sender == ui->logicalPixelZoomCheckBox)
|
||||
{
|
||||
m_settings.m_features.setFlag(pdf::PDFRenderer::LogicalSizeZooming, ui->logicalPixelZoomCheckBox->isChecked());
|
||||
}
|
||||
else if (sender == ui->signatureVerificationEnableCheckBox)
|
||||
{
|
||||
m_settings.m_signatureVerificationEnabled = ui->signatureVerificationEnableCheckBox->isChecked();
|
||||
|
@ -35,7 +35,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>10</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="enginePage">
|
||||
<layout class="QVBoxLayout" name="enginePageLayout">
|
||||
@ -901,6 +901,30 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="magnifierSizeLabel">
|
||||
<property name="text">
|
||||
<string>Magnifier size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="maximumRecentFileCountEdit"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="maximumUndoStepsEdit">
|
||||
<property name="maximum">
|
||||
<number>20</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="maximumUndoStepsLabel">
|
||||
<property name="text">
|
||||
<string>Maximum undo steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="maximumRedoStepsEdit">
|
||||
<property name="maximum">
|
||||
@ -908,6 +932,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="magnifierZoomEdit">
|
||||
<property name="minimum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="maximumRedoStepsLabel">
|
||||
<property name="text">
|
||||
@ -915,17 +949,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="magnifierSizeLabel">
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="developerModeCheckBox">
|
||||
<property name="text">
|
||||
<string>Magnifier size</string>
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="maximumUndoStepsEdit">
|
||||
<property name="maximum">
|
||||
<number>20</number>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="developerModeLabel">
|
||||
<property name="text">
|
||||
<string>Developer mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -949,37 +983,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="maximumRecentFileCountEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="maximumUndoStepsLabel">
|
||||
<property name="text">
|
||||
<string>Maximum undo steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="magnifierZoomEdit">
|
||||
<property name="minimum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="developerModeCheckBox">
|
||||
<widget class="QCheckBox" name="logicalPixelZoomCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="developerModeLabel">
|
||||
<widget class="QLabel" name="logicalPixelZoomLabel">
|
||||
<property name="text">
|
||||
<string>Developer mode</string>
|
||||
<string>Use logical pixels when zooming</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Reference in New Issue
Block a user