Improve usability of the timeline

Keep focus in the lower graphicsview when dragging the playhead
Update the timeline and curve editor when a keyframe value has changed
Select the keyframe when right clicking on an unselected one

Task-number: QDS-1417
Task-number: QDS-2129
Task-number: QDS-670
Task-number: QDS-919
Change-Id: Ic37816c03447b7a7deedce360795fa25805df315
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2020-06-03 15:22:54 +02:00
parent 8b8ecfa28f
commit db3b60d780
5 changed files with 20 additions and 6 deletions

View File

@@ -580,6 +580,7 @@ void TimelineGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
/* The tool has handle the event last. */
QGraphicsScene::mouseReleaseEvent(event);
m_tools.mouseReleaseEvent(topItem, event);
m_parent->setFocus();
}
void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
@@ -733,7 +734,6 @@ void TimelineGraphicsScene::deleteKeyframeGroup(const ModelNode &group)
ModelNode nonConst = group;
nonConst.destroy();
});
}
void TimelineGraphicsScene::deleteKeyframes(const QList<ModelNode> &frames)

View File

@@ -59,13 +59,20 @@ void TimelineToolDelegate::mousePressEvent(TimelineMovableAbstractItem *item,
QGraphicsSceneMouseEvent *event)
{
if (event->buttons() == Qt::LeftButton && hitCanvas(event)) {
m_start = event->scenePos();
m_start = event->scenePos();
if (item) {
setItem(item, event->modifiers());
m_currentTool = m_moveTool.get();
} else
m_currentTool = m_selectTool.get();
} else if (event->buttons() == Qt::RightButton && event->modifiers() == Qt::NoModifier
&& hitCanvas(event) && item) {
setItem(item, Qt::NoModifier);
reset();
} else
m_currentTool = nullptr;

View File

@@ -181,6 +181,7 @@ void TimelineView::instancePropertyChanged(const QList<QPair<ModelNode, Property
} else if (pair.second == "currentFrame") {
if (QmlTimeline::isValidQmlTimeline(pair.first)) {
m_timelineWidget->invalidateTimelinePosition(pair.first);
updateAnimationCurveEditor();
}
} else if (!updated && timeline.hasTimeline(pair.first, pair.second)) {
m_timelineWidget->graphicsScene()->invalidateCurrentValues();
@@ -198,7 +199,7 @@ void TimelineView::variantPropertiesChanged(const QList<VariantProperty> &proper
AbstractView::PropertyChangeFlags /*propertyChange*/)
{
for (const auto &property : propertyList) {
if (property.name() == "frame"
if ((property.name() == "frame" || property.name() == "value")
&& property.parentModelNode().type() == "QtQuick.Timeline.Keyframe"
&& property.parentModelNode().isValid()
&& property.parentModelNode().hasParentProperty()) {

View File

@@ -591,6 +591,11 @@ void TimelineWidget::setTimelineActive(bool b)
}
}
void TimelineWidget::setFocus()
{
m_graphicsView->setFocus();
}
void TimelineWidget::showEvent(QShowEvent *event)
{
Q_UNUSED(event)

View File

@@ -70,6 +70,7 @@ public:
void setTimelineId(const QString &id);
void setTimelineActive(bool b);
void setFocus();
public slots:
void selectionChanged();