Merge pull request #15633 from amerhifi/master

BUGZ 220: Docked Widget Whitelisting
This commit is contained in:
Amer 2019-05-24 15:52:18 -07:00 committed by GitHub
commit 9b26f70e2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -109,7 +109,11 @@ 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
OffscreenUi::applyWhiteList(sourceUrl, quickView->rootContext());
/**jsdoc
* Configures how a <code>NATIVE</code> window is displayed.
@ -150,6 +154,8 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
}
});
_dockWidget->setSource(QUrl(sourceUrl));
mainWindow->addDockWidget(dockArea, _dockWidget.get());
} else {
auto offscreenUi = DependencyManager::get<OffscreenUi>();

View file

@ -307,6 +307,13 @@ void OffscreenQmlSurface::onRootContextCreated(QQmlContext* qmlContext) {
#endif
}
void OffscreenQmlSurface::applyWhiteList(const QUrl& url, QQmlContext* context) {
QList<QmlContextCallback> callbacks = getQmlWhitelist()->getCallbacksForUrl(url);
for(const auto& callback : callbacks){
callback(context);
}
}
QQmlContext* OffscreenQmlSurface::contextForUrl(const QUrl& qmlSource, QQuickItem* parent, bool forceNewContext) {
// Get any whitelist functionality
QList<QmlContextCallback> callbacks = getQmlWhitelist()->getCallbacksForUrl(qmlSource);

View file

@ -26,7 +26,8 @@ public:
static void addWhitelistContextHandler(const std::initializer_list<QUrl>& urls, const QmlContextCallback& callback);
static void addWhitelistContextHandler(const QUrl& url, const QmlContextCallback& callback) { addWhitelistContextHandler({ { url } }, callback); };
static void applyWhiteList(const QUrl& url,QQmlContext* context);
bool isFocusText() const { return _focusText; }
bool getCleaned() { return _isCleaned; }
@ -36,7 +37,8 @@ public:
Q_INVOKABLE void lowerKeyboard();
PointerEvent::EventType choosePointerEventType(QEvent::Type type);
Q_INVOKABLE unsigned int deviceIdByTouchPoint(qreal x, qreal y);
signals:
void focusObjectChanged(QObject* newFocus);
void focusTextChanged(bool focusText);