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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-12-02 11:26:32 -08:00
parent 84a47c0cb4
commit 1bfcf5c0f8

View file

@ -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);
}