From c7fbfd8d1ac6ef09b387c9289c679fb8b221ec1f Mon Sep 17 00:00:00 2001
From: "danil.martynenko" <danil.martynenko@demlabs.net>
Date: Tue, 28 Jul 2020 17:59:28 +0300
Subject: [PATCH] [*] correct

---
 ui/auxiliary/UiScaling.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ui/auxiliary/UiScaling.cpp b/ui/auxiliary/UiScaling.cpp
index 0c3bdd510..9fa9332ed 100644
--- a/ui/auxiliary/UiScaling.cpp
+++ b/ui/auxiliary/UiScaling.cpp
@@ -5,6 +5,7 @@
 #include <QDesktopWidget>
 #include <QRect>
 #include <QApplication>
+#include <qDebug>
 
 #ifdef Q_OS_WIN
 #include "windows.h"
@@ -48,10 +49,10 @@ inline double UiScaling::pointsToInches(float a_pointsValue)
 float UiScaling::getNativDPI(){
 #ifdef Q_OS_WIN
     HDC screen = GetDC(NULL);
-    int hSize=GetDeviceCaps(screen,HORZSIZE);
-    int hRes=GetDeviceCaps(screen,HORZRES);
+    int hSize = GetDeviceCaps(screen, HORZSIZE);
+    int hRes = GetDeviceCaps(screen, HORZRES);
 
-    float PixelsPerMM = (float)hRes / hSize; // pixels per millimeter
+    float PixelsPerMM = (float)(hRes / hSize); // pixels per millimeter
     float dpi = PixelsPerMM * 25.4f;
 #elif defined(Q_OS_LINUX)
 #ifndef Q_OS_ANDROID
@@ -77,8 +78,8 @@ float UiScaling::getNativDPI(){
 #endif
 #ifndef Q_OS_ANDROID
     //if dpi is less than 50, it may have been calculated incorrectly
-    if (dpi>50) return QGuiApplication::primaryScreen()->physicalDotsPerInch();//
-    return (dpi < 50 ? QGuiApplication::primaryScreen()->physicalDotsPerInch() : dpi);
+    qInfo() << "Pixels per mm: " << PixelsPerMM << " Resolution: " << hRes << " Screen height: " << hSize << " UiScaling - dpi: " << dpi;
+    return ((dpi < 50 || dpi > 350) ? QGuiApplication::primaryScreen()->physicalDotsPerInch() : dpi);
 
 #else
     return 1;
-- 
GitLab