diff --git a/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml b/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml index acf70f0a759..571fac50002 100644 --- a/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml +++ b/share/qtcreator/qmldesigner/effectMakerQmlSources/ValueImage.qml @@ -18,7 +18,6 @@ Row { actionIndicatorVisible: false - //TODO: Disable until we figure out how to use images from outside qds - //onAbsoluteFilePathChanged: uniformValue = absoluteFilePath + onAbsoluteFilePathChanged: uniformValue = absoluteFilePath } } diff --git a/src/plugins/effectmakernew/effectmakeruniformsmodel.cpp b/src/plugins/effectmakernew/effectmakeruniformsmodel.cpp index d8aa312df5a..cfbbf3f5778 100644 --- a/src/plugins/effectmakernew/effectmakeruniformsmodel.cpp +++ b/src/plugins/effectmakernew/effectmakeruniformsmodel.cpp @@ -50,8 +50,21 @@ bool EffectMakerUniformsModel::setData(const QModelIndex &index, const QVariant return false; auto uniform = m_uniforms.at(index.row()); - uniform->setValue(value); - g_propertyData.insert(uniform->name(), value); + + if (uniform->type() == Uniform::Type::Sampler) { + QString updatedValue = value.toString(); + int idx = value.toString().indexOf("file:"); + + QString path = idx > 0 ? updatedValue.right(updatedValue.size() - idx - 5) : updatedValue; + updatedValue = QUrl::fromLocalFile(path).toString(); + + uniform->setValue(updatedValue); + g_propertyData.insert(uniform->name(), updatedValue); + } else { + uniform->setValue(value); + g_propertyData.insert(uniform->name(), value); + } + emit dataChanged(index, index, {role}); return true; diff --git a/src/plugins/effectmakernew/effectmakerwidget.cpp b/src/plugins/effectmakernew/effectmakerwidget.cpp index 0199d2eca2a..c26247fef19 100644 --- a/src/plugins/effectmakernew/effectmakerwidget.cpp +++ b/src/plugins/effectmakernew/effectmakerwidget.cpp @@ -14,6 +14,8 @@ #include "qqmlcontext.h" #include "theme.h" +#include "qmldesigner/components/propertyeditor/assetimageprovider.h" + #include #include @@ -136,6 +138,11 @@ void EffectMakerWidget::initView() m_backendModelNode.setup(m_effectMakerView->rootModelNode()); m_quickWidget->rootContext()->setContextProperty("anchorBackend", &m_backendAnchorBinding); m_quickWidget->rootContext()->setContextProperty("modelNodeBackend", &m_backendModelNode); + m_quickWidget->rootContext()->setContextProperty("activeDragSuffix", ""); + + m_quickWidget->engine()->addImageProvider("qmldesigner_thumbnails", + new QmlDesigner::AssetImageProvider( + QmlDesigner::QmlDesignerPlugin::imageCache())); // init the first load of the QML UI elements reloadQmlSource(); diff --git a/src/plugins/effectmakernew/uniform.cpp b/src/plugins/effectmakernew/uniform.cpp index a9729b574ef..c7e460e460e 100644 --- a/src/plugins/effectmakernew/uniform.cpp +++ b/src/plugins/effectmakernew/uniform.cpp @@ -12,8 +12,8 @@ namespace EffectMaker { -Uniform::Uniform(const QJsonObject &propObj, const QString &qenPath) : - m_qenPath(qenPath) +Uniform::Uniform(const QJsonObject &propObj, const QString &qenPath) + : m_qenPath(qenPath) { QString value, defaultValue, minValue, maxValue; @@ -35,9 +35,10 @@ Uniform::Uniform(const QJsonObject &propObj, const QString &qenPath) : QString mipmapProperty = mipmapPropertyName(m_name); g_propertyData[mipmapProperty] = m_enableMipmap; } + if (propObj.contains("value")) { value = propObj.value("value").toString(); - if (m_type == Type::Sampler && !value.isEmpty()) + if (m_type == Type::Sampler) value = getResourcePath(value); } else { // QEN files don't store the current value, so with those use default value diff --git a/src/plugins/effectmakernew/uniform.h b/src/plugins/effectmakernew/uniform.h index 5146de6b67c..8f14383bb4c 100644 --- a/src/plugins/effectmakernew/uniform.h +++ b/src/plugins/effectmakernew/uniform.h @@ -14,8 +14,6 @@ QT_FORWARD_DECLARE_CLASS(QVector2D) namespace EffectMaker { - - class Uniform : public QObject { Q_OBJECT diff --git a/src/plugins/qmldesigner/components/propertyeditor/assetimageprovider.h b/src/plugins/qmldesigner/components/propertyeditor/assetimageprovider.h index 450086d323d..b71543444a6 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/assetimageprovider.h +++ b/src/plugins/qmldesigner/components/propertyeditor/assetimageprovider.h @@ -4,12 +4,13 @@ #pragma once #include "imagecache/midsizeimagecacheprovider.h" +#include "qmldesigner_global.h" #include namespace QmlDesigner { -class AssetImageProvider : public QQuickAsyncImageProvider +class QMLDESIGNER_EXPORT AssetImageProvider : public QQuickAsyncImageProvider { public: AssetImageProvider(AsynchronousImageCache &imageCache, const QImage &defaultImage = {})