Retain zoom factor when showing after hiding

The timeline and transition editor where resetting
their zoom factors to 0 in the showevent.
This is now fixed.

Fixes: QDS-5337
Change-Id: Ic4d9b2af7613b4c5c2fd5e9c646df51978fd05f6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2021-11-23 11:51:36 +01:00
parent 6f27359f15
commit a6e3b39d40
6 changed files with 15 additions and 14 deletions

View File

@@ -136,8 +136,7 @@ void TimelineGraphicsScene::onShow()
int cf = std::round(timeline.currentKeyframe());
setCurrentFrame(cf);
}
emit m_layout->zoomChanged(0);
emit m_layout->zoomChanged(zoom());
}
}

View File

@@ -482,7 +482,7 @@ void TimelineWidget::contextHelp(const Core::IContext::HelpCallback &callback) c
callback({});
}
void TimelineWidget::init()
void TimelineWidget::init(int zoom)
{
QmlTimeline currentTimeline = m_timelineView->timelineForState(m_timelineView->currentState());
if (currentTimeline.isValid()) {
@@ -499,8 +499,8 @@ void TimelineWidget::init()
m_graphicsScene->setWidth(m_graphicsView->viewport()->width());
// setScaleFactor uses QSignalBlocker.
m_toolbar->setScaleFactor(0);
m_graphicsScene->setZoom(0);
m_toolbar->setScaleFactor(zoom);
m_graphicsScene->setZoom(zoom);
}
void TimelineWidget::reset()
@@ -611,6 +611,8 @@ void TimelineWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
int zoom = m_toolbar->scaleFactor();
m_timelineView->setEnabled(true);
graphicsScene()->setWidth(m_graphicsView->viewport()->width());
@@ -622,7 +624,7 @@ void TimelineWidget::showEvent(QShowEvent *event)
//All the events have to be fully processed before we call init()
if (m_timelineView->model())
QTimer::singleShot(0, [this]() { init(); });
QTimer::singleShot(0, [this, zoom]() { init(zoom); });
}
void TimelineWidget::resizeEvent(QResizeEvent *event)

View File

@@ -62,7 +62,7 @@ public:
TimelineView *timelineView() const;
TimelineToolBar *toolBar() const;
void init();
void init(int zoom = 0);
void reset();
void invalidateTimelineDuration(const QmlTimeline &timeline);

View File

@@ -119,7 +119,7 @@ void TransitionEditorGraphicsScene::invalidateScrollbar()
void TransitionEditorGraphicsScene::onShow()
{
emit m_layout->zoomChanged(0);
emit m_layout->zoomChanged(zoom());
}
void TransitionEditorGraphicsScene::setTransition(const ModelNode &transition)

View File

@@ -326,7 +326,7 @@ void TransitionEditorWidget::contextHelp(const Core::IContext::HelpCallback &cal
callback({});
}
void TransitionEditorWidget::init()
void TransitionEditorWidget::init(int zoom)
{
ModelNode root = transitionEditorView()->rootModelNode();
ModelNode transition;
@@ -345,7 +345,7 @@ void TransitionEditorWidget::init()
m_graphicsScene->setWidth(m_graphicsView->viewport()->width());
m_toolbar->setScaleFactor(40);
m_toolbar->setScaleFactor(zoom);
m_toolbar->setCurrentTransition(transition);
@@ -355,13 +355,13 @@ void TransitionEditorWidget::init()
m_toolbar->setDuration(duration);
m_graphicsScene->setZoom(40);
m_graphicsScene->setZoom(zoom);
}
void TransitionEditorWidget::updateData(const ModelNode &transition)
{
if (!transition.isValid()) {
init();
init(m_toolbar->scaleFactor());
return;
}
@@ -409,7 +409,7 @@ void TransitionEditorWidget::showEvent(QShowEvent *event)
m_transitionEditorView->setEnabled(true);
if (m_transitionEditorView->model())
init();
init(m_toolbar->scaleFactor());
graphicsScene()->setWidth(m_graphicsView->viewport()->width());
graphicsScene()->invalidateLayout();

View File

@@ -61,7 +61,7 @@ public:
TransitionEditorView *transitionEditorView() const;
TransitionEditorToolBar *toolBar() const;
void init();
void init(int zoom = 0);
void reset();
void setupScrollbar(int min, int max, int current);