testing context passing to dockWidget via whitelisting.

This commit is contained in:
amerhifi 2019-05-24 10:58:13 -07:00
parent 257ac12bf9
commit bd88a68a0f
3 changed files with 22 additions and 1 deletions

View file

@ -111,6 +111,14 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
auto quickView = _dockWidget->getQuickView();
Application::setupQmlSurface(quickView->rootContext(), true);
auto offscreenUi = DependencyManager::get<OffscreenUi>();
// Build the event bridge and wrapper on the main thread
auto context = offscreenUi->widgetContextForUrl(sourceUrl);
if(context!=nullptr){
_dockWidget->getQuickView()->rootContext()->setContextObject(context);
}
/**jsdoc
* Configures how a <code>NATIVE</code> window is displayed.
* @typedef {object} InteractiveWindow.PresentationWindowInfo

View file

@ -307,6 +307,18 @@ void OffscreenQmlSurface::onRootContextCreated(QQmlContext* qmlContext) {
#endif
}
QQmlContext* OffscreenQmlSurface::widgetContextForUrl(const QUrl& url) {
// Get any whitelist functionality
QList<QmlContextCallback> callbacks = getQmlWhitelist()->getCallbacksForUrl(url);
// If we have whitelisted content, we must load a new context
if(callbacks.empty()){
return nullptr;
}
return contextForUrl(url,nullptr, false);
}
QQmlContext* OffscreenQmlSurface::contextForUrl(const QUrl& qmlSource, QQuickItem* parent, bool forceNewContext) {
// Get any whitelist functionality
QList<QmlContextCallback> callbacks = getQmlWhitelist()->getCallbacksForUrl(qmlSource);

View file

@ -36,7 +36,8 @@ public:
Q_INVOKABLE void lowerKeyboard();
PointerEvent::EventType choosePointerEventType(QEvent::Type type);
Q_INVOKABLE unsigned int deviceIdByTouchPoint(qreal x, qreal y);
QQmlContext* widgetContextForUrl(const QUrl& url);
signals:
void focusObjectChanged(QObject* newFocus);
void focusTextChanged(bool focusText);