forked from qt-creator/qt-creator
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 <miikka.heikkinen@qt.io> Reviewed-by: Ali Kianian <ali.kianian@qt.io>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include "contentlibraryusermodel.h"
|
||||
|
||||
#include <bundleimporter.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <designerpaths.h>
|
||||
#include <nodemetainfo.h>
|
||||
#include <qmldesignerconstants.h>
|
||||
@@ -27,6 +26,9 @@
|
||||
#include <qmldesignerutils/fileextractor.h>
|
||||
#include <qmldesignerutils/multifiledownloader.h>
|
||||
|
||||
#include <coreplugin/fileutils.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
@@ -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<QmlDesigner::FileDownloader>("WebFetcher", 1, 0, "FileDownloader");
|
||||
qmlRegisterType<QmlDesigner::FileExtractor>("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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user