* make init just take the KConfigGroup, make it protected
* introduce restore, which takes both the KConfigGroup and the mode to use and calls init; this is public and retains the save/restore symmetry seen elsewhere in the library svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=849899
This commit is contained in:
parent
b7e61e34c4
commit
fae3b85557
@ -44,6 +44,7 @@ public:
|
||||
Wallpaper *q;
|
||||
KPluginInfo wallpaperDescription;
|
||||
QRectF boundingRect;
|
||||
KServiceAction mode;
|
||||
};
|
||||
|
||||
Wallpaper::Wallpaper(QObject* parentObject, const QVariantList& args)
|
||||
@ -122,6 +123,7 @@ QString Wallpaper::name() const
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return i18n("Unknown Wallpaper");
|
||||
}
|
||||
|
||||
return d->wallpaperDescription.name();
|
||||
}
|
||||
|
||||
@ -130,6 +132,7 @@ QString Wallpaper::icon() const
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
return d->wallpaperDescription.icon();
|
||||
}
|
||||
|
||||
@ -138,14 +141,21 @@ QString Wallpaper::pluginName() const
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
return d->wallpaperDescription.pluginName();
|
||||
}
|
||||
|
||||
QList<KServiceAction> Wallpaper::renderingModes() const
|
||||
KServiceAction Wallpaper::renderingMode() const
|
||||
{
|
||||
return d->mode;
|
||||
}
|
||||
|
||||
QList<KServiceAction> Wallpaper::listRenderingModes() const
|
||||
{
|
||||
if (!d->wallpaperDescription.isValid()) {
|
||||
return QList<KServiceAction>();
|
||||
}
|
||||
|
||||
return d->wallpaperDescription.service()->actions();
|
||||
}
|
||||
|
||||
@ -159,10 +169,25 @@ void Wallpaper::setBoundingRect(const QRectF& boundingRect)
|
||||
d->boundingRect = boundingRect;
|
||||
}
|
||||
|
||||
void Wallpaper::init(const KConfigGroup &config, const QString &mode)
|
||||
void Wallpaper::restore(const KConfigGroup &config, const QString &mode)
|
||||
{
|
||||
KServiceAction modeAction;
|
||||
if (!mode.isEmpty()) {
|
||||
QList<KServiceAction> modes = listRenderingModes();
|
||||
|
||||
foreach (const KServiceAction &action, modes) {
|
||||
if (action.name() == mode) {
|
||||
modeAction = action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(config);
|
||||
}
|
||||
|
||||
void Wallpaper::init(const KConfigGroup &config)
|
||||
{
|
||||
Q_UNUSED(config);
|
||||
Q_UNUSED(mode);
|
||||
}
|
||||
|
||||
void Wallpaper::save(KConfigGroup config)
|
||||
|
24
wallpaper.h
24
wallpaper.h
@ -53,7 +53,8 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
Q_PROPERTY(QString name READ name)
|
||||
Q_PROPERTY(QString pluginName READ pluginName)
|
||||
Q_PROPERTY(QString icon READ icon)
|
||||
Q_PROPERTY(QList<KServiceAction> renderingModes READ renderingModes)
|
||||
Q_PROPERTY(KServiceAction renderingMode READ renderingMode)
|
||||
Q_PROPERTY(QList<KServiceAction> listRenderingModes READ listRenderingModes)
|
||||
Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
|
||||
|
||||
public:
|
||||
@ -110,11 +111,16 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
**/
|
||||
QString icon() const;
|
||||
|
||||
/**
|
||||
* @return the currently active rendering mode
|
||||
*/
|
||||
KServiceAction renderingMode() const;
|
||||
|
||||
/**
|
||||
* Returns modes the wallpaper has, as specified in the
|
||||
* .desktop file.
|
||||
*/
|
||||
QList<KServiceAction> renderingModes() const;
|
||||
QList<KServiceAction> listRenderingModes() const;
|
||||
|
||||
/**
|
||||
* Returns bounding rectangle
|
||||
@ -135,12 +141,13 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
virtual void paint(QPainter *painter, const QRectF& exposedRect) = 0;
|
||||
|
||||
/**
|
||||
* This method is called once the wallpaper is loaded or mode is changed.
|
||||
* 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
|
||||
**/
|
||||
virtual void init(const KConfigGroup &config, const QString &mode = QString());
|
||||
void restore(const KConfigGroup &config, const QString &mode = QString());
|
||||
|
||||
/**
|
||||
* This method is called when settings need to be saved.
|
||||
@ -191,6 +198,15 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
||||
*/
|
||||
Wallpaper(QObject* parent, const QVariantList& args);
|
||||
|
||||
/**
|
||||
* This method is called once the wallpaper is loaded or mode is changed.
|
||||
* The mode can be retrieved using the @see renderMode() method.
|
||||
* @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 KConfigGroup &config);
|
||||
|
||||
private:
|
||||
WallpaperPrivate* const d;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user