diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 47fb610469..4f7639dd0e 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -2,7 +2,6 @@ import QtQuick 2.5 import QtQuick.Controls 1.2 import QtWebChannel 1.0 import QtWebEngine 1.2 -import FileTypeProfile 1.0 import "controls-uit" import "styles" as HifiStyles @@ -209,6 +208,7 @@ ScrollingWindow { WebView { id: webview url: "https://highfidelity.com/" + profile: FileTypeProfile; property alias eventBridgeWrapper: eventBridgeWrapper @@ -218,10 +218,6 @@ ScrollingWindow { property var eventBridge; } - profile: FileTypeProfile { - id: webviewProfile - storageName: "qmlWebEngine" - } webChannel.registeredObjects: [eventBridgeWrapper] diff --git a/interface/resources/qml/TabletBrowser.qml b/interface/resources/qml/TabletBrowser.qml index ee4d05a701..d89aa8626f 100644 --- a/interface/resources/qml/TabletBrowser.qml +++ b/interface/resources/qml/TabletBrowser.qml @@ -8,7 +8,6 @@ import "controls-uit" as HifiControls import "styles" as HifiStyles import "styles-uit" import "windows" -import HFTabletWebEngineProfile 1.0 Item { id: root @@ -47,10 +46,7 @@ Item { width: parent.width height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height - profile: HFTabletWebEngineProfile { - id: webviewTabletProfile - storageName: "qmlTabletWebEngine" - } + profile: HFTabletWebEngineProfile; property string userScriptUrl: "" diff --git a/interface/resources/qml/controls-uit/BaseWebView.qml b/interface/resources/qml/controls-uit/BaseWebView.qml index 670aea71aa..3ca57f03bf 100644 --- a/interface/resources/qml/controls-uit/BaseWebView.qml +++ b/interface/resources/qml/controls-uit/BaseWebView.qml @@ -10,13 +10,10 @@ import QtQuick 2.5 import QtWebEngine 1.2 -import HFWebEngineProfile 1.0 WebEngineView { id: root - // profile: desktop.browserProfile - Component.onCompleted: { console.log("Connecting JS messaging to Hifi Logging") // Ensure the JS from the web-engine makes it to our logging diff --git a/interface/resources/qml/controls/TabletWebScreen.qml b/interface/resources/qml/controls/TabletWebScreen.qml index 93ded724a1..0b265f6fbb 100644 --- a/interface/resources/qml/controls/TabletWebScreen.qml +++ b/interface/resources/qml/controls/TabletWebScreen.qml @@ -2,7 +2,6 @@ import QtQuick 2.5 import QtWebEngine 1.1 import QtWebChannel 1.0 import "../controls-uit" as HiFiControls -import HFTabletWebEngineProfile 1.0 Item { property alias url: root.url @@ -39,10 +38,7 @@ Item { width: parent.width height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height - profile: HFTabletWebEngineProfile { - id: webviewProfile - storageName: "qmlTabletWebEngine" - } + profile: HFTabletWebEngineProfile; property string userScriptUrl: "" diff --git a/interface/resources/qml/controls/TabletWebView.qml b/interface/resources/qml/controls/TabletWebView.qml index 215ac68ac0..3b23cbc19e 100644 --- a/interface/resources/qml/controls/TabletWebView.qml +++ b/interface/resources/qml/controls/TabletWebView.qml @@ -2,7 +2,6 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtWebEngine 1.2 import QtWebChannel 1.0 -import HFTabletWebEngineProfile 1.0 import "../controls-uit" as HiFiControls import "../styles" as HifiStyles import "../styles-uit" @@ -150,10 +149,7 @@ Item { width: parent.width height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height - web.headerHeight : parent.height - web.headerHeight anchors.top: buttons.bottom - profile: HFTabletWebEngineProfile { - id: webviewTabletProfile - storageName: "qmlTabletWebEngine" - } + profile: HFTabletWebEngineProfile; property string userScriptUrl: "" diff --git a/interface/resources/qml/controls/WebEntityView.qml b/interface/resources/qml/controls/WebEntityView.qml index a3d5fe903b..3bd6aad053 100644 --- a/interface/resources/qml/controls/WebEntityView.qml +++ b/interface/resources/qml/controls/WebEntityView.qml @@ -10,13 +10,9 @@ import QtQuick 2.5 import "." -import FileTypeProfile 1.0 WebView { - viewProfile: FileTypeProfile { - id: webviewProfile - storageName: "qmlWebEngine" - } + viewProfile: FileTypeProfile; urlTag: "noDownload=true"; } diff --git a/interface/resources/qml/controls/WebView.qml b/interface/resources/qml/controls/WebView.qml index 06766fa6ef..d08562eea3 100644 --- a/interface/resources/qml/controls/WebView.qml +++ b/interface/resources/qml/controls/WebView.qml @@ -2,7 +2,6 @@ import QtQuick 2.5 import QtWebEngine 1.1 import QtWebChannel 1.0 import "../controls-uit" as HiFiControls -import HFWebEngineProfile 1.0 Item { property alias url: root.url @@ -39,10 +38,7 @@ Item { width: parent.width height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height - profile: HFWebEngineProfile { - id: webviewProfile - storageName: "qmlWebEngine" - } + profile: HFWebEngineProfile; property string userScriptUrl: "" diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index 7857eda3c2..ea9ec2f6c9 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -2,7 +2,6 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtWebEngine 1.1; import Qt.labs.settings 1.0 -import HFWebEngineProfile 1.0 import "../desktop" as OriginalDesktop import ".." @@ -27,11 +26,6 @@ OriginalDesktop.Desktop { property alias toolWindow: toolWindow ToolWindow { id: toolWindow } - property var browserProfile: HFWebEngineProfile { - id: webviewProfile - storageName: "qmlWebEngine" - } - Action { text: "Open Browser" shortcut: "Ctrl+B" diff --git a/interface/resources/qml/hifi/tablet/EditTabView.qml b/interface/resources/qml/hifi/tablet/EditTabView.qml index 35f2b82f0f..d084f1c7b3 100644 --- a/interface/resources/qml/hifi/tablet/EditTabView.qml +++ b/interface/resources/qml/hifi/tablet/EditTabView.qml @@ -5,7 +5,6 @@ import QtWebChannel 1.0 import QtQuick.Controls.Styles 1.4 import "../../controls" import "../toolbars" -import HFWebEngineProfile 1.0 import QtGraphicalEffects 1.0 import "../../controls-uit" as HifiControls import "../../styles-uit" diff --git a/interface/resources/qml/hifi/tablet/TabletMenu.qml b/interface/resources/qml/hifi/tablet/TabletMenu.qml index af36f72c82..62b61d129b 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenu.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenu.qml @@ -4,7 +4,6 @@ import QtQuick.Controls 1.4 import QtQml 2.2 import QtWebChannel 1.0 import QtWebEngine 1.1 -import HFWebEngineProfile 1.0 import "." diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index 97c8854c86..e7654d9ff1 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -1,7 +1,6 @@ import QtQuick 2.0 import Hifi 1.0 import QtQuick.Controls 1.4 -import HFTabletWebEngineProfile 1.0 import "../../dialogs" import "../../controls" diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index bc3944f28d..2c4cd4aa0a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -150,9 +150,6 @@ #include "LODManager.h" #include "ModelPackager.h" #include "networking/CloseEventSender.h" -#include "networking/HFWebEngineProfile.h" -#include "networking/HFTabletWebEngineProfile.h" -#include "networking/FileTypeProfile.h" #include "scripting/TestScriptingInterface.h" #include "scripting/AccountScriptingInterface.h" #include "scripting/AssetMappingsScriptingInterface.h" @@ -1927,14 +1924,10 @@ void Application::initializeUi() { UpdateDialog::registerType(); qmlRegisterType("Hifi", 1, 0, "Preference"); - qmlRegisterType("HFWebEngineProfile", 1, 0, "HFWebEngineProfile"); - qmlRegisterType("HFTabletWebEngineProfile", 1, 0, "HFTabletWebEngineProfile"); - qmlRegisterType("FileTypeProfile", 1, 0, "FileTypeProfile"); - auto offscreenUi = DependencyManager::get(); offscreenUi->create(_glWidget->qglContext()); - auto rootContext = offscreenUi->getRootContext(); + auto surfaceContext = offscreenUi->getSurfaceContext(); offscreenUi->setProxyWindow(_window->windowHandle()); offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); @@ -1946,7 +1939,7 @@ void Application::initializeUi() { // do better detection in the offscreen UI of what has focus offscreenUi->setNavigationFocused(false); - auto engine = rootContext->engine(); + auto engine = surfaceContext->engine(); connect(engine, &QQmlEngine::quit, [] { qApp->quit(); }); @@ -1955,79 +1948,78 @@ void Application::initializeUi() { // For some reason there is already an "Application" object in the QML context, // though I can't find it. Hence, "ApplicationInterface" - rootContext->setContextProperty("ApplicationInterface", this); - rootContext->setContextProperty("Audio", DependencyManager::get().data()); - rootContext->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); - rootContext->setContextProperty("AudioScope", DependencyManager::get().data()); + surfaceContext->setContextProperty("Audio", DependencyManager::get().data()); + surfaceContext->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); + surfaceContext->setContextProperty("AudioScope", DependencyManager::get().data()); - rootContext->setContextProperty("Controller", DependencyManager::get().data()); - rootContext->setContextProperty("Entities", DependencyManager::get().data()); + surfaceContext->setContextProperty("Controller", DependencyManager::get().data()); + surfaceContext->setContextProperty("Entities", DependencyManager::get().data()); _fileDownload = new FileScriptingInterface(engine); - rootContext->setContextProperty("File", _fileDownload); + surfaceContext->setContextProperty("File", _fileDownload); connect(_fileDownload, &FileScriptingInterface::unzipResult, this, &Application::handleUnzip); - rootContext->setContextProperty("MyAvatar", getMyAvatar().get()); - rootContext->setContextProperty("Messages", DependencyManager::get().data()); - rootContext->setContextProperty("Recording", DependencyManager::get().data()); - rootContext->setContextProperty("Preferences", DependencyManager::get().data()); - rootContext->setContextProperty("AddressManager", DependencyManager::get().data()); - rootContext->setContextProperty("FrameTimings", &_frameTimingsScriptingInterface); - rootContext->setContextProperty("Rates", new RatesScriptingInterface(this)); - rootContext->setContextProperty("pathToFonts", "../../"); + surfaceContext->setContextProperty("MyAvatar", getMyAvatar().get()); + surfaceContext->setContextProperty("Messages", DependencyManager::get().data()); + surfaceContext->setContextProperty("Recording", DependencyManager::get().data()); + surfaceContext->setContextProperty("Preferences", DependencyManager::get().data()); + surfaceContext->setContextProperty("AddressManager", DependencyManager::get().data()); + surfaceContext->setContextProperty("FrameTimings", &_frameTimingsScriptingInterface); + surfaceContext->setContextProperty("Rates", new RatesScriptingInterface(this)); - rootContext->setContextProperty("TREE_SCALE", TREE_SCALE); - rootContext->setContextProperty("Quat", new Quat()); - rootContext->setContextProperty("Vec3", new Vec3()); - rootContext->setContextProperty("Uuid", new ScriptUUID()); - rootContext->setContextProperty("Assets", DependencyManager::get().data()); + surfaceContext->setContextProperty("TREE_SCALE", TREE_SCALE); + // FIXME Quat and Vec3 won't work with QJSEngine used by QML + surfaceContext->setContextProperty("Quat", new Quat()); + surfaceContext->setContextProperty("Vec3", new Vec3()); + surfaceContext->setContextProperty("Uuid", new ScriptUUID()); + surfaceContext->setContextProperty("Assets", DependencyManager::get().data()); - rootContext->setContextProperty("AvatarList", DependencyManager::get().data()); - rootContext->setContextProperty("Users", DependencyManager::get().data()); + surfaceContext->setContextProperty("AvatarList", DependencyManager::get().data()); + surfaceContext->setContextProperty("Users", DependencyManager::get().data()); - rootContext->setContextProperty("UserActivityLogger", DependencyManager::get().data()); + surfaceContext->setContextProperty("UserActivityLogger", DependencyManager::get().data()); - rootContext->setContextProperty("Camera", &_myCamera); + surfaceContext->setContextProperty("Camera", &_myCamera); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) - rootContext->setContextProperty("SpeechRecognizer", DependencyManager::get().data()); + surfaceContext->setContextProperty("SpeechRecognizer", DependencyManager::get().data()); #endif - rootContext->setContextProperty("Overlays", &_overlays); - rootContext->setContextProperty("Window", DependencyManager::get().data()); - rootContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); - rootContext->setContextProperty("Stats", Stats::getInstance()); - rootContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); - rootContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); - rootContext->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); - rootContext->setContextProperty("AvatarBookmarks", DependencyManager::get().data()); - rootContext->setContextProperty("LocationBookmarks", DependencyManager::get().data()); + surfaceContext->setContextProperty("Overlays", &_overlays); + surfaceContext->setContextProperty("Window", DependencyManager::get().data()); + surfaceContext->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); + surfaceContext->setContextProperty("Stats", Stats::getInstance()); + surfaceContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance()); + surfaceContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); + surfaceContext->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); + surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get().data()); + surfaceContext->setContextProperty("LocationBookmarks", DependencyManager::get().data()); // Caches - rootContext->setContextProperty("AnimationCache", DependencyManager::get().data()); - rootContext->setContextProperty("TextureCache", DependencyManager::get().data()); - rootContext->setContextProperty("ModelCache", DependencyManager::get().data()); - rootContext->setContextProperty("SoundCache", DependencyManager::get().data()); + surfaceContext->setContextProperty("AnimationCache", DependencyManager::get().data()); + surfaceContext->setContextProperty("TextureCache", DependencyManager::get().data()); + surfaceContext->setContextProperty("ModelCache", DependencyManager::get().data()); + surfaceContext->setContextProperty("SoundCache", DependencyManager::get().data()); - rootContext->setContextProperty("Account", AccountScriptingInterface::getInstance()); - rootContext->setContextProperty("Tablet", DependencyManager::get().data()); - rootContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface); - rootContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); - rootContext->setContextProperty("FaceTracker", DependencyManager::get().data()); - rootContext->setContextProperty("AvatarManager", DependencyManager::get().data()); - rootContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); - rootContext->setContextProperty("LODManager", DependencyManager::get().data()); - rootContext->setContextProperty("Paths", DependencyManager::get().data()); - rootContext->setContextProperty("HMD", DependencyManager::get().data()); - rootContext->setContextProperty("Scene", DependencyManager::get().data()); - rootContext->setContextProperty("Render", _renderEngine->getConfiguration().get()); - rootContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface()); - rootContext->setContextProperty("Snapshot", DependencyManager::get().data()); + surfaceContext->setContextProperty("Account", AccountScriptingInterface::getInstance()); + surfaceContext->setContextProperty("Tablet", DependencyManager::get().data()); + surfaceContext->setContextProperty("DialogsManager", _dialogsManagerScriptingInterface); + surfaceContext->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); + surfaceContext->setContextProperty("FaceTracker", DependencyManager::get().data()); + surfaceContext->setContextProperty("AvatarManager", DependencyManager::get().data()); + surfaceContext->setContextProperty("UndoStack", &_undoStackScriptingInterface); + surfaceContext->setContextProperty("LODManager", DependencyManager::get().data()); + surfaceContext->setContextProperty("Paths", DependencyManager::get().data()); + surfaceContext->setContextProperty("HMD", DependencyManager::get().data()); + surfaceContext->setContextProperty("Scene", DependencyManager::get().data()); + surfaceContext->setContextProperty("Render", _renderEngine->getConfiguration().get()); + surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface()); + surfaceContext->setContextProperty("Snapshot", DependencyManager::get().data()); - rootContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor()); + surfaceContext->setContextProperty("ApplicationCompositor", &getApplicationCompositor()); - rootContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); + surfaceContext->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { - rootContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); + surfaceContext->setContextProperty("Steam", new SteamScriptingInterface(engine, steamClient.get())); } diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 75c793bf77..e26a641206 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -135,7 +135,7 @@ Web3DOverlay::~Web3DOverlay() { void Web3DOverlay::update(float deltatime) { if (_webSurface) { // update globalPosition - _webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); + _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); } } @@ -163,57 +163,56 @@ void Web3DOverlay::loadSourceURL() { _webSurface->resume(); _webSurface->getRootItem()->setProperty("url", _url); _webSurface->getRootItem()->setProperty("scriptURL", _scriptURL); - _webSurface->getRootContext()->setContextProperty("ApplicationInterface", qApp); } else { _webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath())); _webSurface->load(_url, [&](QQmlContext* context, QObject* obj) {}); _webSurface->resume(); - _webSurface->getRootContext()->setContextProperty("Users", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("UserActivityLogger", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Preferences", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Vec3", new Vec3()); - _webSurface->getRootContext()->setContextProperty("Quat", new Quat()); - _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); - _webSurface->getRootContext()->setContextProperty("Entities", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Snapshot", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Users", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("UserActivityLogger", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Preferences", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Vec3", new Vec3()); + _webSurface->getSurfaceContext()->setContextProperty("Quat", new Quat()); + _webSurface->getSurfaceContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); + _webSurface->getSurfaceContext()->setContextProperty("Entities", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Snapshot", DependencyManager::get().data()); if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") { auto tabletScriptingInterface = DependencyManager::get(); auto flags = tabletScriptingInterface->getFlags(); - _webSurface->getRootContext()->setContextProperty("offscreenFlags", flags); - _webSurface->getRootContext()->setContextProperty("AddressManager", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); - _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); - _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); - _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Assets", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("LODManager", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("OctreeStats", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("DCModel", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); - _webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("offscreenFlags", flags); + _webSurface->getSurfaceContext()->setContextProperty("AddressManager", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); + _webSurface->getSurfaceContext()->setContextProperty("HMD", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); + _webSurface->getSurfaceContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); + _webSurface->getSurfaceContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Tablet", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("Assets", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("LODManager", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("OctreeStats", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("DCModel", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); + _webSurface->getSurfaceContext()->setContextProperty("AvatarList", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); + _webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); // mark the TabletProxy object as cpp ownership. QObject* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"); - _webSurface->getRootContext()->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership); + _webSurface->getSurfaceContext()->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership); // Override min fps for tablet UI, for silky smooth scrolling setMaxFPS(90); } } - _webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); + _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); } void Web3DOverlay::setMaxFPS(uint8_t maxFPS) { diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 0d286c46eb..3b3480443d 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -127,7 +127,7 @@ bool RenderableWebEntityItem::buildWebSurface(QSharedPointer _webSurface->resume(); _webSurface->getRootItem()->setProperty("url", _sourceUrl); - _webSurface->getRootContext()->setContextProperty("desktop", QVariant()); + _webSurface->getSurfaceContext()->setContextProperty("desktop", QVariant()); // FIXME - Keyboard HMD only: Possibly add "HMDinfo" object to context for WebView.qml. // forward web events to EntityScriptingInterface @@ -271,7 +271,7 @@ void RenderableWebEntityItem::loadSourceURL() { }); _webSurface->getRootItem()->setProperty("url", _sourceUrl); - _webSurface->getRootContext()->setContextProperty("desktop", QVariant()); + _webSurface->getSurfaceContext()->setContextProperty("desktop", QVariant()); } else { _contentType = qmlContent; @@ -284,7 +284,7 @@ void RenderableWebEntityItem::loadSourceURL() { _webSurface->getRootItem(), _webSurface.data()); } } - _webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); + _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); } @@ -420,7 +420,7 @@ void RenderableWebEntityItem::update(const quint64& now) { if (_webSurface) { // update globalPosition - _webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); + _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); } auto interval = now - _lastRenderTime; diff --git a/libraries/gl/CMakeLists.txt b/libraries/gl/CMakeLists.txt index 3e2097e89e..fd3197410b 100644 --- a/libraries/gl/CMakeLists.txt +++ b/libraries/gl/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME gl) setup_hifi_library(OpenGL Qml Quick) -link_hifi_libraries(shared) +link_hifi_libraries(shared networking) target_opengl() diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index 3bbd26e010..65c311424f 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #include "OffscreenGLCanvas.h" #include "GLHelpers.h" @@ -41,6 +44,7 @@ Q_LOGGING_CATEGORY(trace_render_qml, "trace.render.qml") Q_LOGGING_CATEGORY(trace_render_qml_gl, "trace.render.qml.gl") +Q_LOGGING_CATEGORY(offscreenFocus, "hifi.offscreen.focus") struct TextureSet { // The number of surfaces with this size @@ -254,8 +258,72 @@ QNetworkAccessManager* QmlNetworkAccessManagerFactory::create(QObject* parent) { return new QmlNetworkAccessManager(parent); } -Q_DECLARE_LOGGING_CATEGORY(offscreenFocus) -Q_LOGGING_CATEGORY(offscreenFocus, "hifi.offscreen.focus") +static QQmlEngine* globalEngine { nullptr }; +static size_t globalEngineRefCount { 0 }; + +QString getEventBridgeJavascript() { + // FIXME: Refactor with similar code in RenderableWebEntityItem + QString javaScriptToInject; + QFile webChannelFile(":qtwebchannel/qwebchannel.js"); + QFile createGlobalEventBridgeFile(PathUtils::resourcesPath() + "/html/createGlobalEventBridge.js"); + if (webChannelFile.open(QFile::ReadOnly | QFile::Text) && + createGlobalEventBridgeFile.open(QFile::ReadOnly | QFile::Text)) { + QString webChannelStr = QTextStream(&webChannelFile).readAll(); + QString createGlobalEventBridgeStr = QTextStream(&createGlobalEventBridgeFile).readAll(); + javaScriptToInject = webChannelStr + createGlobalEventBridgeStr; + } else { + qCWarning(glLogging) << "Unable to find qwebchannel.js or createGlobalEventBridge.js"; + } + return javaScriptToInject; +} + + +QQmlEngine* acquireEngine(QQuickWindow* window) { + Q_ASSERT(QThread::currentThread() == qApp->thread()); + if (!globalEngine) { + Q_ASSERT(0 == globalEngineRefCount); + globalEngine = new QQmlEngine(); + globalEngine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory); + + auto importList = globalEngine->importPathList(); + importList.insert(importList.begin(), PathUtils::resourcesPath()); + globalEngine->setImportPathList(importList); + for (const auto& path : importList) { + qDebug() << path; + } + + if (!globalEngine->incubationController()) { + globalEngine->setIncubationController(window->incubationController()); + } + auto rootContext = globalEngine->rootContext(); + rootContext->setContextProperty("GL", ::getGLContextData()); + rootContext->setContextProperty("urlHandler", new UrlHandler()); + rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath())); + rootContext->setContextProperty("pathToFonts", "../../"); + rootContext->setContextProperty("ApplicationInterface", qApp); + auto javaScriptToInject = getEventBridgeJavascript(); + if (!javaScriptToInject.isEmpty()) { + rootContext->setContextProperty("eventBridgeJavaScriptToInject", QVariant(javaScriptToInject)); + } + rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext)); + rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext)); + rootContext->setContextProperty("HFTabletWebEngineProfile", new HFTabletWebEngineProfile(rootContext)); + + + } + + ++globalEngineRefCount; + return globalEngine; +} + +void releaseEngine() { + Q_ASSERT(QThread::currentThread() == qApp->thread()); + Q_ASSERT(0 != globalEngineRefCount); + if (0 == --globalEngineRefCount) { + globalEngine->deleteLater(); + globalEngine = nullptr; + } +} void OffscreenQmlSurface::cleanup() { _canvas->makeCurrent(); @@ -294,6 +362,7 @@ void OffscreenQmlSurface::render() { GLuint texture = offscreenTextures.getNextTexture(_size); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo); glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); _renderControl->render(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, texture); @@ -362,8 +431,8 @@ OffscreenQmlSurface::~OffscreenQmlSurface() { _canvas->deleteLater(); _rootItem->deleteLater(); _qmlComponent->deleteLater(); - _qmlEngine->deleteLater(); _quickWindow->deleteLater(); + releaseEngine(); } void OffscreenQmlSurface::onAboutToQuit() { @@ -375,6 +444,8 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) { qCDebug(glLogging) << "Building QML surface"; _renderControl = new QMyQuickRenderControl(); + connect(_renderControl, &QQuickRenderControl::renderRequested, this, [this] { _render = true; }); + connect(_renderControl, &QQuickRenderControl::sceneChanged, this, [this] { _render = _polish = true; }); QQuickWindow::setDefaultAlphaBuffer(true); @@ -385,7 +456,7 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) { // so we wait until after its ctor to move object/context to this thread. _quickWindow = new QQuickWindow(_renderControl); _quickWindow->setColor(QColor(255, 255, 255, 0)); - _quickWindow->setFlags(_quickWindow->flags() | static_cast(Qt::WA_TranslucentBackground)); + _quickWindow->setClearBeforeRendering(false); _renderControl->_renderWindow = _proxyWindow; @@ -398,32 +469,20 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) { connect(_quickWindow, &QQuickWindow::focusObjectChanged, this, &OffscreenQmlSurface::onFocusObjectChanged); // Create a QML engine. - _qmlEngine = new QQmlEngine; + auto qmlEngine = acquireEngine(_quickWindow); + _qmlContext = new QQmlContext(qmlEngine->rootContext()); - _qmlEngine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory); + _qmlContext->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow())); + _qmlContext->setContextProperty("globalEventBridge", this); + _qmlContext->setContextProperty("webEntity", this); - auto importList = _qmlEngine->importPathList(); - importList.insert(importList.begin(), PathUtils::resourcesPath()); - _qmlEngine->setImportPathList(importList); - if (!_qmlEngine->incubationController()) { - _qmlEngine->setIncubationController(_quickWindow->incubationController()); - } + _qmlComponent = new QQmlComponent(qmlEngine); - // FIXME - _glData = ::getGLContextData(); // Initialize JSON structure so that it can be filled in later and then used in QML. - _qmlEngine->rootContext()->setContextProperty("GL", _glData); - _qmlEngine->rootContext()->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow())); - _qmlComponent = new QQmlComponent(_qmlEngine); - - - connect(_renderControl, &QQuickRenderControl::renderRequested, this, [this] { _render = true; }); - connect(_renderControl, &QQuickRenderControl::sceneChanged, this, [this] { _render = _polish = true; }); if (!_canvas->makeCurrent()) { qWarning("Failed to make context current for QML Renderer"); return; } - _glData = ::getGLContextData(); _renderControl->initialize(_canvas->getContext()); // When Quick says there is a need to render, we will not render immediately. Instead, @@ -433,11 +492,6 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) { _updateTimer.setTimerType(Qt::PreciseTimer); _updateTimer.setInterval(MIN_TIMER_MS); // 5ms, Qt::PreciseTimer required _updateTimer.start(); - - auto rootContext = getRootContext(); - rootContext->setContextProperty("urlHandler", new UrlHandler()); - rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath())); - rootContext->setContextProperty("pathToFonts", "../../"); } static uvec2 clampSize(const uvec2& size, uint32_t maxDimension) { @@ -460,7 +514,7 @@ void OffscreenQmlSurface::resize(const QSize& newSize_, bool forceResize) { return; } - _qmlEngine->rootContext()->setContextProperty("surfaceSize", newSize); + _qmlContext->setContextProperty("surfaceSize", newSize); if (_rootItem) { _rootItem->setSize(newSize); @@ -520,14 +574,19 @@ QQuickItem* OffscreenQmlSurface::getRootItem() { } void OffscreenQmlSurface::setBaseUrl(const QUrl& baseUrl) { - _qmlEngine->setBaseUrl(baseUrl); + _qmlContext->setBaseUrl(baseUrl); } QObject* OffscreenQmlSurface::load(const QUrl& qmlSource, std::function f) { // Synchronous loading may take a while; restart the deadlock timer QMetaObject::invokeMethod(qApp, "updateHeartbeat", Qt::DirectConnection); - _qmlComponent->loadUrl(qmlSource, QQmlComponent::PreferSynchronous); + if ((qmlSource.isRelative() && !qmlSource.isEmpty()) || qmlSource.scheme() == QLatin1String("file")) { + _qmlComponent->loadUrl(_qmlContext->resolvedUrl(qmlSource), QQmlComponent::PreferSynchronous); + } else { + _qmlComponent->loadUrl(qmlSource, QQmlComponent::PreferSynchronous); + } + if (_qmlComponent->isLoading()) { connect(_qmlComponent, &QQmlComponent::statusChanged, this, @@ -541,10 +600,22 @@ QObject* OffscreenQmlSurface::load(const QUrl& qmlSource, std::functionengine()->clearComponentCache(); + _qmlContext->engine()->clearComponentCache(); } QObject* OffscreenQmlSurface::finishQmlLoad(std::function f) { +#if 0 + if (!_rootItem) { + QQmlComponent component(_qmlContext->engine()); + component.setData(R"QML( +import QtQuick 2.0 +import QtWebChannel 1.0 +Item { Component.onCompleted: globalEventBridge.WebChannel.id = "globalEventBridge"; } +)QML", QUrl()); + QObject *helper = component.create(_qmlContext); + qDebug() << "Created helper"; + } +#endif disconnect(_qmlComponent, &QQmlComponent::statusChanged, this, 0); if (_qmlComponent->isError()) { QList errorList = _qmlComponent->errors(); @@ -554,21 +625,8 @@ QObject* OffscreenQmlSurface::finishQmlLoad(std::functionbeginCreate(newContext); + QObject* newObject = _qmlComponent->beginCreate(_qmlContext); if (_qmlComponent->isError()) { QList errorList = _qmlComponent->errors(); foreach(const QQmlError& error, errorList) @@ -579,12 +637,10 @@ QObject* OffscreenQmlSurface::finishQmlLoad(std::functionsetObjectOwnership(this, QQmlEngine::CppOwnership); + _qmlContext->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership); newObject->setProperty("eventBridge", QVariant::fromValue(this)); - newContext->setContextProperty("eventBridgeJavaScriptToInject", QVariant(javaScriptToInject)); - - f(newContext, newObject); + f(_qmlContext, newObject); _qmlComponent->completeCreate(); @@ -735,7 +791,7 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even mouseEvent->screenPos(), mouseEvent->button(), mouseEvent->buttons(), mouseEvent->modifiers()); if (event->type() == QEvent::MouseMove) { - _qmlEngine->rootContext()->setContextProperty("lastMousePosition", transformedPos); + _qmlContext->setContextProperty("lastMousePosition", transformedPos); } mappedEvent.ignore(); if (QCoreApplication::sendEvent(_quickWindow, &mappedEvent)) { @@ -762,9 +818,6 @@ void OffscreenQmlSurface::resume() { if (getRootItem()) { getRootItem()->setProperty("eventBridge", QVariant::fromValue(this)); } - if (getRootContext()) { - getRootContext()->setContextProperty("webEntity", this); - } } bool OffscreenQmlSurface::isPaused() const { @@ -790,8 +843,8 @@ QSize OffscreenQmlSurface::size() const { return _quickWindow->geometry().size(); } -QQmlContext* OffscreenQmlSurface::getRootContext() { - return _qmlEngine->rootContext(); +QQmlContext* OffscreenQmlSurface::getSurfaceContext() { + return _qmlContext; } Q_DECLARE_METATYPE(std::function); diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.h b/libraries/gl/src/gl/OffscreenQmlSurface.h index efd35fce8b..2a078d2b4f 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.h +++ b/libraries/gl/src/gl/OffscreenQmlSurface.h @@ -73,7 +73,7 @@ public: QQuickItem* getRootItem(); QQuickWindow* getWindow(); QObject* getEventHandler(); - QQmlContext* getRootContext(); + QQmlContext* getSurfaceContext(); QPointF mapToVirtualScreen(const QPointF& originalPoint, QObject* originalWidget); bool eventFilter(QObject* originalDestination, QEvent* event) override; @@ -133,11 +133,10 @@ private slots: private: QQuickWindow* _quickWindow { nullptr }; QMyQuickRenderControl* _renderControl{ nullptr }; - QQmlEngine* _qmlEngine { nullptr }; + QQmlContext* _qmlContext { nullptr }; QQmlComponent* _qmlComponent { nullptr }; QQuickItem* _rootItem { nullptr }; OffscreenGLCanvas* _canvas { nullptr }; - QJsonObject _glData; QTimer _updateTimer; uint32_t _fbo { 0 }; diff --git a/libraries/gl/src/gl/OffscreenQmlSurfaceCache.cpp b/libraries/gl/src/gl/OffscreenQmlSurfaceCache.cpp index ad370a1f43..c047738e77 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurfaceCache.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurfaceCache.cpp @@ -49,7 +49,6 @@ QSharedPointer OffscreenQmlSurfaceCache::buildSurface(const surface->create(currentContext); surface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); surface->load(rootSource); - surface->getRootContext()->setContextProperty("ApplicationInterface", qApp); surface->resize(QSize(100, 100)); currentContext->makeCurrent(currentSurface); return surface; diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 288e98d5a5..ff9a05b959 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME networking) -setup_hifi_library(Network) +setup_hifi_library(Network WebEngine) link_hifi_libraries(shared) target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_BINARY_DIR}/includes") diff --git a/interface/src/networking/FileTypeProfile.cpp b/libraries/networking/src/FileTypeProfile.cpp similarity index 100% rename from interface/src/networking/FileTypeProfile.cpp rename to libraries/networking/src/FileTypeProfile.cpp diff --git a/interface/src/networking/FileTypeProfile.h b/libraries/networking/src/FileTypeProfile.h similarity index 100% rename from interface/src/networking/FileTypeProfile.h rename to libraries/networking/src/FileTypeProfile.h diff --git a/interface/src/networking/FileTypeRequestInterceptor.cpp b/libraries/networking/src/FileTypeRequestInterceptor.cpp similarity index 100% rename from interface/src/networking/FileTypeRequestInterceptor.cpp rename to libraries/networking/src/FileTypeRequestInterceptor.cpp diff --git a/interface/src/networking/FileTypeRequestInterceptor.h b/libraries/networking/src/FileTypeRequestInterceptor.h similarity index 100% rename from interface/src/networking/FileTypeRequestInterceptor.h rename to libraries/networking/src/FileTypeRequestInterceptor.h diff --git a/interface/src/networking/HFTabletWebEngineProfile.cpp b/libraries/networking/src/HFTabletWebEngineProfile.cpp similarity index 95% rename from interface/src/networking/HFTabletWebEngineProfile.cpp rename to libraries/networking/src/HFTabletWebEngineProfile.cpp index 46634299bb..a3e3906497 100644 --- a/interface/src/networking/HFTabletWebEngineProfile.cpp +++ b/libraries/networking/src/HFTabletWebEngineProfile.cpp @@ -19,6 +19,7 @@ HFTabletWebEngineProfile::HFTabletWebEngineProfile(QObject* parent) : QQuickWebE static const QString WEB_ENGINE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36"; setHttpUserAgent(WEB_ENGINE_USER_AGENT); + setStorageName(QML_WEB_ENGINE_NAME); auto requestInterceptor = new HFTabletWebEngineRequestInterceptor(this); setRequestInterceptor(requestInterceptor); diff --git a/interface/src/networking/HFTabletWebEngineProfile.h b/libraries/networking/src/HFTabletWebEngineProfile.h similarity index 100% rename from interface/src/networking/HFTabletWebEngineProfile.h rename to libraries/networking/src/HFTabletWebEngineProfile.h diff --git a/interface/src/networking/HFTabletWebEngineRequestInterceptor.cpp b/libraries/networking/src/HFTabletWebEngineRequestInterceptor.cpp similarity index 98% rename from interface/src/networking/HFTabletWebEngineRequestInterceptor.cpp rename to libraries/networking/src/HFTabletWebEngineRequestInterceptor.cpp index fd79fc1cb6..6ee8589615 100644 --- a/interface/src/networking/HFTabletWebEngineRequestInterceptor.cpp +++ b/libraries/networking/src/HFTabletWebEngineRequestInterceptor.cpp @@ -11,7 +11,7 @@ #include "HFTabletWebEngineRequestInterceptor.h" #include -#include +#include "AccountManager.h" bool isTabletAuthableHighFidelityURL(const QUrl& url) { static const QStringList HF_HOSTS = { diff --git a/interface/src/networking/HFTabletWebEngineRequestInterceptor.h b/libraries/networking/src/HFTabletWebEngineRequestInterceptor.h similarity index 100% rename from interface/src/networking/HFTabletWebEngineRequestInterceptor.h rename to libraries/networking/src/HFTabletWebEngineRequestInterceptor.h diff --git a/interface/src/networking/HFWebEngineProfile.cpp b/libraries/networking/src/HFWebEngineProfile.cpp similarity index 94% rename from interface/src/networking/HFWebEngineProfile.cpp rename to libraries/networking/src/HFWebEngineProfile.cpp index 6b377fa900..a69d4d653b 100644 --- a/interface/src/networking/HFWebEngineProfile.cpp +++ b/libraries/networking/src/HFWebEngineProfile.cpp @@ -20,6 +20,7 @@ HFWebEngineProfile::HFWebEngineProfile(QObject* parent) : { static const QString WEB_ENGINE_USER_AGENT = "Chrome/48.0 (HighFidelityInterface)"; setHttpUserAgent(WEB_ENGINE_USER_AGENT); + setStorageName(QML_WEB_ENGINE_STORAGE_NAME); // we use the HFWebEngineRequestInterceptor to make sure that web requests are authenticated for the interface user auto requestInterceptor = new HFWebEngineRequestInterceptor(this); diff --git a/interface/src/networking/HFWebEngineProfile.h b/libraries/networking/src/HFWebEngineProfile.h similarity index 100% rename from interface/src/networking/HFWebEngineProfile.h rename to libraries/networking/src/HFWebEngineProfile.h diff --git a/interface/src/networking/HFWebEngineRequestInterceptor.cpp b/libraries/networking/src/HFWebEngineRequestInterceptor.cpp similarity index 95% rename from interface/src/networking/HFWebEngineRequestInterceptor.cpp rename to libraries/networking/src/HFWebEngineRequestInterceptor.cpp index 59897d427f..eaf0de7245 100644 --- a/interface/src/networking/HFWebEngineRequestInterceptor.cpp +++ b/libraries/networking/src/HFWebEngineRequestInterceptor.cpp @@ -13,7 +13,7 @@ #include -#include +#include "AccountManager.h" #include "RequestFilters.h" void HFWebEngineRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) { diff --git a/interface/src/networking/HFWebEngineRequestInterceptor.h b/libraries/networking/src/HFWebEngineRequestInterceptor.h similarity index 100% rename from interface/src/networking/HFWebEngineRequestInterceptor.h rename to libraries/networking/src/HFWebEngineRequestInterceptor.h diff --git a/interface/src/networking/RequestFilters.cpp b/libraries/networking/src/RequestFilters.cpp similarity index 98% rename from interface/src/networking/RequestFilters.cpp rename to libraries/networking/src/RequestFilters.cpp index fedde94f15..3e72b8a8bd 100644 --- a/interface/src/networking/RequestFilters.cpp +++ b/libraries/networking/src/RequestFilters.cpp @@ -14,7 +14,7 @@ #include -#include +#include "AccountManager.h" namespace { diff --git a/interface/src/networking/RequestFilters.h b/libraries/networking/src/RequestFilters.h similarity index 100% rename from interface/src/networking/RequestFilters.h rename to libraries/networking/src/RequestFilters.h diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 84812b4f60..a80105293b 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -91,14 +91,14 @@ QObject* OffscreenUi::getFlags() { void OffscreenUi::create(QOpenGLContext* context) { OffscreenQmlSurface::create(context); - auto rootContext = getRootContext(); + auto myContext = getSurfaceContext(); - rootContext->setContextProperty("OffscreenUi", this); - rootContext->setContextProperty("offscreenFlags", offscreenFlags = new OffscreenFlags()); - rootContext->setContextProperty("fileDialogHelper", new FileDialogHelper()); + myContext->setContextProperty("OffscreenUi", this); + myContext->setContextProperty("offscreenFlags", offscreenFlags = new OffscreenFlags()); + myContext->setContextProperty("fileDialogHelper", new FileDialogHelper()); auto tabletScriptingInterface = DependencyManager::get(); TabletProxy* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"); - rootContext->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership); + myContext->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership); } void OffscreenUi::show(const QUrl& url, const QString& name, std::function f) { @@ -547,14 +547,14 @@ void OffscreenUi::createDesktop(const QUrl& url) { } #ifdef DEBUG - getRootContext()->setContextProperty("DebugQML", QVariant(true)); + getSurfaceContext()->setContextProperty("DebugQML", QVariant(true)); #else - getRootContext()->setContextProperty("DebugQML", QVariant(false)); + getSurfaceContext()->setContextProperty("DebugQML", QVariant(false)); #endif _desktop = dynamic_cast(load(url)); Q_ASSERT(_desktop); - getRootContext()->setContextProperty("desktop", _desktop); + getSurfaceContext()->setContextProperty("desktop", _desktop); _toolWindow = _desktop->findChild("ToolWindow"); diff --git a/libraries/ui/src/VrMenu.cpp b/libraries/ui/src/VrMenu.cpp index 878514dd41..3959e950e9 100644 --- a/libraries/ui/src/VrMenu.cpp +++ b/libraries/ui/src/VrMenu.cpp @@ -115,7 +115,7 @@ private: VrMenu::VrMenu(OffscreenUi* parent) : QObject(parent) { _rootMenu = parent->getRootItem()->findChild("rootMenu"); - parent->getRootContext()->setContextProperty("rootMenu", _rootMenu); + parent->getSurfaceContext()->setContextProperty("rootMenu", _rootMenu); } QObject* VrMenu::findMenuObject(const QString& menuOption) {