forked from qt-creator/qt-creator
QmlDesigner: Add 3D component from Navigator view context menu
Fixes: QDS-12911 Change-Id: Icd6d32d4a09a6f3e7b925037e73a75fdbf472f28 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -69,6 +69,7 @@ const char mergeTemplateCommandId[] = "MergeTemplate";
|
||||
const char goToImplementationCommandId[] = "GoToImplementation";
|
||||
const char makeComponentCommandId[] = "MakeComponent";
|
||||
const char editMaterialCommandId[] = "EditMaterial";
|
||||
const char addToContentLibraryCommandId[] = "AddToContentLibrary";
|
||||
const char addItemToStackedContainerCommandId[] = "AddItemToStackedContainer";
|
||||
const char addTabBarToStackedContainerCommandId[] = "AddTabBarToStackedContainer";
|
||||
const char increaseIndexOfStackedContainerCommandId[] = "IncreaseIndexOfStackedContainer";
|
||||
@@ -127,6 +128,7 @@ const char mergeTemplateDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen
|
||||
const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation");
|
||||
const char makeComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Create Component");
|
||||
const char editMaterialDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Material");
|
||||
const char addToContentLibraryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add to Content Library");
|
||||
const char editAnnotationsDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Annotations");
|
||||
const char addMouseAreaFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add Mouse Area");
|
||||
const char editIn3dViewDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit in 3D View");
|
||||
@@ -241,7 +243,10 @@ enum PrioritiesEnum : int {
|
||||
SignalsDialog,
|
||||
Refactoring,
|
||||
GenericToolBar,
|
||||
Last
|
||||
Last,
|
||||
/******** Section *****************************/
|
||||
AddingAssetsSection = 7000,
|
||||
Add3DToContentLib
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -1999,6 +1999,17 @@ void DesignerActionManager::createDefaultDesignerActions()
|
||||
[&] (const SelectionContext& context) { mergeWithTemplate(context, m_externalDependencies); },
|
||||
&SelectionContextFunctors::always));
|
||||
|
||||
addDesignerAction(new ModelNodeContextMenuAction(
|
||||
addToContentLibraryCommandId,
|
||||
addToContentLibraryDisplayName,
|
||||
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||
rootCategory,
|
||||
QKeySequence(),
|
||||
Priorities::Add3DToContentLib,
|
||||
&add3DAssetToContentLibrary,
|
||||
&enableAddToContentLib,
|
||||
&enableAddToContentLib));
|
||||
|
||||
addDesignerAction(new ActionGroup(
|
||||
"",
|
||||
genericToolBarCategory,
|
||||
|
@@ -70,6 +70,16 @@ inline bool isModelOrMaterial(const SelectionContext &selectionState)
|
||||
return node.metaInfo().isQtQuick3DModel() || node.metaInfo().isQtQuick3DMaterial();
|
||||
}
|
||||
|
||||
inline bool enableAddToContentLib(const SelectionContext &selectionState)
|
||||
{
|
||||
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
||||
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||
bool isInBundle = modelNode.type().startsWith(compUtils.componentBundlesTypePrefix().toLatin1());
|
||||
bool isNode3D = modelNode.metaInfo().isQtQuick3DNode();
|
||||
|
||||
return isNode3D && !isInBundle;
|
||||
}
|
||||
|
||||
inline bool hasEditableMaterial(const SelectionContext &selectionState)
|
||||
{
|
||||
ModelNode node = selectionState.currentSingleSelectedNode();
|
||||
|
@@ -797,6 +797,12 @@ void moveToComponent(const SelectionContext &selectionContext)
|
||||
selectionContext.view()->model()->rewriterView()->moveToComponent(modelNode);
|
||||
}
|
||||
|
||||
void add3DAssetToContentLibrary(const SelectionContext &selectionContext)
|
||||
{
|
||||
ModelNode node = selectionContext.currentSingleSelectedNode();
|
||||
selectionContext.view()->emitCustomNotification("add_3d_to_content_lib", {node});
|
||||
}
|
||||
|
||||
void goImplementation(const SelectionContext &selectionState)
|
||||
{
|
||||
addSignalHandlerOrGotoImplementation(selectionState, false);
|
||||
|
@@ -96,6 +96,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
||||
void removeLayout(const SelectionContext &selectionContext);
|
||||
void removePositioner(const SelectionContext &selectionContext);
|
||||
void moveToComponent(const SelectionContext &selectionContext);
|
||||
void add3DAssetToContentLibrary(const SelectionContext &selectionContext);
|
||||
PropertyName getIndexPropertyName(const ModelNode &modelNode);
|
||||
void addItemToStackedContainer(const SelectionContext &selectionContext);
|
||||
void increaseIndexOfStackedContainer(const SelectionContext &selectionContext);
|
||||
|
Reference in New Issue
Block a user