not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / scriptengines / javascript / simplejavascriptapplet.h
blob97330bbe37eabd4c65b3a92a8eaf7ffa3654b016
1 /*
2 * Copyright 2007 Richard J. Moore <rich@kde.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef SCRIPT_H
20 #define SCRIPT_H
22 #include <QScriptValue>
24 #include <Plasma/AppletScript>
25 #include <Plasma/DataEngine>
27 #include "uiloader.h"
29 class QScriptEngine;
30 class QScriptContext;
32 class AppletInterface;
34 class SimpleJavaScriptApplet : public Plasma::AppletScript
36 Q_OBJECT
38 public:
39 SimpleJavaScriptApplet( QObject *parent, const QVariantList &args );
40 ~SimpleJavaScriptApplet();
41 bool init();
43 void reportError();
45 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect);
46 QList<QAction*> contextualActions();
47 void constraintsEvent(Plasma::Constraints constraints);
49 Q_INVOKABLE QString findDataResource( const QString &filename );
50 Q_INVOKABLE void debug( const QString &msg );
52 public slots:
53 void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data );
54 void showConfigurationInterface();
55 void configAccepted();
56 void executeAction(const QString &name);
58 private:
59 void importExtensions();
60 void setupObjects();
61 void callFunction(const QString &functionName, const QScriptValueList &args = QScriptValueList());
63 static QString findSvg(QScriptEngine *engine, const QString &file);
64 static QScriptValue dataEngine(QScriptContext *context, QScriptEngine *engine);
65 static QScriptValue service(QScriptContext *context, QScriptEngine *engine);
66 static QScriptValue loadui(QScriptContext *context, QScriptEngine *engine);
67 static QScriptValue newPlasmaSvg(QScriptContext *context, QScriptEngine *engine);
68 static QScriptValue newPlasmaFrameSvg(QScriptContext *context, QScriptEngine *engine);
70 void installWidgets( QScriptEngine *engine );
71 static QScriptValue createWidget(QScriptContext *context, QScriptEngine *engine);
72 static QScriptValue print(QScriptContext *context, QScriptEngine *engine);
73 static QScriptValue createPrototype( QScriptEngine *engine, const QString &name );
75 private:
76 static KSharedPtr<UiLoader> s_widgetLoader;
77 QScriptEngine *m_engine;
78 QScriptValue m_self;
79 AppletInterface *m_interface;
80 friend class AppletInterface;
84 #endif // SCRIPT_H