Changeset View
Changeset View
Standalone View
Standalone View
3rdparty/ext_qt/0035-Deprecate-QT_AUTO_SCREEN_SCALE_FACTOR.patch
- This file was added.
1 | From 4fdc698603e5ac3bc0cf107fdf3880ba68dbfb02 Mon Sep 17 00:00:00 2001 | ||||
---|---|---|---|---|---|
2 | From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@qt.io> | ||||
3 | Date: Thu, 10 Nov 2016 14:17:53 +0100 | ||||
4 | Subject: [PATCH 35/36] Deprecate QT_AUTO_SCREEN_SCALE_FACTOR | ||||
5 | MIME-Version: 1.0 | ||||
6 | Content-Type: text/plain; charset=UTF-8 | ||||
7 | Content-Transfer-Encoding: 8bit | ||||
8 | | ||||
9 | Replace by QT_ENABLE_HIGHDPI_SCALING. | ||||
10 | | ||||
11 | QT_AUTO_SCREEN_SCALE_FACTOR has the usability problem that it mixes | ||||
12 | enabling the high-DPI scaling mode with the method of getting screen | ||||
13 | scale factors (?uto??. Due to this, it ends up with a slightly | ||||
14 | strange name. | ||||
15 | | ||||
16 | QT_ENABLE_HIGHDPI_SCALING matches the C++ option | ||||
17 | (Qt::AA_EnableHighDPiScaling), and leaves the scale factor acquisition | ||||
18 | method unspecified, possibly to be set by some other means (like | ||||
19 | QT_SCREEN_SCALE_FACTORS). | ||||
20 | | ||||
21 | Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> | ||||
22 | Task-number: QTBUG-53022 | ||||
23 | Change-Id: I30033d91175a00db7837efc9c48c33396f5f0449 | ||||
24 | --- | ||||
25 | src/gui/kernel/qhighdpiscaling.cpp | 29 +++++++++++++++++++++++------ | ||||
26 | 1 file changed, 23 insertions(+), 6 deletions(-) | ||||
27 | | ||||
28 | diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp | ||||
29 | index b1350599b7..52c0665b5b 100644 | ||||
30 | --- a/src/gui/kernel/qhighdpiscaling.cpp | ||||
31 | +++ b/src/gui/kernel/qhighdpiscaling.cpp | ||||
32 | @@ -54,8 +54,10 @@ Q_LOGGING_CATEGORY(lcScaling, "qt.scaling"); | ||||
33 | | ||||
34 | #ifndef QT_NO_HIGHDPISCALING | ||||
35 | static const char legacyDevicePixelEnvVar[] = "QT_DEVICE_PIXEL_RATIO"; | ||||
36 | +static const char legacyAutoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; | ||||
37 | + | ||||
38 | +static const char enableHighDpiScalingEnvVar[] = "QT_ENABLE_HIGHDPI_SCALING"; | ||||
39 | static const char scaleFactorEnvVar[] = "QT_SCALE_FACTOR"; | ||||
40 | -static const char autoScreenEnvVar[] = "QT_AUTO_SCREEN_SCALE_FACTOR"; | ||||
41 | static const char screenFactorsEnvVar[] = "QT_SCREEN_SCALE_FACTORS"; | ||||
42 | static const char scaleFactorRoundingPolicyEnvVar[] = "QT_SCALE_FACTOR_ROUNDING_POLICY"; | ||||
43 | static const char dpiAdjustmentPolicyEnvVar[] = "QT_DPI_ADJUSTMENT_POLICY"; | ||||
44 | @@ -88,17 +90,24 @@ static inline qreal initialGlobalScaleFactor() | ||||
45 | result = f; | ||||
46 | } | ||||
47 | } else { | ||||
48 | + // Check for deprecated environment variables. | ||||
49 | if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) { | ||||
50 | qWarning("Warning: %s is deprecated. Instead use:\n" | ||||
51 | " %s to enable platform plugin controlled per-screen factors.\n" | ||||
52 | - " %s to set per-screen factors.\n" | ||||
53 | + " %s to set per-screen DPI.\n" | ||||
54 | " %s to set the application global scale factor.", | ||||
55 | - legacyDevicePixelEnvVar, autoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar); | ||||
56 | + legacyDevicePixelEnvVar, legacyAutoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar); | ||||
57 | | ||||
58 | int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar); | ||||
59 | if (dpr > 0) | ||||
60 | result = dpr; | ||||
61 | } | ||||
62 | + | ||||
63 | + if (qEnvironmentVariableIsSet(legacyAutoScreenEnvVar)) { | ||||
64 | + qWarning("Warning: %s is deprecated. Instead use:\n" | ||||
65 | + " %s to enable platform plugin controlled per-screen factors.", | ||||
66 | + legacyAutoScreenEnvVar, enableHighDpiScalingEnvVar); | ||||
67 | + } | ||||
68 | } | ||||
69 | return result; | ||||
70 | } | ||||
71 | @@ -256,16 +265,24 @@ static inline bool usePixelDensity() | ||||
72 | // Determine if we should set a scale factor based on the pixel density | ||||
73 | // reported by the platform plugin. There are several enablers and several | ||||
74 | // disablers. A single disable may veto all other enablers. | ||||
75 | + | ||||
76 | + // First, check of there is an explicit disable. | ||||
77 | if (QCoreApplication::testAttribute(Qt::AA_DisableHighDpiScaling)) | ||||
78 | return false; | ||||
79 | bool screenEnvValueOk; | ||||
80 | - const int screenEnvValue = qEnvironmentVariableIntValue(autoScreenEnvVar, &screenEnvValueOk); | ||||
81 | + const int screenEnvValue = qEnvironmentVariableIntValue(legacyAutoScreenEnvVar, &screenEnvValueOk); | ||||
82 | if (screenEnvValueOk && screenEnvValue < 1) | ||||
83 | return false; | ||||
84 | + bool enableEnvValueOk; | ||||
85 | + const int enableEnvValue = qEnvironmentVariableIntValue(enableHighDpiScalingEnvVar, &enableEnvValueOk); | ||||
86 | + if (enableEnvValueOk && enableEnvValue < 1) | ||||
87 | + return false; | ||||
88 | + | ||||
89 | + // Then return if there was an enable. | ||||
90 | return QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) | ||||
91 | || (screenEnvValueOk && screenEnvValue > 0) | ||||
92 | - || (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar) && | ||||
93 | - qgetenv(legacyDevicePixelEnvVar).compare("auto", Qt::CaseInsensitive) == 0); | ||||
94 | + || (enableEnvValueOk && enableEnvValue > 0) | ||||
95 | + || (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar) && qgetenv(legacyDevicePixelEnvVar).toLower() == "auto"); | ||||
96 | } | ||||
97 | | ||||
98 | qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen) | ||||
99 | -- | ||||
100 | 2.18.0.windows.1 | ||||
101 | |