summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qscreen.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-11-22 10:34:47 +0100
committerQt by Nokia <qt-info@nokia.com>2011-11-30 19:04:18 +0100
commit6468dd4179278276d3ad98696b6f761efa397924 (patch)
treee744103b678b4e795350df13eaa892c34a1ba979 /src/gui/kernel/qscreen.cpp
parentcc9c85ecd68c8dae28567dac630f894faaaf1acf (diff)
Made more QScreen properties NOTIFY and added average DPI properties.
The physicalDotsPerInch() is the average of the horizontal and vertical physical dots per inch, and likewise logicalDotsPerInch() is the average of the horizontal and vertical logical dots per inch. Change-Id: I18aa610dc9a63efe062f78c823ba29f90b2712f4 Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r--src/gui/kernel/qscreen.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 682e42ad4c..8a35ce6b8f 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -134,7 +134,7 @@ QSize QScreen::size() const
*/
qreal QScreen::physicalDotsPerInchX() const
{
- return size().width() / physicalSize().width() * 25.4;
+ return size().width() / physicalSize().width() * qreal(25.4);
}
/*!
@@ -149,7 +149,28 @@ qreal QScreen::physicalDotsPerInchX() const
*/
qreal QScreen::physicalDotsPerInchY() const
{
- return size().height() / physicalSize().height() * 25.4;
+ return size().height() / physicalSize().height() * qreal(25.4);
+}
+
+/*!
+ \property QScreen::physicalDotsPerInch
+ \brief the number of physical dots or pixels per inch
+
+ This value represents the pixel density on the screen's display.
+ Depending on what information the underlying system provides the value might not be
+ entirely accurate.
+
+ This is a convenience property that's simply the average of the physicalDotsPerInchX
+ and physicalDotsPerInchY properties.
+
+ \sa physicalDotsPerInchX()
+ \sa physicalDotsPerInchY()
+*/
+qreal QScreen::physicalDotsPerInch() const
+{
+ QSize sz = size();
+ QSizeF psz = physicalSize();
+ return ((sz.height() / psz.height()) + (sz.width() / psz.width())) * qreal(25.4 * 0.5);
}
/*!
@@ -181,6 +202,25 @@ qreal QScreen::logicalDotsPerInchY() const
}
/*!
+ \property QScreen::logicalDotsPerInch
+ \brief the number of logical dots or pixels per inch
+
+ This value can be used to convert font point sizes to pixel sizes.
+
+ This is a convenience property that's simply the average of the logicalDotsPerInchX
+ and logicalDotsPerInchY properties.
+
+ \sa logicalDotsPerInchX()
+ \sa logicalDotsPerInchY()
+*/
+qreal QScreen::logicalDotsPerInch() const
+{
+ Q_D(const QScreen);
+ QDpi dpi = d->platformScreen->logicalDpi();
+ return (dpi.first + dpi.second) * qreal(0.5);
+}
+
+/*!
\property QScreen::physicalSize
\brief the screen's physical size (in millimeters)