diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 249b1092b..a761b1838 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -36,6 +36,7 @@ #include #include +#include "kdeclarative/configpropertymap.h" ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) : AppletInterface(parent), @@ -167,9 +168,7 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) void ContainmentInterface::loadWallpaper() { if (m_appletScriptEngine->drawWallpaper()) { - if (m_wallpaperInterface || containment()->wallpaper().isEmpty()) { - return; - } + delete m_wallpaperInterface; m_wallpaperInterface = new WallpaperInterface(this); m_wallpaperInterface->setZ(-1000); @@ -181,6 +180,7 @@ void ContainmentInterface::loadWallpaper() QQmlProperty prop(m_wallpaperInterface, "anchors.fill"); prop.write(expr.evaluate()); + containment()->setProperty("wallpaperGraphicsObject", QVariant::fromValue(m_wallpaperInterface)); } else { if (m_wallpaperInterface) { m_wallpaperInterface->deleteLater(); diff --git a/src/shell/containmentconfigview.cpp b/src/shell/containmentconfigview.cpp index b26a70bfa..fd7af31fa 100644 --- a/src/shell/containmentconfigview.cpp +++ b/src/shell/containmentconfigview.cpp @@ -39,7 +39,8 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow : ConfigView(cont, parent), m_containment(cont), m_wallpaperConfigModel(0), - m_currentWallpaperConfig(0) + m_currentWallpaperConfig(0), + m_ownWallpaperConfig(0) { engine()->rootContext()->setContextProperty("configDialog", this); setCurrentWallpaper(cont->containment()->wallpaper()); @@ -50,7 +51,8 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow QFile file(pkg.filePath("config", "main.xml")); KConfigGroup cfg = m_containment->config(); cfg = KConfigGroup(&cfg, "Wallpaper"); - m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this); + + syncWallpaperObjects(); } ContainmentConfigView::~ContainmentConfigView() @@ -113,13 +115,12 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper) return; } + delete m_ownWallpaperConfig; + m_ownWallpaperConfig = 0; + if (m_containment->wallpaper() == wallpaper) { - delete m_currentWallpaperConfig; - m_currentWallpaperConfig = m_ownWallpaperConfig; + syncWallpaperObjects(); } else { - if (m_containment->wallpaper() != m_currentWallpaper) { - delete m_currentWallpaperConfig; - } //we have to construct an independent ConfigPropertyMap when we want to configure wallpapers that are not the current one Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); @@ -128,7 +129,7 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper) QFile file(pkg.filePath("config", "main.xml")); KConfigGroup cfg = m_containment->config(); cfg = KConfigGroup(&cfg, "Wallpaper"); - m_currentWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this); + m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this); } m_currentWallpaper = wallpaper; @@ -140,12 +141,20 @@ void ContainmentConfigView::applyWallpaper() { m_containment->setWallpaper(m_currentWallpaper); - if (m_currentWallpaperConfig != m_ownWallpaperConfig) { - delete m_currentWallpaperConfig; - m_currentWallpaperConfig = m_ownWallpaperConfig; - emit wallpaperConfigurationChanged(); - } + delete m_ownWallpaperConfig; + m_ownWallpaperConfig = 0; + + syncWallpaperObjects(); + emit wallpaperConfigurationChanged(); } +void ContainmentConfigView::syncWallpaperObjects() +{ + QObject *wallpaperGraphicsObject = m_containment->property("wallpaperGraphicsObject").value(); + engine()->rootContext()->setContextProperty("wallpaper", wallpaperGraphicsObject); + + //FIXME: why m_wallpaperGraphicsObject->property("configuration").value() doesn't work? + m_currentWallpaperConfig = static_cast(wallpaperGraphicsObject->property("configuration").value()); +} #include "moc_containmentconfigview.cpp" diff --git a/src/shell/containmentconfigview.h b/src/shell/containmentconfigview.h index 19f719c4a..b753d418b 100644 --- a/src/shell/containmentconfigview.h +++ b/src/shell/containmentconfigview.h @@ -54,6 +54,9 @@ Q_SIGNALS: void currentWallpaperChanged(); void wallpaperConfigurationChanged(); +protected: + void syncWallpaperObjects(); + private: Plasma::Containment *m_containment; ConfigModel *m_wallpaperConfigModel;