From f2b29195da0bf6db27c693583618ca3efefa707a Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 20 Feb 2024 13:55:00 +0200 Subject: [PATCH] QmlDesigner: Disable "Edit Component" for effect composer effects These components are autogenerated and overwritten by effect composer, so a regular user has no reason to modify them manually. Fixes: QDS-9020 Change-Id: Ida6706f123a8304944a19364c59620b8d9b4adbb Reviewed-by: Qt CI Patch Build Bot Reviewed-by: Mahmoud Badri --- src/plugins/effectcomposer/effectcomposermodel.cpp | 1 + .../components/componentcore/designeractionmanager.cpp | 2 +- .../componentcore/modelnodecontextmenu_helper.cpp | 6 +++--- .../components/componentcore/modelnodecontextmenu_helper.h | 2 +- .../components/propertyeditor/propertyeditorqmlbackend.cpp | 3 ++- .../components/propertyeditor/propertyeditorview.cpp | 4 +++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/effectcomposer/effectcomposermodel.cpp b/src/plugins/effectcomposer/effectcomposermodel.cpp index 6d843b36175..be64cfceead 100644 --- a/src/plugins/effectcomposer/effectcomposermodel.cpp +++ b/src/plugins/effectcomposer/effectcomposermodel.cpp @@ -577,6 +577,7 @@ QString EffectComposerModel::getQmlEffectString() QString header{ R"( // Created with Qt Design Studio (version %1), %2 +// Do not manually edit this file, it will be overwritten if effect is modified in Qt Design Studio. import QtQuick diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 6441d11b733..8dba5b90a41 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -1896,7 +1896,7 @@ void DesignerActionManager::createDefaultDesignerActions() QKeySequence(Qt::Key_F2), Priorities::ComponentActions + 2, &goIntoComponentOperation, - &selectionIsComponent)); + &selectionIsEditableComponent)); addDesignerAction(new ModelNodeContextMenuAction(jumpToCodeCommandId, JumpToCodeDisplayName, diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp index 4a119d88a53..f6e18458b2f 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp @@ -89,10 +89,10 @@ bool fileComponentExists(const ModelNode &modelNode) return QFileInfo::exists(fileName); } -bool selectionIsComponent(const SelectionContext &selectionState) +bool selectionIsEditableComponent(const SelectionContext &selectionState) { - return selectionState.currentSingleSelectedNode().isComponent() - && fileComponentExists(selectionState.currentSingleSelectedNode()); + ModelNode node = selectionState.currentSingleSelectedNode(); + return node.isComponent() && !QmlItemNode(node).isEffectItem() && fileComponentExists(node); } bool selectionIsImported3DAsset(const SelectionContext &selectionState) diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h index e7224f9edd4..593ace34d14 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.h @@ -124,7 +124,7 @@ inline bool singleSelectedItem(const SelectionContext &selectionState) } bool selectionHasSameParent(const SelectionContext &selectionState); -bool selectionIsComponent(const SelectionContext &selectionState); +bool selectionIsEditableComponent(const SelectionContext &selectionState); bool singleSelectionItemIsAnchored(const SelectionContext &selectionState); bool singleSelectionItemIsNotAnchored(const SelectionContext &selectionState); bool selectionIsImported3DAsset(const SelectionContext &selectionState); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 393183f57c4..ab988140f59 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -749,7 +749,8 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &metaTyp qmlTemplate += "Column {\n"; qmlTemplate += "width: parent.width\n"; - if (node.modelNode().isComponent()) + bool isEditableComponent = node.modelNode().isComponent() && !QmlItemNode(node).isEffectItem(); + if (isEditableComponent) qmlTemplate += "ComponentButton {}\n"; QString qmlInnerTemplate = ""; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index 91e62bfef35..98901682a5e 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -574,8 +574,10 @@ void PropertyEditorView::setupQmlBackend() { if constexpr (useProjectStorage()) { auto selfAndPrototypes = m_selectedNode.metaInfo().selfAndPrototypes(); + bool isEditableComponent = m_selectedNode.isComponent() + && !QmlItemNode(m_selectedNode).isEffectItem(); auto specificQmlData = m_propertyEditorComponentGenerator.create(selfAndPrototypes, - m_selectedNode.isComponent()); + isEditableComponent); auto [panePath, specificsPath] = findPaneAndSpecificsPath(selfAndPrototypes, model()->pathCache()); PropertyEditorQmlBackend *currentQmlBackend = getQmlBackend(m_qmlBackendHash,