diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp index b7a68890b82..975a59d478d 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp @@ -33,6 +33,8 @@ #include #include +#include + namespace QmlDesigner { static inline bool itemsHaveSameParent(const QList &siblingList) @@ -94,10 +96,24 @@ bool selectionHasSameParent(const SelectionContext &selectionState) return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes()); } +bool fileComponentExists(const ModelNode &modelNode) +{ + if (!modelNode.metaInfo().isFileComponent()) + return true; + + const QString fileName = modelNode.metaInfo().componentFileName(); + + if (fileName.contains("qml/QtQuick")) + return false; + + return QFile::exists(fileName); +} + bool selectionIsComponent(const SelectionContext &selectionState) { return selectionState.currentSingleSelectedNode().isValid() - && selectionState.currentSingleSelectedNode().isComponent(); + && selectionState.currentSingleSelectedNode().isComponent() + && fileComponentExists(selectionState.currentSingleSelectedNode()); } bool selectionIsImported3DAsset(const SelectionContext &selectionState)