1// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#ifndef QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H
5#define QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H
6
7#include <Qt3DQuickExtras/qt3dquickextras_global.h>
8#include <QtCore/QUrl>
9#include <QtCore/qpointer.h>
10#include <QtQuick/QQuickWindow>
11
12QT_BEGIN_NAMESPACE
13
14class QQmlIncubationController;
15
16namespace Qt3DCore {
17class QAbstractAspect;
18namespace Quick {
19class QQmlAspectEngine;
20}
21}
22
23namespace Qt3DRender {
24class QRenderAspect;
25class QCamera;
26}
27
28namespace Qt3DInput {
29class QInputAspect;
30}
31
32namespace Qt3DLogic {
33class QLogicAspect;
34}
35
36namespace Qt3DExtras {
37
38namespace Quick {
39
40class Qt3DQuickWindowPrivate;
41
42class Q_3DQUICKEXTRASSHARED_EXPORT Qt3DQuickWindow : public QWindow
43{
44 Q_OBJECT
45 Q_PROPERTY(CameraAspectRatioMode cameraAspectRatioMode READ cameraAspectRatioMode WRITE setCameraAspectRatioMode NOTIFY cameraAspectRatioModeChanged)
46
47public:
48 explicit Qt3DQuickWindow(QWindow *parent = nullptr);
49 ~Qt3DQuickWindow();
50
51 void registerAspect(Qt3DCore::QAbstractAspect *aspect);
52 void registerAspect(const QString &name);
53
54 void setSource(const QUrl &source);
55 Qt3DCore::Quick::QQmlAspectEngine *engine() const;
56
57 enum CameraAspectRatioMode {
58 AutomaticAspectRatio,
59 UserAspectRatio
60 };
61 Q_ENUM(CameraAspectRatioMode); // LCOV_EXCL_LINE
62
63 void setCameraAspectRatioMode(CameraAspectRatioMode mode);
64 CameraAspectRatioMode cameraAspectRatioMode() const;
65
66Q_SIGNALS:
67 void cameraAspectRatioModeChanged(CameraAspectRatioMode mode);
68
69protected:
70 void showEvent(QShowEvent *e) override;
71
72private:
73 void onSceneCreated(QObject *rootObject);
74 void setWindowSurface(QObject *rootObject);
75 void setCameraAspectModeHelper();
76 void updateCameraAspectRatio();
77
78 Q_DECLARE_PRIVATE(Qt3DQuickWindow)
79};
80
81} // Quick
82
83} // Qt3DExtras
84
85QT_END_NAMESPACE
86
87#endif // QT3DEXTRAS_QUICK_QT3DQUICKWINDOW_H
88

source code of qt3d/src/quick3d/quick3dextras/qt3dquickwindow.h