aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2022-04-13 16:08:40 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2022-04-14 08:34:36 +0000
commitac0697780e90c292c370f278b1c800d99540c148 (patch)
tree72862f03fddf19a13e0c6b2141a206ec5956f735
parent45ca3e030bf0043462988a017ac83c794d984ece (diff)
QmlDesigner: Only allow goIntoComponent for existing ones
Skip the ones from Qt. Change-Id: I4eae715b87948e8d47be8919d6b3356864fb0bd7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp
index b7a68890b8..975a59d478 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp
@@ -33,6 +33,8 @@
#include <qmldesignerplugin.h>
#include <qmldesignerconstants.h>
+#include <QFile>
+
namespace QmlDesigner {
static inline bool itemsHaveSameParent(const QList<ModelNode> &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)