2008-08-05 17:27:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 by Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2008 by Petri Damsten <damu@iki.fi>
|
|
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_WALLPAPER_H
|
|
|
|
#define PLASMA_WALLPAPER_H
|
|
|
|
|
2008-08-06 03:29:21 +02:00
|
|
|
#include <KDE/KPluginInfo>
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
#include <plasma/plasma.h>
|
|
|
|
#include <plasma/version.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
class WallpaperPrivate;
|
|
|
|
|
|
|
|
/**
|
2008-08-25 19:47:48 +02:00
|
|
|
* @class Wallpaper plasma/wallpaper.h <Plasma/Wallpaper>
|
|
|
|
*
|
2008-08-05 17:27:48 +02:00
|
|
|
* @short The base Wallpaper class
|
|
|
|
*
|
|
|
|
* "Wallpapers" are components that paint the background for Containments that
|
|
|
|
* do not provide their own background rendering.
|
|
|
|
*
|
|
|
|
* Wallpaper plugins are registered using .desktop files. These files should be
|
|
|
|
* named using the following naming scheme:
|
|
|
|
*
|
|
|
|
* plasma-wallpaper-<pluginname>.desktop
|
|
|
|
*
|
|
|
|
* If a wallpaper plugin provides more than on mode (e.g. Single Image, Wallpaper)
|
|
|
|
* it should include a Actions= entry in the .desktop file, listing the possible
|
|
|
|
* actions. An actions group should be included to provide for translatable names.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PLASMA_EXPORT Wallpaper : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
|
|
|
|
Q_PROPERTY(QString name READ name)
|
2008-08-06 03:49:38 +02:00
|
|
|
Q_PROPERTY(QString pluginName READ pluginName)
|
2008-08-20 10:06:34 +02:00
|
|
|
Q_PROPERTY(QString icon READ icon)
|
2008-08-20 14:44:39 +02:00
|
|
|
Q_PROPERTY(KServiceAction renderingMode READ renderingMode)
|
|
|
|
Q_PROPERTY(QList<KServiceAction> listRenderingModes READ listRenderingModes)
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
~Wallpaper();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of all known wallpapers.
|
|
|
|
*
|
|
|
|
* @return list of wallpapers
|
|
|
|
**/
|
|
|
|
static KPluginInfo::List listWallpaperInfo(const QString &formFactor = QString());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load an wallpaper
|
|
|
|
*
|
|
|
|
* Returns a pointer to the wallpaper if successful.
|
|
|
|
* The caller takes responsibility for the wallpaper, including
|
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
|
|
|
* @param args to send the wallpaper extra arguments
|
|
|
|
* @return a pointer to the loaded wallpaper, or 0 on load failure
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
static Wallpaper *load(const QString &name, const QVariantList &args = QVariantList());
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempts to load an wallpaper
|
|
|
|
*
|
|
|
|
* Returns a pointer to the wallpaper if successful.
|
|
|
|
* The caller takes responsibility for the wallpaper, including
|
|
|
|
* deleting it when no longer needed.
|
|
|
|
*
|
|
|
|
* @param info KPluginInfo object for the desired wallpaper
|
|
|
|
* @param args to send the wallpaper extra arguments
|
|
|
|
* @return a pointer to the loaded wallpaper, or 0 on load failure
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
static Wallpaper *load(const KPluginInfo &info, const QVariantList &args = QVariantList());
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the user-visible name for the wallpaper, as specified in the
|
|
|
|
* .desktop file.
|
|
|
|
*
|
|
|
|
* @return the user-visible name for the wallpaper.
|
|
|
|
**/
|
|
|
|
QString name() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the plugin name for the wallpaper
|
|
|
|
*/
|
|
|
|
QString pluginName() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the icon related to this wallpaper
|
|
|
|
**/
|
|
|
|
QString icon() const;
|
|
|
|
|
2008-08-20 14:44:39 +02:00
|
|
|
/**
|
|
|
|
* @return the currently active rendering mode
|
|
|
|
*/
|
|
|
|
KServiceAction renderingMode() const;
|
|
|
|
|
2008-08-05 17:27:48 +02:00
|
|
|
/**
|
|
|
|
* Returns modes the wallpaper has, as specified in the
|
|
|
|
* .desktop file.
|
|
|
|
*/
|
2008-08-20 14:44:39 +02:00
|
|
|
QList<KServiceAction> listRenderingModes() const;
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns bounding rectangle
|
|
|
|
*/
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets bounding rectangle
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
void setBoundingRect(const QRectF &boundingRect);
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called when the wallpaper should be painted.
|
|
|
|
*
|
|
|
|
* @param painter the QPainter to use to do the painting
|
|
|
|
* @param exposedRect the rect to paint within
|
|
|
|
**/
|
2008-10-11 18:19:04 +02:00
|
|
|
virtual void paint(QPainter *painter, const QRectF &exposedRect) = 0;
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
2008-08-20 14:44:39 +02:00
|
|
|
* This method should be called once the wallpaper is loaded or mode is changed.
|
2008-08-20 10:06:34 +02:00
|
|
|
* @param config Config group to load settings
|
2008-08-12 15:53:58 +02:00
|
|
|
* @param mode One of the modes supported by the plugin,
|
|
|
|
* or an empty string for the default mode.
|
2008-08-20 14:44:39 +02:00
|
|
|
* @see init
|
2008-08-05 17:27:48 +02:00
|
|
|
**/
|
2008-08-20 14:44:39 +02:00
|
|
|
void restore(const KConfigGroup &config, const QString &mode = QString());
|
2008-08-20 10:06:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called when settings need to be saved.
|
|
|
|
* @param config Config group to save settings
|
|
|
|
**/
|
2008-08-20 15:11:01 +02:00
|
|
|
virtual void save(KConfigGroup &config);
|
2008-08-05 17:27:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns widget for configuration dialog.
|
|
|
|
*/
|
2008-08-05 19:37:42 +02:00
|
|
|
virtual QWidget *createConfigurationInterface(QWidget *parent);
|
2008-08-05 17:27:48 +02:00
|
|
|
|
2008-08-06 03:59:44 +02:00
|
|
|
/**
|
2008-09-03 18:46:01 +02:00
|
|
|
* Mouse move event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
2008-08-06 03:59:44 +02:00
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
|
|
/**
|
2008-09-03 18:46:01 +02:00
|
|
|
* Mouse press event. To prevent further propagation of the even,
|
|
|
|
* and to receive mouseMoveEvents, the event must be accepted.
|
2008-08-06 03:59:44 +02:00
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
|
|
|
/**
|
2008-09-03 18:46:01 +02:00
|
|
|
* Mouse release event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
2008-08-06 03:59:44 +02:00
|
|
|
*
|
|
|
|
* @param event the mouse event object
|
|
|
|
*/
|
|
|
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
|
2008-09-04 20:11:46 +02:00
|
|
|
/**
|
|
|
|
* Mouse wheel event. To prevent further propagation of the event,
|
|
|
|
* the event must be accepted.
|
|
|
|
*
|
|
|
|
* @param event the wheel event object
|
|
|
|
*/
|
2008-09-05 06:33:40 +02:00
|
|
|
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
2008-09-04 20:11:46 +02:00
|
|
|
|
2008-08-05 17:27:48 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* This signal indicates that wallpaper needs to be repainted.
|
|
|
|
*/
|
|
|
|
void update(const QRectF &exposedArea);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* This constructor is to be used with the plugin loading systems
|
|
|
|
* found in KPluginInfo and KService. The argument list is expected
|
|
|
|
* to have one element: the KService service ID for the desktop entry.
|
|
|
|
*
|
|
|
|
* @param parent a QObject parent; you probably want to pass in 0
|
|
|
|
* @param args a list of strings containing one entry: the service id
|
|
|
|
*/
|
2008-10-11 18:19:04 +02:00
|
|
|
Wallpaper(QObject *parent, const QVariantList &args);
|
2008-08-05 17:27:48 +02:00
|
|
|
|
2008-08-20 14:44:39 +02:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2008-08-05 17:27:48 +02:00
|
|
|
private:
|
2008-10-11 18:19:04 +02:00
|
|
|
WallpaperPrivate *const d;
|
2008-08-05 17:27:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register an wallpaper when it is contained in a loadable module
|
|
|
|
*/
|
|
|
|
#define K_EXPORT_PLASMA_WALLPAPER(libname, classname) \
|
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
|
|
|
K_EXPORT_PLUGIN(factory("plasma_wallpaper_" #libname)) \
|
|
|
|
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|