diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 2b567a8e690..7f83f652e75 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -473,6 +474,9 @@ static void scatterItem(const ModelNode &pastedNode, const ModelNode &targetNode void DesignDocument::paste() { + if (TimelineActions::clipboardContainsKeyframes()) // pasting keyframes is handled in TimelineView + return; + QScopedPointer pasteModel(DesignDocumentView::pasteToModel()); if (!pasteModel) diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp index c9271e490c9..74a543ae9d8 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelineactions.cpp @@ -33,13 +33,12 @@ #include #include #include -#include #include #include #include -#include #include #include +#include namespace QmlDesigner { @@ -291,30 +290,8 @@ void TimelineActions::pasteKeyframes(AbstractView *timelineView, const QmlTimeli bool TimelineActions::clipboardContainsKeyframes() { - QScopedPointer pasteModel(DesignDocumentView::pasteToModel()); - - if (!pasteModel) - return false; - - DesignDocumentView view; - pasteModel->attachView(&view); - - if (!view.rootModelNode().isValid()) - return false; - - ModelNode rootNode = view.rootModelNode(); - - if (!rootNode.hasAnySubModelNodes()) - return false; - - //Sanity check - if (!QmlTimelineKeyframeGroup::checkKeyframesType(rootNode)) { - for (const ModelNode &node : rootNode.directSubModelNodes()) - if (!QmlTimelineKeyframeGroup::checkKeyframesType(node)) - return false; - } - - return true; + QRegularExpression rxp("\\bKeyframe\\s*{.*}", QRegularExpression::DotMatchesEverythingOption); + return rxp.match(QApplication::clipboard()->text()).hasMatch(); } } // namespace QmlDesigner