forked from qt-creator/qt-creator
QmlDesigner: Add "Edit in 3D View" context menu option
This option is only shown when View3D item is selected. Fixes: QDS-12207 Change-Id: I0a98b59a5eb3fe7abd689711939b649fe496eeb7 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -81,6 +81,7 @@ const char fitRootToScreenCommandId[] = "FitRootToScreen";
|
||||
const char fitSelectionToScreenCommandId[] = "FitSelectionToScreen";
|
||||
const char editAnnotationsCommandId[] = "EditAnnotation";
|
||||
const char addMouseAreaFillCommandId[] = "AddMouseAreaFill";
|
||||
const char editIn3dViewCommandId[] = "editIn3dView";
|
||||
|
||||
const char openSignalDialogCommandId[] = "OpenSignalDialog";
|
||||
const char update3DAssetCommandId[] = "Update3DAsset";
|
||||
@@ -130,6 +131,7 @@ const char editMaterialDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu
|
||||
const char editCollectionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit Model");
|
||||
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");
|
||||
|
||||
const char openSignalDialogDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Open Signal Dialog");
|
||||
const char update3DAssetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Update 3D Asset");
|
||||
|
@@ -1916,7 +1916,7 @@ void DesignerActionManager::createDefaultDesignerActions()
|
||||
contextIcon(DesignerIcons::EnterComponentIcon),
|
||||
rootCategory,
|
||||
QKeySequence(Qt::Key_F2),
|
||||
Priorities::ComponentActions + 2,
|
||||
Priorities::ComponentActions + 3,
|
||||
&goIntoComponentOperation,
|
||||
&selectionIsEditableComponent));
|
||||
|
||||
@@ -1963,13 +1963,24 @@ void DesignerActionManager::createDefaultDesignerActions()
|
||||
&singleSelectedAndUiFile));
|
||||
}
|
||||
|
||||
addDesignerAction(new ModelNodeContextMenuAction(
|
||||
editIn3dViewCommandId,
|
||||
editIn3dViewDisplayName,
|
||||
contextIcon(DesignerIcons::EditIcon),
|
||||
rootCategory,
|
||||
QKeySequence(),
|
||||
Priorities::ComponentActions + 1,
|
||||
&editIn3dView,
|
||||
&singleSelectionView3D,
|
||||
&singleSelectionView3D));
|
||||
|
||||
addDesignerAction(new ModelNodeContextMenuAction(
|
||||
makeComponentCommandId,
|
||||
makeComponentDisplayName,
|
||||
contextIcon(DesignerIcons::MakeComponentIcon),
|
||||
rootCategory,
|
||||
QKeySequence(),
|
||||
Priorities::ComponentActions + 1,
|
||||
Priorities::ComponentActions + 2,
|
||||
&moveToComponent,
|
||||
&singleSelection,
|
||||
&singleSelection));
|
||||
|
@@ -97,6 +97,12 @@ inline bool singleSelectionNotRoot(const SelectionContext &selectionState)
|
||||
&& !selectionState.currentSingleSelectedNode().isRootNode();
|
||||
}
|
||||
|
||||
inline bool singleSelectionView3D(const SelectionContext &selectionState)
|
||||
{
|
||||
return selectionState.singleNodeIsSelected()
|
||||
&& selectionState.currentSingleSelectedNode().metaInfo().isQtQuick3DView3D();
|
||||
}
|
||||
|
||||
inline bool selectionHasProperty(const SelectionContext &selectionState, const char *property)
|
||||
{
|
||||
for (const ModelNode &modelNode : selectionState.selectedModelNodes())
|
||||
|
@@ -1689,6 +1689,15 @@ void updateImported3DAsset(const SelectionContext &selectionContext)
|
||||
}
|
||||
}
|
||||
|
||||
void editIn3dView(const SelectionContext &selectionContext)
|
||||
{
|
||||
if (selectionContext.view() && selectionContext.hasSingleSelectedModelNode()
|
||||
&& selectionContext.currentSingleSelectedNode().metaInfo().isQtQuick3DView3D()) {
|
||||
QmlDesignerPlugin::instance()->mainWidget()->showDockWidget("Editor3D", true);
|
||||
selectionContext.view()->emitView3DAction(View3DActionType::AlignViewToCamera, true);
|
||||
}
|
||||
}
|
||||
|
||||
bool isEffectComposerActivated()
|
||||
{
|
||||
const QVector<ExtensionSystem::PluginSpec *> specs = ExtensionSystem::PluginManager::plugins();
|
||||
|
@@ -124,6 +124,7 @@ void addMouseAreaFill(const SelectionContext &selectionContext);
|
||||
|
||||
void openSignalDialog(const SelectionContext &selectionContext);
|
||||
void updateImported3DAsset(const SelectionContext &selectionContext);
|
||||
void editIn3dView(const SelectionContext &selectionContext);
|
||||
|
||||
QMLDESIGNERCOMPONENTS_EXPORT Utils::FilePath getEffectsImportDirectory();
|
||||
QMLDESIGNERCOMPONENTS_EXPORT QString getEffectsDefaultDirectory(const QString &defaultDir = {});
|
||||
|
Reference in New Issue
Block a user