diff --git a/telldus-gui/TelldusCenter/TelldusCenter.pro b/telldus-gui/TelldusCenter/TelldusCenter.pro index b60f4971..a6b7460d 100644 --- a/telldus-gui/TelldusCenter/TelldusCenter.pro +++ b/telldus-gui/TelldusCenter/TelldusCenter.pro @@ -2,7 +2,7 @@ # Project created by QtCreator 2008-12-11T11:01:36 # ------------------------------------------------- TEMPLATE = app - +QT += script SOURCES += main.cpp \ mainwindow.cpp \ tellduscenterapplication.cpp \ diff --git a/telldus-gui/TelldusCenter/tellduscenterapplication.cpp b/telldus-gui/TelldusCenter/tellduscenterapplication.cpp index da13b2b3..0364a85c 100644 --- a/telldus-gui/TelldusCenter/tellduscenterapplication.cpp +++ b/telldus-gui/TelldusCenter/tellduscenterapplication.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -18,6 +19,7 @@ public: SystrayIcon *systrayIcon; PluginList plugins; QPointer mainWindow; + QScriptEngine scriptEngine; }; TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv) @@ -36,6 +38,7 @@ TelldusCenterApplication::TelldusCenterApplication(int &argc, char **argv) tdRegisterDeviceEvent( &TelldusCenterApplication::deviceEvent, 0 ); loadPlugins(); + loadScripts(); } TelldusCenterApplication::~TelldusCenterApplication() { @@ -104,7 +107,10 @@ void TelldusCenterApplication::loadPlugins() { pluginsDir.cdUp(); } #endif - pluginsDir.cd("plugins"); + if (!pluginsDir.cd("plugins")) { + return; + } + this->addLibraryPath( pluginsDir.absolutePath() ); foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { QPluginLoader loader(pluginsDir.absoluteFilePath(fileName)); @@ -129,6 +135,16 @@ void TelldusCenterApplication::loadPlugin(QObject *plugin) { d->plugins.append(iPlugin); } +void TelldusCenterApplication::loadScripts() { + foreach (QString extension, d->scriptEngine.availableExtensions()) { + d->scriptEngine.importExtension( extension ); + if (d->scriptEngine.hasUncaughtException()) { + qDebug() << QString("Error in %1:%2:").arg(extension).arg(d->scriptEngine.uncaughtExceptionLineNumber()) + << d->scriptEngine.uncaughtException().toString(); + } + } +} + void TelldusCenterApplication::deviceEvent(int deviceId, int method, const QString &/*data*/) { char *name = tdGetName(deviceId); QString deviceName(name); diff --git a/telldus-gui/TelldusCenter/tellduscenterapplication.h b/telldus-gui/TelldusCenter/tellduscenterapplication.h index b0a0cfab..d9e7d7f7 100644 --- a/telldus-gui/TelldusCenter/tellduscenterapplication.h +++ b/telldus-gui/TelldusCenter/tellduscenterapplication.h @@ -44,6 +44,7 @@ private: static void deviceEvent(int deviceId, int method, const char *data, int callbackId, void *context); void loadPlugins(); void loadPlugin(QObject *plugin); + void loadScripts(); TelldusCenterApplicationPrivate *d; };