QmlDesigner: Implement new context menu structure

The 2D Context Menu is rearranged

Task-number: QDS-8388
Change-Id: Idca46da89a876f2a9a90acb9072be896d3e74468
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Ali Kianian
2022-12-01 13:17:49 +02:00
parent 430998d769
commit ef8802487e
18 changed files with 231 additions and 320 deletions

View File

@@ -27,53 +27,8 @@
namespace QmlDesigner { namespace QmlDesigner {
class ColorToolAction : public AbstractAction
{
public:
ColorToolAction() : AbstractAction(QCoreApplication::translate("ColorToolAction","Edit Color")) {}
QByteArray category() const override
{
return QByteArray();
}
QByteArray menuId() const override
{
return "ColorTool";
}
int priority() const override
{
return CustomActionsPriority;
}
Type type() const override
{
return FormEditorAction;
}
protected:
bool isVisible(const SelectionContext &selectionContext) const override
{
if (selectionContext.singleNodeIsSelected())
return selectionContext.currentSingleSelectedNode().metaInfo().hasProperty("color");
return false;
}
bool isEnabled(const SelectionContext &selectionContext) const override
{
return isVisible(selectionContext);
}
};
ColorTool::ColorTool() ColorTool::ColorTool()
{ {
auto colorToolAction = new ColorToolAction;
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(colorToolAction);
connect(colorToolAction->action(), &QAction::triggered, [=]() {
view()->changeCurrentToolTo(this);
});
} }
ColorTool::~ColorTool() = default; ColorTool::~ColorTool() = default;

View File

@@ -25,10 +25,10 @@ public:
}; };
enum Priorities { enum Priorities {
HighestPriority = ComponentCoreConstants::priorityFirst, HighestPriority = ComponentCoreConstants::Priorities::Top,
CustomActionsPriority = ComponentCoreConstants::priorityCustomActions, CustomActionsPriority = ComponentCoreConstants::Priorities::CustomActionsSection,
RefactoringActionsPriority = ComponentCoreConstants::priorityRefactoring, RefactoringActionsPriority = ComponentCoreConstants::Priorities::Refactoring,
LowestPriority = ComponentCoreConstants::priorityLast LowestPriority = ComponentCoreConstants::Priorities::Last
}; };
enum class TargetView { enum class TargetView {

View File

@@ -17,7 +17,7 @@ const char arrangeCategory[] = "Arrange";
const char qmlPreviewCategory[] = "QmlPreview"; const char qmlPreviewCategory[] = "QmlPreview";
const char editCategory[] = "Edit"; const char editCategory[] = "Edit";
const char anchorsCategory[] = "Anchors"; const char anchorsCategory[] = "Anchors";
const char positionCategory[] = "Position"; const char positionerCategory[] = "Position";
const char groupCategory[] = "Group"; const char groupCategory[] = "Group";
const char snappingCategory[] = "Snapping"; const char snappingCategory[] = "Snapping";
const char layoutCategory[] = "Layout"; const char layoutCategory[] = "Layout";
@@ -59,7 +59,7 @@ const char goIntoComponentCommandId[] = "GoIntoComponent";
const char mergeTemplateCommandId[] = "MergeTemplate"; const char mergeTemplateCommandId[] = "MergeTemplate";
const char goToImplementationCommandId[] = "GoToImplementation"; const char goToImplementationCommandId[] = "GoToImplementation";
const char addSignalHandlerCommandId[] = "AddSignalHandler"; const char addSignalHandlerCommandId[] = "AddSignalHandler";
const char moveToComponentCommandId[] = "MoveToComponent"; const char makeComponentCommandId[] = "MakeComponent";
const char editMaterialCommandId[] = "EditMaterial"; const char editMaterialCommandId[] = "EditMaterial";
const char addItemToStackedContainerCommandId[] = "AddItemToStackedContainer"; const char addItemToStackedContainerCommandId[] = "AddItemToStackedContainer";
const char addTabBarToStackedContainerCommandId[] = "AddTabBarToStackedContainer"; const char addTabBarToStackedContainerCommandId[] = "AddTabBarToStackedContainer";
@@ -71,7 +71,7 @@ const char addToGroupItemCommandId[] = "AddToGroupItem";
const char removeGroupItemCommandId[] = "RemoveToGroupItem"; const char removeGroupItemCommandId[] = "RemoveToGroupItem";
const char fitRootToScreenCommandId[] = "FitRootToScreen"; const char fitRootToScreenCommandId[] = "FitRootToScreen";
const char fitSelectionToScreenCommandId[] = "FitSelectionToScreen"; const char fitSelectionToScreenCommandId[] = "FitSelectionToScreen";
const char editAnnotationCommandId[] = "EditAnnotation"; const char editAnnotationsCommandId[] = "EditAnnotation";
const char addMouseAreaFillCommandId[] = "AddMouseAreaFill"; const char addMouseAreaFillCommandId[] = "AddMouseAreaFill";
const char openSignalDialogCommandId[] = "OpenSignalDialog"; const char openSignalDialogCommandId[] = "OpenSignalDialog";
@@ -84,8 +84,9 @@ const char selectEffectDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu
const char arrangeCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Arrange"); const char arrangeCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Arrange");
const char editCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit"); const char editCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit");
const char anchorsCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Anchors"); const char anchorsCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Anchors");
const char positionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position"); const char positionerCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Positioner");
const char groupCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Group"); const char groupCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Group");
const char snappingCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Snapping");
const char layoutCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout"); const char layoutCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout");
const char flowCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Flow"); const char flowCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Flow");
const char flowEffectCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Flow Effects"); const char flowEffectCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Flow Effects");
@@ -112,13 +113,13 @@ const char resetPositionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen
const char copyFormatDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Copy Formatting"); const char copyFormatDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Copy Formatting");
const char applyFormatDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Apply Formatting"); const char applyFormatDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Apply Formatting");
const char goIntoComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go into Component"); const char enterComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Enter Component");
const char mergeTemplateDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Merge File With Template"); const char mergeTemplateDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Merge with Template");
const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation"); const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation");
const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler"); const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler");
const char moveToComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Move Component into Separate File"); const char makeComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Make Component");
const char editMaterialDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Material"); const char editMaterialDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Material");
const char editAnnotationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Annotation"); const char editAnnotationsDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Annotations");
const char addMouseAreaFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add Mouse Area"); const char addMouseAreaFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add Mouse Area");
const char openSignalDialogDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Open Signal Dialog"); const char openSignalDialogDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Open Signal Dialog");
@@ -130,13 +131,13 @@ const char resetZDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Re
const char reverseDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reverse"); const char reverseDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reverse");
const char anchorsFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill"); const char anchorsFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Parent");
const char anchorsResetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset"); const char anchorsResetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "No Anchors");
const char layoutColumnPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Column"); const char layoutColumnPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Column Positioner");
const char layoutRowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Row"); const char layoutRowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Row Positioner");
const char layoutGridPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Grid"); const char layoutGridPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Grid Positioner");
const char layoutFlowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Flow"); const char layoutFlowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Flow Positioner");
const char removePositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Positioner"); const char removePositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Positioner");
const char createFlowActionAreaDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Create Flow Action"); const char createFlowActionAreaDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Create Flow Action");
const char setFlowStartDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Flow Start"); const char setFlowStartDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Flow Start");
@@ -151,9 +152,9 @@ const char addTabBarToStackedContainerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesi
const char increaseIndexToStackedContainerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Increase Index"); const char increaseIndexToStackedContainerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Increase Index");
const char decreaseIndexToStackedContainerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Decrease Index"); const char decreaseIndexToStackedContainerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Decrease Index");
const char layoutColumnLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Column Layout"); const char layoutColumnLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Column Layout");
const char layoutRowLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Row Layout"); const char layoutRowLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Row Layout");
const char layoutGridLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Grid Layout"); const char layoutGridLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Grid Layout");
const char layoutFillWidthDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Width"); const char layoutFillWidthDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Width");
const char layoutFillHeightDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Height"); const char layoutFillHeightDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Height");
@@ -183,26 +184,48 @@ const char addFlowActionToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
const char editListModelDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", const char editListModelDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
"Edit List Model..."); "Edit List Model...");
namespace Priorities {
const int priorityFirst = 280; enum PrioritiesEnum : int {
const int prioritySelectionCategory = 220; Top = 0,
const int priorityConnectionsCategory = 210; FlowCategory,
const int priorityQmlPreviewCategory = 200; ComponentActions,
const int priorityStackCategory = 180; /******** Section *****************************/
const int priorityEditCategory = 160; ModifySection = 1000,
const int priorityAnchorsCategory = 140; ConnectionsCategory,
const int priorityFlowCategory = 240; SelectionCategory,
const int priorityGroupCategory = 140; ArrangeCategory,
const int priorityPositionCategory = 130; EditCategory,
const int priorityLayoutCategory = 120; /******** Section *****************************/
const int priorityStackedContainerCategory = priorityLayoutCategory; PositionSection = 2000,
const int priorityEventListCategory = 105; SnappingCategory,
const int priorityTopLevelSeperator = 100; AnchorsCategory,
const int priorityCustomActions = 80; LayoutCategory,
const int priorityRefactoring = 60; PositionCategory,
const int priorityGoIntoComponent = 40; StackedContainerCategory,
const int priorityGenericToolBar = 50; /******** Section *****************************/
const int priorityLast = 60; EventSection = 3000,
TimelineCategory,
EventListCategory,
/******** Section *****************************/
AdditionsSection = 4000,
EditAnnotations,
AddMouseArea,
MergeWithTemplate,
/******** Section *****************************/
ViewOprionsSection = 5000,
ResetView,
Group,
Visibility,
ShowBoundingRect,
/******** Section *****************************/
CustomActionsSection = 6000,
QmlPreviewCategory,
SignalsDialog,
Refactoring,
GenericToolBar,
Last
};
};
const char addImagesDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Image Files"); const char addImagesDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Image Files");
const char addFontsDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Font Files"); const char addFontsDisplayString[] = QT_TRANSLATE_NOOP("QmlDesignerAddResources", "Font Files");

View File

@@ -73,7 +73,7 @@ DesignerActionToolBar *DesignerActionManager::createToolBar(QWidget *parent) con
}); });
Utils::sort(categories, [](ActionInterface *l, ActionInterface *r) { Utils::sort(categories, [](ActionInterface *l, ActionInterface *r) {
return l->priority() > r->priority(); return l->priority() < r->priority();
}); });
for (auto *categoryAction : std::as_const(categories)) { for (auto *categoryAction : std::as_const(categories)) {
@@ -82,7 +82,7 @@ DesignerActionToolBar *DesignerActionManager::createToolBar(QWidget *parent) con
}); });
Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) { Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) {
return l->priority() > r->priority(); return l->priority() < r->priority();
}); });
bool addSeparator = false; bool addSeparator = false;
@@ -142,7 +142,7 @@ QGraphicsWidget *DesignerActionManager::createFormEditorToolBar(QGraphicsItem *p
}); });
Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) { Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) {
return l->priority() > r->priority(); return l->priority() < r->priority();
}); });
QGraphicsWidget *toolbar = new QGraphicsWidget(parent); QGraphicsWidget *toolbar = new QGraphicsWidget(parent);
@@ -401,8 +401,7 @@ public:
if (!ModelNode::isThisOrAncestorLocked(parentNode)) { if (!ModelNode::isThisOrAncestorLocked(parentNode)) {
ActionTemplate *selectionAction = new ActionTemplate("SELECTION", {}, &ModelNodeOperations::select); ActionTemplate *selectionAction = new ActionTemplate("SELECTION", {}, &ModelNodeOperations::select);
selectionAction->setParent(menu()); selectionAction->setParent(menu());
selectionAction->setText(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select parent: %1")).arg( selectionAction->setText(QString(QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Parent")));
captionForModelNode(parentNode)));
SelectionContext nodeSelectionContext = selectionContext(); SelectionContext nodeSelectionContext = selectionContext();
nodeSelectionContext.setTargetNode(parentNode); nodeSelectionContext.setTargetNode(parentNode);
@@ -1341,26 +1340,28 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new SelectionModelNodeAction( addDesignerAction(new SelectionModelNodeAction(
selectionCategoryDisplayName, selectionCategoryDisplayName,
selectionCategory, selectionCategory,
prioritySelectionCategory)); Priorities::SelectionCategory));
addDesignerAction(new ConnectionsModelNodeActionGroup( addDesignerAction(new ConnectionsModelNodeActionGroup(
connectionsCategoryDisplayName, connectionsCategoryDisplayName,
connectionsCategory, connectionsCategory,
priorityConnectionsCategory)); Priorities::ConnectionsCategory));
addDesignerAction(new ActionGroup( addDesignerAction(new ActionGroup(
arrangeCategoryDisplayName, arrangeCategoryDisplayName,
arrangeCategory, arrangeCategory,
priorityStackCategory, Priorities::ArrangeCategory,
&selectionNotEmpty)); &selectionNotEmpty));
addDesignerAction(new SeperatorDesignerAction(arrangeCategory, 10));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
toFrontCommandId, toFrontCommandId,
toFrontDisplayName, toFrontDisplayName,
{}, {},
arrangeCategory, arrangeCategory,
QKeySequence(), QKeySequence(),
200, 1,
&toFront, &toFront,
&raiseAvailable)); &raiseAvailable));
@@ -1370,7 +1371,7 @@ void DesignerActionManager::createDefaultDesignerActions()
Utils::Icon({{":/qmldesigner/icon/designeractions/images/raise.png", Utils::Theme::IconsBaseColor}}).icon(), Utils::Icon({{":/qmldesigner/icon/designeractions/images/raise.png", Utils::Theme::IconsBaseColor}}).icon(),
arrangeCategory, arrangeCategory,
QKeySequence(), QKeySequence(),
180, 11,
&raise, &raise,
&raiseAvailable)); &raiseAvailable));
@@ -1380,7 +1381,7 @@ void DesignerActionManager::createDefaultDesignerActions()
Utils::Icon({{":/qmldesigner/icon/designeractions/images/lower.png", Utils::Theme::IconsBaseColor}}).icon(), Utils::Icon({{":/qmldesigner/icon/designeractions/images/lower.png", Utils::Theme::IconsBaseColor}}).icon(),
arrangeCategory, arrangeCategory,
QKeySequence(), QKeySequence(),
160, 12,
&lower, &lower,
&lowerAvailable)); &lowerAvailable));
@@ -1390,23 +1391,25 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
arrangeCategory, arrangeCategory,
QKeySequence(), QKeySequence(),
140, 2,
&toBack, &toBack,
&lowerAvailable)); &lowerAvailable));
addDesignerAction(new SeperatorDesignerAction(arrangeCategory, 20));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
reverseCommandId, reverseCommandId,
reverseDisplayName, reverseDisplayName,
{}, {},
arrangeCategory, arrangeCategory,
QKeySequence(), QKeySequence(),
100, 21,
&reverse, &reverse,
&multiSelectionAndHasSameParent)); &multiSelectionAndHasSameParent));
addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, priorityEditCategory, &selectionNotEmpty)); addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, Priorities::EditCategory, &selectionNotEmpty));
addDesignerAction(new SeperatorDesignerAction(editCategory, 220)); addDesignerAction(new SeperatorDesignerAction(editCategory, 30));
addDesignerAction( addDesignerAction(
new ModelNodeAction(resetPositionCommandId, new ModelNodeAction(resetPositionCommandId,
@@ -1418,7 +1421,7 @@ void DesignerActionManager::createDefaultDesignerActions()
resetPositionTooltip, resetPositionTooltip,
editCategory, editCategory,
QKeySequence("Ctrl+d"), QKeySequence("Ctrl+d"),
200, 32,
&resetPosition, &resetPosition,
&selectionNotEmptyAndHasXorYProperty)); &selectionNotEmptyAndHasXorYProperty));
@@ -1456,7 +1459,7 @@ void DesignerActionManager::createDefaultDesignerActions()
copyFormatTooltip, copyFormatTooltip,
editCategory, editCategory,
QKeySequence(), QKeySequence(),
120, 41,
&copyFormat, &copyFormat,
&propertiesCopyable)); &propertiesCopyable));
@@ -1466,7 +1469,7 @@ void DesignerActionManager::createDefaultDesignerActions()
applyFormatTooltip, applyFormatTooltip,
editCategory, editCategory,
QKeySequence(), QKeySequence(),
120, 42,
&applyFormat, &applyFormat,
&propertiesApplyable)); &propertiesApplyable));
@@ -1478,24 +1481,24 @@ void DesignerActionManager::createDefaultDesignerActions()
resetSizeToolTip, resetSizeToolTip,
editCategory, editCategory,
QKeySequence("shift+s"), QKeySequence("shift+s"),
180, 31,
&resetSize, &resetSize,
&selectionNotEmptyAndHasWidthOrHeightProperty)); &selectionNotEmptyAndHasWidthOrHeightProperty));
addDesignerAction(new SeperatorDesignerAction(editCategory, 170)); addDesignerAction(new SeperatorDesignerAction(editCategory, 40));
addDesignerAction(new VisiblityModelNodeAction( addDesignerAction(new VisiblityModelNodeAction(
visiblityCommandId, visiblityCommandId,
visibilityDisplayName, visibilityDisplayName,
editCategory, rootCategory,
QKeySequence("Ctrl+g"), QKeySequence("Ctrl+g"),
160, Priorities::Visibility,
&setVisible, &setVisible,
&singleSelectedItem)); &singleSelectedItem));
addDesignerAction(new ActionGroup(anchorsCategoryDisplayName, addDesignerAction(new ActionGroup(anchorsCategoryDisplayName,
anchorsCategory, anchorsCategory,
priorityAnchorsCategory, Priorities::AnchorsCategory,
&anchorsMenuEnabled)); &anchorsMenuEnabled));
addDesignerAction(new ModelNodeAction( addDesignerAction(new ModelNodeAction(
@@ -1505,7 +1508,7 @@ void DesignerActionManager::createDefaultDesignerActions()
anchorsFillToolTip, anchorsFillToolTip,
anchorsCategory, anchorsCategory,
QKeySequence(QKeySequence("shift+f")), QKeySequence(QKeySequence("shift+f")),
200, 2,
&anchorsFill, &anchorsFill,
&singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot)); &singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot));
@@ -1517,46 +1520,49 @@ void DesignerActionManager::createDefaultDesignerActions()
anchorsResetToolTip, anchorsResetToolTip,
anchorsCategory, anchorsCategory,
QKeySequence(QKeySequence("Ctrl+Shift+r")), QKeySequence(QKeySequence("Ctrl+Shift+r")),
180, 1,
&anchorsReset, &anchorsReset,
&singleSelectionItemIsAnchored)); &singleSelectionItemIsAnchored));
addDesignerAction(new SeperatorDesignerAction(anchorsCategory, 170)); addDesignerAction(new SeperatorDesignerAction(anchorsCategory, 10));
addDesignerAction(new ActionGroup( addDesignerAction(new ActionGroup(
positionCategoryDisplayName, positionerCategoryDisplayName,
positionCategory, positionerCategory,
priorityPositionCategory, Priorities::PositionCategory,
&positionOptionVisible)); &positionOptionVisible));
addDesignerAction(new ActionGroup(layoutCategoryDisplayName, addDesignerAction(new ActionGroup(
layoutCategory, layoutCategoryDisplayName,
priorityLayoutCategory, layoutCategory,
&layoutOptionVisible)); Priorities::LayoutCategory,
&layoutOptionVisible));
addDesignerAction(new ActionGroup("Snapping",
snappingCategory,
priorityLayoutCategory + 10,
&selectionEnabled,
&selectionEnabled));
addDesignerAction(new ActionGroup(groupCategoryDisplayName,
groupCategory,
priorityGroupCategory,
&studioComponentsAvailableAndSelectionCanBeLayouted));
addDesignerAction(new ActionGroup( addDesignerAction(new ActionGroup(
flowCategoryDisplayName, snappingCategoryDisplayName,
flowCategory, snappingCategory,
priorityFlowCategory, Priorities::SnappingCategory,
&isFlowTargetOrTransition, &selectionEnabled,
&flowOptionVisible)); &selectionEnabled));
addDesignerAction(new ActionGroup(
groupCategoryDisplayName,
groupCategory,
Priorities::Group,
&studioComponentsAvailableAndSelectionCanBeLayouted));
addDesignerAction(new ActionGroup(
flowCategoryDisplayName,
flowCategory,
Priorities::FlowCategory,
&isFlowTargetOrTransition,
&flowOptionVisible));
auto effectMenu = new ActionGroup( auto effectMenu = new ActionGroup(
flowEffectCategoryDisplayName, flowEffectCategoryDisplayName,
flowEffectCategory, flowEffectCategory,
priorityFlowCategory, Priorities::FlowCategory,
&isFlowTransitionItem, &isFlowTransitionItem,
&flowOptionVisible); &flowOptionVisible);
@@ -1570,7 +1576,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addFlowActionToolTip, addFlowActionToolTip,
flowCategory, flowCategory,
{}, {},
priorityFirst, 1,
&createFlowActionArea, &createFlowActionArea,
&isFlowItem, &isFlowItem,
&flowOptionVisible)); &flowOptionVisible));
@@ -1580,7 +1586,7 @@ void DesignerActionManager::createDefaultDesignerActions()
setFlowStartDisplayName, setFlowStartDisplayName,
{}, {},
flowCategory, flowCategory,
priorityFirst, 2,
{}, {},
&setFlowStartItem, &setFlowStartItem,
&isFlowItem, &isFlowItem,
@@ -1589,7 +1595,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addDesignerAction(new FlowActionConnectAction( addDesignerAction(new FlowActionConnectAction(
flowConnectionCategoryDisplayName, flowConnectionCategoryDisplayName,
flowConnectionCategory, flowConnectionCategory,
priorityFlowCategory)); Priorities::FlowCategory));
const QList<TypeName> transitionTypes = {"FlowFadeEffect", const QList<TypeName> transitionTypes = {"FlowFadeEffect",
@@ -1608,23 +1614,23 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
flowCategory, flowCategory,
{}, {},
priorityFlowCategory, 2,
&selectFlowEffect, &selectFlowEffect,
&isFlowTransitionItemWithEffect)); &isFlowTransitionItemWithEffect));
addDesignerAction(new ActionGroup( addDesignerAction(new ActionGroup(
stackedContainerCategoryDisplayName, stackedContainerCategoryDisplayName,
stackedContainerCategory, stackedContainerCategory,
priorityStackedContainerCategory, Priorities::StackedContainerCategory,
&isStackedContainer)); &isStackedContainer));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
removePositionerCommandId, removePositionerCommandId,
removePositionerDisplayName, removePositionerDisplayName,
{}, {},
positionCategory, positionerCategory,
QKeySequence("Ctrl+Shift+p"), QKeySequence("Ctrl+Shift+p"),
210, 1,
&removePositioner, &removePositioner,
&isPositioner, &isPositioner,
&isPositioner)); &isPositioner));
@@ -1633,9 +1639,9 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutRowPositionerCommandId, layoutRowPositionerCommandId,
layoutRowPositionerDisplayName, layoutRowPositionerDisplayName,
{}, {},
positionCategory, positionerCategory,
QKeySequence(), QKeySequence(),
200, 2,
&layoutRowPositioner, &layoutRowPositioner,
&selectionCanBeLayouted, &selectionCanBeLayouted,
&selectionCanBeLayouted)); &selectionCanBeLayouted));
@@ -1644,9 +1650,9 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutColumnPositionerCommandId, layoutColumnPositionerCommandId,
layoutColumnPositionerDisplayName, layoutColumnPositionerDisplayName,
{}, {},
positionCategory, positionerCategory,
QKeySequence(), QKeySequence(),
180, 3,
&layoutColumnPositioner, &layoutColumnPositioner,
&selectionCanBeLayouted, &selectionCanBeLayouted,
&selectionCanBeLayouted)); &selectionCanBeLayouted));
@@ -1655,9 +1661,9 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutGridPositionerCommandId, layoutGridPositionerCommandId,
layoutGridPositionerDisplayName, layoutGridPositionerDisplayName,
{}, {},
positionCategory, positionerCategory,
QKeySequence(), QKeySequence(),
160, 4,
&layoutGridPositioner, &layoutGridPositioner,
&selectionCanBeLayouted, &selectionCanBeLayouted,
&selectionCanBeLayouted)); &selectionCanBeLayouted));
@@ -1666,14 +1672,14 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutFlowPositionerCommandId, layoutFlowPositionerCommandId,
layoutFlowPositionerDisplayName, layoutFlowPositionerDisplayName,
{}, {},
positionCategory, positionerCategory,
QKeySequence("Ctrl+m"), QKeySequence("Ctrl+m"),
140, 5,
&layoutFlowPositioner, &layoutFlowPositioner,
&selectionCanBeLayouted, &selectionCanBeLayouted,
&selectionCanBeLayouted)); &selectionCanBeLayouted));
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 120)); addDesignerAction(new SeperatorDesignerAction(layoutCategory, 0));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
removeLayoutCommandId, removeLayoutCommandId,
@@ -1681,7 +1687,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
layoutCategory, layoutCategory,
QKeySequence(), QKeySequence(),
110, 1,
&removeLayout, &removeLayout,
&isLayout, &isLayout,
&isLayout)); &isLayout));
@@ -1691,7 +1697,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
groupCategory, groupCategory,
QKeySequence("Ctrl+Shift+g"), QKeySequence("Ctrl+Shift+g"),
110, 1,
&addToGroupItem, &addToGroupItem,
&selectionCanBeLayouted)); &selectionCanBeLayouted));
@@ -1700,7 +1706,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
groupCategory, groupCategory,
QKeySequence(), QKeySequence(),
110, 2,
&removeGroup, &removeGroup,
&isGroup)); &isGroup));
@@ -1710,7 +1716,7 @@ void DesignerActionManager::createDefaultDesignerActions()
addItemToStackedContainerToolTip, addItemToStackedContainerToolTip,
stackedContainerCategory, stackedContainerCategory,
QKeySequence("Ctrl+Shift+a"), QKeySequence("Ctrl+Shift+a"),
110, 1,
&addItemToStackedContainer, &addItemToStackedContainer,
&isStackedContainer, &isStackedContainer,
&isStackedContainer)); &isStackedContainer));
@@ -1721,7 +1727,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
stackedContainerCategory, stackedContainerCategory,
QKeySequence("Ctrl+Shift+t"), QKeySequence("Ctrl+Shift+t"),
100, 2,
&addTabBarToStackedContainer, &addTabBarToStackedContainer,
&isStackedContainerWithoutTabBar, &isStackedContainerWithoutTabBar,
&isStackedContainer)); &isStackedContainer));
@@ -1733,7 +1739,7 @@ void DesignerActionManager::createDefaultDesignerActions()
decreaseIndexOfStackedContainerToolTip, decreaseIndexOfStackedContainerToolTip,
stackedContainerCategory, stackedContainerCategory,
QKeySequence("Ctrl+Shift+Left"), QKeySequence("Ctrl+Shift+Left"),
80, 3,
&decreaseIndexOfStackedContainer, &decreaseIndexOfStackedContainer,
&isStackedContainerAndIndexCanBeDecreased, &isStackedContainerAndIndexCanBeDecreased,
&isStackedContainer)); &isStackedContainer));
@@ -1745,7 +1751,7 @@ void DesignerActionManager::createDefaultDesignerActions()
increaseIndexOfStackedContainerToolTip, increaseIndexOfStackedContainerToolTip,
stackedContainerCategory, stackedContainerCategory,
QKeySequence("Ctrl+Shift+Right"), QKeySequence("Ctrl+Shift+Right"),
80, 4,
&increaseIndexOfStackedContainer, &increaseIndexOfStackedContainer,
&isStackedContainerAndIndexCanBeIncreased, &isStackedContainerAndIndexCanBeIncreased,
&isStackedContainer)); &isStackedContainer));
@@ -1757,7 +1763,7 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutRowLayoutToolTip, layoutRowLayoutToolTip,
layoutCategory, layoutCategory,
QKeySequence("Ctrl+u"), QKeySequence("Ctrl+u"),
100, 2,
&layoutRowLayout, &layoutRowLayout,
&selectionCanBeLayoutedAndQtQuickLayoutPossible)); &selectionCanBeLayoutedAndQtQuickLayoutPossible));
@@ -1768,7 +1774,7 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutColumnLayoutToolTip, layoutColumnLayoutToolTip,
layoutCategory, layoutCategory,
QKeySequence("Ctrl+l"), QKeySequence("Ctrl+l"),
80, 3,
&layoutColumnLayout, &layoutColumnLayout,
&selectionCanBeLayoutedAndQtQuickLayoutPossible)); &selectionCanBeLayoutedAndQtQuickLayoutPossible));
@@ -1779,18 +1785,18 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutGridLayoutToolTip, layoutGridLayoutToolTip,
layoutCategory, layoutCategory,
QKeySequence("shift+g"), QKeySequence("shift+g"),
60, 4,
&layoutGridLayout, &layoutGridLayout,
&selectionCanBeLayoutedAndQtQuickLayoutPossibleAndNotMCU)); &selectionCanBeLayoutedAndQtQuickLayoutPossibleAndNotMCU));
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 50)); addDesignerAction(new SeperatorDesignerAction(layoutCategory, 10));
addDesignerAction(new FillWidthModelNodeAction( addDesignerAction(new FillWidthModelNodeAction(
layoutFillWidthCommandId, layoutFillWidthCommandId,
layoutFillWidthDisplayName, layoutFillWidthDisplayName,
layoutCategory, layoutCategory,
QKeySequence(), QKeySequence(),
40, 11,
&setFillWidth, &setFillWidth,
&singleSelectionAndInQtQuickLayout, &singleSelectionAndInQtQuickLayout,
&singleSelectionAndInQtQuickLayout)); &singleSelectionAndInQtQuickLayout));
@@ -1800,30 +1806,35 @@ void DesignerActionManager::createDefaultDesignerActions()
layoutFillHeightDisplayName, layoutFillHeightDisplayName,
layoutCategory, layoutCategory,
QKeySequence(), QKeySequence(),
20, 12,
&setFillHeight, &setFillHeight,
&singleSelectionAndInQtQuickLayout, &singleSelectionAndInQtQuickLayout,
&singleSelectionAndInQtQuickLayout)); &singleSelectionAndInQtQuickLayout));
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator)); addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::ModifySection));
addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::PositionSection));
addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::EventSection));
addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::AdditionsSection));
addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::ViewOprionsSection));
addDesignerAction(new SeperatorDesignerAction(rootCategory, Priorities::CustomActionsSection));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
goIntoComponentCommandId, goIntoComponentCommandId,
goIntoComponentDisplayName, enterComponentDisplayName,
{}, {},
rootCategory, rootCategory,
QKeySequence(Qt::Key_F2), QKeySequence(Qt::Key_F2),
priorityGoIntoComponent, Priorities::ComponentActions + 2,
&goIntoComponentOperation, &goIntoComponentOperation,
&selectionIsComponent)); &selectionIsComponent));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
editAnnotationCommandId, editAnnotationsCommandId,
editAnnotationDisplayName, editAnnotationsDisplayName,
{}, {},
rootCategory, rootCategory,
QKeySequence(), QKeySequence(),
(priorityLast+6), Priorities::EditAnnotations,
&editAnnotation, &editAnnotation,
&singleSelection, &singleSelection,
&singleSelection)); &singleSelection));
@@ -1834,7 +1845,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
rootCategory, rootCategory,
QKeySequence(), QKeySequence(),
(priorityLast+7), Priorities::AddMouseArea,
&addMouseAreaFill, &addMouseAreaFill,
&addMouseAreaFillCheck, &addMouseAreaFillCheck,
&singleSelection)); &singleSelection));
@@ -1863,12 +1874,12 @@ void DesignerActionManager::createDefaultDesignerActions()
&singleSelectedAndUiFile)); &singleSelectedAndUiFile));
addDesignerAction(new ModelNodeContextMenuAction( addDesignerAction(new ModelNodeContextMenuAction(
moveToComponentCommandId, makeComponentCommandId,
moveToComponentDisplayName, makeComponentDisplayName,
{}, {},
rootCategory, rootCategory,
QKeySequence(), QKeySequence(),
44, Priorities::ComponentActions + 1,
&moveToComponent, &moveToComponent,
&singleSelection, &singleSelection,
&singleSelection)); &singleSelection));
@@ -1889,14 +1900,14 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
rootCategory, rootCategory,
{}, {},
50, Priorities::MergeWithTemplate,
[&] (const SelectionContext& context) { mergeWithTemplate(context, m_externalDependencies); }, [&] (const SelectionContext& context) { mergeWithTemplate(context, m_externalDependencies); },
&SelectionContextFunctors::always)); &SelectionContextFunctors::always));
addDesignerAction(new ActionGroup( addDesignerAction(new ActionGroup(
"", "",
genericToolBarCategory, genericToolBarCategory,
priorityGenericToolBar)); Priorities::GenericToolBar));
addDesignerAction(new ChangeStyleAction()); addDesignerAction(new ChangeStyleAction());
@@ -1908,7 +1919,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
rootCategory, rootCategory,
QKeySequence(), QKeySequence(),
66, Priorities::SignalsDialog,
&openSignalDialog, &openSignalDialog,
&singleSelectionAndHasSlotTrigger)); &singleSelectionAndHasSlotTrigger));
@@ -1918,7 +1929,7 @@ void DesignerActionManager::createDefaultDesignerActions()
{}, {},
rootCategory, rootCategory,
QKeySequence(), QKeySequence(),
priorityGenericToolBar, Priorities::GenericToolBar,
&updateImported3DAsset, &updateImported3DAsset,
&selectionIsImported3DAsset, &selectionIsImported3DAsset,
&selectionIsImported3DAsset)); &selectionIsImported3DAsset));
@@ -2048,7 +2059,7 @@ void DesignerActionManager::addTransitionEffectAction(const TypeName &typeName)
{}, {},
ComponentCoreConstants::flowEffectCategory, ComponentCoreConstants::flowEffectCategory,
{}, {},
typeName == "None" ? 100 : 140, typeName == "None" ? 11 : 1,
[typeName](const SelectionContext &context) [typeName](const SelectionContext &context)
{ ModelNodeOperations::addFlowEffect(context, typeName); }, { ModelNodeOperations::addFlowEffect(context, typeName); },
&isFlowTransitionItem)); &isFlowTransitionItem));
@@ -2062,7 +2073,7 @@ void DesignerActionManager::addCustomTransitionEffectAction()
{}, {},
ComponentCoreConstants::flowEffectCategory, ComponentCoreConstants::flowEffectCategory,
{}, {},
80, 21,
&ModelNodeOperations::addCustomFlowEffect, &ModelNodeOperations::addCustomFlowEffect,
&isFlowTransitionItem)); &isFlowTransitionItem));
} }

View File

@@ -42,7 +42,7 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
QList<ActionInterface* > matchingFactoriesList = Utils::toList(matchingFactories); QList<ActionInterface* > matchingFactoriesList = Utils::toList(matchingFactories);
Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) { Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) {
return l->priority() > r->priority(); return l->priority() < r->priority();
}); });
for (ActionInterface* actionInterface : std::as_const(matchingFactoriesList)) { for (ActionInterface* actionInterface : std::as_const(matchingFactoriesList)) {

View File

@@ -258,7 +258,7 @@ void ViewManager::registerNanotraceActions()
QObject::tr("Start Nanotrace"), QObject::tr("Start Nanotrace"),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
QKeySequence(), QKeySequence(),
220, 22,
handleShutdownNanotraceAction); handleShutdownNanotraceAction);
QObject::connect(startNanotraceAction->defaultAction(), &QAction::triggered, [&]() { QObject::connect(startNanotraceAction->defaultAction(), &QAction::triggered, [&]() {
@@ -273,7 +273,7 @@ void ViewManager::registerNanotraceActions()
QObject::tr("Shut Down Nanotrace"), QObject::tr("Shut Down Nanotrace"),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
QKeySequence(), QKeySequence(),
220, 23,
handleShutdownNanotraceAction); handleShutdownNanotraceAction);
QObject::connect(shutDownNanotraceAction->defaultAction(), &QAction::triggered, [&]() { QObject::connect(shutDownNanotraceAction->defaultAction(), &QAction::triggered, [&]() {

View File

@@ -55,7 +55,7 @@ EventListAction::EventListAction()
QObject::tr("Show Event List"), QObject::tr("Show Event List"),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
QKeySequence("Alt+e"), QKeySequence("Alt+e"),
230, 11,
&handleAction, &handleAction,
&eventListEnabled) &eventListEnabled)
{} {}
@@ -77,7 +77,7 @@ AssignEventEditorAction::AssignEventEditorAction()
QObject::tr("Assign Events to Actions"), QObject::tr("Assign Events to Actions"),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
QKeySequence("Alt+a"), QKeySequence("Alt+a"),
220, 21,
&handleAssignEventActionOperation, &handleAssignEventActionOperation,
&eventListEnabled) &eventListEnabled)
{} {}
@@ -88,7 +88,7 @@ ConnectSignalAction::ConnectSignalAction()
assignEventListIcon(), assignEventListIcon(),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
QKeySequence(), QKeySequence(),
210, 31,
&handleAssignEventActionOperation) &handleAssignEventActionOperation)
{} {}

View File

@@ -45,7 +45,7 @@ void EventListPluginView::registerActions()
designerActionManager.addDesignerAction(new ActionGroup(tr("Event List"), designerActionManager.addDesignerAction(new ActionGroup(tr("Event List"),
ComponentCoreConstants::eventListCategory, ComponentCoreConstants::eventListCategory,
ComponentCoreConstants::priorityEventListCategory, ComponentCoreConstants::Priorities::EventListCategory,
&SelectionContextFunctors::always, &SelectionContextFunctors::always,
&SelectionContextFunctors::always)); &SelectionContextFunctors::always));
auto eventListAction = new EventListAction(); auto eventListAction = new EventListAction();

View File

@@ -68,7 +68,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
auto layoutActionGroup = new QActionGroup(this); auto layoutActionGroup = new QActionGroup(this);
layoutActionGroup->setExclusive(true); layoutActionGroup->setExclusive(true);
m_noSnappingAction = layoutActionGroup->addAction(tr("No snapping")); m_noSnappingAction = layoutActionGroup->addAction(tr("No Snapping"));
m_noSnappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut); m_noSnappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_noSnappingAction->setCheckable(true); m_noSnappingAction->setCheckable(true);
m_noSnappingAction->setChecked(true); m_noSnappingAction->setChecked(true);
@@ -77,7 +77,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
Constants::FORMEDITOR_NO_SNAPPING, Constants::FORMEDITOR_NO_SNAPPING,
QKeySequence(Qt::Key_T), QKeySequence(Qt::Key_T),
ComponentCoreConstants::snappingCategory, ComponentCoreConstants::snappingCategory,
40); 1);
m_snappingAndAnchoringAction = layoutActionGroup->addAction(tr("Snap with Anchors")); m_snappingAndAnchoringAction = layoutActionGroup->addAction(tr("Snap with Anchors"));
m_snappingAndAnchoringAction->setCheckable(true); m_snappingAndAnchoringAction->setCheckable(true);
@@ -87,9 +87,9 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
Constants::FORMEDITOR_NO_SNAPPING_AND_ANCHORING, Constants::FORMEDITOR_NO_SNAPPING_AND_ANCHORING,
QKeySequence(Qt::Key_W), QKeySequence(Qt::Key_W),
ComponentCoreConstants::snappingCategory, ComponentCoreConstants::snappingCategory,
10); 2);
m_snappingAction = layoutActionGroup->addAction(tr("Snap without anchors")); m_snappingAction = layoutActionGroup->addAction(tr("Snap without Anchors"));
m_snappingAction->setCheckable(true); m_snappingAction->setCheckable(true);
m_snappingAction->setChecked(true); m_snappingAction->setChecked(true);
@@ -97,18 +97,18 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
Constants::FORMEDITOR_SNAPPING, Constants::FORMEDITOR_SNAPPING,
QKeySequence(Qt::Key_E), QKeySequence(Qt::Key_E),
ComponentCoreConstants::snappingCategory, ComponentCoreConstants::snappingCategory,
20); 3);
addActions(layoutActionGroup->actions()); addActions(layoutActionGroup->actions());
m_showBoundingRectAction = new QAction(tr("Show bounds"), this); m_showBoundingRectAction = new QAction(tr("Show Bounds"), this);
m_showBoundingRectAction->setCheckable(true); m_showBoundingRectAction->setCheckable(true);
m_showBoundingRectAction->setChecked(false); m_showBoundingRectAction->setChecked(false);
registerActionAsCommand(m_showBoundingRectAction, registerActionAsCommand(m_showBoundingRectAction,
Constants::FORMEDITOR_NO_SHOW_BOUNDING_RECTANGLE, Constants::FORMEDITOR_NO_SHOW_BOUNDING_RECTANGLE,
QKeySequence(Qt::Key_A), QKeySequence(Qt::Key_A),
ComponentCoreConstants::rootCategory, ComponentCoreConstants::rootCategory,
10); ComponentCoreConstants::Priorities::ShowBoundingRect);
addAction(m_showBoundingRectAction.data()); addAction(m_showBoundingRectAction.data());
@@ -273,7 +273,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
Constants::FORMEDITOR_REFRESH, Constants::FORMEDITOR_REFRESH,
QKeySequence(Qt::Key_R), QKeySequence(Qt::Key_R),
ComponentCoreConstants::rootCategory, ComponentCoreConstants::rootCategory,
0); ComponentCoreConstants::Priorities::ResetView);
addAction(m_resetAction.data()); addAction(m_resetAction.data());
upperActions.append(m_resetAction.data()); upperActions.append(m_resetAction.data());

View File

@@ -40,59 +40,8 @@ bool modelNodeHasUrlSource(const QmlDesigner::ModelNode &modelNode)
namespace QmlDesigner { namespace QmlDesigner {
class SourceToolAction : public AbstractAction
{
public:
SourceToolAction() : AbstractAction(QCoreApplication::translate("SourceToolAction","Change Source URL..."))
{
const Utils::Icon prevIcon({
{":/utils/images/fileopen.png", Utils::Theme::OutputPanes_NormalMessageTextColor}}, Utils::Icon::MenuTintedStyle);
action()->setIcon(prevIcon.icon());
}
QByteArray category() const override
{
return QByteArray();
}
QByteArray menuId() const override
{
return "SourceTool";
}
int priority() const override
{
return CustomActionsPriority;
}
Type type() const override
{
return FormEditorAction;
}
protected:
bool isVisible(const SelectionContext &selectionContext) const override
{
if (selectionContext.singleNodeIsSelected())
return modelNodeHasUrlSource(selectionContext.currentSingleSelectedNode());
return false;
}
bool isEnabled(const SelectionContext &selectionContext) const override
{
return isVisible(selectionContext);
}
};
SourceTool::SourceTool() SourceTool::SourceTool()
{ {
auto sourceToolAction = new SourceToolAction;
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(sourceToolAction);
connect(sourceToolAction->action(), &QAction::triggered, [=]() {
view()->changeCurrentToolTo(this);
});
} }
SourceTool::~SourceTool() = default; SourceTool::~SourceTool() = default;

View File

@@ -28,56 +28,8 @@
namespace QmlDesigner { namespace QmlDesigner {
class TextToolAction : public AbstractAction
{
public:
TextToolAction() : AbstractAction(QCoreApplication::translate("TextToolAction","Edit Text")) {}
QByteArray category() const override
{
return QByteArray();
}
QByteArray menuId() const override
{
return "TextTool";
}
int priority() const override
{
return CustomActionsPriority;
}
Type type() const override
{
return ContextMenuAction;
}
protected:
bool isVisible(const SelectionContext &selectionContext) const override
{
if (selectionContext.scenePosition().isNull())
return false;
if (selectionContext.singleNodeIsSelected())
return selectionContext.currentSingleSelectedNode().metaInfo().hasProperty("text");
return false;
}
bool isEnabled(const SelectionContext &selectionContext) const override
{
return isVisible(selectionContext);
}
};
TextTool::TextTool() TextTool::TextTool()
{ {
auto textToolAction = new TextToolAction;
QmlDesignerPlugin::instance()->designerActionManager().addDesignerAction(textToolAction);
connect(textToolAction->action(), &QAction::triggered, [=]() {
view()->changeCurrentToolTo(this);
});
} }
TextTool::~TextTool() = default; TextTool::~TextTool() = default;

View File

@@ -20,7 +20,6 @@ const int timelineBounds = 8;
const int timelineLeftOffset = 10; const int timelineLeftOffset = 10;
const char timelineCategory[] = "Timeline"; const char timelineCategory[] = "Timeline";
const int priorityTimelineCategory = 110;
const char timelineCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Timeline"); const char timelineCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Timeline");
const char timelineCopyKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", const char timelineCopyKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
@@ -28,7 +27,7 @@ const char timelineCopyKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerCo
const char timelinePasteKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", const char timelinePasteKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
"Paste Keyframes"); "Paste Keyframes");
const char timelineInsertKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", const char timelineInsertKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
"Add Keyframes at Current Frame"); "Add Keyframe");
const char timelineDeleteKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", const char timelineDeleteKeyframesDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
"Delete All Keyframes"); "Delete All Keyframes");

View File

@@ -584,7 +584,7 @@ void TimelineView::registerActions()
actionManager.addDesignerAction(new ActionGroup(TimelineConstants::timelineCategoryDisplayName, actionManager.addDesignerAction(new ActionGroup(TimelineConstants::timelineCategoryDisplayName,
TimelineConstants::timelineCategory, TimelineConstants::timelineCategory,
TimelineConstants::priorityTimelineCategory, ComponentCoreConstants::Priorities::TimelineCategory,
timelineEnabled, timelineEnabled,
&SelectionContextFunctors::always)); &SelectionContextFunctors::always));
@@ -594,7 +594,7 @@ void TimelineView::registerActions()
{}, {},
TimelineConstants::timelineCategory, TimelineConstants::timelineCategory,
QKeySequence(), QKeySequence(),
160, 3,
deleteKeyframes, deleteKeyframes,
timelineHasKeyframes)); timelineHasKeyframes));
@@ -604,7 +604,7 @@ void TimelineView::registerActions()
{}, {},
TimelineConstants::timelineCategory, TimelineConstants::timelineCategory,
QKeySequence(), QKeySequence(),
140, 1,
insertKeyframes, insertKeyframes,
timelineHasKeyframes)); timelineHasKeyframes));
@@ -614,7 +614,7 @@ void TimelineView::registerActions()
{}, {},
TimelineConstants::timelineCategory, TimelineConstants::timelineCategory,
QKeySequence(), QKeySequence(),
120, 4,
copyKeyframes, copyKeyframes,
timelineHasKeyframes)); timelineHasKeyframes));
@@ -624,7 +624,7 @@ void TimelineView::registerActions()
{}, {},
TimelineConstants::timelineCategory, TimelineConstants::timelineCategory,
QKeySequence(), QKeySequence(),
100, 5,
pasteKeyframes, pasteKeyframes,
timelineHasClipboard)); timelineHasClipboard));
} }

View File

@@ -8,6 +8,7 @@ namespace Constants {
const char C_BACKSPACE[] = "QmlDesigner.Backspace"; const char C_BACKSPACE[] = "QmlDesigner.Backspace";
const char C_DELETE[] = "QmlDesigner.Delete"; const char C_DELETE[] = "QmlDesigner.Delete";
const char C_DUPLICATE[] = "QmlDesigner.Duplicate";
// Context // Context
const char C_QMLDESIGNER[] = "QmlDesigner::QmlDesignerMain"; const char C_QMLDESIGNER[] = "QmlDesigner::QmlDesignerMain";

View File

@@ -65,7 +65,7 @@ QmlPreviewAction::QmlPreviewAction() : ModelNodeAction(livePreviewId,
QmlPreviewWidgetPlugin::tr("Show Live Preview"), QmlPreviewWidgetPlugin::tr("Show Live Preview"),
ComponentCoreConstants::qmlPreviewCategory, ComponentCoreConstants::qmlPreviewCategory,
QKeySequence("Alt+p"), QKeySequence("Alt+p"),
20, 1,
&handleAction, &handleAction,
&SelectionContextFunctors::always) &SelectionContextFunctors::always)
{ {

View File

@@ -40,7 +40,7 @@ QmlPreviewWidgetPlugin::QmlPreviewWidgetPlugin()
designerActionManager.addDesignerAction(new ActionGroup( designerActionManager.addDesignerAction(new ActionGroup(
QString(), QString(),
ComponentCoreConstants::qmlPreviewCategory, ComponentCoreConstants::qmlPreviewCategory,
ComponentCoreConstants::priorityQmlPreviewCategory, ComponentCoreConstants::Priorities::QmlPreviewCategory,
&SelectionContextFunctors::always)); &SelectionContextFunctors::always));
s_previewPlugin = getPreviewPlugin(); s_previewPlugin = getPreviewPlugin();

View File

@@ -31,6 +31,7 @@
#include <qmljs/qmljsreformatter.h> #include <qmljs/qmljsreformatter.h>
#include "modelnodecontextmenu_helper.h"
#include "qmldesignerconstants.h" #include "qmldesignerconstants.h"
#include "qmldesignerplugin.h" #include "qmldesignerplugin.h"
@@ -40,16 +41,17 @@
namespace QmlDesigner { namespace QmlDesigner {
ShortCutManager::ShortCutManager() ShortCutManager::ShortCutManager()
: QObject() : QObject(),
, m_exportAsImageAction(tr("Export as Image...")) m_exportAsImageAction(tr("Export as &Image...")),
, m_undoAction(tr("&Undo")) m_undoAction(tr("&Undo")),
, m_redoAction(tr("&Redo")) m_redoAction(tr("&Redo")),
, m_deleteAction(tr("Delete")) m_deleteAction(tr("Delete")),
, m_cutAction(tr("Cu&t")) m_cutAction(tr("Cu&t")),
, m_copyAction(tr("&Copy")) m_copyAction(tr("&Copy")),
, m_pasteAction(tr("&Paste")) m_pasteAction(tr("&Paste")),
, m_selectAllAction(tr("Select &All")) m_duplicateAction(tr("&Duplicate")),
, m_escapeAction(this) m_selectAllAction(tr("Select &All")),
m_escapeAction(this)
{ {
} }
@@ -70,6 +72,8 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
connect(&m_deleteAction, &QAction::triggered, this, &ShortCutManager::deleteSelected); connect(&m_deleteAction, &QAction::triggered, this, &ShortCutManager::deleteSelected);
connect(&m_duplicateAction, &QAction::triggered, this, &ShortCutManager::duplicateSelected);
connect(&m_cutAction, &QAction::triggered, this, &ShortCutManager::cutSelected); connect(&m_cutAction, &QAction::triggered, this, &ShortCutManager::cutSelected);
connect(&m_copyAction, &QAction::triggered, this, &ShortCutManager::copySelected); connect(&m_copyAction, &QAction::triggered, this, &ShortCutManager::copySelected);
@@ -126,10 +130,13 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
// Undo / Redo // Undo / Redo
command = Core::ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, qmlDesignerMainContext); command = Core::ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, qmlDesignerMainContext);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 310, Utils::Icons::UNDO_TOOLBAR.icon()); command->setDefaultKeySequence(QKeySequence::Undo);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 1, Utils::Icons::UNDO_TOOLBAR.icon());
command = Core::ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, qmlDesignerMainContext); command = Core::ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, qmlDesignerMainContext);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 300, Utils::Icons::REDO_TOOLBAR.icon()); command->setDefaultKeySequence(QKeySequence::Redo);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 2, Utils::Icons::REDO_TOOLBAR.icon());
designerActionManager.addDesignerAction(new SeperatorDesignerAction(ComponentCoreConstants::editCategory, 10));
//Edit Menu //Edit Menu
m_deleteAction.setIcon(QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::EDIT_CLEAR_TOOLBAR.icon())); m_deleteAction.setIcon(QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::EDIT_CLEAR_TOOLBAR.icon()));
@@ -140,28 +147,34 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
if (!Utils::HostOsInfo::isMacHost()) if (!Utils::HostOsInfo::isMacHost())
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 280); designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 14);
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext); Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext);
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerEditor3DContext); Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerEditor3DContext);
command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext); command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Cut); command->setDefaultKeySequence(QKeySequence::Cut);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 260, Utils::Icons::CUT_TOOLBAR.icon()); designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 13, Utils::Icons::CUT_TOOLBAR.icon());
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext); Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext);
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerEditor3DContext); Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerEditor3DContext);
command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext); command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Copy); command->setDefaultKeySequence(QKeySequence::Copy);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 250, Utils::Icons::COPY_TOOLBAR.icon()); designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 11, Utils::Icons::COPY_TOOLBAR.icon());
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext); Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext);
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerEditor3DContext); Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerEditor3DContext);
command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext); command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Paste); command->setDefaultKeySequence(QKeySequence::Paste);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 240, Utils::Icons::PASTE_TOOLBAR.icon()); designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 12, Utils::Icons::PASTE_TOOLBAR.icon());
Core::ActionManager::registerAction(&m_duplicateAction, Constants::C_DUPLICATE, qmlDesignerFormEditorContext);
Core::ActionManager::registerAction(&m_duplicateAction, Constants::C_DUPLICATE, qmlDesignerEditor3DContext);
command = Core::ActionManager::registerAction(&m_duplicateAction, Constants::C_DUPLICATE, qmlDesignerMainContext);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 15);
Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerFormEditorContext); Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
command = Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerNavigatorContext); command = Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerNavigatorContext);
@@ -258,6 +271,12 @@ void ShortCutManager::copySelected()
currentDesignDocument()->copySelected(); currentDesignDocument()->copySelected();
} }
void ShortCutManager::duplicateSelected()
{
if (currentDesignDocument())
currentDesignDocument()->duplicateSelected();
}
void ShortCutManager::paste() void ShortCutManager::paste()
{ {
if (currentDesignDocument()) if (currentDesignDocument())

View File

@@ -41,6 +41,7 @@ private:
void deleteSelected(); void deleteSelected();
void cutSelected(); void cutSelected();
void copySelected(); void copySelected();
void duplicateSelected();
void paste(); void paste();
void selectAll(); void selectAll();
void undoAvailable(bool isAvailable); void undoAvailable(bool isAvailable);
@@ -61,6 +62,7 @@ private:
QAction m_cutAction; QAction m_cutAction;
QAction m_copyAction; QAction m_copyAction;
QAction m_pasteAction; QAction m_pasteAction;
QAction m_duplicateAction;
QAction m_selectAllAction; QAction m_selectAllAction;
QAction m_escapeAction; QAction m_escapeAction;