aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickscreen.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2013-10-25 15:16:46 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-26 01:52:10 +0200
commitcca9522e7ca0c040ae354b20f09983005ef955bd (patch)
treec3b728631f0d167c4c57041cb19b7d90df40a0d1 /src/quick/items/qquickscreen.cpp
parentb3bff5bb3c8ee0e1c45d20d04b1c3c0236aa9d38 (diff)
Screen attached property: expose pixelDensity property
Because logicalPixelDensity is different than physical density on multiple platforms, having the actual density is critical to be able to design resolution-independent controls. Change-Id: I06bbdc6e6869718058a796ca737668ce69802f2b Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/quick/items/qquickscreen.cpp')
-rw-r--r--src/quick/items/qquickscreen.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 75eccf6c59..e32f31308e 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -136,6 +136,13 @@ QT_BEGIN_NAMESPACE
pixels.
*/
/*!
+ \qmlattachedproperty real QtQuick.Window::Screen::pixelDensity
+ \readonly
+ \since 5.2
+
+ The number of physical pixels per millimeter.
+*/
+/*!
\qmlattachedproperty Qt::ScreenOrientation QtQuick.Window::Screen::primaryOrientation
\readonly
@@ -233,6 +240,13 @@ qreal QQuickScreenAttached::logicalPixelDensity() const
return m_screen->logicalDotsPerInch() / 25.4;
}
+qreal QQuickScreenAttached::pixelDensity() const
+{
+ if (!m_screen)
+ return 0.0;
+ return m_screen->physicalDotsPerInch() / 25.4;
+}
+
Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const
{
if (!m_screen)
@@ -291,6 +305,8 @@ void QQuickScreenAttached::screenChanged(QScreen *screen)
emit desktopGeometryChanged();
if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
emit logicalPixelDensityChanged();
+ if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
+ emit pixelDensityChanged();
connect(screen, SIGNAL(geometryChanged(QRect)),
this, SIGNAL(widthChanged()));
@@ -304,6 +320,8 @@ void QQuickScreenAttached::screenChanged(QScreen *screen)
this, SIGNAL(desktopGeometryChanged()));
connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
this, SIGNAL(logicalPixelDensityChanged()));
+ connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
+ this, SIGNAL(pixelDensityChanged()));
}
}