From 0d223742ab6d42a517944b31117fb5de588b2a56 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 17 Feb 2022 09:40:37 +0100 Subject: [PATCH] kwineffects: Add OffscreenQuickScene::setSource with initial properties Signed-off-by: Eike Hein --- src/libkwineffects/kwinoffscreenquickview.cpp | 7 ++++++- src/libkwineffects/kwinoffscreenquickview.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libkwineffects/kwinoffscreenquickview.cpp b/src/libkwineffects/kwinoffscreenquickview.cpp index cdcadb14a9..acd81ec39f 100644 --- a/src/libkwineffects/kwinoffscreenquickview.cpp +++ b/src/libkwineffects/kwinoffscreenquickview.cpp @@ -624,6 +624,11 @@ OffscreenQuickScene::OffscreenQuickScene(QObject *parent, OffscreenQuickView::Ex OffscreenQuickScene::~OffscreenQuickScene() = default; void OffscreenQuickScene::setSource(const QUrl &source) +{ + setSource(source, QVariantMap()); +} + +void OffscreenQuickScene::setSource(const QUrl &source, const QVariantMap &initialProperties) { if (!d->qmlComponent) { d->qmlComponent.reset(new QQmlComponent(d->qmlEngine.data())); @@ -638,7 +643,7 @@ void OffscreenQuickScene::setSource(const QUrl &source) d->quickItem.reset(); - QScopedPointer qmlObject(d->qmlComponent->create()); + QScopedPointer qmlObject(d->qmlComponent->createWithInitialProperties(initialProperties)); QQuickItem *item = qobject_cast(qmlObject.data()); if (!item) { qCWarning(LIBKWINEFFECTS) << "Root object of effect quick view" << source << "is not a QQuickItem"; diff --git a/src/libkwineffects/kwinoffscreenquickview.h b/src/libkwineffects/kwinoffscreenquickview.h index ed42d9234e..40fa70bcfe 100644 --- a/src/libkwineffects/kwinoffscreenquickview.h +++ b/src/libkwineffects/kwinoffscreenquickview.h @@ -187,6 +187,7 @@ public: QQuickItem *rootItem() const; void setSource(const QUrl &source); + void setSource(const QUrl &source, const QVariantMap &initialProperties); private: class Private;