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)
|
||||
|
Reference in New Issue
Block a user