commit 8b6460e4f2d4040e3df41ef0abc70cbbe14ad875
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Thu Feb 25 17:56:11 2021 +0100
Improve HiDpi handling
Add code stolen from QBitTorrent and Qt Creator that properly enables
HighDpi handling.
The rules are:
1/ nothing needs to be done for macOS and Qt >= 6
2/ HighDpi support is set by default starting with Qt 5.6.
3/ Support for fractional scaling is added for Qt >= 5.14.
Hopefully fixes bug #12060.
(cherry picked from commit d7a4f47e7d42af33858ff263823bd7cdbea98b57)
(cherry picked from commit f92f2f95ffd5f0d9d9704c9d7f67e4a9e74db0f6)
---
src/frontends/qt4/GuiApplication.cpp | 19 +++++++++++++++++++
status.23x | 3 +++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/frontends/qt4/GuiApplication.cpp
b/src/frontends/qt4/GuiApplication.cpp
index 458e711..29b708e 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -63,6 +63,7 @@
#include "support/convert.h"
#include "support/debug.h"
#include "support/ExceptionMessage.h"
+#include "support/environment.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/ForkedCalls.h"
@@ -194,6 +195,24 @@ frontend::Application * createApplication(int & argc, char
* argv[])
AllowSetForegroundWindow(ASFW_ANY);
#endif
+
+// Setup high DPI handling. This is a bit complicated, but will be default in
Qt6.
+// macOS does it by itself.
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && !defined(Q_OS_MAC)
+#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
+ // Attribute Qt::AA_EnableHighDpiScaling must be set before
QCoreApplication is created
+ if (getEnv("QT_ENABLE_HIGHDPI_SCALING").empty()
+ && getEnv("QT_AUTO_SCREEN_SCALE_FACTOR").empty())
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
+#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ // HighDPI scale factor policy must be set before QGuiApplication is
created
+ if (getEnv("QT_SCALE_FACTOR_ROUNDING_POLICY").empty())
+
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
+#endif
+#endif
+
frontend::GuiApplication * guiApp = new frontend::GuiApplication(argc,
argv);
// I'd rather do that in the constructor, but I do not think that
// the palette is accessible there.
diff --git a/status.23x b/status.23x
index 06a0d57..441d2dd 100644
--- a/status.23x
+++ b/status.23x
@@ -34,8 +34,11 @@ What's new
- Other than directly inserted, now references can also be pasted as insets
into an equation, instead of simply as text (bug 11539).
+- Add support for High DPI screens in Windows and Linux (bug 12060).
+
- Add Qt platform name in About dialog.
+
* DOCUMENTATION AND LOCALIZATION
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs