Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Make disabling high-DPI scaling work with Qt6

Carsten Hartenfelsc4ce3f491b9b
diff --git a/krita/main.cc b/krita/main.cc
index 319ae10428..02a45ace99 100644
--- a/krita/main.cc
+++ b/krita/main.cc
@@ -376,12 +376,20 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)
bool openGLDebugSynchronous = false;
bool logUsage = true;
{
- if (kritarc.value("EnableHiDPI", true).toBool()) {
- QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ bool enableHighDpiScaling = kritarc.value("EnableHiDPI", true).toBool() || !qgetenv("KRITA_HIDPI").isEmpty();
+ // The AA_(Enable|Disable)HighDpiScaling attributes no longer have an
+ // effect on Qt6, high-DPI scaling is always enabled. To "disable" it,
+ // we need to use an environment variable instead, but we'll only do
+ // that if the user doesn't have it set yet to avoid clobberage.
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ if (!enableHighDpiScaling && !qEnvironmentVariableIsSet("QT_ENABLE_HIGHDPI_SCALING")) {
+ qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
}
- if (!qgetenv("KRITA_HIDPI").isEmpty()) {
+#else
+ if (enableHighDpiScaling) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
}
+#endif
#ifdef HAVE_HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY
if (kritarc.value("EnableHiDPIFractionalScaling", false).toBool()) {
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);