Plasma
wallpaperscript.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2009 by Aaron Seigo <aseigo@kde.org> 00003 * Copyright 2009 by Petri Damsten <damu@iki.fi> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Library General Public License as 00007 * published by the Free Software Foundation; either version 2, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details 00014 * 00015 * You should have received a copy of the GNU Library General Public 00016 * License along with this program; if not, write to the 00017 * Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef PLASMA_WALLPAPERSCRIPT_H 00022 #define PLASMA_WALLPAPERSCRIPT_H 00023 00024 #include <kgenericfactory.h> 00025 #include <kplugininfo.h> 00026 00027 #include <plasma/plasma_export.h> 00028 #include <plasma/scripting/scriptengine.h> 00029 #include <plasma/wallpaper.h> 00030 00031 namespace Plasma 00032 { 00033 00034 class WallpaperScriptPrivate; 00035 class Service; 00036 00042 class PLASMA_EXPORT WallpaperScript : public ScriptEngine 00043 { 00044 Q_OBJECT 00045 00046 public: 00054 explicit WallpaperScript(QObject *parent = 0); 00055 ~WallpaperScript(); 00056 00060 void setWallpaper(Wallpaper *wallpaper); 00061 00065 Wallpaper *wallpaper() const; 00066 00074 virtual void initWallpaper(const KConfigGroup &config); 00075 00082 virtual void paint(QPainter *painter, const QRectF &exposedRect); 00083 00088 virtual void save(KConfigGroup &config); 00089 00106 virtual QWidget *createConfigurationInterface(QWidget *parent); 00107 00114 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 00115 00122 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 00123 00130 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00131 00138 virtual void wheelEvent(QGraphicsSceneWheelEvent *event); 00139 00140 protected: 00144 QString mainScript() const; 00145 00151 const Package *package() const; 00152 00156 KPluginInfo description() const; 00157 00158 bool isInitialized() const; 00159 QRectF boundingRect() const; 00160 DataEngine *dataEngine(const QString &name) const; 00161 void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod); 00162 void setTargetSizeHint(const QSizeF &targetSize); 00163 void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString()); 00164 void render(const QString &sourceImagePath, const QSize &size, 00165 Wallpaper::ResizeMethod resizeMethod = Plasma::Wallpaper::ScaledResize, 00166 const QColor &color = QColor(0, 0, 0)); 00167 void setUsingRenderingCache(bool useCache); 00168 bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0); 00169 void insertIntoCache(const QString& key, const QImage &image); 00170 void setContextualActions(const QList<QAction*> &actions); 00171 void update(const QRectF &exposedArea); 00172 void configNeedsSaving(); 00173 00174 protected Q_SLOTS: 00175 virtual void renderCompleted(const QImage &image); 00176 virtual void urlDropped(const KUrl &url); 00177 00178 private: 00179 WallpaperScriptPrivate *const d; 00180 }; 00181 00182 #define K_EXPORT_PLASMA_WALLPAPERSCRIPTENGINE(libname, classname) \ 00183 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00184 K_EXPORT_PLUGIN(factory("plasma_wallpaperscriptengine_" #libname)) 00185 00186 } //Plasma namespace 00187 00188 #endif
KDE 4.6 API Reference