Make WallpaperInterface use the suggested async object loading API
Just asks QmlObject to create an object and waits for QmlObject::finished signal to acquire it. REVIEW: 121148
This commit is contained in:
parent
7c65143e12
commit
fe0d60cfca
@ -124,6 +124,7 @@ void WallpaperInterface::syncWallpaperPackage()
|
|||||||
m_qmlObject = new KDeclarative::QmlObject(this);
|
m_qmlObject = new KDeclarative::QmlObject(this);
|
||||||
s_rootObjects[m_qmlObject->engine()] = this;
|
s_rootObjects[m_qmlObject->engine()] = this;
|
||||||
m_qmlObject->setInitializationDelayed(true);
|
m_qmlObject->setInitializationDelayed(true);
|
||||||
|
connect(m_qmlObject, &KDeclarative::QmlObject::finished, this, &WallpaperInterface::loadFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_actions->clear();
|
m_actions->clear();
|
||||||
@ -145,7 +146,10 @@ void WallpaperInterface::syncWallpaperPackage()
|
|||||||
m_qmlObject->setSource(QUrl::fromLocalFile(m_pkg.filePath("mainscript")));
|
m_qmlObject->setSource(QUrl::fromLocalFile(m_pkg.filePath("mainscript")));
|
||||||
m_qmlObject->engine()->rootContext()->setContextProperty("wallpaper", this);
|
m_qmlObject->engine()->rootContext()->setContextProperty("wallpaper", this);
|
||||||
m_qmlObject->completeInitialization();
|
m_qmlObject->completeInitialization();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WallpaperInterface::loadFinished()
|
||||||
|
{
|
||||||
if (m_qmlObject->mainComponent() &&
|
if (m_qmlObject->mainComponent() &&
|
||||||
m_qmlObject->rootObject() &&
|
m_qmlObject->rootObject() &&
|
||||||
!m_qmlObject->mainComponent()->isError()) {
|
!m_qmlObject->mainComponent()->isError()) {
|
||||||
|
@ -96,6 +96,7 @@ Q_SIGNALS:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void syncWallpaperPackage();
|
void syncWallpaperPackage();
|
||||||
void executeAction(const QString &name);
|
void executeAction(const QString &name);
|
||||||
|
void loadFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_wallpaperPlugin;
|
QString m_wallpaperPlugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user