diff options
author | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-06-02 18:17:44 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2015-06-03 07:59:18 +0000 |
commit | 77162b16ebda05e335291b9917b358d1c129096c (patch) | |
tree | 8a849401abaeceaa986cf697a568ff83bdb5d777 /src/gui/kernel/qhighdpiscaling.cpp | |
parent | 39413100cdc8cd7d3ef55ff3c79d94b7cf89cc5e (diff) |
Print "deprecated" warning on QT_DEVICE_PIXEL_RATIO usage.
Also clean up the env. variable definitions.
Change-Id: If51ab515d7d7d6be9b984417ce7262a83ea48a66
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling.cpp')
-rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 4a71f12a5a..0adcc65a2c 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -52,23 +52,31 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); -static const char legacyEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; +static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; +static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR"; +static const char autoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; static inline qreal initialScaleFactor() { - static const char envVar[] = "QT_SCALE_FACTOR"; + qreal result = 1; - if (qEnvironmentVariableIsSet(envVar)) { + if (qEnvironmentVariableIsSet(scaleFactorEnvVar)) { bool ok; - const qreal f = qgetenv(envVar).toDouble(&ok); + const qreal f = qgetenv(scaleFactorEnvVar).toDouble(&ok); if (ok && f > 0) { - qCDebug(lcScaling) << "Apply QT_SCALE_FACTOR" << f; + qCDebug(lcScaling) << "Apply " << scaleFactorEnvVar << f; result = f; } } else { - int dpr = qEnvironmentVariableIntValue(legacyEnvVar); - if (dpr > 0) - result = dpr; + if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) { + qWarning() << "Warning:" << legacyDevicePixelEnvVar << "is deprecated. Instead use:"; + qWarning() << " " << scaleFactorEnvVar << "to set the application global scale factor."; + qWarning() << " " << autoScreenEnvVar << "to enable platform plugin controlled per-screen factors."; + + int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar); + if (dpr > 0) + result = dpr; + } } return result; } @@ -93,7 +101,8 @@ bool QHighDpiScaling::m_usePixelDensity; // use scale factor from platform plugi void QHighDpiScaling::initHighDPiScaling() { m_factor = initialScaleFactor(); - bool usePlatformPluginPixelDensity = qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR") || qgetenv(legacyEnvVar).toLower() == "auto"; + bool usePlatformPluginPixelDensity = qEnvironmentVariableIsSet(autoScreenEnvVar) + || qgetenv(legacyDevicePixelEnvVar).toLower() == "auto"; // m_active below is "overall active" - is there any scale factor set. m_active = !qFuzzyCompare(m_factor, qreal(1)) || usePlatformPluginPixelDensity; |