Rename “pixelDensity” variables

QHighDpiScaling now computes scale factors based on
QPlatformScreen::logicalDpi(), instead of by calling
QPlatformScreen::pixelDensity() as done earlier.

We forgot the rename the internal state variables,
update them to indicate that platform screen DPI is
used.

Change-Id: Ib718a6176e0ac138395eea13b292f75f69dac3ad
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2020-08-07 12:21:29 +02:00
parent 351d066adb
commit 1b7ee06605
2 changed files with 16 additions and 16 deletions

View File

@ -271,8 +271,8 @@ static inline qreal initialGlobalScaleFactor()
qreal QHighDpiScaling::m_factor = 1.0;
bool QHighDpiScaling::m_active = false; //"overall active" - is there any scale factor set.
bool QHighDpiScaling::m_usePixelDensity = false; // use scale factor from platform plugin
bool QHighDpiScaling::m_pixelDensityScalingActive = false; // pixel density scale factor > 1
bool QHighDpiScaling::m_usePlatformPluginDpi = false; // use scale factor based on platform plugin DPI
bool QHighDpiScaling::m_platformPluginDpiScalingActive = false; // platform plugin DPI gives a scale factor > 1
bool QHighDpiScaling::m_globalScalingActive = false; // global scale factor is active
bool QHighDpiScaling::m_screenFactorSet = false; // QHighDpiScaling::setScreenFactor has been used
@ -281,9 +281,9 @@ bool QHighDpiScaling::m_screenFactorSet = false; // QHighDpiScaling::setScreenFa
platform plugin is created.
*/
static inline bool usePixelDensity()
static inline bool usePlatformPluginDpi()
{
// Determine if we should set a scale factor based on the pixel density
// Determine if we should set a scale factor based on the logical DPI
// reported by the platform plugin.
bool enableEnvValueOk;
@ -493,22 +493,22 @@ void QHighDpiScaling::initHighDpiScaling()
m_factor = initialGlobalScaleFactor();
m_globalScalingActive = !qFuzzyCompare(m_factor, qreal(1));
m_usePixelDensity = usePixelDensity();
m_usePlatformPluginDpi = usePlatformPluginDpi();
m_pixelDensityScalingActive = false; //set in updateHighDpiScaling below
m_platformPluginDpiScalingActive = false; //set in updateHighDpiScaling below
m_active = m_globalScalingActive || m_usePixelDensity;
m_active = m_globalScalingActive || m_usePlatformPluginDpi;
}
void QHighDpiScaling::updateHighDpiScaling()
{
m_usePixelDensity = usePixelDensity();
m_usePlatformPluginDpi = usePlatformPluginDpi();
if (m_usePixelDensity && !m_pixelDensityScalingActive) {
if (m_usePlatformPluginDpi && !m_platformPluginDpiScalingActive ) {
const auto screens = QGuiApplication::screens();
for (QScreen *screen : screens) {
if (!qFuzzyCompare(screenSubfactor(screen->handle()), qreal(1))) {
m_pixelDensityScalingActive = true;
m_platformPluginDpiScalingActive = true;
break;
}
}
@ -546,7 +546,7 @@ void QHighDpiScaling::updateHighDpiScaling()
++i;
}
}
m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive ;
}
/*
@ -561,7 +561,7 @@ void QHighDpiScaling::setGlobalFactor(qreal factor)
m_globalScalingActive = !qFuzzyCompare(factor, qreal(1));
m_factor = m_globalScalingActive ? factor : qreal(1);
m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive;
m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive ;
const auto screens = QGuiApplication::screens();
for (QScreen *screen : screens)
screen->d_func()->updateHighDpi();
@ -638,7 +638,7 @@ qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
}
}
if (!screenPropertyUsed && m_usePixelDensity)
if (!screenPropertyUsed && m_usePlatformPluginDpi)
factor = roundScaleFactor(rawScaleFactor(screen));
return factor;
@ -650,7 +650,7 @@ QDpi QHighDpiScaling::logicalDpi(const QScreen *screen)
if (!screen || !screen->handle())
return QDpi(96, 96);
if (!m_usePixelDensity) {
if (!m_usePlatformPluginDpi) {
const qreal screenScaleFactor = screenSubfactor(screen->handle());
const QDpi dpi = QPlatformScreen::overrideDpi(screen->handle()->logicalDpi());
return QDpi{ dpi.first / screenScaleFactor, dpi.second / screenScaleFactor };

View File

@ -134,9 +134,9 @@ private:
static qreal m_factor;
static bool m_active;
static bool m_usePixelDensity;
static bool m_usePlatformPluginDpi;
static bool m_platformPluginDpiScalingActive;
static bool m_globalScalingActive;
static bool m_pixelDensityScalingActive;
static bool m_screenFactorSet;
static QDpi m_logicalDpi;
};