fix scalling issue

This commit is contained in:
Geoffray Levasseur committed 2026-11-06 18:07:08 +01:00
1 parent 51c483dd60
commit e3886af964
1 file changed
+13 -6
+13 -6
View File
@@ -29,8 +29,6 @@
#include "Dpi/DpiCommon.h"
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>
#include <QtMath>
namespace Dpi {
@@ -40,16 +38,25 @@ int ScreenInfo::dpi()
return qRound(96.0 * toNative());
}
// Qt widgets/QPainter/QFont already operate in device-independent pixels
// and scale to the physical display automatically (see
// https://doc.qt.io/qt-6/highdpi.html) - unlike the original LCL app,
// which had no such automatic scaling and needed every pixel value
// manually converted. Returning anything other than 1.0 here double-
// scales all geometry/fonts on top of Qt's own scaling (invisible at
// 100% display scaling, since multiplying by 1.0 is a no-op, but very
// visible - overlapping text, misplaced/oversized bitmaps - at any other
// scale factor, e.g. a 4K screen set to 125%). Kept as a function (not
// removed) so callers that genuinely need the physical/native pixel
// ratio in the future have one obvious, documented place to get it from.
double ScreenInfo::toNative()
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen ? screen->devicePixelRatio() : 1.0;
return 1.0;
}
double ScreenInfo::fromNative()
{
const double ratio = toNative();
return ratio != 0.0 ? 1.0 / ratio : 1.0;
return 1.0;
}
int scaleToNative(int value)