diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-07-04 17:27:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-07-04 11:51:17 -0700 |
commit | 65580fceda8017007d16f6470730d7fcd8273939 (patch) | |
tree | 8549e6b9f4064f1d74ebb87fc7bffbeb74b22cae /profile-widget | |
parent | 6b2e56e5131aa707216c4b0da5805199fcc0034d (diff) | |
download | subsurface-65580fceda8017007d16f6470730d7fcd8273939.tar.gz |
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>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveeventitem.cpp | 7 | ||||
-rw-r--r-- | profile-widget/diveeventitem.h | 4 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 2 |
3 files changed, 7 insertions, 6 deletions
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); |