mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Merge pull request #778 from ctrlaltdavid/feature/chat-open-browser
Open chat hyperlinks in Interface browser window
This commit is contained in:
commit
ea4ae45d9e
6 changed files with 23 additions and 13 deletions
|
@ -5,6 +5,7 @@ module.exports = {
|
|||
"ecmaVersion": 5
|
||||
},
|
||||
"globals": {
|
||||
"About": false,
|
||||
"Account": false,
|
||||
"Agent": false,
|
||||
"AnimationCache": false,
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue