profile: pass fontPrintScale at construction time

Instead of intializing the text fields and then changing the
font scale via signal-rigmarole, pass down the font-scale
at construction time.

Since the fontPrintScale is only set in print mode, we also
can access it directly instead of testing for printMode.

Since the DiveTextItem is not updated using signals anymore,
the connected flag can be removed.

The commit is larger than I had hoped for, but this makes
things ultimately less brittle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-06-03 17:19:38 +02:00 committed by Dirk Hohndel
parent 7744fec0bf
commit 01983c65c3
9 changed files with 88 additions and 98 deletions

View file

@ -28,7 +28,7 @@ public:
LeftToRight,
RightToLeft
};
DiveCartesianAxis(ProfileWidget2 *widget);
DiveCartesianAxis(double fontPrintScale, ProfileWidget2 *widget);
~DiveCartesianAxis();
void setPrintMode(bool mode);
void setMinimum(double minimum);
@ -70,12 +70,13 @@ protected:
double labelScale;
qreal line_size;
bool changed;
double fontPrintScale;
};
class DepthAxis : public DiveCartesianAxis {
Q_OBJECT
public:
DepthAxis(ProfileWidget2 *widget);
DepthAxis(double fontPrintScale, ProfileWidget2 *widget);
private:
QString textForValue(double value) const override;
QColor colorForValue(double value) const override;
@ -106,7 +107,7 @@ private:
class PartialGasPressureAxis : public DiveCartesianAxis {
Q_OBJECT
public:
PartialGasPressureAxis(const DivePlotDataModel &model, ProfileWidget2 *widget);
PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, ProfileWidget2 *widget);
public
slots:
void update();