diff --git a/src/scriptengines/qml/plasmoid/configview.cpp b/src/scriptengines/qml/plasmoid/configview.cpp index 5dbd478e2..072e74c70 100644 --- a/src/scriptengines/qml/plasmoid/configview.cpp +++ b/src/scriptengines/qml/plasmoid/configview.cpp @@ -19,6 +19,8 @@ #include "configview.h" #include "plasmoid/appletinterface.h" +#include "plasmoid/containmentinterface.h" +#include "plasmoid/wallpaperinterface.h" #include #include @@ -314,6 +316,15 @@ ConfigModel *ConfigView::wallpaperConfigModel() return m_wallpaperConfigModel; } +QObject *ConfigView::wallpaperConfiguration() const +{ + ContainmentInterface *cont = qobject_cast(m_appletInterface); + if (cont) { + return cont->wallpaperInterface()->configuration(); + } + return 0; +} + //To emulate Qt::WA_DeleteOnClose that QWindow doesn't have void ConfigView::hideEvent(QHideEvent *ev) { diff --git a/src/scriptengines/qml/plasmoid/configview.h b/src/scriptengines/qml/plasmoid/configview.h index ab42fb191..532d640ec 100644 --- a/src/scriptengines/qml/plasmoid/configview.h +++ b/src/scriptengines/qml/plasmoid/configview.h @@ -102,11 +102,15 @@ private: QWeakPointer m_appletInterface; }; + +//TODO: the config view for the containment should be a subclass +//TODO: is it possible to move this in the shell? class ConfigView : public QQuickView { Q_OBJECT Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT) Q_PROPERTY(ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT) + Q_PROPERTY(QObject *wallpaperConfiguration READ wallpaperConfiguration CONSTANT) public: ConfigView(AppletInterface *scriptEngine, QWindow *parent = 0); @@ -114,6 +118,7 @@ public: ConfigModel *configModel() const; ConfigModel *wallpaperConfigModel(); + QObject *wallpaperConfiguration() const; protected: void hideEvent(QHideEvent *ev); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 7ee26fd64..4421dada6 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -61,7 +61,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent) connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged, this, &ContainmentInterface::availableScreenRegionChanged); } - loadWallpaper(); } QList ContainmentInterface::applets() @@ -163,11 +162,12 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet) void ContainmentInterface::loadWallpaper() { if (m_appletScriptEngine->drawWallpaper()) { - if (m_wallpaperInterface) { + if (m_wallpaperInterface || containment()->wallpaper().isEmpty()) { return; } m_wallpaperInterface = new WallpaperInterface(this); + m_wallpaperInterface->setZ(-1000); //Qml seems happier if the parent gets set in this way m_wallpaperInterface->setProperty("parent", QVariant::fromValue(this)); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.h b/src/scriptengines/qml/plasmoid/containmentinterface.h index 227d8432b..8243c2f8b 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.h +++ b/src/scriptengines/qml/plasmoid/containmentinterface.h @@ -50,9 +50,12 @@ public: CustomPanelContainment = 128 /**< A customized desktop panel */ }; ContainmentInterface(DeclarativeAppletScript *parent); - +//Not for QML inline Plasma::Containment *containment() const { return static_cast(m_appletScriptEngine->applet()); } + inline WallpaperInterface *wallpaperInterface() const { return m_wallpaperInterface;} + +//For QML use QList applets(); void setDrawWallpaper(bool drawWallpaper); diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 8c9c250f4..caf278b8c 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -35,7 +35,8 @@ WallpaperInterface::WallpaperInterface(ContainmentInterface *parent) : QQuickItem(parent), m_containmentInterface(parent), m_qmlObject(0), - m_configLoader(0) + m_configLoader(0), + m_configuration(0) { connect(m_containmentInterface->containment(), &Plasma::Containment::wallpaperChanged, this, &WallpaperInterface::syncWallpaperPackage); @@ -60,7 +61,8 @@ QObject* WallpaperInterface::configuration() const Plasma::ConfigLoader *WallpaperInterface::configScheme() { if (!m_configLoader) { - const QString xmlPath = m_pkg.filePath("mainconfigxml"); + //FIXME: do we need "mainconfigxml" in wallpaper packagestructures? + const QString xmlPath = m_pkg.filePath("config", "main.xml"); KConfigGroup cfg = m_containmentInterface->containment()->config(); cfg = KConfigGroup(&cfg, "Wallpaper"); @@ -87,6 +89,8 @@ void WallpaperInterface::syncWallpaperPackage() m_pkg.setDefaultPackageRoot("plasma/wallpapers"); m_pkg.setPath(m_containmentInterface->containment()->wallpaper()); + m_configLoader->deleteLater(); + m_configuration->deleteLater(); if (configScheme()) { m_configuration = new ConfigPropertyMap(configScheme(), this); } @@ -116,6 +120,7 @@ void WallpaperInterface::syncWallpaperPackage() } emit packageChanged(); + emit configurationChanged(); } #include "moc_wallpaperinterface.cpp" diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.h b/src/scriptengines/qml/plasmoid/wallpaperinterface.h index d7b9814e0..59aa1cabd 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.h +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.h @@ -37,7 +37,7 @@ class WallpaperInterface : public QQuickItem Q_OBJECT //Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) - Q_PROPERTY(QObject* configuration READ configuration CONSTANT) + Q_PROPERTY(QObject* configuration READ configuration NOTIFY configurationChanged) public: WallpaperInterface(ContainmentInterface *parent = 0); @@ -51,6 +51,7 @@ public: Q_SIGNALS: void packageChanged(); + void configurationChanged(); private Q_SLOTS: void syncWallpaperPackage(); diff --git a/src/shell/qmlpackages/wallpaper/contents/ui/config.qml b/src/shell/qmlpackages/wallpaper/contents/ui/config.qml index 37664d547..8060e698b 100644 --- a/src/shell/qmlpackages/wallpaper/contents/ui/config.qml +++ b/src/shell/qmlpackages/wallpaper/contents/ui/config.qml @@ -17,8 +17,15 @@ */ import QtQuick 2.0 +import org.kde.plasma.components 0.1 as PlasmaComponents -Text { +Row { id: root - text: "Image wallpaper configuration module" + PlasmaComponents.Label { + text: "Color" + } + PlasmaComponents.TextField { + text: configDialog.wallpaperConfiguration.Color + onTextChanged: configDialog.wallpaperConfiguration.Color = text + } } \ No newline at end of file diff --git a/src/shell/qmlpackages/wallpaper/contents/ui/main.qml b/src/shell/qmlpackages/wallpaper/contents/ui/main.qml index 567263916..fa8a756bf 100644 --- a/src/shell/qmlpackages/wallpaper/contents/ui/main.qml +++ b/src/shell/qmlpackages/wallpaper/contents/ui/main.qml @@ -18,6 +18,7 @@ import QtQuick 2.0 + Rectangle { id: root color: wallpaper.configuration.Color