diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-01-18 12:32:47 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-18 12:32:47 -0800 |
commit | 464b88f01fed745342080af3be12c21d64f1e449 (patch) | |
tree | 5ec0bfc006ad5a291dcf62a6e8caef7b6db9be64 /qt-mobile/qmlprofile.cpp | |
parent | 38c60e02c7705044f8b7eb9ea177139a63239446 (diff) | |
download | subsurface-464b88f01fed745342080af3be12c21d64f1e449.tar.gz |
QML UI: yet another attempt to fix the profile scaling
This one appears to work in my testing so far. And reading the code it
seems to make sense. We look at the size that the widget thinks it is. And
we scale the scene to fill that size (including a margin). And then let Qt
and QML deal with the rest of it. Assuming this works it shows that we
have been trying too hard all this time.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlprofile.cpp')
-rw-r--r-- | qt-mobile/qmlprofile.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp index c617b73a3..82f7dfe4c 100644 --- a/qt-mobile/qmlprofile.cpp +++ b/qt-mobile/qmlprofile.cpp @@ -22,20 +22,14 @@ QMLProfile::~QMLProfile() void QMLProfile::paint(QPainter *painter) { - m_profileWidget->setGeometry(QRect(0, 0, width(), height())); - // scale the profile widget's image to devicePixelRatio and a magic number - qreal dpr = 104; // that should give us 2% margin all around - qreal sx = width() / dpr; - qreal sy = height() / dpr; - - qDebug() << "paint called; rect" << x() << y() << width() << height() << "dpr" << dpr << "sx/sy" << sx << sy; - + // let's look at the intended size of the content and scale our scene accordingly + QRect rect = m_profileWidget->contentsRect(); + qreal sceneSize = 104; // that should give us 2% margin all around (100x100 scene) + qreal sx = rect.width() / sceneSize; + qreal sy = rect.height() / sceneSize; QTransform profileTransform; profileTransform.scale(sx, sy); m_profileWidget->setTransform(profileTransform); - qDebug() << "viewportTransform" << m_profileWidget->viewportTransform(); - qDebug() << "after scaling we have margin/rect" << m_profileWidget->contentsMargins() << m_profileWidget->contentsRect(); - qDebug() << "size of the QMLProfile:" << this->contentsSize() << this->contentsScale(); m_profileWidget->render(painter); } |