Merge pull request #778 from ctrlaltdavid/feature/chat-open-browser

Open chat hyperlinks in Interface browser window
This commit is contained in:
kasenvr 2020-10-06 04:34:48 -04:00 committed by GitHub
commit ea4ae45d9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 13 deletions

View file

@ -5,6 +5,7 @@ module.exports = {
"ecmaVersion": 5
},
"globals": {
"About": false,
"Account": false,
"Agent": false,
"AnimationCache": false,

View file

@ -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<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system");
auto hmd = DependencyManager::get<HMDScriptingInterface>();
auto offscreenUi = DependencyManager::get<OffscreenUi>();

View file

@ -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.
*/

View file

@ -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>();
offscreenUi->load("Browser.qml");
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
if (!url.isEmpty()) {
newObject->setProperty("url", url);
}
});
}

View file

@ -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:

View file

@ -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);