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.
22 #include <QScriptValue>
24 #include <Plasma/AppletScript>
25 #include <Plasma/DataEngine>
32 class AppletInterface
;
34 class SimpleJavaScriptApplet
: public Plasma::AppletScript
39 SimpleJavaScriptApplet( QObject
*parent
, const QVariantList
&args
);
40 ~SimpleJavaScriptApplet();
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
);
53 void dataUpdated( const QString
&name
, const Plasma::DataEngine::Data
&data
);
54 void showConfigurationInterface();
55 void configAccepted();
56 void executeAction(const QString
&name
);
59 void importExtensions();
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
);
76 static KSharedPtr
<UiLoader
> s_widgetLoader
;
77 QScriptEngine
*m_engine
;
79 AppletInterface
*m_interface
;
80 friend class AppletInterface
;