forked from qt-creator/qt-creator
QmlDesigner: Add support for dragging textures to materials
Dragging textures to materials within material browser now works. Fixes: QDS-8552 Change-Id: I1ec0287020fe2cd347bc0db7cda9d235678e9f04 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -43,6 +43,18 @@ Rectangle {
|
||||
color: "transparent"
|
||||
visible: materialVisible
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
onEntered: (drag) => {
|
||||
drag.accepted = drag.formats[0] === "application/vnd.qtdesignstudio.texture"
|
||||
}
|
||||
|
||||
onDropped: (drag) => {
|
||||
rootView.acceptTextureDropOnMaterial(index, drag.getDataAsString(drag.keys[0]))
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
|
@@ -265,6 +265,17 @@ void MaterialBrowserWidget::acceptBundleTextureDrop()
|
||||
m_materialBrowserView->emitCustomNotification("drop_bundle_texture", {}, {}); // To ContentLibraryView
|
||||
}
|
||||
|
||||
void MaterialBrowserWidget::acceptTextureDropOnMaterial(int matIndex, const QString &texId)
|
||||
{
|
||||
ModelNode mat = m_materialBrowserModel->materialAt(matIndex);
|
||||
ModelNode tex = m_materialBrowserView->modelNodeForInternalId(texId.toInt());
|
||||
|
||||
if (mat.isValid() && tex.isValid()) {
|
||||
m_materialBrowserModel->selectMaterial(matIndex);
|
||||
m_materialBrowserView->applyTextureToMaterial({mat}, tex);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialBrowserWidget::focusMaterialSection(bool focusMatSec)
|
||||
{
|
||||
if (focusMatSec != m_materialSectionFocused) {
|
||||
|
@@ -56,6 +56,7 @@ public:
|
||||
Q_INVOKABLE void startDragTexture(int index, const QPointF &mousePos);
|
||||
Q_INVOKABLE void acceptBundleMaterialDrop();
|
||||
Q_INVOKABLE void acceptBundleTextureDrop();
|
||||
Q_INVOKABLE void acceptTextureDropOnMaterial(int matIndex, const QString &texId);
|
||||
Q_INVOKABLE void focusMaterialSection(bool focusMatSec);
|
||||
|
||||
QQuickWidget *quickWidget() const;
|
||||
|
Reference in New Issue
Block a user