Plasma
wallpaper.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PLASMA_WALLPAPER_H
00022 #define PLASMA_WALLPAPER_H
00023
00024 #include <kplugininfo.h>
00025
00026 #include <plasma/plasma.h>
00027 #include <plasma/packagestructure.h>
00028 #include <plasma/version.h>
00029
00030 namespace Plasma
00031 {
00032
00033 class DataEngine;
00034 class WallpaperPrivate;
00035
00054 class PLASMA_EXPORT Wallpaper : public QObject
00055 {
00056 Q_OBJECT
00057 Q_PROPERTY(QRectF boundingRect READ boundingRect WRITE setBoundingRect)
00058 Q_PROPERTY(QString name READ name)
00059 Q_PROPERTY(QString pluginName READ pluginName)
00060 Q_PROPERTY(QString icon READ icon)
00061 Q_PROPERTY(KServiceAction renderingMode READ renderingMode)
00062 Q_PROPERTY(QList<KServiceAction> listRenderingModes READ listRenderingModes)
00063 Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache)
00064
00065 public:
00069 enum ResizeMethod {
00070 ScaledResize ,
00071 CenteredResize ,
00072 ScaledAndCroppedResize ,
00073 TiledResize ,
00074 CenterTiledResize ,
00075 MaxpectResize
00076 };
00077 Q_ENUMS(ResizeMethod)
00078
00079
00082 explicit Wallpaper(QObject * parent = 0);
00083
00084 ~Wallpaper();
00085
00091 static KPluginInfo::List listWallpaperInfo(const QString &formFactor = QString());
00092
00104 static Wallpaper *load(const QString &name, const QVariantList &args = QVariantList());
00105
00117 static Wallpaper *load(const KPluginInfo &info, const QVariantList &args = QVariantList());
00118
00128 static PackageStructure::Ptr packageStructure(Wallpaper *paper = 0);
00129
00136 QString name() const;
00137
00141 QString pluginName() const;
00142
00146 QString icon() const;
00147
00151 KServiceAction renderingMode() const;
00152
00153
00159 void setRenderingMode(const QString &mode);
00160
00165 QList<KServiceAction> listRenderingModes() const;
00166
00170 bool isInitialized() const;
00171
00175 QRectF boundingRect() const;
00176
00180 void setBoundingRect(const QRectF &boundingRect);
00181
00188 virtual void paint(QPainter *painter, const QRectF &exposedRect) = 0;
00189
00195 void restore(const KConfigGroup &config);
00196
00201 virtual void save(KConfigGroup &config);
00202
00219 virtual QWidget *createConfigurationInterface(QWidget *parent);
00220
00227 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00228
00235 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
00236
00243 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00244
00251 virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
00252
00272 Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
00273
00279 bool configurationRequired() const;
00280
00285 bool isUsingRenderingCache() const;
00286
00297 void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod);
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 void setTargetSizeHint(const QSizeF &targetSize);
00309
00310 Q_SIGNALS:
00314 void update(const QRectF &exposedArea);
00315
00320 void configureRequested();
00321
00327 void configurationRequired(bool needsConfig);
00328
00334 void configNeedsSaving();
00335
00340 void renderCompleted(const QImage &image);
00341
00345 void renderHintsChanged();
00346
00347 protected:
00356 Wallpaper(QObject *parent, const QVariantList &args);
00357
00365 virtual void init(const KConfigGroup &config);
00366
00378 void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
00379
00393 void render(const QString &sourceImagePath, const QSize &size,
00394 Wallpaper::ResizeMethod resizeMethod = ScaledResize,
00395 const QColor &color = QColor(0, 0, 0));
00396
00407 void setUsingRenderingCache(bool useCache);
00408
00420 bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0);
00421
00435 void insertIntoCache(const QString& key, const QImage &image);
00436
00437 private:
00438 Q_PRIVATE_SLOT(d, void newRenderCompleted(const WallpaperRenderRequest &request,
00439 const QImage &image))
00440
00441 friend class WallpaperPackage;
00442 friend class WallpaperPrivate;
00443 WallpaperPrivate *const d;
00444 };
00445
00446 }
00447
00451 #define K_EXPORT_PLASMA_WALLPAPER(libname, classname) \
00452 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00453 K_EXPORT_PLUGIN(factory("plasma_wallpaper_" #libname)) \
00454 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00455
00456 #endif // multiple inclusion guard