summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-16 13:21:58 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-06-18 13:16:19 +0000
commit60f5e7c0eb82abd86e7eef732b3bcf41745dc331 (patch)
treec029530d003afa4b70d5b60d559374d8c5045e1d /src/gui/kernel/qhighdpiscaling.cpp
parent30ab9184ad452c892ddd02126ff52d7c7b5f5c38 (diff)
Scale logicalDpi when turning on screen scaling
Assume that the logical DPI for the primary screen is sane, and keep font sizes constant as screens are scaled. The global scale factor will act as a zoom level, and will cause all fonts to be bigger. Note that since we do not change logicalDpi after application startup, the manual test sliders will not match what happens with auto scaling. We may want to fix that... Change-Id: I5a3daa57c2dacf0158836492d31573723e49399a Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling.cpp')
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 2fee06c77d..8dd6c6687d 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -128,6 +128,7 @@ bool QHighDpiScaling::m_usePixelDensity; // use scale factor from platform plugi
bool QHighDpiScaling::m_pixelDensityScalingActive; // pixel density scale factor > 1
bool QHighDpiScaling::m_globalScalingActive; // global scale factor is active
bool QHighDpiScaling::m_screenFactorSet; // QHighDpiScaling::setScreenFactor has been used
+QDpi QHighDpiScaling::m_logicalDpi; // The scaled logical DPI of the primary screen
/*
Initializes the QHighDpiScaling global variables. Called before the
@@ -159,6 +160,11 @@ void QHighDpiScaling::updateHighDpiScaling()
}
}
m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
+
+ QPlatformScreen *primaryScreen = QGuiApplication::primaryScreen()->handle();
+ qreal sf = screenSubfactor(primaryScreen);
+ QDpi primaryDpi = primaryScreen->logicalDpi();
+ m_logicalDpi = QDpi(primaryDpi.first / sf, primaryDpi.second / sf);
}
/*
@@ -246,6 +252,11 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
return factor;
}
+QDpi QHighDpiScaling::logicalDpi()
+{
+ return m_logicalDpi;
+}
+
qreal QHighDpiScaling::factor(const QScreen *screen)
{
// Fast path for when scaling in Qt is not used at all.