diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-10-17 14:24:07 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-10-23 09:03:16 +0200 |
commit | e2764c722571025835e41632637d1421ba44fb02 (patch) | |
tree | fcbe4624419e0332ba0330aa6402123c39f03523 /src | |
parent | a1b43cb272ff05bd8c681d4d6320dcfee7339d84 (diff) |
Screen attached property: expose devicePixelRatio property
Change-Id: I08b22766b3e389b7d27ca4c56729f550b0647a08
Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickscreen.cpp | 18 | ||||
-rw-r--r-- | src/quick/items/qquickscreen_p.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp index 926ac7b4ee..8ac5a1e292 100644 --- a/src/quick/items/qquickscreen.cpp +++ b/src/quick/items/qquickscreen.cpp @@ -142,6 +142,15 @@ QT_BEGIN_NAMESPACE The number of physical pixels per millimeter. */ /*! + \qmlattachedproperty real Screen::devicePixelRatio + \readonly + \since 5.4 + + The ratio between physical pixels and device-independent pixels for the screen. + + Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays. +*/ +/*! \qmlattachedproperty Qt::ScreenOrientation Screen::primaryOrientation \readonly @@ -260,6 +269,13 @@ qreal QQuickScreenAttached::pixelDensity() const return m_screen->physicalDotsPerInch() / 25.4; } +qreal QQuickScreenAttached::devicePixelRatio() const +{ + if (!m_screen) + return 1.0; + return m_screen->devicePixelRatio(); +} + Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const { if (!m_screen) @@ -340,6 +356,8 @@ void QQuickScreenAttached::screenChanged(QScreen *screen) emit logicalPixelDensityChanged(); if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch()) emit pixelDensityChanged(); + if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio()) + emit devicePixelRatioChanged(); connect(screen, SIGNAL(geometryChanged(QRect)), this, SIGNAL(widthChanged())); diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h index d661cc6f56..257b18cfe0 100644 --- a/src/quick/items/qquickscreen_p.h +++ b/src/quick/items/qquickscreen_p.h @@ -57,6 +57,7 @@ class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject Q_PROPERTY(int desktopAvailableHeight READ desktopAvailableHeight NOTIFY desktopGeometryChanged) Q_PROPERTY(qreal logicalPixelDensity READ logicalPixelDensity NOTIFY logicalPixelDensityChanged) Q_PROPERTY(qreal pixelDensity READ pixelDensity NOTIFY pixelDensityChanged) + Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged) // TODO Qt 6 Rename primaryOrientation to orientation Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged) // TODO Qt 6 Remove this orientation -> incomplete device orientation -> better use OrientationSensor @@ -74,6 +75,7 @@ public: int desktopAvailableHeight() const; qreal logicalPixelDensity() const; qreal pixelDensity() const; + qreal devicePixelRatio() const; Qt::ScreenOrientation primaryOrientation() const; Qt::ScreenOrientation orientation() const; Qt::ScreenOrientations orientationUpdateMask() const; @@ -91,6 +93,7 @@ Q_SIGNALS: void desktopGeometryChanged(); void logicalPixelDensityChanged(); void pixelDensityChanged(); + void devicePixelRatioChanged(); void primaryOrientationChanged(); void orientationChanged(); void orientationUpdateMaskChanged(); |