QMLProfile: correctly track the device pixel ratio
And set the font size accordingly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7f99d9e9c3
commit
f798132862
@ -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());
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user