Plasma
qscript.h
Go to the documentation of this file.00001 /* 00002 * Copyright 2007 Richard J. Moore <rich@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 version 2 as 00006 * published by the Free Software Foundation 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details 00012 * 00013 * You should have received a copy of the GNU Library General Public 00014 * License along with this program; if not, write to the 00015 * Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef SCRIPT_H 00020 #define SCRIPT_H 00021 00022 #include <QScriptValue> 00023 00024 #include <plasma/scripting/appletscript.h> 00025 #include <plasma/dataengine.h> 00026 00027 class QScriptEngine; 00028 class QScriptContext; 00029 00030 class QScriptApplet : public Plasma::AppletScript 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 QScriptApplet( QObject *parent, const QVariantList &args ); 00036 ~QScriptApplet(); 00037 bool init(); 00038 00039 void reportError(); 00040 00041 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect); 00042 00043 Q_INVOKABLE QString findDataResource( const QString &filename ); 00044 Q_INVOKABLE void debug( const QString &msg ); 00045 // Q_INVOKABLE void update( const QRectF & rect = QRectF() ) { Applet::update(rect); } 00046 00047 public slots: 00048 void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ); 00049 void showConfigurationInterface(); 00050 void configAccepted(); 00051 00052 private: 00053 void importExtensions(); 00054 void setupObjects(); 00055 00056 //static QScriptValue dataEngine(QScriptContext *context, QScriptEngine *engine); 00057 static QScriptValue loadui(QScriptContext *context, QScriptEngine *engine); 00058 static QScriptValue newPlasmaSvg(QScriptContext *context, QScriptEngine *engine); 00059 00060 void installWidgets( QScriptEngine *engine ); 00061 static QScriptValue createWidget(QScriptContext *context, QScriptEngine *engine); 00062 00063 static QScriptValue createPrototype( QScriptEngine *engine, const QString &name ); 00064 00065 private: 00066 QScriptEngine *m_engine; 00067 QScriptValue m_self; 00068 }; 00069 00070 K_EXPORT_PLASMA_APPLETSCRIPTENGINE(qscriptapplet, QScriptApplet) 00071 00072 00073 #endif // SCRIPT_H 00074