diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-02-08 11:10:12 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2018-02-08 11:57:20 +0000 |
commit | a8c45eb68816f9715b76842e1e07d237bccf88e8 (patch) | |
tree | 94b8e2ffecb4e7351616926bd896feef272eb8dd /examples | |
parent | 9dd64ef2b09f13e8c63b3016ac314eeb63e43d35 (diff) |
Port Studio3D properties and signals
Add the following:
Signals:
frameUpdate - emitted on every frame action invocation
presentationReady - emitted upon each successful presentation load
Properties:
running - emitted on presentation load. Some semantics cannot really be
ported over since the engines work differently. There's also a lack of
true -> false -> true transition when opening another presentation but
that's assumed to be acceptable.
error - error messages from parsing and others is now collected in a
string (and no widget dialog is shown when using Studio3D)
ignoredEvents - input events can be disabled. Unlike 3DS1 we use a
proper property with a flag-based API in Qt style.
Change-Id: I608840d5c8dceb169541441de635a576ac014e30
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/3dstudioruntime2/simpleqml/main.cpp | 4 | ||||
-rw-r--r-- | examples/3dstudioruntime2/simpleqml/main.qml | 41 | ||||
-rw-r--r-- | examples/3dstudioruntime2/simpleqml/simpleqml.pro | 2 |
3 files changed, 43 insertions, 4 deletions
diff --git a/examples/3dstudioruntime2/simpleqml/main.cpp b/examples/3dstudioruntime2/simpleqml/main.cpp index d503f4d..44ac32b 100644 --- a/examples/3dstudioruntime2/simpleqml/main.cpp +++ b/examples/3dstudioruntime2/simpleqml/main.cpp @@ -48,14 +48,14 @@ ** ****************************************************************************/ -#include <QtGui/QGuiApplication> +#include <QtWidgets/QApplication> // for MessageDialog #include <QtQuick/QQuickView> #include <q3dsruntimeglobal.h> int main(int argc, char *argv[]) { qputenv("QSG_INFO", "1"); - QGuiApplication app(argc, argv); + QApplication app(argc, argv); QSurfaceFormat::setDefaultFormat(Q3DS::surfaceFormat()); QQuickView viewer; diff --git a/examples/3dstudioruntime2/simpleqml/main.qml b/examples/3dstudioruntime2/simpleqml/main.qml index b489a1f..cbf1817 100644 --- a/examples/3dstudioruntime2/simpleqml/main.qml +++ b/examples/3dstudioruntime2/simpleqml/main.qml @@ -59,6 +59,10 @@ Rectangle { id: root color: "lightGray" + MessageDialog { + id: errorDialog + } + Studio3D { id: s3d focus: true @@ -68,6 +72,29 @@ Rectangle { id: s3dpres source: "qrc:/presentation/barrel.uip" } + ignoredEvents: mouseEvCb.checked ? Studio3D.EnableAllEvents : (Studio3D.IgnoreMouseEvents | Studio3D.IgnoreWheelEvents) + onRunningChanged: console.log("running: " + s3d.running) + onPresentationReady: console.log("presentationReady") + onErrorChanged: { + if (s3d.error !== "") { + errorDialog.text = s3d.error; + errorDialog.open(); + } + } + + property int frameCount: 0 + onFrameUpdate: frameCount += 1 + + Timer { + running: true + repeat: true + interval: 1000 + onTriggered: { + fpsCount.text = "~" + s3d.frameCount + " FPS"; + s3d.frameCount = 0; + } + } + NumberAnimation on opacity { id: opacityAnimation from: 1 @@ -111,12 +138,24 @@ Rectangle { text: "Open" onClicked: openDialog.open() } + CheckBox { + id: mouseEvCb + text: "Let mouse events through" + checked: true + } + } + + Text { + id: fpsCount + text: "0 FPS" + anchors.bottom: parent.bottom + anchors.left: parent.left } FileDialog { id: openDialog fileMode: FileDialog.OpenFile - nameFilters: ["UIP files (*.uip)", "UIA files (*.uia)"] + nameFilters: ["UIP files (*.uip)", "UIA files (*.uia)", "All files (*)"] onAccepted: s3dpres.source = file } } diff --git a/examples/3dstudioruntime2/simpleqml/simpleqml.pro b/examples/3dstudioruntime2/simpleqml/simpleqml.pro index 208fdae..b0cd0c2 100644 --- a/examples/3dstudioruntime2/simpleqml/simpleqml.pro +++ b/examples/3dstudioruntime2/simpleqml/simpleqml.pro @@ -1,6 +1,6 @@ TEMPLATE = app -QT += qml quick 3dstudioruntime2 +QT += widgets qml quick 3dstudioruntime2 SOURCES += \ main.cpp |