forked from qt-creator/qt-creator
QmlDesigner: remove a texture from content library user tab
Fixes: QDS-12542 Change-Id: Iee3ea0bd8a3ce6cb41c27a645801eef608cd8da8 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -12,6 +12,7 @@ StudioControls.Menu {
|
||||
|
||||
property var targetTexture: null
|
||||
property bool hasSceneEnv: false
|
||||
property bool enableRemove: false // true: adds an option to remove targetTexture
|
||||
|
||||
property bool canUse3D: targetTexture && ContentLibraryBackend.rootView.hasQuick3DImport && ContentLibraryBackend.rootView.hasMaterialLibrary
|
||||
|
||||
@@ -32,13 +33,20 @@ StudioControls.Menu {
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Add texture")
|
||||
enabled: canUse3D
|
||||
enabled: root.canUse3D
|
||||
onTriggered: ContentLibraryBackend.rootView.addTexture(root.targetTexture)
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Add light probe")
|
||||
enabled: root.hasSceneEnv && canUse3D
|
||||
enabled: root.hasSceneEnv && root.canUse3D
|
||||
onTriggered: ContentLibraryBackend.rootView.addLightProbe(root.targetTexture)
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Remove from Content Library")
|
||||
visible: root.targetTexture && root.enableRemove
|
||||
height: visible ? implicitHeight : 0
|
||||
onTriggered: ContentLibraryBackend.userModel.removeTexture(root.targetTexture)
|
||||
}
|
||||
}
|
||||
|
@@ -61,6 +61,7 @@ HelperWidgets.ScrollView {
|
||||
ContentLibraryTextureContextMenu {
|
||||
id: ctxMenuTexture
|
||||
|
||||
enableRemove: true
|
||||
hasSceneEnv: ContentLibraryBackend.texturesModel.hasSceneEnv
|
||||
}
|
||||
|
||||
|
@@ -121,6 +121,21 @@ void ContentLibraryUserModel::addTextures(const QStringList &paths)
|
||||
emit dataChanged(index(texSectionIdx), index(texSectionIdx));
|
||||
}
|
||||
|
||||
void ContentLibraryUserModel::removeTexture(ContentLibraryTexture *tex)
|
||||
{
|
||||
// remove resources
|
||||
Utils::FilePath::fromString(tex->texturePath()).removeFile();
|
||||
Utils::FilePath::fromString(tex->iconPath()).removeFile();
|
||||
|
||||
// remove from model
|
||||
m_userTextures.removeOne(tex);
|
||||
tex->deleteLater();
|
||||
|
||||
// update model
|
||||
int texSectionIdx = 1;
|
||||
emit dataChanged(index(texSectionIdx), index(texSectionIdx));
|
||||
}
|
||||
|
||||
// returns unique library material's name and qml component
|
||||
QPair<QString, QString> ContentLibraryUserModel::getUniqueLibMaterialNameAndQml(const QString &matName) const
|
||||
{
|
||||
|
@@ -72,6 +72,7 @@ public:
|
||||
Q_INVOKABLE void applyToSelected(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||
Q_INVOKABLE void addToProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryMaterial *mat);
|
||||
Q_INVOKABLE void removeTexture(QmlDesigner::ContentLibraryTexture *tex);
|
||||
|
||||
signals:
|
||||
void isEmptyChanged();
|
||||
|
Reference in New Issue
Block a user