From d6095f9763d89dcbe055f9b6de4910300a338540 Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Mon, 12 Aug 2019 12:53:42 +0200 Subject: Do not clear selection when clicking on a selected keyframe Change-Id: Ia2907a3687b70faf32bc32540bac8f381b507b73 Reviewed-by: Tim Jenssen --- .../components/curveeditor/detail/selector.cpp | 20 +++++++++++++++++--- .../components/curveeditor/detail/selector.h | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp index 6119e8e9960..13fdeb72ed3 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp @@ -58,14 +58,15 @@ void Selector::mousePress(QMouseEvent *event, GraphicsView *view) if (view->hasActiveHandle()) return; - if (select(SelectionTool::Undefined, view->globalToScene(event->globalPos()), view)) - applyPreSelection(view); - m_mouseInit = event->globalPos(); m_mouseCurr = event->globalPos(); QPointF click = view->globalToScene(m_mouseInit); + if (!isOverSelectedKeyframe(click, view)) + if (select(SelectionTool::Undefined, click, view)) + applyPreSelection(view); + m_lasso = QPainterPath(click); m_lasso.closeSubpath(); @@ -119,6 +120,19 @@ void Selector::mouseRelease(QMouseEvent *event, GraphicsView *view) m_rect = QRectF(); } +bool Selector::isOverSelectedKeyframe(const QPointF &pos, GraphicsView *view) +{ + const auto itemList = view->items(); + for (auto *item : itemList) { + if (auto *frame = qgraphicsitem_cast(item)) { + QRectF itemRect = frame->mapRectToScene(frame->boundingRect()); + if (itemRect.contains(pos)) + return frame->selected(); + } + } + return false; +} + bool Selector::select(const SelectionTool &tool, const QPointF &pos, GraphicsView *view) { auto selectWidthTool = [this, tool](SelectionMode mode, const QPointF &pos, GraphicsView *view) { diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selector.h b/src/plugins/qmldesigner/components/curveeditor/detail/selector.h index 1c955de5bef..4027cc87b1c 100644 --- a/src/plugins/qmldesigner/components/curveeditor/detail/selector.h +++ b/src/plugins/qmldesigner/components/curveeditor/detail/selector.h @@ -54,6 +54,8 @@ public: void mouseRelease(QMouseEvent *event, GraphicsView *view); private: + bool isOverSelectedKeyframe(const QPointF &pos, GraphicsView *view); + bool select(const SelectionTool &tool, const QPointF &pos, GraphicsView *view); bool pressSelection(SelectionMode mode, const QPointF &pos, GraphicsView *view); -- cgit v1.2.3