diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-03-08 19:33:19 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-03-08 20:50:47 -0800 |
commit | f7981328627666dd0df51c0ac296e2fa7511238f (patch) | |
tree | a8cd3d95716beb39c588e265a824d245372e84bd | |
parent | 7f99d9e9c3d8fbfd4178ed57ee792832b6a81f51 (diff) | |
download | subsurface-f7981328627666dd0df51c0ac296e2fa7511238f.tar.gz |
QMLProfile: correctly track the device pixel ratio
And set the font size accordingly.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-mobile/qmlprofile.cpp | 11 | ||||
-rw-r--r-- | qt-mobile/qmlprofile.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp index 512aa6a3a..e382e4e07 100644 --- a/qt-mobile/qmlprofile.cpp +++ b/qt-mobile/qmlprofile.cpp @@ -1,7 +1,9 @@ #include "qmlprofile.h" +#include "qmlmanager.h" #include "profile-widget/profilewidget2.h" #include "subsurface-core/dive.h" #include <QTransform> +#include <QScreen> QMLProfile::QMLProfile(QQuickItem *parent) : QQuickPaintedItem(parent), @@ -13,7 +15,8 @@ QMLProfile::QMLProfile(QQuickItem *parent) : m_profileWidget->setProfileState(); m_profileWidget->setPrintMode(true); m_profileWidget->setFontPrintScale(0.8); - //m_profileWidget->setGeometry(this->geometry()); + connect(QMLManager::instance(), &QMLManager::sendScreenChanged, this, &QMLProfile::screenChanged); + setDevicePixelRatio(QMLManager::instance()->lastDevicePixelRatio()); } QMLProfile::~QMLProfile() @@ -65,6 +68,12 @@ void QMLProfile::setDevicePixelRatio(qreal dpr) { if (dpr != m_devicePixelRatio) { m_devicePixelRatio = dpr; + m_profileWidget->setFontPrintScale(0.8 * dpr); emit devicePixelRatioChanged(); } } + +void QMLProfile::screenChanged(QScreen *screen) +{ + setDevicePixelRatio(screen->devicePixelRatio()); +} diff --git a/qt-mobile/qmlprofile.h b/qt-mobile/qmlprofile.h index 35332ce8d..c8a77d700 100644 --- a/qt-mobile/qmlprofile.h +++ b/qt-mobile/qmlprofile.h @@ -24,11 +24,13 @@ public: public slots: void setMargin(int margin); + void screenChanged(QScreen *screen); private: QString m_diveId; qreal m_devicePixelRatio; int m_margin; ProfileWidget2 *m_profileWidget; + signals: void rightAlignedChanged(); void diveIdChanged(); |