summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@qt.io>2019-05-21 12:38:46 +0300
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-05-21 12:38:46 +0300
commit6e6fc518adf0d4da2d5bbe0deaa558c192c85a15 (patch)
tree39781293e726a8c698a6494330e14291f525c6f1
parentda98cee59c3ff8d26f1c10d203733cab24e7a57c (diff)
QML Engine patch
Change-Id: I0c34762c5de069165035bf9dacbe0d1a7ec33035 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.cpp14
-rw-r--r--src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.h1
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.cpp15
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer.h4
-rw-r--r--src/Runtime/api/studio3d/q3dssurfaceviewer_p.h2
5 files changed, 36 insertions, 0 deletions
diff --git a/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.cpp b/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.cpp
index caa633ac..9b8550cf 100644
--- a/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.cpp
+++ b/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.cpp
@@ -237,3 +237,17 @@ void Q3DSQmlStreamProxy::setPath(const QString& path)
QString modPath = QFileInfo(path).path(); // path() strips filename out
m_path = pathToUrl(modPath);
}
+
+void Q3DSQmlStreamProxy::setEngine(QQmlEngine *engine)
+{
+ if (m_engine)
+ delete m_engine;
+
+ m_engine = engine;
+
+ // Add extra import path for binary installations
+ QString extraImportPath(QStringLiteral("%1/qml"));
+ m_engine->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath()));
+
+ m_engine->setIncubationController(new Q3DSIncubationController(this));
+}
diff --git a/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.h b/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.h
index daba821b..85a1cc6d 100644
--- a/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.h
+++ b/src/QtExtras/qmlstreamer/q3dsqmlstreamproxy.h
@@ -52,6 +52,7 @@ public:
void unregisterPresentation(const QString &presentationId);
void setSettings(Q3DSSubPresentationSettings *settings);
void setPath(const QString& path);
+ void setEngine(QQmlEngine *engine);
private:
void loadPresentationItem(const QString& presentationId, const QString& presentationArgs);
diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
index fc90e341..7fe2bfa9 100644
--- a/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
+++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.cpp
@@ -341,6 +341,18 @@ QImage Q3DSSurfaceViewerPrivate::grab(const QRect &rect)
return image;
}
+QQmlEngine *Q3DSSurfaceViewer::qmlEngine() const
+{
+ Q_D(const Q3DSSurfaceViewer);
+ return d->qmlEngine;
+}
+
+void Q3DSSurfaceViewer::setQmlEngine(QQmlEngine *qmlEngine)
+{
+ Q_D(Q3DSSurfaceViewer);
+ d->qmlEngine = qmlEngine;
+}
+
bool Q3DSSurfaceViewerPrivate::eventFilter(QObject *obj, QEvent *e)
{
if (m_surface && e->type() == QEvent::PlatformSurface) {
@@ -371,6 +383,9 @@ bool Q3DSSurfaceViewerPrivate::initializeRuntime()
if (m_autoSize)
m_size = m_surface->size();
+ if (nullptr != qmlEngine)
+ m_presentation->d_ptr->streamProxy()->setEngine(qmlEngine);
+
if (!m_viewerApp->InitializeApp(int(m_size.width() * m_pixelRatio),
int(m_size.height() * m_pixelRatio),
m_context->format(), m_fboId, localSource,
diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer.h b/src/Runtime/api/studio3d/q3dssurfaceviewer.h
index 90d25aa1..7ac6bda2 100644
--- a/src/Runtime/api/studio3d/q3dssurfaceviewer.h
+++ b/src/Runtime/api/studio3d/q3dssurfaceviewer.h
@@ -44,6 +44,7 @@ class QSurface;
class QOpenGLContext;
class Q3DSViewerSettings;
class Q3DSPresentation;
+class QQmlEngine;
class Q_STUDIO3D_EXPORT Q3DSSurfaceViewer : public QObject
{
@@ -63,6 +64,9 @@ public:
QImage grab(const QRect &rect = QRect());
+ QQmlEngine *qmlEngine() const;
+ void setQmlEngine(QQmlEngine *qmlEngine);
+
// Property accessors
QSize size() const;
bool autoSize() const;
diff --git a/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h b/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h
index 9c56c1b5..656d139c 100644
--- a/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h
+++ b/src/Runtime/api/studio3d/q3dssurfaceviewer_p.h
@@ -52,6 +52,7 @@ class QSurface;
class QOpenGLContext;
class Q3DSViewerSettings;
class Q3DSPresentation;
+class QQmlEngine;
class Q_STUDIO3D_EXPORT Q3DSSurfaceViewerPrivate : public QObject
{
@@ -96,6 +97,7 @@ private:
Q3DSPresentation *m_presentation;
QString m_id;
QElapsedTimer m_startupTimer;
+ QQmlEngine *qmlEngine = nullptr;
};
QT_END_NAMESPACE