diff options
| author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2016-11-10 14:17:53 +0100 |
|---|---|---|
| committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2019-08-23 03:41:14 +0200 |
| commit | 1de8b01d2b6db8a4fe2eddd0c595d9e680964db5 (patch) | |
| tree | b2cea85b45939facfe375065e94a9b2655e7318c /src | |
| parent | 35da4eeba263db411d929fd278a4617dd7cf5c22 (diff) | |
Deprecate QT_AUTO_SCREEN_SCALE_FACTOR
Replace by QT_ENABLE_HIGHDPI_SCALING.
QT_AUTO_SCREEN_SCALE_FACTOR has the usability problem that it mixes
enabling the high-DPI scaling mode with the method of getting screen
scale factors (“auto”). Due to this, it ends up with a slightly
strange name.
QT_ENABLE_HIGHDPI_SCALING matches the C++ option
(Qt::AA_EnableHighDPiScaling), and leaves the scale factor acquisition
method unspecified, possibly to be set by some other means (like
QT_SCREEN_SCALE_FACTORS).
Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io>
Task-number: QTBUG-53022
Change-Id: I30033d91175a00db7837efc9c48c33396f5f0449
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui/kernel/qhighdpiscaling.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index 3de67d5cfa2..4a9c9a99347 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -56,8 +56,10 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); #ifndef QT_NO_HIGHDPISCALING static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; +static const char legacyAutoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; + +static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING"; static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR"; -static const char autoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; static const char screenFactorsEnvVar[] = "QT_SCREEN_SCALE_FACTORS"; static const char scaleFactorRoundingPolicyEnvVar[] = "QT_SCALE_FACTOR_ROUNDING_POLICY"; static const char dpiAdjustmentPolicyEnvVar[] = "QT_DPI_ADJUSTMENT_POLICY"; @@ -90,17 +92,24 @@ static inline qreal initialGlobalScaleFactor() result = f; } } else { + // Check for deprecated environment variables. if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) { qWarning("Warning: %s is deprecated. Instead use:\n" " %s to enable platform plugin controlled per-screen factors.\n" - " %s to set per-screen factors.\n" + " %s to set per-screen DPI.\n" " %s to set the application global scale factor.", - legacyDevicePixelEnvVar, autoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar); + legacyDevicePixelEnvVar, legacyAutoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar); int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar); if (dpr > 0) result = dpr; } + + if (qEnvironmentVariableIsSet(legacyAutoScreenEnvVar)) { + qWarning("Warning: %s is deprecated. Instead use:\n" + " %s to enable platform plugin controlled per-screen factors.", + legacyAutoScreenEnvVar, enableHighDpiScalingEnvVar); + } } return result; } @@ -258,16 +267,24 @@ static inline bool usePixelDensity() // Determine if we should set a scale factor based on the pixel density // reported by the platform plugin. There are several enablers and several // disablers. A single disable may veto all other enablers. + + // First, check of there is an explicit disable. if (QCoreApplication::testAttribute(Qt::AA_DisableHighDpiScaling)) return false; bool screenEnvValueOk; - const int screenEnvValue = qEnvironmentVariableIntValue(autoScreenEnvVar, &screenEnvValueOk); + const int screenEnvValue = qEnvironmentVariableIntValue(legacyAutoScreenEnvVar, &screenEnvValueOk); if (screenEnvValueOk && screenEnvValue < 1) return false; + bool enableEnvValueOk; + const int enableEnvValue = qEnvironmentVariableIntValue(enableHighDpiScalingEnvVar, &enableEnvValueOk); + if (enableEnvValueOk && enableEnvValue < 1) + return false; + + // Then return if there was an enable. return QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) || (screenEnvValueOk && screenEnvValue > 0) - || (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar) && - qgetenv(legacyDevicePixelEnvVar).compare("auto", Qt::CaseInsensitive) == 0); + || (enableEnvValueOk && enableEnvValue > 0) + || (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar) && qgetenv(legacyDevicePixelEnvVar).toLower() == "auto"); } qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen) |
