summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qscreen.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-09-30 14:25:43 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-06 09:36:39 +0200
commit7d2cfbe5aa1e67d12010a66481625c9d40f0c174 (patch)
tree26734132827c40ba425d79481c2c4193bac5c5ea /src/gui/kernel/qscreen.cpp
parent29948e666583a26966ddb97faf4808099824b80d (diff)
Improved logical and physical DPI APIs.
Made physicalSize() return QSizeF instead, to prevent rounding errors. Added logicalSize() as the base to compute font pixel sizes instead, and added convenience functions in QScreen to access the logical and physical sizes and DPI metrics. Task-number: QTBUG-21736 Task-number: QTBUG-21737 Change-Id: Ic705dc98eb3632617659e65a0c9a552673dc0c65 Reviewed-on: http://codereview.qt-project.org/5888 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r--src/gui/kernel/qscreen.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 96ed2bd410..c2049af1e5 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -102,6 +102,75 @@ QSize QScreen::size() const
}
/*!
+ Gets the number of physical dots or pixels per inch in the horizontal direction.
+
+ This value represents the actual horizontal pixel density on the screen's display.
+ Depending on what information the underlying system provides the value might not be
+ entirely accurate.
+
+ \sa physicalDotsPerInchY()
+*/
+qreal QScreen::physicalDotsPerInchX() const
+{
+ return size().width() / physicalSize().width() * 25.4;
+}
+
+/*!
+ Gets the number of physical dots or pixels per inch in the vertical direction.
+
+ This value represents the actual vertical pixel density on the screen's display.
+ Depending on what information the underlying system provides the value might not be
+ entirely accurate.
+
+ \sa physicalDotsPerInchX()
+*/
+qreal QScreen::physicalDotsPerInchY() const
+{
+ return size().height() / physicalSize().height() * 25.4;
+}
+
+/*!
+ Gets the number of logical dots or pixels per inch in the horizontal direction.
+
+ This value is used to convert font point sizes to pixel sizes.
+
+ \sa logicalDotsPerInchY()
+*/
+qreal QScreen::logicalDotsPerInchX() const
+{
+ Q_D(const QScreen);
+ return d->platformScreen->logicalDpi().first;
+}
+
+/*!
+ Gets the number of logical dots or pixels per inch in the vertical direction.
+
+ This value is used to convert font point sizes to pixel sizes.
+
+ \sa logicalDotsPerInchX()
+*/
+qreal QScreen::logicalDotsPerInchY() const
+{
+ Q_D(const QScreen);
+ return d->platformScreen->logicalDpi().second;
+}
+
+/*!
+ Get the screen's physical size (in millimeters).
+
+ The physical size represents the actual physical dimensions of the
+ screen's display.
+
+ Depending on what information the underlying system provides the value
+ might not be entirely accurate.
+*/
+QSizeF QScreen::physicalSize() const
+{
+ Q_D(const QScreen);
+ return d->platformScreen->physicalSize();
+}
+
+/*!
Get the screen's available size.
The available size is the size excluding window manager reserved areas