aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKnud Dollereder <knud.dollereder@qt.io>2019-08-12 12:53:42 +0200
committerKnud Dollereder <knud.dollereder@qt.io>2019-08-12 12:22:15 +0000
commitd6095f9763d89dcbe055f9b6de4910300a338540 (patch)
tree313bdcb38783c0f14c9f528ebe4fbbb3e2490c02 /src
parentdf48ba57813150026f2a52d7721b4b546ac1bb31 (diff)
Do not clear selection when clicking on a selected keyframe
Change-Id: Ia2907a3687b70faf32bc32540bac8f381b507b73 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp20
-rw-r--r--src/plugins/qmldesigner/components/curveeditor/detail/selector.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp b/src/plugins/qmldesigner/components/curveeditor/detail/selector.cpp
index 6119e8e996..13fdeb72ed 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<KeyframeItem *>(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 1c955de5be..4027cc87b1 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);