1
0

fix: zoom jump due to stupid bug

This commit is contained in:
Gary Wang
2019-11-02 13:32:13 +08:00
parent f2d83e3f85
commit fb9207cb71
2 changed files with 7 additions and 12 deletions

View File

@@ -103,7 +103,6 @@ qreal GraphicsView::scaleFactor() const
void GraphicsView::resetTransform()
{
m_scaleFactor = 1;
m_rotateAngle = 0;
QGraphicsView::resetTransform();
}
@@ -111,15 +110,13 @@ void GraphicsView::resetTransform()
void GraphicsView::zoomView(qreal scaleFactor)
{
m_enableFitInView = false;
m_scaleFactor *= scaleFactor;
reapplyViewTransform();
scale(scaleFactor, scaleFactor);
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
}
void GraphicsView::resetScale()
{
m_scaleFactor = 1;
reapplyViewTransform();
resetWithScaleAndRotate(1, m_rotateAngle);
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), m_rotateAngle);
}
@@ -127,13 +124,12 @@ void GraphicsView::rotateView(qreal rotateAngel)
{
m_rotateAngle += rotateAngel;
m_rotateAngle = static_cast<int>(m_rotateAngle) % 360;
reapplyViewTransform();
resetWithScaleAndRotate(1, m_rotateAngle);
}
void GraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode)
{
QGraphicsView::fitInView(rect, aspectRadioMode);
m_scaleFactor = scaleFactor();
}
void GraphicsView::checkAndDoFitInView()
@@ -291,9 +287,9 @@ void GraphicsView::setCheckerboardEnabled(bool enabled)
}
}
void GraphicsView::reapplyViewTransform()
void GraphicsView::resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle)
{
QGraphicsView::resetTransform();
scale(m_scaleFactor, m_scaleFactor);
rotate(m_rotateAngle);
scale(scaleFactor, scaleFactor);
rotate(rotateAngle);
}