make the wallpaper stuff a bit more robust and integrated around configuration issues

svn path=/trunk/KDE/kdelibs/; revision=948052
This commit is contained in:
Aaron J. Seigo 2009-04-02 04:15:50 +00:00
parent 5d29960ad8
commit 04f8e295b7
3 changed files with 63 additions and 2 deletions

View File

@ -1364,6 +1364,11 @@ void Containment::setWallpaper(const QString &pluginName, const QString &mode)
} }
if (newPlugin || newMode) { if (newPlugin || newMode) {
if (newPlugin && d->wallpaper) {
connect(d->wallpaper, SIGNAL(configureRequested()), this, SLOT(configureRequested()));
connect(d->wallpaper, SIGNAL(configNeedsSaving()), this, SLOT(configNeedsSaving()));
}
emit configNeedsSaving(); emit configNeedsSaving();
} }
} }

View File

@ -36,7 +36,8 @@ public:
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) : WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) :
q(wallpaper), q(wallpaper),
wallpaperDescription(service), wallpaperDescription(service),
initialized(false) initialized(false),
needsConfig(false)
{ {
}; };
@ -48,7 +49,8 @@ public:
KPluginInfo wallpaperDescription; KPluginInfo wallpaperDescription;
QRectF boundingRect; QRectF boundingRect;
KServiceAction mode; KServiceAction mode;
bool initialized; bool initialized : 1;
bool needsConfig : 1;
}; };
Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args) Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
@ -245,6 +247,25 @@ DataEngine *Wallpaper::dataEngine(const QString &name) const
return d->dataEngine(name); return d->dataEngine(name);
} }
bool Wallpaper::configurationRequired() const
{
return d->needsConfig;
}
void Wallpaper::setConfigurationRequired(bool needsConfig, const QString &reason)
{
//TODO: implement something for reason. first, we need to decide where/how
// to communicate it to the user
Q_UNUSED(reason)
if (d->needsConfig == needsConfig) {
return;
}
d->needsConfig = needsConfig;
emit configurationRequired(needsConfig);
}
} // Plasma namespace } // Plasma namespace
#include "wallpaper.moc" #include "wallpaper.moc"

View File

@ -227,12 +227,35 @@ class PLASMA_EXPORT Wallpaper : public QObject
*/ */
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const; Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
/**
* @return true if the wallpaper currently needs to be configured,
* otherwise, false
*/
bool configurationRequired() const;
Q_SIGNALS: Q_SIGNALS:
/** /**
* This signal indicates that wallpaper needs to be repainted. * This signal indicates that wallpaper needs to be repainted.
*/ */
void update(const QRectF &exposedArea); void update(const QRectF &exposedArea);
/**
* Emitted when the user wants to configure/change the wallpaper.
*/
void configureRequested();
/**
* Emitted when the state of the wallpaper requiring configuration
* changes.
*/
void configurationRequired(bool needsConfig);
/**
* Emitted when the configuration of the wallpaper needs to be saved
* to disk.
*/
void configNeedsSaving();
protected: protected:
/** /**
* This constructor is to be used with the plugin loading systems * This constructor is to be used with the plugin loading systems
@ -253,6 +276,18 @@ class PLASMA_EXPORT Wallpaper : public QObject
**/ **/
virtual void init(const KConfigGroup &config); virtual void init(const KConfigGroup &config);
/**
* When the wallpaper needs to be configured before being usable, this
* method can be called to denote that action is required
*
* @param needsConfiguring true if the applet needs to be configured,
* or false if it doesn't
* @param reason a translated message for the user explaining that the
* applet needs configuring; this should note what needs
* to be configured
*/
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
private: private:
WallpaperPrivate *const d; WallpaperPrivate *const d;
}; };