Add URL parameter to Window.openUrl() API function

This commit is contained in:
David Rowe 2020-10-03 17:00:43 +13:00
parent 86aa3c8709
commit 64eb4d11e1
2 changed files with 11 additions and 6 deletions

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: