From 489230d0efd664e30e6c9a3b9311a7f8aa3caade Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Wed, 9 Apr 2025 14:57:33 +0300 Subject: [PATCH] QmlDesigner: Add "show in graphical shell" option ...to content library user tab's custom categories Fixes: QDS-15153 Change-Id: If899ca6ff3f8416205718bb4ae6f5570ed2ab312 Reviewed-by: Miikka Heikkinen Reviewed-by: Ali Kianian --- .../ContentLibraryTextureContextMenu.qml | 20 ++++++++++++++++++- .../ContentLibraryUserView.qml | 6 +++++- .../contentlibrary/contentlibrarywidget.cpp | 10 +++++++++- .../contentlibrary/contentlibrarywidget.h | 3 +++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTextureContextMenu.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTextureContextMenu.qml index 3dba67243fe..f64306743f7 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTextureContextMenu.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryTextureContextMenu.qml @@ -13,12 +13,14 @@ StudioControls.Menu { property var targetTexture: null property bool hasSceneEnv: false property bool showRemoveAction: false // true: adds an option to remove targetTexture + property bool showInGraphicalShellVisible: false property bool canUse3D: targetTexture && ContentLibraryBackend.rootView.hasQuick3DImport && ContentLibraryBackend.rootView.hasMaterialLibrary - function popupMenu(targetTexture = null) + function popupMenu(targetTexture = null, showInGraphicalShellItemVisible = false) { this.targetTexture = targetTexture + root.showInGraphicalShellVisible = showInGraphicalShellItemVisible ContentLibraryBackend.rootView.updateSceneEnvState(); popup() } @@ -49,4 +51,20 @@ StudioControls.Menu { height: visible ? implicitHeight : 0 onTriggered: ContentLibraryBackend.userModel.removeTexture(root.targetTexture) } + + StudioControls.MenuSeparator { + visible: root.showInGraphicalShellVisible + height: visible ? StudioTheme.Values.border : 0 + } + + StudioControls.MenuItem { + text: ContentLibraryBackend.rootView.showInGraphicalShellMsg + + visible: root.showInGraphicalShellVisible + height: visible ? implicitHeight : 0 + + onTriggered: { + ContentLibraryBackend.rootView.showInGraphicalShell(root.targetTexture.textureParentPath) + } + } } diff --git a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryUserView.qml b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryUserView.qml index 91d131bb9aa..9a8eda0a5e7 100644 --- a/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryUserView.qml +++ b/share/qtcreator/qmldesigner/contentLibraryQmlSource/ContentLibraryUserView.qml @@ -191,10 +191,14 @@ Item { } Grid { + id: grid + width: section.width - section.leftPadding - section.rightPadding spacing: StudioTheme.Values.sectionGridSpacing columns: root.numColumns + property int catIdx: index + Repeater { id: repeater @@ -220,7 +224,7 @@ Item { width: root.cellWidth height: root.cellWidth // for textures use a square size since there is no name row - onShowContextMenu: ctxMenuTexture.popupMenu(modelData) + onShowContextMenu: ctxMenuTexture.popupMenu(modelData, grid.catIdx > 2) } } DelegateChoice { diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp index 9b3860cebf1..793b35a675d 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp @@ -13,7 +13,6 @@ #include "contentlibraryusermodel.h" #include -#include #include #include #include @@ -27,6 +26,9 @@ #include #include +#include +#include + #include #include #include @@ -135,6 +137,7 @@ ContentLibraryWidget::ContentLibraryWidget() , m_environmentsModel(new ContentLibraryTexturesModel("Environments", this)) , m_effectsModel(new ContentLibraryEffectsModel(this)) , m_userModel(new ContentLibraryUserModel(this)) + , m_showInGraphicalShellMsg(Core::FileUtils::msgGraphicalShellAction()) { qmlRegisterType("WebFetcher", 1, 0, "FileDownloader"); qmlRegisterType("WebFetcher", 1, 0, "FileExtractor"); @@ -946,4 +949,9 @@ void ContentLibraryWidget::setHasModelSelection(bool b) emit hasModelSelectionChanged(); } +void ContentLibraryWidget::showInGraphicalShell(const QString &path) +{ + Core::FileUtils::showInGraphicalShell(Utils::FilePath::fromString(path)); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h index ee7cb3509d2..7509b94d361 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h @@ -42,6 +42,7 @@ class ContentLibraryWidget : public QFrame Q_PROPERTY(bool isQt6Project READ isQt6Project NOTIFY isQt6ProjectChanged) Q_PROPERTY(bool importerRunning READ importerRunning WRITE setImporterRunning NOTIFY importerRunningChanged) Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged) + Q_PROPERTY(QString showInGraphicalShellMsg MEMBER m_showInGraphicalShellMsg CONSTANT) // Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged) @@ -105,6 +106,7 @@ public: Q_INVOKABLE bool hasTexture(const QString &format, const QVariant &data) const; Q_INVOKABLE void addQtQuick3D(); Q_INVOKABLE void browseBundleFolder(); + Q_INVOKABLE void showInGraphicalShell(const QString &path); QSize sizeHint() const override; @@ -180,6 +182,7 @@ private: bool m_hasModelSelection = false; QString m_textureBundleUrl; QString m_bundlePath; + QString m_showInGraphicalShellMsg; }; } // namespace QmlDesigner