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/plasma_export.h> 00031 #include <plasma/scripting/scriptengine.h> 00032 00033 class QAction; 00034 class QPainter; 00035 class QStyleOptionGraphicsItem; 00036 class KConfigDialog; 00037 00038 namespace Plasma 00039 { 00040 00041 class Animation; 00042 class AppletScriptPrivate; 00043 class Extender; 00044 00050 class PLASMA_EXPORT AppletScript : public ScriptEngine 00051 { 00052 Q_OBJECT 00053 00054 public: 00063 explicit AppletScript(QObject *parent = 0); 00064 ~AppletScript(); 00065 00069 void setApplet(Plasma::Applet *applet); 00070 00074 Plasma::Applet *applet() const; 00075 00084 virtual void paintInterface(QPainter *painter, 00085 const QStyleOptionGraphicsItem *option, 00086 const QRect &contentsRect); 00087 00091 Q_INVOKABLE QSizeF size() const; 00092 00104 virtual void constraintsEvent(Plasma::Constraints constraints); 00105 00112 virtual QList<QAction*> contextualActions(); 00113 00117 virtual QPainterPath shape() const; 00118 00124 void setHasConfigurationInterface(bool hasInterface); 00125 00129 void setConfigurationRequired(bool req, const QString &reason = QString()); 00130 00134 void setFailedToLaunch(bool failed, const QString &reason = QString()); 00135 00139 void configNeedsSaving() const; 00140 00144 Extender *extender() const; 00145 00146 Q_SIGNALS: 00150 void saveState(KConfigGroup &group) const; 00151 00155 void popupEvent(bool popped) const; 00156 00157 public Q_SLOTS: 00158 00162 virtual void showConfigurationInterface(); 00163 00167 virtual void configChanged(); 00168 00169 protected: 00174 Q_INVOKABLE DataEngine *dataEngine(const QString &engine) const; 00175 00179 QString mainScript() const; 00180 00186 const Package *package() const; 00187 00191 KPluginInfo description() const; 00192 00199 KConfigDialog *standardConfigurationDialog(); 00200 00207 void addStandardConfigurationPages(KConfigDialog *dialog); 00208 00212 void showMessage(const QIcon &icon, const QString &message, const MessageButtons buttons); 00213 00217 void registerAsDragHandle(QGraphicsItem *item); 00218 00222 void unregisterAsDragHandle(QGraphicsItem *item); 00223 00227 bool isRegisteredAsDragHandle(QGraphicsItem *item); 00228 00235 Animation *loadAnimationFromPackage(const QString &name, QObject *parent); 00236 00237 private: 00238 friend class Applet; 00239 friend class PopupApplet; 00240 00241 AppletScriptPrivate *const d; 00242 }; 00243 00244 #define K_EXPORT_PLASMA_APPLETSCRIPTENGINE(libname, classname) \ 00245 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \ 00246 K_EXPORT_PLUGIN(factory("plasma_appletscriptengine_" #libname)) 00247 00248 } //Plasma namespace 00249 00250 #endif
KDE 4.6 API Reference