From 1fbe8242ece70fe5aa2b50e9a782ec509b163b78 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Jan 2012 11:49:35 +0100 Subject: QStyleHelper: Base DPI-calculation on QScreen. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use qt_defaultDpiX() to obtain the resolution, which obtains it from QScreen. This implies that for X11, which previously used a hardcoded default of 96 DPI, the real resolution will be used (typically 75). - Since many tests (layouts, graphicsview) contain test data for 96 DPI, add an attribute to QCoreApplication making it possible to set the resolution to 96 DPI for testing. Change-Id: I77c8233a96b0d75de07406f58d48886a89c3de06 Reviewed-by: Samuel Rødal --- src/widgets/styles/qstylehelper.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 823d29bc83..8f2d7364c1 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -46,17 +46,13 @@ #include #include -#if defined(Q_WS_WIN) -#include "qt_windows.h" -#elif defined(Q_WS_MAC) -#include -#endif - #include "qstylehelper_p.h" #include QT_BEGIN_NAMESPACE +Q_GUI_EXPORT int qt_defaultDpiX(); + namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) @@ -81,20 +77,7 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & qreal dpiScaled(qreal value) { - static qreal scale = -1; - if (scale < 0) { - scale = 1.0; -#if defined(Q_WS_WIN) - { - HDC hdcScreen = GetDC(0); - int dpi = GetDeviceCaps(hdcScreen, LOGPIXELSX); - ReleaseDC(0, hdcScreen); - scale = dpi/96.0; - } -#elif defined(Q_WS_MAC) - scale = qt_mac_get_scalefactor(); -#endif - } + static const qreal scale = qreal(qt_defaultDpiX()) / 96.0; return value * scale; } -- cgit v1.2.3