Plasma
appletscript.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2007 by Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_APPLETSCRIPT_H 00021 #define PLASMA_APPLETSCRIPT_H 00022 00023 #include <QtCore/QObject> 00024 #include <QtCore/QRect> 00025 #include <QtCore/QSizeF> 00026 00027 #include <kgenericfactory.h> 00028 #include <kplugininfo.h> 00029 00030 #include <plasma/containment.h> 00031 #include <plasma/plasma_export.h> 00032 #include <plasma/scripting/scriptengine.h> 00033 00034 class QAction; 00035 class QPainter; 00036 class QStyleOptionGraphicsItem; 00037 class KConfigDialog; 00038 00039 namespace Plasma 00040 { 00041 00042 class Animation; 00043 class AppletScriptPrivate; 00044 class Extender; 00045 00051 class PLASMA_EXPORT AppletScript : public ScriptEngine 00052 { 00053 Q_OBJECT 00054 00055 public: 00064 explicit AppletScript(QObject *parent = 0); 00065 ~AppletScript(); 00066 00070 void setApplet(Plasma::Applet *applet); 00071 00075 Plasma::Applet *applet() const; 00076 00085 virtual void paintInterface(QPainter *painter, 00086 const QStyleOptionGraphicsItem *option, 00087 const QRect &contentsRect); 00088 00092 Q_INVOKABLE QSizeF size() const; 00093 00105 virtual void constraintsEvent(Plasma::Constraints constraints); 00106 00113 virtual QList<QAction*> contextualActions(); 00114 00118 virtual QPainterPath shape() const; 00119 00125 void setHasConfigurationInterface(bool hasInterface); 00126 00130 void setConfigurationRequired(bool req, const QString &reason = QString()); 00131 00135 void setFailedToLaunch(bool failed, const QString &reason = QString()); 00136 00140 void configNeedsSaving() const; 00141 00145 Extender *extender() const; 00146 00147 //FIXME plasma2: setWallpaperEnabled and setContainmentType should become public? 00153 bool drawWallpaper() const; 00159 void setDrawWallpaper(bool drawWallpaper); 00160 00165 Containment::Type containmentType() const; 00166 00171 void setContainmentType(Containment::Type type); 00172 00173 Q_SIGNALS: 00177 void saveState(KConfigGroup &group) const; 00178 00182 void popupEvent(bool popped) const; 00183 00184 public Q_SLOTS: 00185 00189 virtual void showConfigurationInterface(); 00190 00194 virtual void configChanged(); 00195 00196 protected: 00201 Q_INVOKABLE DataEngine *dataEngine(const QString &engine) const; 00202 00206 QString mainScript() const; 00207 00213 const Package *package() const; 00214 00218 KPluginInfo description() const; 00219 00226 KConfigDialog *standardConfigurationDialog(); 00227 00234 void addStandardConfigurationPages(KConfigDialog *dialog); 00235 00239 void showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons); 00240 00244 void registerAsDragHandle(QGraphicsItem *item); 00245 00249 void unregisterAsDragHandle(QGraphicsItem *item); 00250 00254 bool isRegisteredAsDragHandle(QGraphicsItem *item); 00255 00262 Animation *loadAnimationFromPackage(const QString &name, QObject *parent); 00263 00264 private: 00265 friend class Applet; 00266 friend class PopupApplet; 00267 00268 AppletScriptPrivate *const d; 00269 }; 00270 00271 #define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ 00272 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00273 K_EXPORT_PLUGIN(factory("plasma_appletscriptengine_" #libname)) 00274 00275 } //Plasma namespace 00276 00277 #endif
KDE 4.7 API Reference