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>
(cherry picked from commit cc187e1ce6
)
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
f7142be4e5
commit
4be50f14db
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -97,6 +97,21 @@ void ContentLibraryUserModel::addMaterial(const QString &name, const QString &qm
|
||||
emit dataChanged(index(matSectionIdx, 0), index(matSectionIdx, 0));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
@@ -71,6 +71,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