forked from qt-creator/qt-creator
QmlDesigner: Allow importing/exporting a component from Navigator
Fixes: QDS-13200 Change-Id: I771e962cca210d82a2434ff6c328e7bbe93e6b0a Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -68,6 +68,8 @@ inline constexpr char jumpToCodeCommandId[] = "JumpToCode";
|
|||||||
inline constexpr char mergeTemplateCommandId[] = "MergeTemplate";
|
inline constexpr char mergeTemplateCommandId[] = "MergeTemplate";
|
||||||
inline constexpr char goToImplementationCommandId[] = "GoToImplementation";
|
inline constexpr char goToImplementationCommandId[] = "GoToImplementation";
|
||||||
inline constexpr char makeComponentCommandId[] = "MakeComponent";
|
inline constexpr char makeComponentCommandId[] = "MakeComponent";
|
||||||
|
inline constexpr char importComponentCommandId[] = "ImportComponent";
|
||||||
|
inline constexpr char exportComponentCommandId[] = "ExportComponent";
|
||||||
inline constexpr char editMaterialCommandId[] = "EditMaterial";
|
inline constexpr char editMaterialCommandId[] = "EditMaterial";
|
||||||
inline constexpr char addToContentLibraryCommandId[] = "AddToContentLibrary";
|
inline constexpr char addToContentLibraryCommandId[] = "AddToContentLibrary";
|
||||||
inline constexpr char addItemToStackedContainerCommandId[] = "AddItemToStackedContainer";
|
inline constexpr char addItemToStackedContainerCommandId[] = "AddItemToStackedContainer";
|
||||||
@@ -161,6 +163,10 @@ inline constexpr char editMaterialDisplayName[] = QT_TRANSLATE_NOOP("QmlDesigner
|
|||||||
"Edit Material");
|
"Edit Material");
|
||||||
inline constexpr char addToContentLibraryDisplayName[] = QT_TRANSLATE_NOOP(
|
inline constexpr char addToContentLibraryDisplayName[] = QT_TRANSLATE_NOOP(
|
||||||
"QmlDesignerContextMenu", "Add to Content Library");
|
"QmlDesignerContextMenu", "Add to Content Library");
|
||||||
|
inline constexpr char importComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
||||||
|
"Import Component");
|
||||||
|
inline constexpr char exportComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
||||||
|
"Export Component");
|
||||||
inline constexpr char editAnnotationsDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
inline constexpr char editAnnotationsDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
||||||
"Edit Annotations");
|
"Edit Annotations");
|
||||||
inline constexpr char addMouseAreaFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
inline constexpr char addMouseAreaFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu",
|
||||||
@@ -325,7 +331,9 @@ enum PrioritiesEnum : int {
|
|||||||
Last,
|
Last,
|
||||||
/******** Section *****************************/
|
/******** Section *****************************/
|
||||||
AddingAssetsSection = 7000,
|
AddingAssetsSection = 7000,
|
||||||
Add3DToContentLib
|
Add3DToContentLib,
|
||||||
|
ImportComponent,
|
||||||
|
ExportComponent,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1978,6 +1978,26 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
&singleSelection,
|
&singleSelection,
|
||||||
&singleSelection));
|
&singleSelection));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
importComponentCommandId,
|
||||||
|
importComponentDisplayName,
|
||||||
|
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||||
|
rootCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
Priorities::ImportComponent,
|
||||||
|
&importComponent));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
exportComponentCommandId,
|
||||||
|
exportComponentDisplayName,
|
||||||
|
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||||
|
rootCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
Priorities::ExportComponent,
|
||||||
|
&exportComponent,
|
||||||
|
&is3DNode,
|
||||||
|
&is3DNode));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeContextMenuAction(
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
editMaterialCommandId,
|
editMaterialCommandId,
|
||||||
editMaterialDisplayName,
|
editMaterialDisplayName,
|
||||||
|
|||||||
@@ -80,6 +80,13 @@ inline bool enableAddToContentLib(const SelectionContext &selectionState)
|
|||||||
return isNode3D && !isInBundle;
|
return isNode3D && !isInBundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is3DNode(const SelectionContext &selectionState)
|
||||||
|
{
|
||||||
|
ModelNode modelNode = selectionState.currentSingleSelectedNode();
|
||||||
|
|
||||||
|
return modelNode.metaInfo().isQtQuick3DNode();
|
||||||
|
}
|
||||||
|
|
||||||
inline bool hasEditableMaterial(const SelectionContext &selectionState)
|
inline bool hasEditableMaterial(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
ModelNode node = selectionState.currentSingleSelectedNode();
|
ModelNode node = selectionState.currentSingleSelectedNode();
|
||||||
|
|||||||
@@ -803,6 +803,17 @@ void add3DAssetToContentLibrary(const SelectionContext &selectionContext)
|
|||||||
selectionContext.view()->emitCustomNotification("add_3d_to_content_lib", {node});
|
selectionContext.view()->emitCustomNotification("add_3d_to_content_lib", {node});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void importComponent(const SelectionContext &selectionContext)
|
||||||
|
{
|
||||||
|
selectionContext.view()->emitCustomNotification("import_bundle_to_project");
|
||||||
|
}
|
||||||
|
|
||||||
|
void exportComponent(const SelectionContext &selectionContext)
|
||||||
|
{
|
||||||
|
ModelNode node = selectionContext.currentSingleSelectedNode();
|
||||||
|
selectionContext.view()->emitCustomNotification("export_item_as_bundle", {node});
|
||||||
|
}
|
||||||
|
|
||||||
void goImplementation(const SelectionContext &selectionState)
|
void goImplementation(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
addSignalHandlerOrGotoImplementation(selectionState, false);
|
addSignalHandlerOrGotoImplementation(selectionState, false);
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ void removeLayout(const SelectionContext &selectionContext);
|
|||||||
void removePositioner(const SelectionContext &selectionContext);
|
void removePositioner(const SelectionContext &selectionContext);
|
||||||
void moveToComponent(const SelectionContext &selectionContext);
|
void moveToComponent(const SelectionContext &selectionContext);
|
||||||
void add3DAssetToContentLibrary(const SelectionContext &selectionContext);
|
void add3DAssetToContentLibrary(const SelectionContext &selectionContext);
|
||||||
|
void importComponent(const SelectionContext &selectionContext);
|
||||||
|
void exportComponent(const SelectionContext &selectionContext);
|
||||||
PropertyName getIndexPropertyName(const ModelNode &modelNode);
|
PropertyName getIndexPropertyName(const ModelNode &modelNode);
|
||||||
void addItemToStackedContainer(const SelectionContext &selectionContext);
|
void addItemToStackedContainer(const SelectionContext &selectionContext);
|
||||||
void increaseIndexOfStackedContainer(const SelectionContext &selectionContext);
|
void increaseIndexOfStackedContainer(const SelectionContext &selectionContext);
|
||||||
|
|||||||
@@ -368,13 +368,13 @@ void Edit3DWidget::createContextMenu()
|
|||||||
|
|
||||||
m_importBundleAction = m_contextMenu->addAction(
|
m_importBundleAction = m_contextMenu->addAction(
|
||||||
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||||
tr("Import Components"), [&] {
|
tr("Import Component"), [&] {
|
||||||
view()->emitCustomNotification("import_bundle_to_project"); // To ContentLibrary
|
view()->emitCustomNotification("import_bundle_to_project"); // To ContentLibrary
|
||||||
});
|
});
|
||||||
|
|
||||||
m_exportBundleAction = m_contextMenu->addAction(
|
m_exportBundleAction = m_contextMenu->addAction(
|
||||||
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
contextIcon(DesignerIcons::CreateIcon), // TODO: placeholder icon
|
||||||
tr("Export Components"), [&] {
|
tr("Export Component"), [&] {
|
||||||
view()->emitCustomNotification("export_item_as_bundle", {m_contextMenuTarget}); // To ContentLibrary
|
view()->emitCustomNotification("export_item_as_bundle", {m_contextMenuTarget}); // To ContentLibrary
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user