• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
  • scripting
wallpaperscript.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2009 by Aaron Seigo <aseigo@kde.org>
3  * Copyright 2009 by Petri Damsten <damu@iki.fi>
4  *
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.
9  *
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
14  *
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.
19  */
20 
21 #include "wallpaperscript.h"
22 #include "private/wallpaper_p.h"
23 #include "package.h"
24 
25 namespace Plasma
26 {
27 
28 class WallpaperScriptPrivate
29 {
30 public:
31  Wallpaper *wallpaper;
32 };
33 
34 WallpaperScript::WallpaperScript(QObject *parent)
35  : ScriptEngine(parent),
36  d(new WallpaperScriptPrivate)
37 {
38 }
39 
40 WallpaperScript::~WallpaperScript()
41 {
42  delete d;
43 }
44 
45 void WallpaperScript::setWallpaper(Wallpaper *wallpaper)
46 {
47  d->wallpaper = wallpaper;
48  connect(wallpaper, SIGNAL(renderCompleted(QImage)),
49  this, SLOT(renderCompleted(QImage)));
50  connect(wallpaper, SIGNAL(urlDropped(KUrl)),
51  this, SLOT(urlDropped(KUrl)));
52 }
53 
54 Wallpaper *WallpaperScript::wallpaper() const
55 {
56  return d->wallpaper;
57 }
58 
59 QString WallpaperScript::mainScript() const
60 {
61  Q_ASSERT(d->wallpaper);
62  return d->wallpaper->package()->filePath("mainscript");
63 }
64 
65 const Package *WallpaperScript::package() const
66 {
67  Q_ASSERT(d->wallpaper);
68  return d->wallpaper->package();
69 }
70 
71 KPluginInfo WallpaperScript::description() const
72 {
73  Q_ASSERT(d->wallpaper);
74  return d->wallpaper->d->wallpaperDescription;
75 }
76 
77 void WallpaperScript::initWallpaper(const KConfigGroup &config)
78 {
79  Q_UNUSED(config)
80 }
81 
82 void WallpaperScript::paint(QPainter *painter, const QRectF &exposedRect)
83 {
84  Q_UNUSED(painter)
85  Q_UNUSED(exposedRect)
86 }
87 
88 void WallpaperScript::save(KConfigGroup &config)
89 {
90  Q_UNUSED(config)
91 }
92 
93 QWidget *WallpaperScript::createConfigurationInterface(QWidget *parent)
94 {
95  Q_UNUSED(parent)
96  return 0;
97 }
98 
99 void WallpaperScript::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
100 {
101  Q_UNUSED(event)
102 }
103 
104 void WallpaperScript::mousePressEvent(QGraphicsSceneMouseEvent *event)
105 {
106  Q_UNUSED(event)
107 }
108 
109 void WallpaperScript::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
110 {
111  Q_UNUSED(event)
112 }
113 
114 void WallpaperScript::wheelEvent(QGraphicsSceneWheelEvent *event)
115 {
116  Q_UNUSED(event)
117 }
118 
119 void WallpaperScript::setUrls(const KUrl::List urls)
120 {
121  //TODO KDE5 replace urlDropped with addUrls
122  foreach (const KUrl &url, urls) {
123  urlDropped(url);
124  }
125 }
126 
127 bool WallpaperScript::isInitialized() const
128 {
129  if (d->wallpaper) {
130  return d->wallpaper->isInitialized();
131  }
132  return false;
133 }
134 
135 QRectF WallpaperScript::boundingRect() const
136 {
137  if (d->wallpaper) {
138  return d->wallpaper->boundingRect();
139  }
140  return QRectF();
141 }
142 
143 DataEngine *WallpaperScript::dataEngine(const QString &name) const
144 {
145  Q_ASSERT(d->wallpaper);
146  return d->wallpaper->dataEngine(name);
147 }
148 
149 void WallpaperScript::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
150 {
151  if (d->wallpaper) {
152  d->wallpaper->setResizeMethodHint(resizeMethod);
153  }
154 }
155 
156 void WallpaperScript::setTargetSizeHint(const QSizeF &targetSize)
157 {
158  if (d->wallpaper) {
159  d->wallpaper->setTargetSizeHint(targetSize);
160  }
161 }
162 
163 void WallpaperScript::setConfigurationRequired(bool needsConfiguring, const QString &reason)
164 {
165  if (d->wallpaper) {
166  d->wallpaper->setConfigurationRequired(needsConfiguring, reason);
167  }
168 }
169 
170 void WallpaperScript::render(const QString &sourceImagePath, const QSize &size,
171  Wallpaper::ResizeMethod resizeMethod, const QColor &color)
172 {
173  if (d->wallpaper) {
174  d->wallpaper->render(sourceImagePath, size, resizeMethod, color);
175  }
176 }
177 
178 void WallpaperScript::setUsingRenderingCache(bool useCache)
179 {
180  if (d->wallpaper) {
181  d->wallpaper->setUsingRenderingCache(useCache);
182  }
183 }
184 
185 bool WallpaperScript::findInCache(const QString &key, QImage &image, unsigned int lastModified)
186 {
187  if (d->wallpaper) {
188  return d->wallpaper->findInCache(key, image, lastModified);
189  }
190  return false;
191 }
192 
193 void WallpaperScript::insertIntoCache(const QString& key, const QImage &image)
194 {
195  if (d->wallpaper) {
196  d->wallpaper->insertIntoCache(key, image);
197  }
198 }
199 
200 void WallpaperScript::setContextualActions(const QList<QAction*> &actions)
201 {
202  if (d->wallpaper) {
203  d->wallpaper->setContextualActions(actions);
204  }
205 }
206 
207 void WallpaperScript::update(const QRectF &exposedArea)
208 {
209  if (d->wallpaper) {
210  d->wallpaper->update(exposedArea);
211  }
212 }
213 
214 void WallpaperScript::configNeedsSaving()
215 {
216  if (d->wallpaper) {
217  d->wallpaper->configNeedsSaving();
218  }
219 }
220 
221 void WallpaperScript::renderCompleted(const QImage &image)
222 {
223  Q_UNUSED(image)
224 }
225 
226 void WallpaperScript::urlDropped(const KUrl &url)
227 {
228  Q_UNUSED(url)
229 }
230 
231 } // Plasma namespace
232 
233 #include "wallpaperscript.moc"
Plasma::WallpaperScript::initWallpaper
virtual void initWallpaper(const KConfigGroup &config)
This method is called once the wallpaper is loaded or mode is changed.
Definition: wallpaperscript.cpp:77
Plasma::WallpaperScript::setContextualActions
void setContextualActions(const QList< QAction * > &actions)
Definition: wallpaperscript.cpp:200
Plasma::WallpaperScript::setConfigurationRequired
void setConfigurationRequired(bool needsConfiguring, const QString &reason=QString())
Definition: wallpaperscript.cpp:163
Plasma::WallpaperScript::configNeedsSaving
void configNeedsSaving()
Definition: wallpaperscript.cpp:214
Plasma::WallpaperScript::package
const Package * package() const
Definition: wallpaperscript.cpp:65
Plasma::WallpaperScript::wallpaper
Wallpaper * wallpaper() const
Returns the Plasma::Wallpaper associated with this script component.
Definition: wallpaperscript.cpp:54
QWidget
Plasma::WallpaperScript::insertIntoCache
void insertIntoCache(const QString &key, const QImage &image)
Definition: wallpaperscript.cpp:193
Plasma::WallpaperScript::setTargetSizeHint
void setTargetSizeHint(const QSizeF &targetSize)
Definition: wallpaperscript.cpp:156
Plasma::Wallpaper::ResizeMethod
ResizeMethod
Various resize modes supported by the built in image renderer.
Definition: wallpaper.h:74
Plasma::WallpaperScript::setUsingRenderingCache
void setUsingRenderingCache(bool useCache)
Definition: wallpaperscript.cpp:178
QObject
Plasma::WallpaperScript::WallpaperScript
WallpaperScript(QObject *parent=0)
Default constructor for a WallpaperScript.
Definition: wallpaperscript.cpp:34
Plasma::WallpaperScript::createConfigurationInterface
virtual QWidget * createConfigurationInterface(QWidget *parent)
Returns a widget that can be used to configure the options (if any) associated with this wallpaper...
Definition: wallpaperscript.cpp:93
Plasma::WallpaperScript::save
virtual void save(KConfigGroup &config)
This method is called when settings need to be saved.
Definition: wallpaperscript.cpp:88
Plasma::ScriptEngine
The base class for scripting interfaces to be used in loading plasmoids of a given language...
Definition: scriptengine.h:65
Plasma::WallpaperScript::mouseMoveEvent
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Mouse move event.
Definition: wallpaperscript.cpp:99
Plasma::DataEngine
Data provider for plasmoids (Plasma plugins)
Definition: dataengine.h:58
Plasma::Package
object representing an installed Plasmagik package
Definition: package.h:42
Plasma::WallpaperScript::findInCache
bool findInCache(const QString &key, QImage &image, unsigned int lastModified=0)
Definition: wallpaperscript.cpp:185
Plasma::WallpaperScript::render
void render(const QString &sourceImagePath, const QSize &size, Wallpaper::ResizeMethod resizeMethod=Plasma::Wallpaper::ScaledResize, const QColor &color=QColor(0, 0, 0))
Definition: wallpaperscript.cpp:170
Plasma::WallpaperScript::~WallpaperScript
~WallpaperScript()
Definition: wallpaperscript.cpp:40
Plasma::WallpaperScript::update
void update(const QRectF &exposedArea)
Definition: wallpaperscript.cpp:207
Plasma::WallpaperScript::wheelEvent
virtual void wheelEvent(QGraphicsSceneWheelEvent *event)
Mouse wheel event.
Definition: wallpaperscript.cpp:114
Plasma::WallpaperScript::paint
virtual void paint(QPainter *painter, const QRectF &exposedRect)
This method is called when the wallpaper should be painted.
Definition: wallpaperscript.cpp:82
Plasma::WallpaperScript::setUrls
void setUrls(const KUrl::List urls)
Adds urls (e.g.
Definition: wallpaperscript.cpp:119
Plasma::WallpaperScript::boundingRect
QRectF boundingRect() const
Definition: wallpaperscript.cpp:135
Plasma::WallpaperScript::setWallpaper
void setWallpaper(Wallpaper *wallpaper)
Sets the Plasma::Wallpaper associated with this WallpaperScript.
Definition: wallpaperscript.cpp:45
Plasma::WallpaperScript::mainScript
QString mainScript() const
Definition: wallpaperscript.cpp:59
package.h
Plasma::WallpaperScript::description
KPluginInfo description() const
Definition: wallpaperscript.cpp:71
wallpaperscript.h
Plasma::WallpaperScript::isInitialized
bool isInitialized() const
Definition: wallpaperscript.cpp:127
Plasma::WallpaperScript::setResizeMethodHint
void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
Definition: wallpaperscript.cpp:149
Plasma::WallpaperScript::mouseReleaseEvent
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Mouse release event.
Definition: wallpaperscript.cpp:109
Plasma::WallpaperScript::dataEngine
DataEngine * dataEngine(const QString &name) const
Definition: wallpaperscript.cpp:143
Plasma::WallpaperScript::renderCompleted
virtual void renderCompleted(const QImage &image)
Definition: wallpaperscript.cpp:221
Plasma::WallpaperScript::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Mouse press event.
Definition: wallpaperscript.cpp:104
Plasma::Wallpaper
The base Wallpaper class.
Definition: wallpaper.h:56
Plasma::WallpaperScript::urlDropped
virtual void urlDropped(const KUrl &url)
Definition: wallpaperscript.cpp:226
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal