export drawWallpaper and ContainmentType

export in AppletScript drawWallpaper and ContainmentType:
it's the only way to make them settable by scripted JS/QML containments
This commit is contained in:
Marco Martin 2011-02-22 13:21:33 +01:00
parent 56a7b2e5df
commit 0abb1cfd6e
3 changed files with 69 additions and 0 deletions

View File

@ -541,6 +541,7 @@ Q_SIGNALS:
void configChanged();
protected:
//FIXME plasma2: those should be public to allow scripted containments access them
/**
* Sets the type of this containment.
*/
@ -659,6 +660,7 @@ Q_SIGNALS:
friend class Applet;
friend class AppletPrivate;
friend class AppletScript;
friend class CoronaPrivate;
friend class ContainmentPrivate;
friend class ContainmentActions;

View File

@ -255,6 +255,46 @@ Extender *AppletScript::extender() const
return d->applet->extender();
}
bool AppletScript::drawWallpaper() const
{
Q_ASSERT(d->applet);
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
if (cont) {
return cont->drawWallpaper();
} else {
return false;
}
}
void AppletScript::setDrawWallpaper(bool drawWallpaper)
{
Q_ASSERT(d->applet);
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
if (cont) {
cont->setDrawWallpaper(drawWallpaper);
}
}
Containment::Type AppletScript::containmentType() const
{
Q_ASSERT(d->applet);
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
if (cont) {
return cont->containmentType();
} else {
return Containment::NoContainmentType;
}
}
void AppletScript::setContainmentType(Containment::Type type)
{
Q_ASSERT(d->applet);
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(d->applet);
if (cont) {
cont->setContainmentType(type);
}
}
} // Plasma namespace
#include "appletscript.moc"

View File

@ -27,6 +27,7 @@
#include <kgenericfactory.h>
#include <kplugininfo.h>
#include <plasma/containment.h>
#include <plasma/plasma_export.h>
#include <plasma/scripting/scriptengine.h>
@ -143,6 +144,32 @@ public:
*/
Extender *extender() const;
//FIXME plasma2: setWallpaperEnabled and setContainmentType should become public?
/**
* @return true if the applet is a containment AND if the wallpaper is enabled
* @see Containment
* @since 4.7
*/
bool drawWallpaper() const;
/**
* set if the containment draws its own wallpaper: it has no effect if the applet is not a containment
* @see Containment
* @since 4.7
*/
void setDrawWallpaper(bool drawWallpaper);
/**
* @see Containment
* @since 4.7
*/
Containment::Type containmentType() const;
/**
* @see Containment
* @since 4.7
*/
void setContainmentType(Containment::Type type);
Q_SIGNALS:
/**
* @see Applet