From 65580fceda8017007d16f6470730d7fcd8273939 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 4 Jul 2021 17:27:10 +0200 Subject: 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 --- profile-widget/diveeventitem.cpp | 7 ++++--- profile-widget/diveeventitem.h | 4 ++-- profile-widget/profilewidget2.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 513e48172..f1f0f8016 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -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) diff --git a/profile-widget/diveeventitem.h b/profile-widget/diveeventitem.h index ca3cc2623..2fb584aae 100644 --- a/profile-widget/diveeventitem.h +++ b/profile-widget/diveeventitem.h @@ -13,7 +13,7 @@ class DiveEventItem : public DivePixmapItem { public: DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix, DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, - int speed, QGraphicsItem *parent = nullptr); + int speed, double fontPrintScale, QGraphicsItem *parent = nullptr); ~DiveEventItem(); const struct event *getEvent() const; struct event *getEventMutable(); @@ -28,7 +28,7 @@ slots: private: void setupToolTipString(struct gasmix lastgasmix); - void setupPixmap(struct gasmix lastgasmix); + void setupPixmap(struct gasmix lastgasmix, double fontPrintScale); int depthAtTime(int time); DiveCartesianAxis *vAxis; DiveCartesianAxis *hAxis; diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index f0c3f1d0a..930df1267 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -721,7 +721,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict // printMode is always selected for SUBSURFACE_MOBILE due to font problems // BUT events are wanted. #endif - DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel, timeAxis, profileYAxis, animSpeed); + DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel, timeAxis, profileYAxis, animSpeed, getFontPrintScale()); item->setZValue(2); #ifndef SUBSURFACE_MOBILE item->setScale(printMode ? 4 :1); -- cgit v1.2.3-70-g09d2