QML UI: take device pixel ratio into account when scaling pixmaps on iOS

This way warning icons and tank change icons and other event markers are no
longer ridiculously tiny on retina screens. Oddly this doesn't appear to be
needed on Android, only on iOS.

Fixes #1033

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-03-28 16:43:40 -05:00
parent 8185d24e61
commit dd0d88f9d7
4 changed files with 17 additions and 1 deletions

View file

@ -65,8 +65,13 @@ void DiveEventItem::setupPixmap()
const IconMetrics& metrics = defaultIconMetrics();
#ifndef SUBSURFACE_MOBILE
int sz_bigger = metrics.sz_med + metrics.sz_small; // ex 40px
#else
#if defined(Q_OS_IOS)
// on iOS devices we need to adjust for Device Pixel Ratio
int sz_bigger = metrics.sz_med * metrics.dpr;
#else
int sz_bigger = metrics.sz_med;
#endif
#endif
int sz_pix = sz_bigger/2; // ex 20px

View file

@ -2,6 +2,7 @@
#include "qmlmanager.h"
#include "profile-widget/profilewidget2.h"
#include "subsurface-core/dive.h"
#include "subsurface-core/metrics.h"
#include <QTransform>
#include <QScreen>
@ -99,6 +100,7 @@ void QMLProfile::setDevicePixelRatio(qreal dpr)
if (dpr != m_devicePixelRatio) {
m_devicePixelRatio = dpr;
m_profileWidget->setFontPrintScale(0.8 * dpr);
updateDevicePixelRatio(dpr);
emit devicePixelRatioChanged();
}
}

View file

@ -15,7 +15,8 @@ IconMetrics::IconMetrics() :
sz_med(-1),
sz_big(-1),
sz_pic(-1),
spacing(-1)
spacing(-1),
dpr(1.0)
{
}
@ -57,3 +58,8 @@ const IconMetrics & defaultIconMetrics()
return dfltIconMetrics;
}
void updateDevicePixelRatio(double dpr)
{
dfltIconMetrics.dpr = dpr;
}

View file

@ -25,9 +25,12 @@ struct IconMetrics {
int sz_pic; // ex 128px
// icon spacing
int spacing; // ex 2px
// devicePixelRatio
double dpr; // 1.0 for traditional screens, HiDPI screens up to 3.0
IconMetrics();
};
const IconMetrics & defaultIconMetrics();
void updateDevicePixelRatio(double dpr);
#endif // METRICS_H