High-DPI: Enable scaling by default in Qt 6

Enable high-DPI support for all platforms which use
QHighDpiScaling. This changes the default behavior
of Qt applications on X11, Windows, and Android.

Qt::AA_EnableHighDpiScaling is now effectively on by
default, and Qt 6 applications do not have to set
this application attribute. Opting out is possible by
setting the Qt::AA_DisableHighDpiScaling attribute.

Task-number: QTBUG-83068
Change-Id: Ia2bd3e6f490130afcacd3a951bc50dbb40a79d7f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Morten Johan Sørvig 2019-09-12 12:01:28 +02:00 committed by Tor Arne Vestbø
parent 756d7facf6
commit 080a8285eb

View File

@ -265,7 +265,7 @@ static inline bool usePixelDensity()
// 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.
// Check if there is an explicit disable
if (QCoreApplication::testAttribute(Qt::AA_DisableHighDpiScaling))
return false;
bool screenEnvValueOk;
@ -277,12 +277,8 @@ static inline bool usePixelDensity()
if (enableEnvValueOk && enableEnvValue < 1)
return false;
// Then return if there was an enable.
return QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling)
|| (screenEnvValueOk && screenEnvValue > 0)
|| (enableEnvValueOk && enableEnvValue > 0)
|| (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)
&& qEnvironmentVariable(legacyDevicePixelEnvVar).compare(QLatin1String("auto"), Qt::CaseInsensitive) == 0);
// Enable by default
return true;
}
qreal QHighDpiScaling::rawScaleFactor(const QPlatformScreen *screen)