From 6ef08218015ebb4a3763b9edb5532c1e98176456 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Fri, 26 Jul 2019 12:44:48 -0700 Subject: [PATCH 1/7] steam gets the oculus store commerce treatment --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1872a03221..7ba6a455f9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1225,8 +1225,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo #endif bool isStore = property(hifi::properties::OCULUS_STORE).toBool(); - - DependencyManager::get()->setLimitedCommerce(isStore); // Or we could make it a separate arg, or if either arg is set, etc. And should this instead by a hifi::properties? + // Or we could make it a separate arg, or if either arg is set, etc. And should this instead by a hifi::properties? + DependencyManager::get()->setLimitedCommerce(isStore || property(hifi::properties::STEAM).toBool()); updateHeartbeat(); From b2e07fd990101cd179b0589d8cb37c0704241fec Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Fri, 26 Jul 2019 13:02:59 -0700 Subject: [PATCH 2/7] changing raw pointer to unique pointer with custom deleter --- interface/src/ui/InteractiveWindow.cpp | 21 ++++++++------------- interface/src/ui/InteractiveWindow.h | 11 +++++++++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 4359995448..f5ae611632 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -134,14 +134,13 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap InteractiveWindowPresentationMode presentationMode = InteractiveWindowPresentationMode::Native; if (properties.contains(PRESENTATION_MODE_PROPERTY)) { - presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); + 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::unique_ptr(new InteractiveWindowProxy()); + + 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(); @@ -161,7 +160,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap _dockWidget = std::shared_ptr(new DockWidget(title, mainWindow), dockWidgetDeleter); auto quickView = _dockWidget->getQuickView(); - Application::setupQmlSurface(quickView->rootContext() , true); + Application::setupQmlSurface(quickView->rootContext(), true); //add any whitelisted callbacks OffscreenUi::applyWhiteList(sourceUrl, quickView->rootContext()); @@ -201,7 +200,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap 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, _interactiveWindowProxy); + _dockWidget->getQuickView()->rootContext()->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy.get()); // The qmlToScript method handles the thread-safety of this call. Because the QVariant argument // passed to the sendToScript signal may wrap an externally managed and thread-unsafe QJSValue, // qmlToScript needs to be called directly, so the QJSValue can be immediately converted to a plain QVariant. @@ -222,7 +221,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap // Build the event bridge and wrapper on the main thread offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, [&](QQmlContext* context, QObject* object) { _qmlWindowProxy = std::shared_ptr(new QmlWindowProxy(object, nullptr), qmlWindowProxyDeleter); - context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy); + context->setContextProperty(EVENT_BRIDGE_PROPERTY, _interactiveWindowProxy.get()); if (properties.contains(ADDITIONAL_FLAGS_PROPERTY)) { object->setProperty(ADDITIONAL_FLAGS_PROPERTY, properties[ADDITIONAL_FLAGS_PROPERTY].toUInt()); } @@ -313,10 +312,6 @@ void InteractiveWindow::close() { _qmlWindowProxy->deleteLater(); } - if (_interactiveWindowProxy) { - _interactiveWindowProxy->deleteLater(); - } - 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 a1eede8b8a..dda71b3087 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -37,11 +37,12 @@ private: }; + class InteractiveWindowProxy : public QObject { Q_OBJECT public: InteractiveWindowProxy(){} - + public slots: void emitScriptEvent(const QVariant& scriptMessage); @@ -53,6 +54,12 @@ signals: void webEventReceived(const QVariant& message); }; +struct InteractiveWindowProxyDeleter { + void operator()(InteractiveWindowProxy * p) { + p->deleteLater(); + } +}; + namespace InteractiveWindowEnums { Q_NAMESPACE @@ -325,7 +332,7 @@ protected slots: private: std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; - InteractiveWindowProxy *_interactiveWindowProxy{ nullptr }; + std::unique_ptr _interactiveWindowProxy; }; typedef InteractiveWindow* InteractiveWindowPointer; From 087b19d64d9fe75579ccd3c6d74f88ac5791020f Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Fri, 26 Jul 2019 13:15:01 -0700 Subject: [PATCH 3/7] removed extra space --- 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 f5ae611632..8fdcb1d9d6 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -134,7 +134,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap InteractiveWindowPresentationMode presentationMode = InteractiveWindowPresentationMode::Native; if (properties.contains(PRESENTATION_MODE_PROPERTY)) { - presentationMode = (InteractiveWindowPresentationMode)properties[PRESENTATION_MODE_PROPERTY].toInt(); + presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } _interactiveWindowProxy = std::unique_ptr(new InteractiveWindowProxy()); From de0b038ee1d1bb2c82f2326216c2a2025da5c9a0 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Fri, 26 Jul 2019 13:52:38 -0700 Subject: [PATCH 4/7] trunked to a lambda for simplicity --- interface/src/ui/InteractiveWindow.cpp | 6 ++++-- interface/src/ui/InteractiveWindow.h | 10 +--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 8fdcb1d9d6..8cc2f9a3d5 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -136,8 +136,10 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap if (properties.contains(PRESENTATION_MODE_PROPERTY)) { presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } - - _interactiveWindowProxy = std::unique_ptr(new InteractiveWindowProxy()); + + _interactiveWindowProxy= std::unique_ptr>(new InteractiveWindowProxy, [](InteractiveWindowProxy *p) { + p->deleteLater(); + }); QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index dda71b3087..357db3744a 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -37,7 +37,6 @@ private: }; - class InteractiveWindowProxy : public QObject { Q_OBJECT public: @@ -54,13 +53,6 @@ signals: void webEventReceived(const QVariant& message); }; -struct InteractiveWindowProxyDeleter { - void operator()(InteractiveWindowProxy * p) { - p->deleteLater(); - } -}; - - namespace InteractiveWindowEnums { Q_NAMESPACE @@ -332,7 +324,7 @@ protected slots: private: std::shared_ptr _qmlWindowProxy; std::shared_ptr _dockWidget { nullptr }; - std::unique_ptr _interactiveWindowProxy; + std::unique_ptr> _interactiveWindowProxy; }; typedef InteractiveWindow* InteractiveWindowPointer; From 854f89caced3611ffb5fc10ee2b90c3f015585a2 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Mon, 29 Jul 2019 09:39:31 -0700 Subject: [PATCH 5/7] addressing comment --- interface/src/ui/InteractiveWindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 8cc2f9a3d5..8ad006006c 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -137,12 +137,15 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } - _interactiveWindowProxy= std::unique_ptr>(new InteractiveWindowProxy, [](InteractiveWindowProxy *p) { - p->deleteLater(); + _interactiveWindowProxy= std::unique_ptr>(new InteractiveWindowProxy, [](InteractiveWindowProxy *p) { + p->deleteLater(); }); - QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); - QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); + 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(); From b3ea9d0de7cc0f6b72e8d1159d3efb6a8958ff94 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Mon, 29 Jul 2019 09:40:58 -0700 Subject: [PATCH 6/7] addressing commetn --- interface/src/ui/InteractiveWindow.cpp | 4 ++-- interface/src/ui/InteractiveWindow.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 8ad006006c..992c6abefc 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -142,9 +142,9 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap p->deleteLater(); }); - QObject::connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, + connect(_interactiveWindowProxy.get(), &InteractiveWindowProxy::webEventReceived, this, &InteractiveWindow::emitWebEvent, Qt::QueuedConnection); - QObject::connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy.get(), + connect(this, &InteractiveWindow::scriptEventReceived, _interactiveWindowProxy.get(), &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index 357db3744a..67f0a9ea2e 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -41,7 +41,6 @@ class InteractiveWindowProxy : public QObject { Q_OBJECT public: InteractiveWindowProxy(){} - public slots: void emitScriptEvent(const QVariant& scriptMessage); From 85fa510d38cfb94dc56150eeb056641a0b1f6827 Mon Sep 17 00:00:00 2001 From: amer cerkic Date: Mon, 29 Jul 2019 10:28:31 -0700 Subject: [PATCH 7/7] 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 992c6abefc..c0f3e82b29 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -137,7 +137,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap presentationMode = (InteractiveWindowPresentationMode) properties[PRESENTATION_MODE_PROPERTY].toInt(); } - _interactiveWindowProxy= std::unique_ptr>(new InteractiveWindowProxy, [](InteractiveWindowProxy *p) { p->deleteLater(); });