forked from qt-creator/qt-creator
QmlDesigner: Remove flow related actions
Change-Id: I74b3a522886aad7b41167b477cc2945425c48049 Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -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";
|
||||
|
@@ -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,78 +1698,7 @@ 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<TypeName> 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,
|
||||
addDesignerAction(new ActionGroup(stackedContainerCategoryDisplayName,
|
||||
stackedContainerCategory,
|
||||
addIcon.icon(),
|
||||
Priorities::StackedContainerCategory,
|
||||
@@ -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<DesignerIcons>("qtds_propertyIconFont.ttf",
|
||||
|
@@ -129,8 +129,6 @@ public:
|
||||
void addAddActionCallback(ActionAddedInterface callback);
|
||||
|
||||
private:
|
||||
void addTransitionEffectAction(const TypeName &typeName);
|
||||
void addCustomTransitionEffectAction();
|
||||
void setupIcons();
|
||||
QString designerIconResourcesPath() const;
|
||||
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user