forked from qt-creator/qt-creator
QmlDesigner: Use new validation approach in timeline editor
Many validation tests can now be skipped. Task-number: QDS-7454 Change-Id: I8b7c1a5cdce2d19dd62cf2400d297dc9fffd4fcc Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -142,15 +142,12 @@ void TimelineActions::copyKeyframes(const QList<ModelNode> &keyframes)
|
||||
|
||||
bool isKeyframe(const ModelNode &node)
|
||||
{
|
||||
return node.isValid() && node.metaInfo().isQtQuickTimelineKeyframe();
|
||||
return node.metaInfo().isQtQuickTimelineKeyframe();
|
||||
}
|
||||
|
||||
QVariant getValue(const ModelNode &node)
|
||||
{
|
||||
if (node.isValid())
|
||||
return node.variantProperty("value").value();
|
||||
|
||||
return QVariant();
|
||||
return node.variantProperty("value").value();
|
||||
}
|
||||
|
||||
qreal getTime(const ModelNode &node)
|
||||
|
@@ -769,7 +769,7 @@ void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)
|
||||
ModelNode frame = keyframe;
|
||||
ModelNode parent = frame.parentProperty().parentModelNode();
|
||||
keyframe.destroy();
|
||||
if (parent.isValid() && parent.defaultNodeListProperty().isEmpty())
|
||||
if (parent.defaultNodeListProperty().isEmpty())
|
||||
parent.destroy();
|
||||
}
|
||||
}
|
||||
|
@@ -257,10 +257,7 @@ void TimelinePropertyItem::updateFrames()
|
||||
|
||||
bool TimelinePropertyItem::isSelected() const
|
||||
{
|
||||
if (m_frames.isValid() && m_frames.target().isValid())
|
||||
return m_frames.target().isSelected();
|
||||
|
||||
return false;
|
||||
return m_frames.target().isSelected();
|
||||
}
|
||||
|
||||
QString convertVariant(const QVariant &variant)
|
||||
@@ -564,7 +561,7 @@ void TimelineKeyframeItem::enableUpdates()
|
||||
|
||||
bool TimelineKeyframeItem::hasManualBezier() const
|
||||
{
|
||||
return m_frame.isValid() && m_frame.hasProperty("easing.bezierCurve");
|
||||
return m_frame.hasProperty("easing.bezierCurve");
|
||||
}
|
||||
|
||||
void TimelineKeyframeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
|
@@ -187,7 +187,7 @@ AbstractView *TimelineSectionItem::view() const
|
||||
|
||||
bool TimelineSectionItem::isSelected() const
|
||||
{
|
||||
return m_targetNode.isValid() && m_targetNode.isSelected();
|
||||
return m_targetNode.isSelected();
|
||||
}
|
||||
|
||||
ModelNode TimelineSectionItem::targetNode() const
|
||||
@@ -967,7 +967,7 @@ void TimelineBarItem::commitPosition(const QPointF & /*point*/)
|
||||
|
||||
bool TimelineBarItem::isLocked() const
|
||||
{
|
||||
return sectionItem()->targetNode().isValid() && sectionItem()->targetNode().locked();
|
||||
return sectionItem()->targetNode().locked();
|
||||
}
|
||||
|
||||
TimelineBarItem *TimelineBarItem::asTimelineBarItem()
|
||||
@@ -994,13 +994,10 @@ void TimelineBarItem::paint(QPainter *painter,
|
||||
const QColor indicatorColor = Theme::getColor(Theme::PanelTextColorLight);
|
||||
|
||||
ModelNode target = sectionItem()->targetNode();
|
||||
if (target.isValid()) {
|
||||
QColor overrideColor = target.auxiliaryDataWithDefault(timelineOverrideColorProperty)
|
||||
.value<QColor>();
|
||||
if (overrideColor.isValid()) {
|
||||
brushColorSelected = overrideColor;
|
||||
brushColor = brushColorSelected.darker(120);
|
||||
}
|
||||
QColor overrideColor = target.auxiliaryDataWithDefault(timelineOverrideColorProperty).value<QColor>();
|
||||
if (overrideColor.isValid()) {
|
||||
brushColorSelected = overrideColor;
|
||||
brushColor = brushColorSelected.darker(120);
|
||||
}
|
||||
|
||||
const QRectF itemRect = rect();
|
||||
@@ -1079,8 +1076,7 @@ void TimelineBarItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
|
||||
QAction* resetColor = menu.addAction(tr("Reset Color"));
|
||||
auto reset = [this]() {
|
||||
ModelNode target = sectionItem()->targetNode();
|
||||
if (target.isValid())
|
||||
target.removeAuxiliaryData(timelineOverrideColorProperty);
|
||||
target.removeAuxiliaryData(timelineOverrideColorProperty);
|
||||
};
|
||||
QObject::connect(resetColor, &QAction::triggered, reset);
|
||||
|
||||
|
@@ -208,9 +208,9 @@ void TimelineSettingsModel::addState(const ModelNode &state)
|
||||
QList<QStandardItem *> items;
|
||||
|
||||
QmlTimeline timeline = timelineView()->timelineForState(state);
|
||||
const QString timelineId = timeline.isValid() ? timeline.modelNode().id() : QString("");
|
||||
const QString timelineId = timeline.modelNode().id();
|
||||
ModelNode animation = animationForTimelineAndState(timeline, state);
|
||||
const QString animationId = animation.isValid() ? animation.id() : QString("");
|
||||
const QString animationId = animation.id();
|
||||
|
||||
QStandardItem *stateItem = createStateItem(state);
|
||||
auto *timelinelItem = new QStandardItem(timelineId);
|
||||
@@ -318,34 +318,24 @@ void TimelineSettingsModel::updateAnimation(int row)
|
||||
ModelNode oldAnimation = animationForTimelineAndState(oldTimeline, modelState);
|
||||
|
||||
if (modelState.isBaseState()) {
|
||||
if (oldAnimation.isValid())
|
||||
oldAnimation.variantProperty("running").setValue(false);
|
||||
if (animation.isValid())
|
||||
animation.variantProperty("running").setValue(true);
|
||||
if (timeline.isValid() && timeline.modelNode().hasProperty("currentFrame"))
|
||||
timeline.modelNode().removeProperty("currentFrame");
|
||||
oldAnimation.variantProperty("running").setValue(false);
|
||||
animation.variantProperty("running").setValue(true);
|
||||
timeline.modelNode().removeProperty("currentFrame");
|
||||
} else {
|
||||
if (oldAnimation.isValid() && modelState.affectsModelNode(oldAnimation)) {
|
||||
if (modelState.affectsModelNode(oldAnimation)) {
|
||||
QmlPropertyChanges propertyChanges(modelState.propertyChanges(oldAnimation));
|
||||
if (propertyChanges.isValid() && propertyChanges.modelNode().hasProperty("running"))
|
||||
propertyChanges.modelNode().removeProperty("running");
|
||||
propertyChanges.modelNode().removeProperty("running");
|
||||
}
|
||||
|
||||
ModelNode baseAnimation(animationForRow(0));
|
||||
|
||||
if (baseAnimation.isValid()) {
|
||||
if (ModelNode baseAnimation = animationForRow(0)) {
|
||||
QmlPropertyChanges propertyChanges(modelState.propertyChanges(baseAnimation));
|
||||
if (propertyChanges.isValid()) {
|
||||
propertyChanges.modelNode().variantProperty("running").setValue(false);
|
||||
if (propertyChanges.modelNode().hasProperty("currentFrame"))
|
||||
propertyChanges.modelNode().removeProperty("currentFrame");
|
||||
}
|
||||
propertyChanges.modelNode().variantProperty("running").setValue(false);
|
||||
propertyChanges.modelNode().removeProperty("currentFrame");
|
||||
}
|
||||
|
||||
if (animation.isValid()) { /* If animation is invalid 'none' was selected */
|
||||
QmlPropertyChanges propertyChanges(modelState.propertyChanges(animation));
|
||||
if (propertyChanges.isValid())
|
||||
propertyChanges.modelNode().variantProperty("running").setValue(true);
|
||||
propertyChanges.modelNode().variantProperty("running").setValue(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -363,20 +353,17 @@ void TimelineSettingsModel::updateFixedFrameRow(int row)
|
||||
int fixedFrame = fixedFrameForRow(row);
|
||||
|
||||
if (modelState.isBaseState()) {
|
||||
if (animation.isValid())
|
||||
animation.variantProperty("running").setValue(false);
|
||||
if (timeline.isValid())
|
||||
timeline.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
||||
animation.variantProperty("running").setValue(false);
|
||||
timeline.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
||||
} else {
|
||||
if (animation.isValid() && modelState.affectsModelNode(animation)) {
|
||||
if (modelState.affectsModelNode(animation)) {
|
||||
QmlPropertyChanges propertyChanges(modelState.propertyChanges(animation));
|
||||
if (propertyChanges.isValid() && propertyChanges.modelNode().hasProperty("running"))
|
||||
if (propertyChanges.modelNode().hasProperty("running"))
|
||||
propertyChanges.modelNode().removeProperty("running");
|
||||
}
|
||||
|
||||
QmlPropertyChanges propertyChanges(modelState.propertyChanges(timeline));
|
||||
if (propertyChanges.isValid())
|
||||
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
||||
propertyChanges.modelNode().variantProperty("currentFrame").setValue(fixedFrame);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -394,10 +381,8 @@ void TimelineSettingsModel::resetRow(int row)
|
||||
QmlTimeline timeline(timelineForRow(row));
|
||||
ModelNode animation = animationForTimelineAndState(timeline, modelState);
|
||||
|
||||
if (animationItem) {
|
||||
const QString animationId = animation.isValid() ? animation.id() : QString();
|
||||
animationItem->setText(animationId);
|
||||
}
|
||||
if (animationItem)
|
||||
animationItem->setText(animation.id());
|
||||
|
||||
if (fixedFrameItem) {
|
||||
auto fixedValue = propertyValueForState(timeline, modelState, "currentFrame");
|
||||
|
@@ -98,22 +98,16 @@ void TimelineView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
if (lastId != currentId)
|
||||
m_timelineWidget->setTimelineId(currentId);
|
||||
|
||||
} else if (removedNode.parentProperty().isValid()
|
||||
&& QmlTimeline::isValidQmlTimeline(
|
||||
removedNode.parentProperty().parentModelNode())) {
|
||||
if (removedNode.hasBindingProperty("target")) {
|
||||
const ModelNode target = removedNode.bindingProperty("target").resolveToModelNode();
|
||||
if (target.isValid()) {
|
||||
QmlTimeline timeline(removedNode.parentProperty().parentModelNode());
|
||||
if (timeline.hasKeyframeGroupForTarget(target))
|
||||
QTimer::singleShot(0, [this, target, timeline]() {
|
||||
if (timeline.hasKeyframeGroupForTarget(target))
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(
|
||||
target);
|
||||
else
|
||||
m_timelineWidget->graphicsScene()->invalidateScene();
|
||||
});
|
||||
}
|
||||
} else if (QmlTimeline::isValidQmlTimeline(removedNode.parentProperty().parentModelNode())) {
|
||||
if (const ModelNode target = removedNode.bindingProperty("target").resolveToModelNode()) {
|
||||
QmlTimeline timeline(removedNode.parentProperty().parentModelNode());
|
||||
if (timeline.hasKeyframeGroupForTarget(target))
|
||||
QTimer::singleShot(0, [this, target, timeline]() {
|
||||
if (timeline.hasKeyframeGroupForTarget(target))
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(target);
|
||||
else
|
||||
m_timelineWidget->graphicsScene()->invalidateScene();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,7 +184,6 @@ void TimelineView::variantPropertiesChanged(const QList<VariantProperty> &proper
|
||||
for (const auto &property : propertyList) {
|
||||
if ((property.name() == "frame" || property.name() == "value")
|
||||
&& property.parentModelNode().type() == "QtQuick.Timeline.Keyframe"
|
||||
&& property.parentModelNode().isValid()
|
||||
&& property.parentModelNode().hasParentProperty()) {
|
||||
const ModelNode framesNode
|
||||
= property.parentModelNode().parentProperty().parentModelNode();
|
||||
|
Reference in New Issue
Block a user