diff --git a/.eslintrc.js b/.eslintrc.js index 9900825b23..df606f0dc9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,6 +5,7 @@ module.exports = { "ecmaVersion": 5 }, "globals": { + "About": false, "Account": false, "Agent": false, "AnimationCache": false, diff --git a/interface/src/AboutUtil.cpp b/interface/src/AboutUtil.cpp index 56cabce03d..b9bea2d85c 100644 --- a/interface/src/AboutUtil.cpp +++ b/interface/src/AboutUtil.cpp @@ -45,6 +45,16 @@ QString AboutUtil::getQtVersion() const { } void AboutUtil::openUrl(const QString& url) const { + auto abboutUtilInstance = AboutUtil::getInstance(); + if (!abboutUtilInstance) { + return; + } + + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(abboutUtilInstance, "openUrl", Q_ARG(const QString&, url)); + return; + } + auto tablet = DependencyManager::get()->getTablet("com.highfidelity.interface.tablet.system"); auto hmd = DependencyManager::get(); auto offscreenUi = DependencyManager::get(); diff --git a/interface/src/AboutUtil.h b/interface/src/AboutUtil.h index a602528154..8cc76dad1e 100644 --- a/interface/src/AboutUtil.h +++ b/interface/src/AboutUtil.h @@ -79,7 +79,7 @@ public: public slots: /**jsdoc - * Display a web page in an Interface browser window. + * Display a web page in an Interface browser window or the tablet. * @function About.openUrl * @param {string} url - The URL of the web page you want to view in Interface. */ diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index 434adf0bc8..14a0d04023 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -645,12 +645,16 @@ void WindowScriptingInterface::setActiveDisplayPlugin(int index) { qApp->setActiveDisplayPlugin(name); } -void WindowScriptingInterface::openWebBrowser() { +void WindowScriptingInterface::openWebBrowser(const QString& url) { if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "openWebBrowser", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url)); return; } auto offscreenUi = DependencyManager::get(); - offscreenUi->load("Browser.qml"); + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + if (!url.isEmpty()) { + newObject->setProperty("url", url); + } + }); } diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 28a725f3cb..86d0f400ea 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -616,10 +616,11 @@ public slots: void setActiveDisplayPlugin(int index); /**jsdoc - * Opens a web browser in a pop-up window. + * Opens an Interface web browser window. * @function Window.openWebBrowser + * @param {string} [url=""] - The URL of the web page to display. */ - void openWebBrowser(); + void openWebBrowser(const QString& url = ""); private slots: diff --git a/scripts/communityScripts/chat/FloofChat.js b/scripts/communityScripts/chat/FloofChat.js index b558e52bf8..1208a36e5f 100644 --- a/scripts/communityScripts/chat/FloofChat.js +++ b/scripts/communityScripts/chat/FloofChat.js @@ -322,13 +322,7 @@ function onWebEventReceived(event) { gotoConfirm(event.url); } if (event.cmd === "URL") { - new OverlayWebWindow({ - title: 'Web', - source: event.url, - width: 900, - height: 700, - visible: true - }); + Window.openWebBrowser(event.url); } if (event.cmd === "EXTERNALURL") { Window.openUrl(event.url);