QmlDesigner: Add "Edit Component" functionality to imported 3d assets

Doubleclicking .q3d file in assets view will trigger edit component on
the imported 3d component represented by that file.
Context menu for .q3d files now also has "Edit Component" option that
does the same.

Fixes: QDS-14789
Change-Id: I97a041f5bfe521058c03ee717479b2752bc45ff0
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2025-02-21 12:59:46 +02:00
parent 3170bf47b5
commit cbf71616a5
4 changed files with 26 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ T.TreeViewDelegate {
readonly property string suffix: model.fileName.substr(-4) readonly property string suffix: model.fileName.substr(-4)
readonly property bool isFont: root.suffix === ".ttf" || root.suffix === ".otf" readonly property bool isFont: root.suffix === ".ttf" || root.suffix === ".otf"
readonly property bool isEffect: root.suffix === ".qep" readonly property bool isEffect: root.suffix === ".qep"
readonly property bool isImported3d: root.suffix === ".q3d"
property bool currFileSelected: false property bool currFileSelected: false
property int initialDepth: -1 property int initialDepth: -1
property bool __isDirectory: assetsModel.isDirectory(model.filePath) property bool __isDirectory: assetsModel.isDirectory(model.filePath)
@@ -213,8 +214,12 @@ T.TreeViewDelegate {
mouseArea.forceActiveFocus() mouseArea.forceActiveFocus()
mouseArea.allowTooltip = false mouseArea.allowTooltip = false
AssetsLibraryBackend.tooltipBackend.hideTooltip() AssetsLibraryBackend.tooltipBackend.hideTooltip()
if (mouse.button === Qt.LeftButton && root.isEffect) if (mouse.button === Qt.LeftButton) {
if (root.isEffect)
AssetsLibraryBackend.rootView.openEffectComposer(filePath) AssetsLibraryBackend.rootView.openEffectComposer(filePath)
else if (root.isImported3d)
AssetsLibraryBackend.rootView.editAssetComponent(filePath)
}
} }
StudioControls.ToolTip { StudioControls.ToolTip {

View File

@@ -129,7 +129,16 @@ StudioControls.Menu {
&& root.assetsModel.allFilePathsAreComposedEffects(root.__selectedAssetPathsList) && root.assetsModel.allFilePathsAreComposedEffects(root.__selectedAssetPathsList)
&& root.rootView.canCreateEffects && root.rootView.canCreateEffects
height: editInEffectComposerItem.visible ? editInEffectComposerItem.implicitHeight : 0 height: editInEffectComposerItem.visible ? editInEffectComposerItem.implicitHeight : 0
onTriggered: AssetsLibraryBackend.rootView.openEffectComposer(root.__selectedAssetPathsList[0]) onTriggered: root.rootView.openEffectComposer(root.__selectedAssetPathsList[0])
}
StudioControls.MenuItem {
id: editComponent
text: qsTr("Edit Component")
visible: root.__fileIndex && root.__selectedAssetPathsList.length === 1
&& root.rootView.assetIsImported3d(root.__selectedAssetPathsList[0])
height: editComponent.visible ? editComponent.implicitHeight : 0
onTriggered: root.rootView.editAssetComponent(root.__selectedAssetPathsList[0])
} }
StudioControls.MenuItem { StudioControls.MenuItem {

View File

@@ -609,6 +609,14 @@ void AssetsLibraryWidget::openEffectComposer(const QString &filePath)
ModelNodeOperations::openEffectComposer(filePath); ModelNodeOperations::openEffectComposer(filePath);
} }
void AssetsLibraryWidget::editAssetComponent(const QString &filePath)
{
Utils::FilePath fullPath = QmlDesignerPlugin::instance()->documentManager()
.generatedComponentUtils().getImported3dQml(filePath);
if (fullPath.exists())
DocumentManager::goIntoComponent(fullPath.toFSPathString());
}
QString AssetsLibraryWidget::qmlSourcesPath() QString AssetsLibraryWidget::qmlSourcesPath()
{ {
#ifdef SHARE_QML_PATH #ifdef SHARE_QML_PATH

View File

@@ -84,6 +84,7 @@ public:
const QString &targetDirPath = {}); const QString &targetDirPath = {});
Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex); Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex);
Q_INVOKABLE void openEffectComposer(const QString &filePath); Q_INVOKABLE void openEffectComposer(const QString &filePath);
Q_INVOKABLE void editAssetComponent(const QString &filePath);
Q_INVOKABLE int qtVersion() const; Q_INVOKABLE int qtVersion() const;
Q_INVOKABLE void invalidateThumbnail(const QString &id); Q_INVOKABLE void invalidateThumbnail(const QString &id);
Q_INVOKABLE QSize imageSize(const QString &id); Q_INVOKABLE QSize imageSize(const QString &id);