fix the wallpaper configuration
still pretty hacky, makes a lot of assumptions about the scriptengine object hyerarchy and for some reason digging a ConfigPropertyMap out of a qvariant doesn't work properly
This commit is contained in:
parent
3d290decd2
commit
f9436999d9
@ -36,6 +36,7 @@
|
|||||||
#include <Plasma/Package>
|
#include <Plasma/Package>
|
||||||
#include <Plasma/PluginLoader>
|
#include <Plasma/PluginLoader>
|
||||||
|
|
||||||
|
#include "kdeclarative/configpropertymap.h"
|
||||||
|
|
||||||
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
ContainmentInterface::ContainmentInterface(DeclarativeAppletScript *parent)
|
||||||
: AppletInterface(parent),
|
: AppletInterface(parent),
|
||||||
@ -167,9 +168,7 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
|
|||||||
void ContainmentInterface::loadWallpaper()
|
void ContainmentInterface::loadWallpaper()
|
||||||
{
|
{
|
||||||
if (m_appletScriptEngine->drawWallpaper()) {
|
if (m_appletScriptEngine->drawWallpaper()) {
|
||||||
if (m_wallpaperInterface || containment()->wallpaper().isEmpty()) {
|
delete m_wallpaperInterface;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_wallpaperInterface = new WallpaperInterface(this);
|
m_wallpaperInterface = new WallpaperInterface(this);
|
||||||
m_wallpaperInterface->setZ(-1000);
|
m_wallpaperInterface->setZ(-1000);
|
||||||
@ -181,6 +180,7 @@ void ContainmentInterface::loadWallpaper()
|
|||||||
QQmlProperty prop(m_wallpaperInterface, "anchors.fill");
|
QQmlProperty prop(m_wallpaperInterface, "anchors.fill");
|
||||||
prop.write(expr.evaluate());
|
prop.write(expr.evaluate());
|
||||||
|
|
||||||
|
containment()->setProperty("wallpaperGraphicsObject", QVariant::fromValue(m_wallpaperInterface));
|
||||||
} else {
|
} else {
|
||||||
if (m_wallpaperInterface) {
|
if (m_wallpaperInterface) {
|
||||||
m_wallpaperInterface->deleteLater();
|
m_wallpaperInterface->deleteLater();
|
||||||
|
@ -39,7 +39,8 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow
|
|||||||
: ConfigView(cont, parent),
|
: ConfigView(cont, parent),
|
||||||
m_containment(cont),
|
m_containment(cont),
|
||||||
m_wallpaperConfigModel(0),
|
m_wallpaperConfigModel(0),
|
||||||
m_currentWallpaperConfig(0)
|
m_currentWallpaperConfig(0),
|
||||||
|
m_ownWallpaperConfig(0)
|
||||||
{
|
{
|
||||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
engine()->rootContext()->setContextProperty("configDialog", this);
|
||||||
setCurrentWallpaper(cont->containment()->wallpaper());
|
setCurrentWallpaper(cont->containment()->wallpaper());
|
||||||
@ -50,7 +51,8 @@ ContainmentConfigView::ContainmentConfigView(Plasma::Containment *cont, QWindow
|
|||||||
QFile file(pkg.filePath("config", "main.xml"));
|
QFile file(pkg.filePath("config", "main.xml"));
|
||||||
KConfigGroup cfg = m_containment->config();
|
KConfigGroup cfg = m_containment->config();
|
||||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
cfg = KConfigGroup(&cfg, "Wallpaper");
|
||||||
m_currentWallpaperConfig = m_ownWallpaperConfig = new ConfigPropertyMap(new Plasma::ConfigLoader(&cfg, &file), this);
|
|
||||||
|
syncWallpaperObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainmentConfigView::~ContainmentConfigView()
|
ContainmentConfigView::~ContainmentConfigView()
|
||||||
@ -113,13 +115,12 @@ void ContainmentConfigView::setCurrentWallpaper(const QString &wallpaper)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete m_ownWallpaperConfig;
|
||||||
|
m_ownWallpaperConfig = 0;
|
||||||
|
|
||||||
if (m_containment->wallpaper() == wallpaper) {
|
if (m_containment->wallpaper() == wallpaper) {
|
||||||
delete m_currentWallpaperConfig;
|
syncWallpaperObjects();
|
||||||
m_currentWallpaperConfig = m_ownWallpaperConfig;
|
|
||||||
} else {
|
} 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
|
//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");
|
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"));
|
QFile file(pkg.filePath("config", "main.xml"));
|
||||||
KConfigGroup cfg = m_containment->config();
|
KConfigGroup cfg = m_containment->config();
|
||||||
cfg = KConfigGroup(&cfg, "Wallpaper");
|
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;
|
m_currentWallpaper = wallpaper;
|
||||||
@ -140,12 +141,20 @@ void ContainmentConfigView::applyWallpaper()
|
|||||||
{
|
{
|
||||||
m_containment->setWallpaper(m_currentWallpaper);
|
m_containment->setWallpaper(m_currentWallpaper);
|
||||||
|
|
||||||
if (m_currentWallpaperConfig != m_ownWallpaperConfig) {
|
delete m_ownWallpaperConfig;
|
||||||
delete m_currentWallpaperConfig;
|
m_ownWallpaperConfig = 0;
|
||||||
m_currentWallpaperConfig = m_ownWallpaperConfig;
|
|
||||||
|
syncWallpaperObjects();
|
||||||
emit wallpaperConfigurationChanged();
|
emit wallpaperConfigurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContainmentConfigView::syncWallpaperObjects()
|
||||||
|
{
|
||||||
|
QObject *wallpaperGraphicsObject = m_containment->property("wallpaperGraphicsObject").value<QObject *>();
|
||||||
|
engine()->rootContext()->setContextProperty("wallpaper", wallpaperGraphicsObject);
|
||||||
|
|
||||||
|
//FIXME: why m_wallpaperGraphicsObject->property("configuration").value<ConfigPropertyMap *>() doesn't work?
|
||||||
|
m_currentWallpaperConfig = static_cast<ConfigPropertyMap *>(wallpaperGraphicsObject->property("configuration").value<QObject *>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "moc_containmentconfigview.cpp"
|
#include "moc_containmentconfigview.cpp"
|
||||||
|
@ -54,6 +54,9 @@ Q_SIGNALS:
|
|||||||
void currentWallpaperChanged();
|
void currentWallpaperChanged();
|
||||||
void wallpaperConfigurationChanged();
|
void wallpaperConfigurationChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void syncWallpaperObjects();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::Containment *m_containment;
|
Plasma::Containment *m_containment;
|
||||||
ConfigModel *m_wallpaperConfigModel;
|
ConfigModel *m_wallpaperConfigModel;
|
||||||
|
Loading…
Reference in New Issue
Block a user