aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/main.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2023-09-29 23:28:23 +0200
committerAlessandro Portale <alessandro.portale@qt.io>2023-10-04 13:08:40 +0000
commit3726f0d6c1d05452f070b911683c51fe95df65c4 (patch)
tree9ac41e82fa10f486670b24c87f50a18a1d5c5869 /src/app/main.cpp
parent70f4d9bda083d4db1e9faa80ebad649076d82e65 (diff)
Core: Add a setting for HighDpiScaleFactorRoundingPolicy
In Qt 6, the API and environment variables intended to influence the HighDPI behavior changed quite a bit. Until recently, (see "Amends" change), Qt Creator still supported the Qt 5 options instead of the Qt 6 options. With Qt 6, HighDpi support is always enabled. Just the DPI rounding policy should be set by user or application. This change adds a ComboBox in the General settings, which allows to select a DPI rounding policy: https://doc.qt.io/qt-6/qt.html#HighDpiScaleFactorRoundingPolicy-enum The default setting is "PassThrough", which is the default policy for Qt 6, and which is also the default in Qt Creator since version 11.0.2. Amends: d1deeb2c0d2c3f22be7d970e5e0f166f5101667b Fixes: QTCREATORBUG-29501 Change-Id: Ib19b40cb3945cecc71b7c10f42fa2b06b3cc6153 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/app/main.cpp')
-rw-r--r--src/app/main.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 49f0a10a6a..ce09e0d6ad 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -285,11 +285,11 @@ static void setHighDpiEnvironmentVariable()
std::unique_ptr<Utils::QtcSettings> settings(createUserSettings());
- const bool defaultValue = Utils::HostOsInfo::isWindowsHost();
- const bool enableHighDpiScaling = settings->value("Core/EnableHighDpiScaling", defaultValue).toBool();
- const auto policy = enableHighDpiScaling ? Qt::HighDpiScaleFactorRoundingPolicy::PassThrough
- : Qt::HighDpiScaleFactorRoundingPolicy::Floor;
- QGuiApplication::setHighDpiScaleFactorRoundingPolicy(policy);
+ using Policy = Qt::HighDpiScaleFactorRoundingPolicy;
+ const Policy defaultPolicy = Utils::HostOsInfo::defaultHighDpiScaleFactorRoundingPolicy();
+ const Policy userPolicy = settings->value("Core/HighDpiScaleFactorRoundingPolicy",
+ int(defaultPolicy)).value<Policy>();
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(userPolicy);
}
void setPixmapCacheLimit()
@@ -522,8 +522,6 @@ int main(int argc, char **argv)
}
qputenv("QSG_RHI_BACKEND", "opengl");
- QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
- Qt::HighDpiScaleFactorRoundingPolicy::Round);
if (qEnvironmentVariableIsSet("QTCREATOR_DISABLE_NATIVE_MENUBAR")
|| qgetenv("XDG_CURRENT_DESKTOP").startsWith("Unity")) {