Wallpaper API changes:
- modes -> renderingModes - remove modeName & modeIcon - add config group to init for reading config - add save for config saving Update containment for api changes. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849801
This commit is contained in:
parent
3f368be2c1
commit
0a2eb79e61
@ -249,12 +249,19 @@ void Containment::restore(KConfigGroup &group)
|
||||
setContext(group.readEntry("context", QString()));
|
||||
|
||||
flushPendingConstraintsEvents();
|
||||
//kDebug() << "Containment" << id() << "geometry is" << geometry() << "config'd with" << appletConfig.name();
|
||||
restoreContents(group);
|
||||
setImmutability((ImmutabilityType)group.readEntry("immutability", (int)Mutable));
|
||||
|
||||
setWallpaper(group.readEntry("wallpaperplugin", QString()),
|
||||
group.readEntry("wallpaperpluginmode", QString()));
|
||||
setWallpaper(group.readEntry("wallpaperplugin", "image"),
|
||||
group.readEntry("wallpaperpluginmode", "SingleImage"));
|
||||
/*
|
||||
kDebug() << "Containment" << id() <<
|
||||
"screen" << screen() <<
|
||||
"geometry is" << geometry() <<
|
||||
"wallpaper" << ((d->wallpaper) ? d->wallpaper->pluginName() : QString()) <<
|
||||
"wallpaper mode" << wallpaperMode() <<
|
||||
"config entries" << group.entryMap();
|
||||
*/
|
||||
}
|
||||
|
||||
void Containment::save(KConfigGroup &g) const
|
||||
@ -1027,6 +1034,14 @@ void Containment::removeAssociatedWidget(QWidget *widget)
|
||||
void Containment::setDrawWallpaper(bool drawWallpaper)
|
||||
{
|
||||
d->drawWallpaper = drawWallpaper;
|
||||
if (d->drawWallpaper) {
|
||||
KConfigGroup cfg = config();
|
||||
setWallpaper(cfg.readEntry("wallpaperplugin", "image"),
|
||||
cfg.readEntry("wallpaperpluginmode", "SingleImage"));
|
||||
} else if (!d->drawWallpaper && d->wallpaper) {
|
||||
delete d->wallpaper;
|
||||
d->wallpaper = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool Containment::drawWallpaper()
|
||||
@ -1036,20 +1051,26 @@ bool Containment::drawWallpaper()
|
||||
|
||||
void Containment::setWallpaper(const QString &pluginName, const QString &mode)
|
||||
{
|
||||
delete d->wallpaper;
|
||||
if (!pluginName.isEmpty()) {
|
||||
d->wallpaper = Plasma::Wallpaper::load(pluginName);
|
||||
setDrawWallpaper(d->wallpaper != 0);
|
||||
KConfigGroup cfg = config();
|
||||
|
||||
if (d->drawWallpaper) {
|
||||
if (d->wallpaper && d->wallpaper->pluginName() != pluginName) {
|
||||
delete d->wallpaper;
|
||||
d->wallpaper = 0;
|
||||
}
|
||||
if (!pluginName.isEmpty() && !d->wallpaper) {
|
||||
d->wallpaper = Plasma::Wallpaper::load(pluginName);
|
||||
}
|
||||
if (d->wallpaper) {
|
||||
d->wallpaper->setBoundingRect(geometry());
|
||||
d->wallpaper->init(mode);
|
||||
d->wallpaper->init(KConfigGroup(&cfg, "Wallpaper"), mode);
|
||||
connect(d->wallpaper, SIGNAL(update(const QRectF&)),
|
||||
this, SLOT(updateRect(const QRectF&)));
|
||||
}
|
||||
} else {
|
||||
d->wallpaper = 0;
|
||||
setDrawWallpaper(false);
|
||||
update();
|
||||
}
|
||||
cfg.writeEntry("wallpaperplugin", pluginName);
|
||||
cfg.writeEntry("wallpaperpluginmode", mode);
|
||||
}
|
||||
|
||||
Plasma::Wallpaper* Containment::wallpaper() const
|
||||
@ -1057,6 +1078,12 @@ Plasma::Wallpaper* Containment::wallpaper() const
|
||||
return d->wallpaper;
|
||||
}
|
||||
|
||||
QString Containment::wallpaperMode() const
|
||||
{
|
||||
KConfigGroup cfg = config();
|
||||
return cfg.readEntry("wallpaperpluginmode", QString());
|
||||
}
|
||||
|
||||
void Containment::setContext(const QString &context)
|
||||
{
|
||||
if (d->context != context) {
|
||||
@ -1149,6 +1176,8 @@ void Containment::destroy()
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO For desktop containment change we need to remove containment so do we need these?
|
||||
#if 0
|
||||
if (isContainment()) {
|
||||
//don't remove a desktop that's in use
|
||||
//FIXME allow removal of containments for screens that don't currently exist
|
||||
@ -1165,8 +1194,9 @@ void Containment::destroy()
|
||||
Applet::destroy();
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
Applet::destroy();
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -1415,14 +1445,14 @@ void ContainmentPrivate::appletDestroyed(QObject* object)
|
||||
if (focusedApplet == applet) {
|
||||
focusedApplet = 0;
|
||||
}
|
||||
|
||||
|
||||
foreach (AppletHandle* handle, handles) {
|
||||
if (handles.contains(applet)) {
|
||||
handles.remove(handle->applet());
|
||||
handle->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
emit q->appletRemoved(applet);
|
||||
emit q->configNeedsSaving();
|
||||
}
|
||||
|
@ -275,11 +275,6 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void removeAssociatedWidget(QWidget *widget);
|
||||
|
||||
/**
|
||||
* Sets whether wallpaper is painted or not.
|
||||
*/
|
||||
void setDrawWallpaper(bool drawWallpaper);
|
||||
|
||||
/**
|
||||
* Return whether wallpaper is painted or not.
|
||||
*/
|
||||
@ -300,6 +295,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
Plasma::Wallpaper* wallpaper() const;
|
||||
|
||||
/**
|
||||
* Return wallpaper mode.
|
||||
*/
|
||||
QString wallpaperMode() const;
|
||||
|
||||
/**
|
||||
* Sets the current context
|
||||
*
|
||||
@ -365,6 +365,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void focusRequested(Plasma::Containment *containment);
|
||||
|
||||
/**
|
||||
* Emitted when the user wants to configure/change containment.
|
||||
*/
|
||||
void configureRequested();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Informs the Corona as to what position it is in. This is informational
|
||||
@ -410,6 +415,11 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void setContainmentType(Containment::Type type);
|
||||
|
||||
/**
|
||||
* Sets whether wallpaper is painted or not.
|
||||
*/
|
||||
void setDrawWallpaper(bool drawWallpaper);
|
||||
|
||||
/**
|
||||
* Called when the contents of the containment should be saved. By default this saves
|
||||
* all loaded Applets
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
toolBox(0),
|
||||
type(Containment::NoContainmentType),
|
||||
positioning(false),
|
||||
drawWallpaper(false)
|
||||
drawWallpaper(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -141,32 +141,12 @@ QString Wallpaper::pluginName() const
|
||||
return d->wallpaperDescription.pluginName();
|
||||
}
|
||||
|
||||
QStringList Wallpaper::modes() const
|
||||
QList<KServiceAction> Wallpaper::renderingModes() const
|
||||
{
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QStringList();
|
||||
return QList<KServiceAction>();
|
||||
}
|
||||
return d->wallpaperDescription.property("Actions").toStringList();
|
||||
}
|
||||
|
||||
QString Wallpaper::modeName(const QString& mode) const
|
||||
{
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QString();
|
||||
}
|
||||
KConfigGroup wallpaperCfg = d->wallpaperDescription.config();
|
||||
KConfigGroup cfg(&wallpaperCfg, QString("Desktop Action %1").arg(mode));
|
||||
return cfg.readEntry("Name");
|
||||
}
|
||||
|
||||
QString Wallpaper::modeIcon(const QString& mode) const
|
||||
{
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QString();
|
||||
}
|
||||
KConfigGroup wallpaperCfg = d->wallpaperDescription.config();
|
||||
KConfigGroup cfg(&wallpaperCfg, QString("Desktop Action %1").arg(mode));
|
||||
return cfg.readEntry("Icon");
|
||||
return d->wallpaperDescription.service()->actions();
|
||||
}
|
||||
|
||||
QRectF Wallpaper::boundingRect() const
|
||||
@ -179,11 +159,17 @@ void Wallpaper::setBoundingRect(const QRectF& boundingRect)
|
||||
d->boundingRect = boundingRect;
|
||||
}
|
||||
|
||||
void Wallpaper::init(const QString &mode)
|
||||
void Wallpaper::init(const KConfigGroup &config, const QString &mode)
|
||||
{
|
||||
Q_UNUSED(config);
|
||||
Q_UNUSED(mode);
|
||||
}
|
||||
|
||||
void Wallpaper::save(KConfigGroup config)
|
||||
{
|
||||
Q_UNUSED(config);
|
||||
}
|
||||
|
||||
QWidget *Wallpaper::createConfigurationInterface(QWidget *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
26
wallpaper.h
26
wallpaper.h
@ -52,7 +52,8 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
|
||||
Q_PROPERTY(QString name READ name)
|
||||
Q_PROPERTY(QString pluginName READ pluginName)
|
||||
Q_PROPERTY(QStringList modes READ modes)
|
||||
Q_PROPERTY(QString icon READ icon)
|
||||
Q_PROPERTY(QList<KServiceAction> renderingModes READ renderingModes)
|
||||
Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
|
||||
|
||||
public:
|
||||
@ -113,17 +114,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
* Returns modes the wallpaper has, as specified in the
|
||||
* .desktop file.
|
||||
*/
|
||||
QStringList modes() const;
|
||||
|
||||
/**
|
||||
* Returns the translted name for the mode.
|
||||
*/
|
||||
QString modeName(const QString& mode) const;
|
||||
|
||||
/**
|
||||
* Returns icon for the mode.
|
||||
*/
|
||||
QString modeIcon(const QString& mode) const;
|
||||
QList<KServiceAction> renderingModes() const;
|
||||
|
||||
/**
|
||||
* Returns bounding rectangle
|
||||
@ -144,11 +135,18 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
virtual void paint(QPainter *painter, const QRectF& exposedRect) = 0;
|
||||
|
||||
/**
|
||||
* This method is called once the wallpaper is loaded.
|
||||
* This method is called once the wallpaper is loaded or mode is changed.
|
||||
* @param config Config group to load settings
|
||||
* @param mode One of the modes supported by the plugin,
|
||||
* or an empty string for the default mode.
|
||||
**/
|
||||
virtual void init(const QString &mode = QString());
|
||||
virtual void init(const KConfigGroup &config, const QString &mode = QString());
|
||||
|
||||
/**
|
||||
* This method is called when settings need to be saved.
|
||||
* @param config Config group to save settings
|
||||
**/
|
||||
virtual void save(KConfigGroup config);
|
||||
|
||||
/**
|
||||
* Returns widget for configuration dialog.
|
||||
|
Loading…
Reference in New Issue
Block a user