QmlDesigner: Keep hasActiveTimeline QML context property up to date

Change hasActiveTimeline QML context property setting to be based on
current timeline change notifications instead of timeline node
creation, as the timeline will not be valid at the time of the node
creation. That also failed to detect timeline deletion.

Also fixed the timeline logic to clear current timeline from model
when the timeline is deleted.

Change-Id: I9191300c964bc624a958003b6aa0d5d9e77ddf9a
Fixes: QDS-2139
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2020-06-02 12:11:43 +03:00
parent 5551791077
commit 279454a54b
4 changed files with 5 additions and 10 deletions

View File

@@ -357,12 +357,9 @@ bool PropertyEditorView::locked() const
return m_locked;
}
void PropertyEditorView::nodeCreated(const ModelNode &modelNode)
void PropertyEditorView::currentTimelineChanged(const ModelNode &)
{
if (!m_qmlBackEndForCurrentType->contextObject()->hasActiveTimeline()
&& QmlTimeline::isValidQmlTimeline(modelNode)) {
m_qmlBackEndForCurrentType->contextObject()->setHasActiveTimeline(QmlTimeline::hasActiveTimeline(this));
}
m_qmlBackEndForCurrentType->contextObject()->setHasActiveTimeline(QmlTimeline::hasActiveTimeline(this));
}
void PropertyEditorView::updateSize()

View File

@@ -94,7 +94,7 @@ public:
bool locked() const;
void nodeCreated(const ModelNode &createdNode) override;
void currentTimelineChanged(const ModelNode &node) override;
protected:
void timerEvent(QTimerEvent *event) override;

View File

@@ -386,9 +386,7 @@ void TimelineView::setTimelineRecording(bool value)
{
ModelNode node = widget()->graphicsScene()->currentTimeline();
QTC_ASSERT(node.isValid(), return );
if (value) {
if (value && node.isValid()) {
activateTimelineRecording(node);
} else {
deactivateTimelineRecording();

View File

@@ -563,11 +563,11 @@ void TimelineWidget::setTimelineId(const QString &id)
if (m_timelineView->isAttached() && !empty) {
m_toolbar->setCurrentTimeline(m_timelineView->modelNodeForId(id));
m_toolbar->setCurrentState(m_timelineView->currentState().name());
m_timelineView->setTimelineRecording(false);
} else {
m_toolbar->setCurrentTimeline({});
m_toolbar->setCurrentState({});
}
m_timelineView->setTimelineRecording(false);
}
void TimelineWidget::setTimelineActive(bool b)