History

Hooked up EventBridge to TabletScriptingInterface.

Anthony J. Thibault committed 9 years ago

Commit 3c2f9ac1 parent 850db0b6 files · +55 −17Browse files

Showing the changes to libraries/script-engine/src/TabletScriptingInterface.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/TabletScriptingInterface.cpp+13−5
@@ -29,10 +29,10 @@ QObject* TabletScriptingInterface::getTablet(const QString& tabletId) { · 28 unmodified lines
2929 }
3030 }
3131
32−void TabletScriptingInterface::setQmlTabletRoot(QString tabletId, QQuickItem* qmlTabletRoot) {
32+void TabletScriptingInterface::setQmlTabletRoot(QString tabletId, QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
3333 TabletProxy* tablet = qobject_cast<TabletProxy*>(getTablet(tabletId));
34− if (tablet) {
35− tablet->setQmlTabletRoot(qmlTabletRoot);
34+ if (tablet && qmlOffscreenSurface) {
35+ tablet->setQmlTabletRoot(qmlTabletRoot, qmlOffscreenSurface);
3636 } else {
3737 qCWarning(scriptengine) << "TabletScriptingInterface::setupTablet() bad tablet object";
3838 }
@@ -72,10 +72,12 @@ static void addButtonProxyToQmlTablet(QQuickItem* qmlTablet, TabletButtonProxy* · 33 unmodified lines
7272 buttonProxy->setQmlButton(qobject_cast<QQuickItem*>(qmlButton));
7373 }
7474
75−void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot) {
75+void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) {
7676 std::lock_guard<std::mutex> guard(_mutex);
77+ _qmlOffscreenSurface = qmlOffscreenSurface;
7778 _qmlTabletRoot = qmlTabletRoot;
78− if (_qmlTabletRoot) {
79+ if (_qmlTabletRoot && _qmlOffscreenSurface) {
80+ QObject::connect(_qmlOffscreenSurface, SIGNAL(webEventReceived(QVariant)), this, SIGNAL(webEventReceived(QVariant)));
7981 gotoHomeScreen();
8082 } else {
8183 removeButtonsFromHomeScreen();
@@ -141,6 +143,12 @@ void TabletProxy::removeButton(QObject* tabletButtonProxy) { · 59 unmodified lines
141143 }
142144 }
143145
146+void TabletProxy::emitScriptEvent(QVariant msg) {
147+ if (_qmlOffscreenSurface) {
148+ QMetaObject::invokeMethod(_qmlOffscreenSurface, "emitScriptEvent", Qt::AutoConnection, Q_ARG(QVariant, msg));
149+ }
150+}
151+
144152 void TabletProxy::addButtonsToHomeScreen() {
145153 auto tablet = getQmlTablet();
146154 if (!tablet) {