From 18a663228f888f28a64507092fa772117351a455 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 7 Mar 2013 15:27:53 +0100 Subject: [PATCH] switch wallpaper plugins --- .../qml/plasmoid/containmentconfigview.cpp | 5 +++++ .../qml/plasmoid/containmentconfigview.h | 2 ++ .../qml/plasmoid/wallpaperinterface.cpp | 2 ++ .../ConfigurationContainmentAppearance.qml | 21 ++++++++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/scriptengines/qml/plasmoid/containmentconfigview.cpp b/src/scriptengines/qml/plasmoid/containmentconfigview.cpp index 1bd057e12..56761b3a2 100644 --- a/src/scriptengines/qml/plasmoid/containmentconfigview.cpp +++ b/src/scriptengines/qml/plasmoid/containmentconfigview.cpp @@ -117,4 +117,9 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper) emit currentWallpaperChanged(); } +void ContainmentConfigView::applyWallpaper() +{ + m_contianmentInterface->containment()->setWallpaper(m_currentWallpaper); +} + #include "moc_containmentconfigview.cpp" diff --git a/src/scriptengines/qml/plasmoid/containmentconfigview.h b/src/scriptengines/qml/plasmoid/containmentconfigview.h index 6cebaa23e..e1aa15ae3 100644 --- a/src/scriptengines/qml/plasmoid/containmentconfigview.h +++ b/src/scriptengines/qml/plasmoid/containmentconfigview.h @@ -44,6 +44,8 @@ public: void setCurrentWallpaper(const QString &wallpaper); ConfigPropertyMap *wallpaperConfiguration() const; + Q_INVOKABLE void applyWallpaper(); + Q_SIGNALS: void currentWallpaperChanged(); diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 8ec2a2ecc..ef1914093 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -91,6 +91,8 @@ void WallpaperInterface::syncWallpaperPackage() m_configLoader->deleteLater(); m_configuration->deleteLater(); + m_configLoader = 0; + m_configuration = 0; if (configScheme()) { m_configuration = new ConfigPropertyMap(configScheme(), this); } diff --git a/src/shell/qmlpackages/desktop/contents/components/ConfigurationContainmentAppearance.qml b/src/shell/qmlpackages/desktop/contents/components/ConfigurationContainmentAppearance.qml index f4cb0e8c2..12b3ce7b4 100644 --- a/src/shell/qmlpackages/desktop/contents/components/ConfigurationContainmentAppearance.qml +++ b/src/shell/qmlpackages/desktop/contents/components/ConfigurationContainmentAppearance.qml @@ -34,6 +34,7 @@ Column { configDialog.wallpaperConfiguration[key] = main.currentPage["cfg_"+key] } } + configDialog.applyWallpaper() } function restoreConfig() { @@ -65,10 +66,10 @@ Column { } width: 64 onClicked: { + configDialog.currentWallpaper = model.pluginName if (delegate.current) { return } else { - configDialog.currentWallpaper = model.pluginName main.sourceFile = model.source root.restoreConfig() } @@ -78,10 +79,28 @@ Column { categoriesView.currentIndex = index } } + Component.onCompleted: { + if (configDialog.currentWallpaper == model.pluginName) { + loadWallpaperTimer.pendingCurrent = model + loadWallpaperTimer.restart() + } + } } highlight: Rectangle { color: theme.highlightColor } + Timer { + id: loadWallpaperTimer + interval: 100 + property variant pendingCurrent + onTriggered: { + if (pendingCurrent) { + main.sourceFile = pendingCurrent.source + root.restoreConfig() + categoriesView.currentIndex = pendingCurrent.index + } + } + } } PlasmaComponents.PageStack { id: main