forked from qt-creator/qt-creator
QmlDesigner: Enable drag & drop in EffectComposer image fields
Fixes: QDS-13574 Change-Id: I2c5727f48306140f5d26ea21de51322b833b5c4b Reviewed-by: Marco Bubke <marco.bubke@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "effectcomposermodel.h"
|
||||
#include "effectcomposernodesmodel.h"
|
||||
#include "effectcomposerwidget.h"
|
||||
#include "studioquickwidget.h"
|
||||
|
||||
#include <designermcumanager.h>
|
||||
#include <documentmanager.h>
|
||||
@@ -234,4 +235,27 @@ void EffectComposerView::removeUnusedEffectImports()
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComposerView::highlightSupportedProperties(bool highlight, const QString &suffix)
|
||||
{
|
||||
QQmlContext *ctxObj = m_widget->quickWidget()->rootContext();
|
||||
ctxObj->setContextProperty("activeDragSuffix", suffix);
|
||||
ctxObj->setContextProperty("hasActiveDrag", highlight);
|
||||
}
|
||||
|
||||
void EffectComposerView::dragStarted(QMimeData *mimeData)
|
||||
{
|
||||
if (mimeData->hasFormat(QmlDesigner::Constants::MIME_TYPE_ASSETS)) {
|
||||
QString format = mimeData->formats()[0];
|
||||
const QString assetPath = QString::fromUtf8(mimeData->data(format)).split(',')[0];
|
||||
const QString suffix = "*." + assetPath.split('.').last().toLower();
|
||||
|
||||
highlightSupportedProperties(true, suffix);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectComposerView::dragEnded()
|
||||
{
|
||||
highlightSupportedProperties(false);
|
||||
}
|
||||
|
||||
} // namespace EffectComposer
|
||||
|
@@ -41,6 +41,11 @@ public:
|
||||
const QList<QmlDesigner::ModelNode> &lastSelectedNodeList) override;
|
||||
void nodeAboutToBeRemoved(const QmlDesigner::ModelNode &removedNode) override;
|
||||
|
||||
void dragStarted(QMimeData *mimeData) override;
|
||||
void dragEnded() override;
|
||||
|
||||
void highlightSupportedProperties(bool highlight, const QString &suffix = {});
|
||||
|
||||
private:
|
||||
void customNotification(const AbstractView *view, const QString &identifier,
|
||||
const QList<QmlDesigner::ModelNode> &nodeList, const QList<QVariant> &data) override;
|
||||
|
@@ -57,6 +57,14 @@ Uniform::Uniform(const QString &effectName, const QJsonObject &propObj, const QS
|
||||
|
||||
m_backendValue = new QmlDesigner::PropertyEditorValue(this);
|
||||
m_backendValue->setValue(value);
|
||||
|
||||
connect(m_backendValue, &QmlDesigner::PropertyEditorValue::dropCommitted,
|
||||
this, [this](const QString &dropData) {
|
||||
m_backendValue->setValue(dropData);
|
||||
auto *model = QmlDesigner::QmlDesignerPlugin::instance()
|
||||
->currentDesignDocument()->currentModel();
|
||||
model->endDrag();
|
||||
});
|
||||
}
|
||||
|
||||
Uniform::Type Uniform::type() const
|
||||
|
@@ -530,7 +530,12 @@ void PropertyEditorValue::commitDrop(const QString &dropData)
|
||||
});
|
||||
}
|
||||
|
||||
m_modelNode.view()->model()->endDrag();
|
||||
emit dropCommitted(dropData);
|
||||
|
||||
if (!m_modelNode.model())
|
||||
return;
|
||||
|
||||
m_modelNode.model()->endDrag();
|
||||
}
|
||||
|
||||
void PropertyEditorValue::openMaterialEditor(int idx)
|
||||
|
@@ -200,6 +200,7 @@ signals:
|
||||
void isValidChanged();
|
||||
void isExplicitChanged();
|
||||
void hasActiveDragChanged();
|
||||
void dropCommitted(QString dropData);
|
||||
|
||||
private:
|
||||
QStringList generateStringList(const QString &string) const;
|
||||
|
@@ -1948,6 +1948,9 @@ void Model::startDrag(std::unique_ptr<QMimeData> mimeData, const QPixmap &icon,
|
||||
|
||||
void Model::endDrag()
|
||||
{
|
||||
if (!d->drag)
|
||||
return;
|
||||
|
||||
d->notifyDragEnded();
|
||||
d->drag.reset();
|
||||
}
|
||||
|
Reference in New Issue
Block a user