History

Add URL parameter to Window.openUrl() API function

David Rowe committed 6 years ago

Commit 64eb4d11 parent 86aa3c82 files · +11 −6Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+8−4
@@ -645,12 +645,16 @@ void WindowScriptingInterface::setActiveDisplayPlugin(int index) { · 644 unmodified lines
645645 qApp->setActiveDisplayPlugin(name);
646646 }
647647
648−void WindowScriptingInterface::openWebBrowser() {
648+void WindowScriptingInterface::openWebBrowser(const QString& url) {
649649 if (QThread::currentThread() != thread()) {
650− QMetaObject::invokeMethod(this, "openWebBrowser", Qt::QueuedConnection);
650+ QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url));
651651 return;
652652 }
653−
653+
654654 auto offscreenUi = DependencyManager::get<OffscreenUi>();
655− offscreenUi->load("Browser.qml");
655+ offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
656+ if (!url.isEmpty()) {
657+ newObject->setProperty("url", url);
658+ }
659+ });
656660 }