diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-04-03 17:29:06 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-04-04 11:00:18 -0700 |
commit | 01d091fbd5ff88ac530f26c36b2cba3cc936448b (patch) | |
tree | 640207dbd88d285f78dcb7b6a04f8ab583d3cc83 /mobile-widgets | |
parent | e700ea9638907c63a2cc032e005da9352341bd1c (diff) | |
download | subsurface-01d091fbd5ff88ac530f26c36b2cba3cc936448b.tar.gz |
QML UI: better handling of device pixel ratio
In order to make sure we don't render the initial profiles with the
wrong scale on devices, we need to seed the device pixel ratio with the
device default and then update it once the window has been created.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 10 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index a834259f7..d24a4579d 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -85,10 +85,10 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), m_updateSelectedDive(-1), m_selectedDiveTimestamp(0), m_credentialStatus(UNKNOWN), - m_lastDevicePixelRatio(1.0), alreadySaving(false) { m_instance = this; + m_lastDevicePixelRatio = qApp->devicePixelRatio(); connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged); appendTextToLog(getUserAgent()); appendTextToLog(QStringLiteral("build with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion())); @@ -1412,6 +1412,14 @@ qreal QMLManager::lastDevicePixelRatio() return m_lastDevicePixelRatio; } +void QMLManager::setDevicePixelRatio(qreal dpr, QScreen *screen) +{ + if (m_lastDevicePixelRatio != dpr) { + m_lastDevicePixelRatio = dpr; + emit sendScreenChanged(screen); + } +} + void QMLManager::screenChanged(QScreen *screen) { m_lastDevicePixelRatio = screen->devicePixelRatio(); diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 8c5b02fa1..04f4a40dd 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -154,6 +154,7 @@ public slots: void refreshDiveList(); void screenChanged(QScreen *screen); qreal lastDevicePixelRatio(); + void setDevicePixelRatio(qreal dpr, QScreen *screen); void appendTextToLog(const QString &newText); void quit(); void hasLocationSourceChanged(); |