prepare Wallpaper for delay init: add a setRenderingMode and an isInitialized

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=872753
This commit is contained in:
Aaron J. Seigo 2008-10-18 01:30:52 +00:00
parent 333b91acfb
commit 390f76d33a
2 changed files with 31 additions and 5 deletions

View File

@ -33,7 +33,8 @@ class WallpaperPrivate
public:
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) :
q(wallpaper),
wallpaperDescription(service)
wallpaperDescription(service),
initialized(false)
{
};
@ -45,6 +46,7 @@ public:
KPluginInfo wallpaperDescription;
QRectF boundingRect;
KServiceAction mode;
bool initialized;
};
Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
@ -164,13 +166,22 @@ QRectF Wallpaper::boundingRect() const
return d->boundingRect;
}
bool Wallpaper::isInitialized() const
{
return d->initialized;
}
void Wallpaper::setBoundingRect(const QRectF &boundingRect)
{
d->boundingRect = boundingRect;
}
void Wallpaper::restore(const KConfigGroup &config, const QString &mode)
void Wallpaper::setRenderingMode(const QString &mode)
{
if (d->mode.name() == mode) {
return;
}
d->mode = KServiceAction();
if (!mode.isEmpty()) {
QList<KServiceAction> modes = listRenderingModes();
@ -182,7 +193,11 @@ void Wallpaper::restore(const KConfigGroup &config, const QString &mode)
}
}
}
}
void Wallpaper::restore(const KConfigGroup &config)
{
d->initialized = true;
init(config);
}

View File

@ -117,12 +117,25 @@ class PLASMA_EXPORT Wallpaper : public QObject
*/
KServiceAction renderingMode() const;
/**
* Sets the rendering mode for this wallpaper.
* @param mode One of the modes supported by the plugin,
* or an empty string for the default mode.
*/
void setRenderingMode(const QString &mode);
/**
* Returns modes the wallpaper has, as specified in the
* .desktop file.
*/
QList<KServiceAction> listRenderingModes() const;
/**
* @return true if initialized (usually by calling retore), false otherwise
*/
bool isInitialized() const;
/**
* Returns bounding rectangle
*/
@ -144,11 +157,9 @@ class PLASMA_EXPORT Wallpaper : public QObject
/**
* This method should be 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.
* @see init
**/
void restore(const KConfigGroup &config, const QString &mode = QString());
void restore(const KConfigGroup &config);
/**
* This method is called when settings need to be saved.