profile: pass printFontScale on creation of the profile

Not having to readjust the scale on-demand will make the
code distinctly simpler. Let's just pass it once.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-05-31 22:29:00 +02:00 committed by Dirk Hohndel
parent 5df0efbc7f
commit a14f740df0
7 changed files with 15 additions and 23 deletions

View file

@ -95,7 +95,7 @@ T *ProfileWidget2::createItem(const DiveCartesianAxis &vAxis, int vColumn, int z
return res;
}
ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, QWidget *parent) : QGraphicsView(parent),
ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double fontPrintScale, QWidget *parent) : QGraphicsView(parent),
currentState(INVALID),
dataModel(new DivePlotDataModel(this)),
plannerModel(plannerModelIn),
@ -139,7 +139,7 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, QWidget *
#endif
tankItem(new TankItem(*timeAxis)),
shouldCalculateMax(true),
fontPrintScale(1.0)
fontPrintScale(fontPrintScale)
{
init_plot_info(&plotInfo);

View file

@ -66,7 +66,7 @@ public:
};
// Pass null as plannerModel if no support for planning required
ProfileWidget2(DivePlannerPointsModel *plannerModel, QWidget *parent = 0);
ProfileWidget2(DivePlannerPointsModel *plannerModel, double fontPrintScale, QWidget *parent = 0);
~ProfileWidget2();
void resetZoom();
void scale(qreal sx, qreal sy);

View file

@ -28,10 +28,9 @@ QMLProfile::QMLProfile(QQuickItem *parent) :
void QMLProfile::createProfileView()
{
m_profileWidget.reset(new ProfileWidget2(nullptr, nullptr));
m_profileWidget.reset(new ProfileWidget2(nullptr, fontScale * m_devicePixelRatio, nullptr));
m_profileWidget->setProfileState(nullptr, 0);
m_profileWidget->setPrintMode(true);
m_profileWidget->setFontPrintScale(fontScale * m_devicePixelRatio);
}
// we need this so we can connect update() to the scaleChanged() signal - which the connect above cannot do