Plasma
wallpaperscript.cpp
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 #include "wallpaperscript.h" 00022 #include "private/wallpaper_p.h" 00023 #include "package.h" 00024 00025 namespace Plasma 00026 { 00027 00028 class WallpaperScriptPrivate 00029 { 00030 public: 00031 Wallpaper *wallpaper; 00032 }; 00033 00034 WallpaperScript::WallpaperScript(QObject *parent) 00035 : ScriptEngine(parent), 00036 d(new WallpaperScriptPrivate) 00037 { 00038 } 00039 00040 WallpaperScript::~WallpaperScript() 00041 { 00042 delete d; 00043 } 00044 00045 void WallpaperScript::setWallpaper(Wallpaper *wallpaper) 00046 { 00047 d->wallpaper = wallpaper; 00048 connect(wallpaper, SIGNAL(renderCompleted(const QImage&)), 00049 this, SLOT(renderCompleted(const QImage&))); 00050 connect(wallpaper, SIGNAL(urlDropped(const KUrl&)), 00051 this, SLOT(urlDropped(const KUrl&))); 00052 } 00053 00054 Wallpaper *WallpaperScript::wallpaper() const 00055 { 00056 return d->wallpaper; 00057 } 00058 00059 QString WallpaperScript::mainScript() const 00060 { 00061 Q_ASSERT(d->wallpaper); 00062 return d->wallpaper->package()->filePath("mainscript"); 00063 } 00064 00065 const Package *WallpaperScript::package() const 00066 { 00067 Q_ASSERT(d->wallpaper); 00068 return d->wallpaper->package(); 00069 } 00070 00071 KPluginInfo WallpaperScript::description() const 00072 { 00073 Q_ASSERT(d->wallpaper); 00074 return d->wallpaper->d->wallpaperDescription; 00075 } 00076 00077 void WallpaperScript::initWallpaper(const KConfigGroup &config) 00078 { 00079 Q_UNUSED(config) 00080 } 00081 00082 void WallpaperScript::paint(QPainter *painter, const QRectF &exposedRect) 00083 { 00084 Q_UNUSED(painter) 00085 Q_UNUSED(exposedRect) 00086 } 00087 00088 void WallpaperScript::save(KConfigGroup &config) 00089 { 00090 Q_UNUSED(config) 00091 } 00092 00093 QWidget *WallpaperScript::createConfigurationInterface(QWidget *parent) 00094 { 00095 Q_UNUSED(parent) 00096 return 0; 00097 } 00098 00099 void WallpaperScript::mouseMoveEvent(QGraphicsSceneMouseEvent *event) 00100 { 00101 Q_UNUSED(event) 00102 } 00103 00104 void WallpaperScript::mousePressEvent(QGraphicsSceneMouseEvent *event) 00105 { 00106 Q_UNUSED(event) 00107 } 00108 00109 void WallpaperScript::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 00110 { 00111 Q_UNUSED(event) 00112 } 00113 00114 void WallpaperScript::wheelEvent(QGraphicsSceneWheelEvent *event) 00115 { 00116 Q_UNUSED(event) 00117 } 00118 00119 bool WallpaperScript::isInitialized() const 00120 { 00121 if (d->wallpaper) { 00122 return d->wallpaper->isInitialized(); 00123 } 00124 return false; 00125 } 00126 00127 QRectF WallpaperScript::boundingRect() const 00128 { 00129 if (d->wallpaper) { 00130 return d->wallpaper->boundingRect(); 00131 } 00132 return QRectF(); 00133 } 00134 00135 DataEngine *WallpaperScript::dataEngine(const QString &name) const 00136 { 00137 Q_ASSERT(d->wallpaper); 00138 return d->wallpaper->dataEngine(name); 00139 } 00140 00141 void WallpaperScript::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod) 00142 { 00143 if (d->wallpaper) { 00144 d->wallpaper->setResizeMethodHint(resizeMethod); 00145 } 00146 } 00147 00148 void WallpaperScript::setTargetSizeHint(const QSizeF &targetSize) 00149 { 00150 if (d->wallpaper) { 00151 d->wallpaper->setTargetSizeHint(targetSize); 00152 } 00153 } 00154 00155 void WallpaperScript::setConfigurationRequired(bool needsConfiguring, const QString &reason) 00156 { 00157 if (d->wallpaper) { 00158 d->wallpaper->setConfigurationRequired(needsConfiguring, reason); 00159 } 00160 } 00161 00162 void WallpaperScript::render(const QString &sourceImagePath, const QSize &size, 00163 Wallpaper::ResizeMethod resizeMethod, const QColor &color) 00164 { 00165 if (d->wallpaper) { 00166 d->wallpaper->render(sourceImagePath, size, resizeMethod, color); 00167 } 00168 } 00169 00170 void WallpaperScript::setUsingRenderingCache(bool useCache) 00171 { 00172 if (d->wallpaper) { 00173 d->wallpaper->setUsingRenderingCache(useCache); 00174 } 00175 } 00176 00177 bool WallpaperScript::findInCache(const QString &key, QImage &image, unsigned int lastModified) 00178 { 00179 if (d->wallpaper) { 00180 return d->wallpaper->findInCache(key, image, lastModified); 00181 } 00182 return false; 00183 } 00184 00185 void WallpaperScript::insertIntoCache(const QString& key, const QImage &image) 00186 { 00187 if (d->wallpaper) { 00188 d->wallpaper->insertIntoCache(key, image); 00189 } 00190 } 00191 00192 void WallpaperScript::setContextualActions(const QList<QAction*> &actions) 00193 { 00194 if (d->wallpaper) { 00195 d->wallpaper->setContextualActions(actions); 00196 } 00197 } 00198 00199 void WallpaperScript::update(const QRectF &exposedArea) 00200 { 00201 if (d->wallpaper) { 00202 d->wallpaper->update(exposedArea); 00203 } 00204 } 00205 00206 void WallpaperScript::configNeedsSaving() 00207 { 00208 if (d->wallpaper) { 00209 d->wallpaper->configNeedsSaving(); 00210 } 00211 } 00212 00213 void WallpaperScript::renderCompleted(const QImage &image) 00214 { 00215 Q_UNUSED(image) 00216 } 00217 00218 void WallpaperScript::urlDropped(const KUrl &url) 00219 { 00220 Q_UNUSED(url) 00221 } 00222 00223 } // Plasma namespace 00224 00225 #include "wallpaperscript.moc"
KDE 4.6 API Reference