From ddc678bbc0dc5e8cf7d92e9307f9032b7adeadc9 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Tue, 23 Jul 2019 16:57:53 -0700 Subject: [PATCH 1/8] added interactivewindow proxy. moved event bridge binding to the proxy instead --- interface/src/ui/InteractiveWindow.cpp | 29 ++++++++++++++++++++++---- interface/src/ui/InteractiveWindow.h | 17 +++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index fc2d8c56bf..0b83e2ed88 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -69,6 +69,16 @@ void QmlWindowProxy::parentNativeWindowToMainWindow() { #endif } +void InteractiveWindowProxy::emitScriptEvent(const QVariant& scriptMessage){ + qDebug() << "EmitScriptEvent"; + emit scriptEventReceived(scriptMessage); +} + +void InteractiveWindowProxy::emitWebEvent(const QVariant& webMessage) { + qDebug() << "EmitWebEvent"; + emit webEventReceived(webMessage); +} + static void qmlWindowProxyDeleter(QmlWindowProxy* qmlWindowProxy) { qmlWindowProxy->deleteLater(); } @@ -129,6 +139,10 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } + if (!_interactiveWindowProxy) { + _interactiveWindowProxy = new InteractiveWindowProxy(); + } + if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); Qt::DockWidgetArea dockArea = Qt::TopDockWidgetArea; @@ -182,11 +196,12 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap break; } } - + + QObject::connect(quickView.get(), &QQuickView::statusChanged, [&, this] (QQuickView::Status status) { if (status == QQuickView::Ready) { QQuickItem* rootItem = _dockWidget->getRootItem(); - _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, this); + _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); QObject::connect(rootItem, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)), Qt::QueuedConnection); QObject::connect(rootItem, SIGNAL(keyPressEvent(int, int)), this, SLOT(forwardKeyPressEvent(int, int)), @@ -202,9 +217,9 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap } else { auto offscreenUi = DependencyManager::get(); // Build the event bridge and wrapper on the main thread - offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&](QQmlContext* context, QObject* object) { + offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&, this](QQmlContext* context, QObject* object) { _qmlWindowProxy = std::shared_ptr(new QmlWindowProxy(object, nullptr), qmlWindowProxyDeleter); - context->setContextProperty(EVENT_BRIDGE_PROPERTY, this); + context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); if (properties.contains(ADDITIONAL_FLAGS_PROPERTY)) { object->setProperty(ADDITIONAL_FLAGS_PROPERTY, properties[ADDITIONAL_FLAGS_PROPERTY].toUInt()); } @@ -275,10 +290,12 @@ void InteractiveWindow::sendToQml(const QVariant& message) { } void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { + //_interactiveWindowProxy->emitScriptEvent(scriptMessage); emit scriptEventReceived(scriptMessage); } void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { + //_interactiveWindowProxy->emitWebEvent(webMessage); emit webEventReceived(webMessage); } @@ -291,6 +308,10 @@ void InteractiveWindow::close() { _qmlWindowProxy->deleteLater(); } + if (_interactiveWindowProxy) { + delete(_interactiveWindowProxy); + } + if (_dockWidget) { auto window = qApp->getWindow(); if (QThread::currentThread() != window->thread()) { diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index 0098658c16..a1eede8b8a 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -34,7 +34,23 @@ public: QObject* getQmlWindow() const { return _qmlWindow; } private: QObject* _qmlWindow; +}; + +class InteractiveWindowProxy : public QObject { + Q_OBJECT +public: + InteractiveWindowProxy(){} + +public slots: + + void emitScriptEvent(const QVariant& scriptMessage); + void emitWebEvent(const QVariant& webMessage); + +signals: + + void scriptEventReceived(const QVariant& message); + void webEventReceived(const QVariant& message); }; @@ -309,6 +325,7 @@ protected slots: private: std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; + InteractiveWindowProxy *_interactiveWindowProxy{ nullptr }; }; typedef InteractiveWindow* InteractiveWindowPointer; From 8c022b025da1386ca0d5b4ff57886cddb63ae49d Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 11:19:32 -0700 Subject: [PATCH 2/8] implementing Dante's change to connect the slots --- interface/src/ui/InteractiveWindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 0b83e2ed88..5cafae6a83 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -70,12 +70,10 @@ void QmlWindowProxy::parentNativeWindowToMainWindow() { } void InteractiveWindowProxy::emitScriptEvent(const QVariant& scriptMessage){ - qDebug() << "EmitScriptEvent"; emit scriptEventReceived(scriptMessage); } void InteractiveWindowProxy::emitWebEvent(const QVariant& webMessage) { - qDebug() << "EmitWebEvent"; emit webEventReceived(webMessage); } @@ -141,6 +139,8 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap if (!_interactiveWindowProxy) { _interactiveWindowProxy = new InteractiveWindowProxy(); + QObject::connect(_interactiveWindowProxy, &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); + QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy, &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); } if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { @@ -278,6 +278,7 @@ InteractiveWindow::~InteractiveWindow() { } void InteractiveWindow::sendToQml(const QVariant& message) { + // Forward messages received from the script on to QML if (_dockWidget) { QQuickItem* rootItem = _dockWidget->getRootItem(); @@ -296,7 +297,7 @@ void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { //_interactiveWindowProxy->emitWebEvent(webMessage); - emit webEventReceived(webMessage); + emit webEventReceived(webMessage); } void InteractiveWindow::close() { @@ -309,7 +310,7 @@ void InteractiveWindow::close() { } if (_interactiveWindowProxy) { - delete(_interactiveWindowProxy); + _interactiveWindowProxy->deleteLater(); } if (_dockWidget) { @@ -322,6 +323,7 @@ void InteractiveWindow::close() { } _dockWidget = nullptr; _qmlWindowProxy = nullptr; + _interactiveWindowProxy = nullptr; } void InteractiveWindow::show() { From ac17493a40d8e746b49f969812490a3c7cce5a7d Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 11:37:38 -0700 Subject: [PATCH 3/8] removing comments --- interface/src/ui/InteractiveWindow.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 5cafae6a83..49c8d51812 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -291,12 +291,10 @@ void InteractiveWindow::sendToQml(const QVariant& message) { } void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { - //_interactiveWindowProxy->emitScriptEvent(scriptMessage); emit scriptEventReceived(scriptMessage); } void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { - //_interactiveWindowProxy->emitWebEvent(webMessage); emit webEventReceived(webMessage); } From f94b082946f425263ce947169d9b7b03ab83103f Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 11:47:10 -0700 Subject: [PATCH 4/8] addressing comment --- interface/src/ui/InteractiveWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 49c8d51812..f8961c6de1 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -217,7 +217,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap } else { auto offscreenUi = DependencyManager::get(); // Build the event bridge and wrapper on the main thread - offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&, this](QQmlContext* context, QObject* object) { + offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&](QQmlContext* context, QObject* object) { _qmlWindowProxy = std::shared_ptr(new QmlWindowProxy(object, nullptr), qmlWindowProxyDeleter); context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); if (properties.contains(ADDITIONAL_FLAGS_PROPERTY)) { From bea31237b7b1f58ce6926725a3ec203c499e1320 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 14:30:43 -0700 Subject: [PATCH 5/8] addressing comments --- interface/src/ui/InteractiveWindow.cpp | 12 ++++++------ interface/src/ui/InteractiveWindow.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index f8961c6de1..8225e5f438 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -70,7 +70,7 @@ void QmlWindowProxy::parentNativeWindowToMainWindow() { } void InteractiveWindowProxy::emitScriptEvent(const QVariant& scriptMessage){ - emit scriptEventReceived(scriptMessage); + // emit scriptEventReceived(scriptMessage); } void InteractiveWindowProxy::emitWebEvent(const QVariant& webMessage) { @@ -137,11 +137,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } - if (!_interactiveWindowProxy) { - _interactiveWindowProxy = new InteractiveWindowProxy(); - QObject::connect(_interactiveWindowProxy, &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); - QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy, &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); - } + _interactiveWindowProxy = std::make_unique(); + QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, + this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); + QObject::connect(this, &InteractiveWindow::scriptEventReceived, + _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index a1eede8b8a..57025140a2 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -325,7 +325,7 @@ protected slots: private: std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; - InteractiveWindowProxy *_interactiveWindowProxy{ nullptr }; + std::unique_ptr _interactiveWindowProxy{ nullptr }; }; typedef InteractiveWindow* InteractiveWindowPointer; From 3315271493852a8f879c5c1dcbba1c89a14a4325 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 15:43:31 -0700 Subject: [PATCH 6/8] reverting commit: --- interface/src/ui/InteractiveWindow.cpp | 12 ++++++------ interface/src/ui/InteractiveWindow.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 8225e5f438..f8961c6de1 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -70,7 +70,7 @@ void QmlWindowProxy::parentNativeWindowToMainWindow() { } void InteractiveWindowProxy::emitScriptEvent(const QVariant& scriptMessage){ - // emit scriptEventReceived(scriptMessage); + emit scriptEventReceived(scriptMessage); } void InteractiveWindowProxy::emitWebEvent(const QVariant& webMessage) { @@ -137,11 +137,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } - _interactiveWindowProxy = std::make_unique(); - QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, - this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); - QObject::connect(this, &InteractiveWindow::scriptEventReceived, - _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); + if (!_interactiveWindowProxy) { + _interactiveWindowProxy = new InteractiveWindowProxy(); + QObject::connect(_interactiveWindowProxy, &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); + QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy, &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); + } if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index 57025140a2..a1eede8b8a 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -325,7 +325,7 @@ protected slots: private: std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; - std::unique_ptr _interactiveWindowProxy{ nullptr }; + InteractiveWindowProxy *_interactiveWindowProxy{ nullptr }; }; typedef InteractiveWindow* InteractiveWindowPointer; From 5d7286b055903f7254eceac2ba4ac7422ce70879 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Wed, 24 Jul 2019 16:05:13 -0700 Subject: [PATCH 7/8] removed change from my master branch, that is getting checked in on separate pr --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8fd5b7637..5e4746418d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ endif() include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros/TargetPython.cmake") target_python() -if (WIN32 AND NOT HIFI_ANDROID) +if (WIN32) # Force x64 toolset set(CMAKE_GENERATOR_TOOLSET "host=x64" CACHE STRING "64-bit toolset" FORCE) endif() From 9872c1c2f709785ef2461d6656fd8330375da640 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 25 Jul 2019 13:55:44 -0700 Subject: [PATCH 8/8] Add missing emit inside of --- interface/src/ui/InteractiveWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index d432fc0793..4359995448 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -301,6 +301,7 @@ void InteractiveWindow::emitScriptEvent(const QVariant& scriptMessage) { } void InteractiveWindow::emitWebEvent(const QVariant& webMessage) { + emit webEventReceived(webMessage); } void InteractiveWindow::close() {