From ed1604087f5e43b7599040fb41d270f3ee40fb0d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 20 May 2023 14:46:58 +0200 Subject: [PATCH] profile: read DPR from QML page This is needed on mobile, where some screens have a high DPR. Signed-off-by: Berthold Stoeger --- profile-widget/profileview.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/profile-widget/profileview.cpp b/profile-widget/profileview.cpp index 9c4068e32..6a82ebb0a 100644 --- a/profile-widget/profileview.cpp +++ b/profile-widget/profileview.cpp @@ -23,8 +23,7 @@ ProfileView::ProfileView(QQuickItem *parent) : ChartView(parent, ProfileZValue:: zoomLevel(0), zoomedPosition(0.0), empty(true), - shouldCalculateMax(true), - profileScene(std::make_unique(1.0, false, false)) + shouldCalculateMax(true) { setBackgroundColor(Qt::black); setFlag(ItemHasContents, true); @@ -56,7 +55,8 @@ void ProfileView::clear() { //clearPictures(); //disconnectTemporaryConnections(); - profileScene->clear(); + if (profileScene) + profileScene->clear(); //handles.clear(); //gases.clear(); empty = true; @@ -73,6 +73,11 @@ void ProfileView::plotDive(const struct dive *dIn, int dcIn, int flags) return; } + // We can't create the scene in the constructor, because we can't get the DPR property there. Oh joy! + if (!profileScene) { + double dpr = std::clamp(property("dpr").toReal(), 1.0, 100.0); + profileScene = std::make_unique(dpr, false, false); + } // If there was no previously displayed dive, turn off animations if (empty) flags |= RenderFlags::Instant;