diff options
author | Aaron Barany <akb825@gmail.com> | 2023-08-02 16:11:18 -0700 |
---|---|---|
committer | Aaron Barany <akb825@gmail.com> | 2023-08-09 18:50:44 +0000 |
commit | d1deeb2c0d2c3f22be7d970e5e0f166f5101667b (patch) | |
tree | 342ce4a5c82481ab27b19c6bf11c1a9b9850be2f /src/app | |
parent | 9c2527eea6d7d2e703e51d056a16cc10c0f12667 (diff) |
App: Use PassThrough high DPI rounding policy
When high DPI is enabled, use PassThrough rounding policy to allow
for fractional scaling without having to manually set an environment
variable.
The high DPI setting is now respected even if various Qt scale/ratio
environment variables are set, which is the case in valid default
situations such as setting the global scaling factor for KDE Plasma.
Task-number: QTCREATORBUG-29461
Change-Id: Ife2820d205b3440646255dc997744b2b8867bc70
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/main.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp index d4c4a47b8c..46233ba19c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -278,26 +278,16 @@ static Utils::QtcSettings *createUserSettings() static void setHighDpiEnvironmentVariable() { - if (Utils::HostOsInfo::isMacHost()) + if (Utils::HostOsInfo::isMacHost() || qEnvironmentVariableIsSet("QT_SCALE_FACTOR_ROUNDING_POLICY")) return; std::unique_ptr<QSettings> settings(createUserSettings()); const bool defaultValue = Utils::HostOsInfo::isWindowsHost(); const bool enableHighDpiScaling = settings->value("Core/EnableHighDpiScaling", defaultValue).toBool(); - - static const char ENV_VAR_QT_DEVICE_PIXEL_RATIO[] = "QT_DEVICE_PIXEL_RATIO"; - if (enableHighDpiScaling - && !qEnvironmentVariableIsSet(ENV_VAR_QT_DEVICE_PIXEL_RATIO) // legacy in 5.6, but still functional - && !qEnvironmentVariableIsSet("QT_AUTO_SCREEN_SCALE_FACTOR") - && !qEnvironmentVariableIsSet("QT_SCALE_FACTOR") - && !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) { - return; - } - - if (!qEnvironmentVariableIsSet("QT_SCALE_FACTOR_ROUNDING_POLICY")) - QGuiApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Floor); + const auto policy = enableHighDpiScaling ? Qt::HighDpiScaleFactorRoundingPolicy::PassThrough + : Qt::HighDpiScaleFactorRoundingPolicy::Floor; + QGuiApplication::setHighDpiScaleFactorRoundingPolicy(policy); } void setPixmapCacheLimit() |