kwineffects: Add OffscreenQuickScene::setSource with initial properties

Signed-off-by: Eike Hein <eike.hein@mbition.io>
This commit is contained in:
Kai Uwe Broulik 2022-02-17 09:40:37 +01:00 committed by Kai Uwe Broulik
parent 19a18e4b5d
commit 0d223742ab
2 changed files with 7 additions and 1 deletions

View file

@ -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<QObject> qmlObject(d->qmlComponent->create());
QScopedPointer<QObject> qmlObject(d->qmlComponent->createWithInitialProperties(initialProperties));
QQuickItem *item = qobject_cast<QQuickItem *>(qmlObject.data());
if (!item) {
qCWarning(LIBKWINEFFECTS) << "Root object of effect quick view" << source << "is not a QQuickItem";

View file

@ -187,6 +187,7 @@ public:
QQuickItem *rootItem() const;
void setSource(const QUrl &source);
void setSource(const QUrl &source, const QVariantMap &initialProperties);
private:
class Private;