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>
This commit is contained in:
Dirk Hohndel 2017-04-03 17:29:06 -07:00
parent e700ea9638
commit 01d091fbd5
3 changed files with 11 additions and 1 deletions

View file

@ -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();