Added class ScriptFunctionWrapper to allow QML-scripts to call functions in our normal scripts
This commit is contained in:
parent
b6581e2380
commit
a9b68f553e
6 changed files with 69 additions and 10 deletions
23
telldus-gui/Plugins/QML/scriptfunctionwrapper.cpp
Normal file
23
telldus-gui/Plugins/QML/scriptfunctionwrapper.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "scriptfunctionwrapper.h"
|
||||
|
||||
class ScriptFunctionWrapper::PrivateData {
|
||||
public:
|
||||
QScriptValue object;
|
||||
QString name;
|
||||
};
|
||||
|
||||
ScriptFunctionWrapper::ScriptFunctionWrapper(const QScriptValue &object, const QString &name, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
d = new PrivateData;
|
||||
d->object = object;
|
||||
d->name = name;
|
||||
}
|
||||
|
||||
ScriptFunctionWrapper::~ScriptFunctionWrapper() {
|
||||
delete d;
|
||||
}
|
||||
|
||||
QVariant ScriptFunctionWrapper::call() {
|
||||
return d->object.property(d->name).call().toVariant();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue