summaryrefslogtreecommitdiff
path: root/src/gui/styles/qstylehelper.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@nokia.com>2009-06-25 16:35:55 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2009-06-25 16:37:04 +0200
commitdb24e82b6b74be303492f186a45d784fcd84fdc6 (patch)
tree13b3358df74d262a97356c5759a77debec4051bc /src/gui/styles/qstylehelper.cpp
parent47c9e7b1b3551ff6dbe71590461a45ae398a9501 (diff)
downloadqt4-tools-db24e82b6b74be303492f186a45d784fcd84fdc6.tar.gz
Improved support for DPI on Mac and Vista/7
This significantly improves the support for higher DPI-values on these platforms by ensuring that common pixelmetrics are scaled accordingly. In addition we mark all Qt apps as DPI-aware on Windows 7 by calling SetProcessDPIAware. We also changed the way we draw pixmaps on the mac paintengine when using dpi scaling > 1 to ensure smooth pixmap scaling. Reviewed-by: nrc Task-id: 242417
Diffstat (limited to 'src/gui/styles/qstylehelper.cpp')
-rw-r--r--src/gui/styles/qstylehelper.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
index 997bd682b8..f9010e8279 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/gui/styles/qstylehelper.cpp
@@ -48,6 +48,12 @@
#include <private/qstyle_p.h>
#include <qmath.h>
+#if defined(Q_WS_WIN)
+#include "qt_windows.h"
+#elif defined(Q_WS_MAC)
+#include <private/qt_cocoa_helpers_mac_p.h>
+#endif
+
QT_BEGIN_NAMESPACE
namespace QStyleHelper {
@@ -72,6 +78,26 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
return tmp;
}
+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
+ }
+ return value * scale;
+}
+
+
#ifndef QT_NO_DIAL
int calcBigLineSize(int radius)
@@ -178,7 +204,6 @@ QPolygonF calcLines(const QStyleOptionSlider *dial)
return poly;
}
-
// This will draw a nice and shiny QDial for us. We don't want
// all the shinyness in QWindowsStyle, hence we place it here