profile: scale dive event items according to font print scale

When printing with low DPI, the dive event items become comically
large, because they are not resized like the fonts. Therefore,
scale using the fontPrintScale.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-07-04 17:27:10 +02:00 committed by Dirk Hohndel
parent 6b2e56e513
commit 65580fceda
3 changed files with 7 additions and 6 deletions

View file

@ -16,7 +16,7 @@
DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
int speed, QGraphicsItem *parent) : DivePixmapItem(parent),
int speed, double fontPrintScale, QGraphicsItem *parent) : DivePixmapItem(parent),
vAxis(vAxis),
hAxis(hAxis),
dataModel(model),
@ -25,7 +25,7 @@ DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasm
{
setFlag(ItemIgnoresTransformations);
setupPixmap(lastgasmix);
setupPixmap(lastgasmix, fontPrintScale);
setupToolTipString(lastgasmix);
recalculatePos(0);
@ -48,7 +48,7 @@ struct event *DiveEventItem::getEventMutable()
return ev;
}
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
void DiveEventItem::setupPixmap(struct gasmix lastgasmix, double fontPrintScale)
{
const IconMetrics& metrics = defaultIconMetrics();
#ifndef SUBSURFACE_MOBILE
@ -63,6 +63,7 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
int sz_bigger = metrics.sz_big + metrics.sz_med;
#endif
#endif
sz_bigger = lrint(sz_bigger * fontPrintScale);
int sz_pix = sz_bigger/2; // ex 20px
#define EVENT_PIXMAP(PIX) QPixmap(QString(PIX)).scaled(sz_pix, sz_pix, Qt::KeepAspectRatio, Qt::SmoothTransformation)