chore: add the ability to know if it's the first loaded user media

This could make it easier to allow set “Keep Transform” mode at
start-up.

This change is sponsored by @EdgarHartel.

Related: https://github.com/BLumia/pineapple-pictures/issues/146#issuecomment-2778192785
This commit is contained in:
2025-04-08 23:19:02 +08:00
parent fc417b30e5
commit 0a45cd7c22
2 changed files with 11 additions and 2 deletions

View File

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