forked from qt-creator/qt-creator
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:
@@ -24,6 +24,7 @@ T.TreeViewDelegate {
|
||||
readonly property string suffix: model.fileName.substr(-4)
|
||||
readonly property bool isFont: root.suffix === ".ttf" || root.suffix === ".otf"
|
||||
readonly property bool isEffect: root.suffix === ".qep"
|
||||
readonly property bool isImported3d: root.suffix === ".q3d"
|
||||
property bool currFileSelected: false
|
||||
property int initialDepth: -1
|
||||
property bool __isDirectory: assetsModel.isDirectory(model.filePath)
|
||||
@@ -213,8 +214,12 @@ T.TreeViewDelegate {
|
||||
mouseArea.forceActiveFocus()
|
||||
mouseArea.allowTooltip = false
|
||||
AssetsLibraryBackend.tooltipBackend.hideTooltip()
|
||||
if (mouse.button === Qt.LeftButton && root.isEffect)
|
||||
AssetsLibraryBackend.rootView.openEffectComposer(filePath)
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
if (root.isEffect)
|
||||
AssetsLibraryBackend.rootView.openEffectComposer(filePath)
|
||||
else if (root.isImported3d)
|
||||
AssetsLibraryBackend.rootView.editAssetComponent(filePath)
|
||||
}
|
||||
}
|
||||
|
||||
StudioControls.ToolTip {
|
||||
|
@@ -129,7 +129,16 @@ StudioControls.Menu {
|
||||
&& root.assetsModel.allFilePathsAreComposedEffects(root.__selectedAssetPathsList)
|
||||
&& root.rootView.canCreateEffects
|
||||
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 {
|
||||
|
@@ -609,6 +609,14 @@ void AssetsLibraryWidget::openEffectComposer(const QString &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()
|
||||
{
|
||||
#ifdef SHARE_QML_PATH
|
||||
|
@@ -84,6 +84,7 @@ public:
|
||||
const QString &targetDirPath = {});
|
||||
Q_INVOKABLE QSet<QString> supportedAssetSuffixes(bool complex);
|
||||
Q_INVOKABLE void openEffectComposer(const QString &filePath);
|
||||
Q_INVOKABLE void editAssetComponent(const QString &filePath);
|
||||
Q_INVOKABLE int qtVersion() const;
|
||||
Q_INVOKABLE void invalidateThumbnail(const QString &id);
|
||||
Q_INVOKABLE QSize imageSize(const QString &id);
|
||||
|
Reference in New Issue
Block a user