mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
adding whitelisting for dockedWidgets
This commit is contained in:
parent
ee3e2f0dd7
commit
6f04e039fe
3 changed files with 14 additions and 14 deletions
|
@ -109,16 +109,14 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
|||
auto mainWindow = qApp->getWindow();
|
||||
_dockWidget = std::shared_ptr<DockWidget>(new DockWidget(title, mainWindow), dockWidgetDeleter);
|
||||
auto quickView = _dockWidget->getQuickView();
|
||||
Application::setupQmlSurface(quickView->rootContext(), true);
|
||||
|
||||
Application::setupQmlSurface(quickView->rootContext() , true);
|
||||
|
||||
|
||||
//add any whitelisted callbacks
|
||||
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);
|
||||
}
|
||||
offscreenUi->widgetContextForUrl(sourceUrl, quickView->rootContext());
|
||||
|
||||
/**jsdoc
|
||||
* Configures how a <code>NATIVE</code> window is displayed.
|
||||
* @typedef {object} InteractiveWindow.PresentationWindowInfo
|
||||
|
@ -158,6 +156,8 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
|||
}
|
||||
});
|
||||
_dockWidget->setSource(QUrl(sourceUrl));
|
||||
|
||||
|
||||
mainWindow->addDockWidget(dockArea, _dockWidget.get());
|
||||
} else {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
|
|
|
@ -307,16 +307,16 @@ void OffscreenQmlSurface::onRootContextCreated(QQmlContext* qmlContext) {
|
|||
#endif
|
||||
}
|
||||
|
||||
QQmlContext* OffscreenQmlSurface::widgetContextForUrl(const QUrl& url) {
|
||||
void OffscreenQmlSurface::widgetContextForUrl(const QUrl& url, QQmlContext* context) {
|
||||
|
||||
// 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;
|
||||
if(!callbacks.empty()){
|
||||
for(const auto& callback : callbacks){
|
||||
callback(context);
|
||||
}
|
||||
}
|
||||
|
||||
return contextForUrl(url,nullptr, false);
|
||||
}
|
||||
|
||||
QQmlContext* OffscreenQmlSurface::contextForUrl(const QUrl& qmlSource, QQuickItem* parent, bool forceNewContext) {
|
||||
|
|
|
@ -36,7 +36,7 @@ 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);
|
||||
void widgetContextForUrl(const QUrl& url,QQmlContext* context);
|
||||
|
||||
signals:
|
||||
void focusObjectChanged(QObject* newFocus);
|
||||
|
|
Loading…
Reference in a new issue