From 1bfcf5c0f820633e7f9387722438370f0a3a5a48 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 2 Dec 2015 11:26:32 -0800 Subject: QML UI: fix profile scaling The scaling needs to happen before we draw the profile on the viewport, not before we render that viewport into the pixmap. This is why prior to this patch the first time the profile was rendered it was way off, but then if it got re-rendered things worked better. I'm still not 100% happy with the size and position of the profile, but this is a huge improvement. Signed-off-by: Dirk Hohndel --- qt-mobile/qmlprofile.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'qt-mobile') diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp index a55bf8d32..1ad84e735 100644 --- a/qt-mobile/qmlprofile.cpp +++ b/qt-mobile/qmlprofile.cpp @@ -19,9 +19,6 @@ QMLProfile::~QMLProfile() void QMLProfile::paint(QPainter *painter) { - QTransform profileTransform; - profileTransform.scale(width() / 100, height() / 100); - m_profileWidget->setTransform(profileTransform); m_profileWidget->render(painter); } @@ -43,6 +40,11 @@ void QMLProfile::setDiveId(const QString &diveId) if (!d) return; + // set the profile widget's geometry and scale the viewport so + // the scene fills it, then plot the dive on that widget m_profileWidget->setGeometry(QRect(x(), y(), width(), height())); + QTransform profileTransform; + profileTransform.scale(width() / 100, height() / 100); + m_profileWidget->setTransform(profileTransform); m_profileWidget->plotDive(d); } -- cgit v1.2.3-70-g09d2