aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp')
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp
index 2ee841d872..b9adeb01cc 100644
--- a/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp
+++ b/src/plugins/qmldesigner/components/curveeditor/detail/keyframeitem.cpp
@@ -75,15 +75,15 @@ void KeyframeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->restore();
}
-void KeyframeItem::setLocked(bool locked)
+void KeyframeItem::lockedCallback()
{
- SelectableItem::setLocked(locked);
+ SelectableItem::lockedCallback();
if (m_left)
- m_left->setLocked(locked);
+ m_left->setLocked(locked());
if (m_right)
- m_right->setLocked(locked);
+ m_right->setLocked(locked());
}
KeyframeItem::~KeyframeItem() {}
@@ -103,14 +103,14 @@ bool KeyframeItem::hasRightHandle() const
return m_frame.hasRightHandle();
}
-HandleSlot KeyframeItem::handleSlot(HandleItem *item) const
+QTransform KeyframeItem::transform() const
{
- if (item == m_left)
- return HandleSlot::Left;
- else if (item == m_right)
- return HandleSlot::Right;
- else
- return HandleSlot::Undefined;
+ return m_transform;
+}
+
+bool KeyframeItem::contains(HandleItem *handle, const QPointF &point) const
+{
+ return false;
}
void KeyframeItem::setHandleVisibility(bool visible)
@@ -168,7 +168,7 @@ void KeyframeItem::setKeyframe(const Keyframe &keyframe)
if (m_frame.hasLeftHandle()) {
if (!m_left) {
- m_left = new HandleItem(this);
+ m_left = new HandleItem(this, HandleItem::Slot::Left);
auto updateLeftHandle = [this]() { updateHandle(m_left); };
connect(m_left, &QGraphicsObject::xChanged, updateLeftHandle);
connect(m_left, &QGraphicsObject::yChanged, updateLeftHandle);
@@ -181,7 +181,7 @@ void KeyframeItem::setKeyframe(const Keyframe &keyframe)
if (m_frame.hasRightHandle()) {
if (!m_right) {
- m_right = new HandleItem(this);
+ m_right = new HandleItem(this, HandleItem::Slot::Right);
auto updateRightHandle = [this]() { updateHandle(m_right); };
connect(m_right, &QGraphicsObject::xChanged, updateRightHandle);
connect(m_right, &QGraphicsObject::yChanged, updateRightHandle);
@@ -244,7 +244,7 @@ void KeyframeItem::moveKeyframe(const QPointF &direction)
emit redrawCurve();
}
-void KeyframeItem::moveHandle(HandleSlot handle, double deltaAngle, double deltaLength)
+void KeyframeItem::moveHandle(HandleItem::Slot slot, double deltaAngle, double deltaLength)
{
auto move = [this, deltaAngle, deltaLength](HandleItem *item) {
if (!item)
@@ -259,9 +259,9 @@ void KeyframeItem::moveHandle(HandleSlot handle, double deltaAngle, double delta
this->blockSignals(true);
- if (handle == HandleSlot::Left)
+ if (slot == HandleItem::Slot::Left)
move(m_left);
- else if (handle == HandleSlot::Right)
+ else if (slot == HandleItem::Slot::Right)
move(m_right);
this->blockSignals(false);
@@ -280,14 +280,13 @@ void KeyframeItem::updateHandle(HandleItem *handle, bool emitChanged)
QPointF oldPosition;
QPointF newPosition;
- HandleSlot slot = HandleSlot::Undefined;
- if (handle == m_left) {
- slot = HandleSlot::Left;
+ HandleItem::Slot slot = handle->slot();
+
+ if (slot == HandleItem::Slot::Left) {
oldPosition = m_frame.leftHandle();
m_frame.setLeftHandle(m_frame.position() + handlePosition);
newPosition = m_frame.leftHandle();
- } else {
- slot = HandleSlot::Right;
+ } else if (slot == HandleItem::Slot::Right) {
oldPosition = m_frame.rightHandle();
m_frame.setRightHandle(m_frame.position() + handlePosition);
newPosition = m_frame.rightHandle();
@@ -349,14 +348,18 @@ void KeyframeItem::selectionCallback()
if (selected()) {
if (m_visibleOverride) {
setHandleVisibility(true);
- setHandleVisibility(true);
}
} else {
if (!m_visibleOverride) {
setHandleVisibility(false);
- setHandleVisibility(false);
}
}
+
+ if (m_left)
+ m_left->setSelected(selected());
+
+ if (m_right)
+ m_right->setSelected(selected());
}
} // End namespace DesignTools.