Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dloader_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QQUICK3DLOADER_P_H
7#define QQUICK3DLOADER_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3D/private/qquick3dnode_p.h>
21#include <QQmlIncubator>
22#include <private/qqmlguard_p.h>
23
24#include <private/qv4value_p.h>
25
26QT_BEGIN_NAMESPACE
27class QQuick3DLoader;
29{
30public:
31 QQuick3DLoaderIncubator(QQuick3DLoader *l, IncubationMode mode)
32 : QQmlIncubator(mode), m_loader(l) {}
33
34protected:
35 void statusChanged(Status) override;
36 void setInitialState(QObject *) override;
37
38private:
39 QQuick3DLoader *m_loader;
40};
41
42class QQmlContext;
43
44class Q_QUICK3D_EXPORT QQuick3DLoader : public QQuick3DNode
45{
46 Q_OBJECT
47
48 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
49 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
50 Q_PROPERTY(QQmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
51 Q_PROPERTY(QObject *item READ item NOTIFY itemChanged)
52 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
53 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
54 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
55
56 QML_NAMED_ELEMENT(Loader3D)
57
58public:
59 explicit QQuick3DLoader(QQuick3DNode *parent = nullptr);
60 ~QQuick3DLoader() override;
61
62 bool active() const;
63 void setActive(bool newVal);
64
65 Q_INVOKABLE void setSource(QQmlV4FunctionPtr);
66
67 QUrl source() const;
68 void setSource(const QUrl &);
69
70 QQmlComponent *sourceComponent() const;
71 void setSourceComponent(QQmlComponent *);
72 void resetSourceComponent();
73
74 enum Status { Null, Ready, Loading, Error };
75 Q_ENUM(Status)
76 Status status() const;
77 qreal progress() const;
78
79 bool asynchronous() const;
80 void setAsynchronous(bool a);
81
82 QObject *item() const;
83
84Q_SIGNALS:
85 void itemChanged();
86 void activeChanged();
87 void sourceChanged();
88 void sourceComponentChanged();
89 void statusChanged();
90 void progressChanged();
91 void loaded();
92 void asynchronousChanged();
93
94protected:
95 void componentComplete() override;
96
97private Q_SLOTS:
98 void sourceLoaded();
99
100private:
101 Q_DISABLE_COPY(QQuick3DLoader)
102 friend QQuick3DLoaderIncubator;
103 void setSource(const QUrl &sourceUrl, bool needsClear);
104 void loadFromSource();
105 void loadFromSourceComponent();
106 void clear();
107 void load();
108
109 void incubatorStateChanged(QQmlIncubator::Status status);
110 void setInitialState(QObject *obj);
111 void disposeInitialPropertyValues();
112 static QUrl resolveSourceUrl(QQmlV4FunctionPtr args);
113 QV4::ReturnedValue extractInitialPropertyValues(QQmlV4FunctionPtr args, bool *error);
114
115 void createComponent();
116
117 QUrl m_source;
118 QQuick3DNode *m_item;
119 QObject *m_object;
120 QQmlStrongJSQObjectReference<QQmlComponent> m_component;
121 QQmlContext *m_itemContext;
122 QQuick3DLoaderIncubator *m_incubator;
123 QV4::PersistentValue m_initialPropertyValues;
124 QV4::PersistentValue m_qmlCallingContext;
125 bool m_active : 1;
126 bool m_loadingFromSource : 1;
127 bool m_asynchronous : 1;
128};
129
130QT_END_NAMESPACE
131
132QML_DECLARE_TYPE(QQuick3DLoader)
133
134#endif // QQUICK3DLOADER_P_H
void statusChanged(Status) override
Called when the status of the incubator changes.
void setInitialState(QObject *) override
Called after the object is first created, but before complex property bindings are evaluated and,...
QQuick3DLoaderIncubator(QQuick3DLoader *l, IncubationMode mode)
Combined button and popup list for selecting options.