diff --git a/app/graphicsview.cpp b/app/graphicsview.cpp index 91fb50b..f5b7555 100644 --- a/app/graphicsview.cpp +++ b/app/graphicsview.cpp @@ -118,7 +118,7 @@ qreal GraphicsView::scaleFactor() const void GraphicsView::resetTransform() { - if (!m_avoidResetTransform) { + if (!shouldAvoidTransform()) { QGraphicsView::resetTransform(); } } @@ -196,7 +196,7 @@ void GraphicsView::fitByOrientation(Qt::Orientation ori, bool scaleDownOnly) void GraphicsView::displayScene() { - if (m_avoidResetTransform) { + if (shouldAvoidTransform()) { emit navigatorViewRequired(!isThingSmallerThanWindowWith(transform()), transform()); return; } @@ -206,6 +206,7 @@ void GraphicsView::displayScene() } m_enableFitInView = true; + m_firstUserMediaLoaded = true; } bool GraphicsView::isSceneBiggerThanView() const @@ -365,3 +366,8 @@ void GraphicsView::applyTransformationModeByScaleFactor() scene()->trySetTransformationMode(Qt::FastTransformation, this->scaleFactor()); } } + +bool GraphicsView::shouldAvoidTransform() const +{ + return m_firstUserMediaLoaded && m_avoidResetTransform; +} diff --git a/app/graphicsview.h b/app/graphicsview.h index 87fed81..c03f1a2 100644 --- a/app/graphicsview.h +++ b/app/graphicsview.h @@ -64,6 +64,8 @@ private: void setCheckerboardEnabled(bool enabled, bool invertColor = false); void applyTransformationModeByScaleFactor(); + inline bool shouldAvoidTransform() const; + // Consider switch to 3 state for "no fit", "always fit" and "fit when view is smaller"? // ... or even more? e.g. "fit/snap width" things... // Currently it's "no fit" when it's false and "fit when view is smaller" when it's true. @@ -71,6 +73,7 @@ private: bool m_avoidResetTransform = false; bool m_checkerboardEnabled = false; bool m_useLightCheckerboard = false; + bool m_firstUserMediaLoaded = false; }; #endif // GRAPHICSVIEW_H