fix: always flip according to current viewport state

This commit is contained in:
Gary Wang 2021-03-27 22:22:04 +08:00
parent 483bb07b09
commit e1324d901c
2 changed files with 8 additions and 14 deletions

View File

@ -135,11 +135,12 @@ void GraphicsView::zoomView(qreal scaleFactor)
void GraphicsView::flipView(bool horizontal)
{
if (horizontal) {
scale(-1, 1);
} else {
scale(1, -1);
}
QTransform tf(horizontal ? -1 : 1, 0, 0,
0, horizontal ? 1 : -1, 0,
0, 0, 1);
tf = transform() * tf;
setTransform(tf);
// Ensure the navigation view is also flipped.
emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform());
}
@ -179,6 +180,8 @@ inline double zeroOrOne(double number)
return qFuzzyIsNull(number) ? 0 : (number > 0 ? 1 : -1);
}
// Note: this only works if we only have 90 degree based rotation
// and no shear/translate.
QTransform GraphicsView::resetScale(const QTransform & orig)
{
return QTransform(zeroOrOne(orig.m11()), zeroOrOne(orig.m12()),
@ -349,10 +352,3 @@ void GraphicsView::applyTransformationModeByScaleFactor()
scene()->trySetTransformationMode(Qt::FastTransformation);
}
}
void GraphicsView::resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle)
{
QGraphicsView::resetTransform();
scale(scaleFactor, scaleFactor);
rotate(rotateAngle);
}

View File

@ -59,8 +59,6 @@ private:
void setCheckerboardEnabled(bool enabled, bool invertColor = false);
void applyTransformationModeByScaleFactor();
void resetWithScaleAndRotate(qreal scaleFactor, qreal rotateAngle);
bool m_enableFitInView = false;
bool m_checkerboardEnabled = false;
bool m_isLastCheckerboardColorInverted = false;