some more win32'fication to fix non-ascii filename handling
[kdelibs.git] / plasma / wallpaper.h
blob00204f97dc51e60da5220b40bdbddc3173445d9b
1 /*
2 * Copyright 2008 by Aaron Seigo <aseigo@kde.org>
3 * Copyright 2008 by Petri Damsten <damu@iki.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as
7 * published by the Free Software Foundation; either version 2, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details
15 * You should have received a copy of the GNU Library General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef PLASMA_WALLPAPER_H
22 #define PLASMA_WALLPAPER_H
24 #include <kplugininfo.h>
26 #include <plasma/plasma.h>
27 #include <plasma/version.h>
29 namespace Plasma
31 class WallpaperPrivate;
33 /**
34 * @class Wallpaper plasma/wallpaper.h <Plasma/Wallpaper>
36 * @short The base Wallpaper class
38 * "Wallpapers" are components that paint the background for Containments that
39 * do not provide their own background rendering.
41 * Wallpaper plugins are registered using .desktop files. These files should be
42 * named using the following naming scheme:
44 * plasma-wallpaper-\<pluginname\>.desktop
46 * If a wallpaper plugin provides more than on mode (e.g. Single Image, Wallpaper)
47 * it should include a Actions= entry in the .desktop file, listing the possible
48 * actions. An actions group should be included to provide for translatable names.
51 class PLASMA_EXPORT Wallpaper : public QObject
53 Q_OBJECT
54 Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
55 Q_PROPERTY(QString name READ name)
56 Q_PROPERTY(QString pluginName READ pluginName)
57 Q_PROPERTY(QString icon READ icon)
58 Q_PROPERTY(KServiceAction renderingMode READ renderingMode)
59 Q_PROPERTY(QList<KServiceAction> listRenderingModes READ listRenderingModes)
61 public:
62 ~Wallpaper();
64 /**
65 * Returns a list of all known wallpapers.
67 * @return list of wallpapers
68 **/
69 static KPluginInfo::List listWallpaperInfo(const QString &formFactor = QString());
71 /**
72 * Attempts to load an wallpaper
74 * Returns a pointer to the wallpaper if successful.
75 * The caller takes responsibility for the wallpaper, including
76 * deleting it when no longer needed.
78 * @param name the plugin name, as returned by KPluginInfo::pluginName()
79 * @param args to send the wallpaper extra arguments
80 * @return a pointer to the loaded wallpaper, or 0 on load failure
81 **/
82 static Wallpaper *load(const QString &name, const QVariantList &args = QVariantList());
84 /**
85 * Attempts to load an wallpaper
87 * Returns a pointer to the wallpaper if successful.
88 * The caller takes responsibility for the wallpaper, including
89 * deleting it when no longer needed.
91 * @param info KPluginInfo object for the desired wallpaper
92 * @param args to send the wallpaper extra arguments
93 * @return a pointer to the loaded wallpaper, or 0 on load failure
94 **/
95 static Wallpaper *load(const KPluginInfo &info, const QVariantList &args = QVariantList());
97 /**
98 * Returns the user-visible name for the wallpaper, as specified in the
99 * .desktop file.
101 * @return the user-visible name for the wallpaper.
103 QString name() const;
106 * Returns the plugin name for the wallpaper
108 QString pluginName() const;
111 * Returns the icon related to this wallpaper
113 QString icon() const;
116 * @return the currently active rendering mode
118 KServiceAction renderingMode() const;
122 * Sets the rendering mode for this wallpaper.
123 * @param mode One of the modes supported by the plugin,
124 * or an empty string for the default mode.
126 void setRenderingMode(const QString &mode);
129 * Returns modes the wallpaper has, as specified in the
130 * .desktop file.
132 QList<KServiceAction> listRenderingModes() const;
135 * @return true if initialized (usually by calling retore), false otherwise
137 bool isInitialized() const;
140 * Returns bounding rectangle
142 QRectF boundingRect() const;
145 * Sets bounding rectangle
147 void setBoundingRect(const QRectF &boundingRect);
150 * This method is called when the wallpaper should be painted.
152 * @param painter the QPainter to use to do the painting
153 * @param exposedRect the rect to paint within
155 virtual void paint(QPainter *painter, const QRectF &exposedRect) = 0;
158 * This method should be called once the wallpaper is loaded or mode is changed.
159 * @param config Config group to load settings
160 * @see init
162 void restore(const KConfigGroup &config);
165 * This method is called when settings need to be saved.
166 * @param config Config group to save settings
168 virtual void save(KConfigGroup &config);
171 * Returns widget for configuration dialog.
173 virtual QWidget *createConfigurationInterface(QWidget *parent);
176 * Mouse move event. To prevent further propagation of the event,
177 * the event must be accepted.
179 * @param event the mouse event object
181 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
184 * Mouse press event. To prevent further propagation of the even,
185 * and to receive mouseMoveEvents, the event must be accepted.
187 * @param event the mouse event object
189 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
192 * Mouse release event. To prevent further propagation of the event,
193 * the event must be accepted.
195 * @param event the mouse event object
197 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
200 * Mouse wheel event. To prevent further propagation of the event,
201 * the event must be accepted.
203 * @param event the wheel event object
205 virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
207 Q_SIGNALS:
209 * This signal indicates that wallpaper needs to be repainted.
211 void update(const QRectF &exposedArea);
213 protected:
215 * This constructor is to be used with the plugin loading systems
216 * found in KPluginInfo and KService. The argument list is expected
217 * to have one element: the KService service ID for the desktop entry.
219 * @param parent a QObject parent; you probably want to pass in 0
220 * @param args a list of strings containing one entry: the service id
222 Wallpaper(QObject *parent, const QVariantList &args);
225 * This method is called once the wallpaper is loaded or mode is changed.
227 * The mode can be retrieved using the renderMode() method.
229 * @param config Config group to load settings
231 virtual void init(const KConfigGroup &config);
233 private:
234 WallpaperPrivate *const d;
237 } // Plasma namespace
240 * Register an wallpaper when it is contained in a loadable module
242 #define K_EXPORT_PLASMA_WALLPAPER(libname, classname) \
243 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
244 K_EXPORT_PLUGIN(factory("plasma_wallpaper_" #libname)) \
245 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
247 #endif // multiple inclusion guard