From 0d84e720edaabfa8e1168c7bebd8447656e78522 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 4 Jun 2025 16:19:09 +0200 Subject: [PATCH] QmlDesigner: Remove flow related actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I74b3a522886aad7b41167b477cc2945425c48049 Reviewed-by: Henning Gründl --- .../componentcore/componentcore_constants.h | 6 - .../componentcore/designeractionmanager.cpp | 192 +----------------- .../componentcore/designeractionmanager.h | 2 - .../components/formeditor/transitiontool.cpp | 80 -------- 4 files changed, 6 insertions(+), 274 deletions(-) diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h index 0e6e572b635..13516278cd1 100644 --- a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h +++ b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h @@ -21,9 +21,6 @@ inline constexpr char positionerCategory[] = "Position"; inline constexpr char groupCategory[] = "Group"; inline constexpr char snappingCategory[] = "Snapping"; inline constexpr char layoutCategory[] = "Layout"; -inline constexpr char flowCategory[] = "Flow"; -inline constexpr char flowEffectCategory[] = "FlowEffect"; -inline constexpr char flowConnectionCategory[] = "FlowConnection"; inline constexpr char stackedContainerCategory[] = "StackedContainer"; inline constexpr char genericToolBarCategory[] = "GenericToolBar"; inline constexpr char eventListCategory[] = "QmlEventList"; @@ -54,9 +51,6 @@ inline constexpr char anchorParentVerticalCenterCommandId[] = "AnchorParentVerti inline constexpr char anchorParentHorizontalCenterCommandId[] = "AnchorParentHorizontalCenter"; inline constexpr char removePositionerCommandId[] = "RemovePositioner"; -inline constexpr char createFlowActionAreaCommandId[] = "CreateFlowActionArea"; -inline constexpr char setFlowStartCommandId[] = "SetFlowStart"; -inline constexpr char selectFlowEffectCommandId[] = "SelectFlowEffect"; inline constexpr char layoutRowPositionerCommandId[] = "LayoutRowPositioner"; inline constexpr char layoutColumnPositionerCommandId[] = "LayoutColumnPositioner"; inline constexpr char layoutGridPositionerCommandId[] = "LayoutGridPositioner"; diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 04c231a9ba4..4a027af1a6c 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -947,88 +947,6 @@ public: } }; -bool flowOptionVisible(const SelectionContext &context) -{ - return QmlFlowViewNode::isValidQmlFlowViewNode(context.rootNode()); -} - -bool isFlowItem(const SelectionContext &context) -{ - return context.singleNodeIsSelected() - && QmlFlowItemNode::isValidQmlFlowItemNode(context.currentSingleSelectedNode()); -} - -bool isFlowTarget(const SelectionContext &context) -{ - return context.singleNodeIsSelected() - && QmlFlowTargetNode::isFlowEditorTarget(context.currentSingleSelectedNode()); -} - -bool isFlowTransitionItem(const SelectionContext &context) -{ - return context.singleNodeIsSelected() - && QmlFlowItemNode::isFlowTransition(context.currentSingleSelectedNode()); -} - -bool isFlowTransitionItemWithEffect(const SelectionContext &context) -{ - if (!isFlowTransitionItem(context)) - return false; - - ModelNode node = context.currentSingleSelectedNode(); - - return node.hasNodeProperty("effect"); -} - -bool isFlowActionItemItem(const SelectionContext &context) -{ - const ModelNode selectedNode = context.currentSingleSelectedNode(); - - return context.singleNodeIsSelected() - && (QmlFlowActionAreaNode::isValidQmlFlowActionAreaNode(selectedNode) - || QmlVisualNode::isFlowDecision(selectedNode) - || QmlVisualNode::isFlowWildcard(selectedNode)); -} - -bool isFlowTargetOrTransition(const SelectionContext &context) -{ - return isFlowTarget(context) || isFlowTransitionItem(context); -} - -class FlowActionConnectAction : public ActionGroup -{ -public: - FlowActionConnectAction(const QString &displayName, const QByteArray &menuId, const QIcon &icon, int priority) : - ActionGroup(displayName, menuId, icon, priority, - &isFlowActionItemItem, &flowOptionVisible) - - {} - - void updateContext() override - { - menu()->clear(); - if (selectionContext().isValid()) { - action()->setEnabled(isEnabled(selectionContext())); - action()->setVisible(isVisible(selectionContext())); - } else { - return; - } - if (action()->isEnabled()) { - for (const QmlFlowItemNode &node : QmlFlowViewNode(selectionContext().rootNode()).flowItems()) { - if (node != selectionContext().currentSingleSelectedNode().parentProperty().parentModelNode()) { - QString what = QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Connect: %1")).arg(captionForModelNode(node)); - ActionTemplate *connectionAction = new ActionTemplate("CONNECT", what, &ModelNodeOperations::addTransition); - - SelectionContext nodeSelectionContext = selectionContext(); - nodeSelectionContext.setTargetNode(node); - connectionAction->setSelectionContext(nodeSelectionContext); - - menu()->addAction(connectionAction); - } - } - } - } -}; namespace { const char xProperty[] = "x"; const char yProperty[] = "y"; @@ -1780,83 +1698,12 @@ void DesignerActionManager::createDefaultDesignerActions() {}, Priorities::Group)); - addDesignerAction(new ActionGroup( - flowCategoryDisplayName, - flowCategory, - {}, - Priorities::FlowCategory, - &isFlowTargetOrTransition, - &flowOptionVisible)); - - - auto effectMenu = new ActionGroup( - flowEffectCategoryDisplayName, - flowEffectCategory, - {}, - Priorities::FlowCategory, - &isFlowTransitionItem, - &flowOptionVisible); - - effectMenu->setCategory(flowCategory); - addDesignerAction(effectMenu); - - addDesignerAction(new ModelNodeFormEditorAction( - createFlowActionAreaCommandId, - createFlowActionAreaDisplayName, - addIcon.icon(), - addFlowActionToolTip, - flowCategory, - {}, - 1, - &createFlowActionArea, - &isFlowItem, - &flowOptionVisible)); - - addDesignerAction(new ModelNodeContextMenuAction( - setFlowStartCommandId, - setFlowStartDisplayName, - {}, - flowCategory, - {}, - 2, - &setFlowStartItem, - &isFlowItem, - &flowOptionVisible)); - - addDesignerAction(new FlowActionConnectAction( - flowConnectionCategoryDisplayName, - flowConnectionCategory, - {}, - Priorities::FlowCategory)); - - - const QList transitionTypes = {"FlowFadeEffect", - "FlowPushEffect", - "FlowMoveEffect", - "None"}; - - for (const TypeName &typeName : transitionTypes) - addTransitionEffectAction(typeName); - - addCustomTransitionEffectAction(); - - addDesignerAction(new ModelNodeContextMenuAction( - selectFlowEffectCommandId, - selectEffectDisplayName, - {}, - flowCategory, - {}, - 2, - &selectFlowEffect, - &isFlowTransitionItemWithEffect)); - - addDesignerAction(new ActionGroup( - stackedContainerCategoryDisplayName, - stackedContainerCategory, - addIcon.icon(), - Priorities::StackedContainerCategory, - &isStackedContainer, - &isStackedContainer)); + addDesignerAction(new ActionGroup(stackedContainerCategoryDisplayName, + stackedContainerCategory, + addIcon.icon(), + Priorities::StackedContainerCategory, + &isStackedContainer, + &isStackedContainer)); addDesignerAction(new ModelNodeContextMenuAction( removePositionerCommandId, @@ -2342,33 +2189,6 @@ DesignerActionManager::DesignerActionManager(DesignerActionManagerView *designer DesignerActionManager::~DesignerActionManager() = default; -void DesignerActionManager::addTransitionEffectAction(const TypeName &typeName) -{ - addDesignerAction(new ModelNodeContextMenuAction( - QByteArray(ComponentCoreConstants::flowAssignEffectCommandId) + typeName, - QLatin1String(ComponentCoreConstants::flowAssignEffectDisplayName) + typeName, - {}, - ComponentCoreConstants::flowEffectCategory, - {}, - typeName == "None" ? 11 : 1, - [typeName](const SelectionContext &context) - { ModelNodeOperations::addFlowEffect(context, typeName); }, - &isFlowTransitionItem)); -} - -void DesignerActionManager::addCustomTransitionEffectAction() -{ - addDesignerAction(new ModelNodeContextMenuAction( - QByteArray(ComponentCoreConstants::flowAssignEffectCommandId), - ComponentCoreConstants::flowAssignCustomEffectDisplayName, - {}, - ComponentCoreConstants::flowEffectCategory, - {}, - 21, - &ModelNodeOperations::addCustomFlowEffect, - &isFlowTransitionItem)); -} - void DesignerActionManager::setupIcons() { m_designerIcons = std::make_unique("qtds_propertyIconFont.ttf", diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h index ec49ff60403..db7f9b4fe81 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h @@ -129,8 +129,6 @@ public: void addAddActionCallback(ActionAddedInterface callback); private: - void addTransitionEffectAction(const TypeName &typeName); - void addCustomTransitionEffectAction(); void setupIcons(); QString designerIconResourcesPath() const; diff --git a/src/plugins/qmldesigner/components/formeditor/transitiontool.cpp b/src/plugins/qmldesigner/components/formeditor/transitiontool.cpp index f0463802980..ec0b0bccd03 100644 --- a/src/plugins/qmldesigner/components/formeditor/transitiontool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/transitiontool.cpp @@ -96,25 +96,6 @@ private: QByteArray m_menuId; }; -class TransitionCustomAction : public TransitionToolAction -{ -public: - TransitionCustomAction(const QByteArray &menuId, const QString &name) - : TransitionToolAction(menuId, name) - {} - - QByteArray category() const override - { - return ComponentCoreConstants::flowCategory; - } - - SelectionContext selectionContext() const - { - return AbstractAction::selectionContext(); - } - -}; - static QRectF paintedBoundingRect(FormEditorItem *item) { QRectF boundingRect = item->qmlItemNode().instanceBoundingRect(); @@ -140,67 +121,6 @@ TransitionTool::TransitionTool() : QObject(), AbstractCustomTool() { NanotraceHR::Tracer tracer{"transition tool constructor", category()}; - - TransitionToolAction *transitionToolAction = new TransitionToolAction("AddTransition", - tr("Add Transition")); - QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(transitionToolAction); - - connect(transitionToolAction->action(), &QAction::triggered, - this, &TransitionTool::activateTool); - - TransitionCustomAction *removeAction = new TransitionCustomAction("RemoveTransition", - tr("Remove Transitions")); - QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(removeAction); - - connect(removeAction->action(), &QAction::triggered, - this, [removeAction](){ - - SelectionContext context = removeAction->selectionContext(); - QmlFlowTargetNode node = QmlFlowTargetNode(context.currentSingleSelectedNode()); - - context.view()->executeInTransaction("Remove Transitions", [&node](){ - if (node.isValid()) - node.removeTransitions(); - }); - }); - - TransitionCustomAction *removeAllTransitionsAction = new TransitionCustomAction( - "RemoveAllTransitions", tr("Remove All Transitions")); - QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(removeAllTransitionsAction); - - connect(removeAllTransitionsAction->action(), &QAction::triggered, - this, [removeAllTransitionsAction](){ - - if (QMessageBox::question(Core::ICore::dialogParent(), - tr("Remove All Transitions"), - tr("Do you really want to remove all transitions?"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) - return; - - SelectionContext context = removeAllTransitionsAction->selectionContext(); - QmlFlowTargetNode node = QmlFlowTargetNode(context.currentSingleSelectedNode()); - - context.view()->executeInTransaction("Remove All Transitions", [&node](){ - if (node.isValid() && node.flowView().isValid()) - node.flowView().removeAllTransitions(); - }); - }); - - TransitionCustomAction *removeDanglingTransitionAction = new TransitionCustomAction( - "RemoveDanglindTransitions", tr("Remove Dangling Transitions")); - QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(removeDanglingTransitionAction); - - connect(removeDanglingTransitionAction->action(), &QAction::triggered, - this, [removeDanglingTransitionAction](){ - - SelectionContext context = removeDanglingTransitionAction->selectionContext(); - QmlFlowTargetNode node = QmlFlowTargetNode(context.currentSingleSelectedNode()); - - context.view()->executeInTransaction("Remove Dangling Transitions", [&node](){ - if (node.isValid() && node.flowView().isValid()) - node.flowView().removeDanglingTransitions(); - }); - }); } TransitionTool::~TransitionTool()