expose the wallpaper config to the config ui
there is still a serious problem: it is possible to configure only the currently loaded wallpaper plugin
This commit is contained in:
parent
f5664e8b3f
commit
7064d02e1a
@ -19,6 +19,8 @@
|
||||
|
||||
#include "configview.h"
|
||||
#include "plasmoid/appletinterface.h"
|
||||
#include "plasmoid/containmentinterface.h"
|
||||
#include "plasmoid/wallpaperinterface.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@ -314,6 +316,15 @@ ConfigModel *ConfigView::wallpaperConfigModel()
|
||||
return m_wallpaperConfigModel;
|
||||
}
|
||||
|
||||
QObject *ConfigView::wallpaperConfiguration() const
|
||||
{
|
||||
ContainmentInterface *cont = qobject_cast<ContainmentInterface *>(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)
|
||||
{
|
||||
|
@ -102,11 +102,15 @@ private:
|
||||
QWeakPointer<AppletInterface> 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);
|
||||
|
@ -61,7 +61,6 @@ ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
||||
connect(containment()->corona(), &Plasma::Corona::availableScreenRegionChanged,
|
||||
this, &ContainmentInterface::availableScreenRegionChanged);
|
||||
}
|
||||
loadWallpaper();
|
||||
}
|
||||
|
||||
QList <QObject *> 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));
|
||||
|
||||
|
@ -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<Plasma::Containment *>(m_appletScriptEngine->applet()); }
|
||||
|
||||
inline WallpaperInterface *wallpaperInterface() const { return m_wallpaperInterface;}
|
||||
|
||||
//For QML use
|
||||
QList<QObject *> applets();
|
||||
|
||||
void setDrawWallpaper(bool drawWallpaper);
|
||||
|
@ -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"
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
color: wallpaper.configuration.Color
|
||||
|
Loading…
Reference in New Issue
Block a user