1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKLOADER_P_H
5#define QQUICKLOADER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickimplicitsizeitem_p.h"
19
20QT_BEGIN_NAMESPACE
21
22class QQuickLoaderPrivate;
23class QQmlV4Function;
24class Q_QUICK_PRIVATE_EXPORT QQuickLoader : public QQuickImplicitSizeItem
25{
26 Q_OBJECT
27
28 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged FINAL)
29 Q_PROPERTY(QUrl source READ source WRITE setSourceWithoutResolve NOTIFY sourceChanged FINAL)
30 Q_PROPERTY(QQmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged FINAL)
31 Q_PROPERTY(QObject *item READ item NOTIFY itemChanged FINAL)
32 Q_PROPERTY(Status status READ status NOTIFY statusChanged FINAL)
33 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged FINAL)
34 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged FINAL)
35 QML_NAMED_ELEMENT(Loader)
36 QML_ADDED_IN_VERSION(2, 0)
37
38public:
39 QQuickLoader(QQuickItem *parent = nullptr);
40 virtual ~QQuickLoader();
41
42 bool active() const;
43 void setActive(bool newVal);
44
45 Q_INVOKABLE void setSource(const QUrl &source, QJSValue initialProperties);
46 Q_INVOKABLE void setSource(const QUrl &source);
47
48 QUrl source() const;
49 void setSourceWithoutResolve(const QUrl &source);
50
51 QQmlComponent *sourceComponent() const;
52 void setSourceComponent(QQmlComponent *);
53 void resetSourceComponent();
54
55 enum Status { Null, Ready, Loading, Error };
56 Q_ENUM(Status)
57 Status status() const;
58 qreal progress() const;
59
60 bool asynchronous() const;
61 void setAsynchronous(bool a);
62
63 QObject *item() const;
64
65Q_SIGNALS:
66 void itemChanged();
67 void activeChanged();
68 void sourceChanged();
69 void sourceComponentChanged();
70 void statusChanged();
71 void progressChanged();
72 void loaded();
73 void asynchronousChanged();
74
75protected:
76 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
77 void componentComplete() override;
78 void itemChange(ItemChange change, const ItemChangeData &value) override;
79
80private:
81 QUrl setSourceUrlHelper(const QUrl &unresolvedUrl);
82 void setSource(const QUrl &sourceUrl, bool needsClear);
83 void loadFromSource();
84 void loadFromSourceComponent();
85 Q_DISABLE_COPY(QQuickLoader)
86 Q_DECLARE_PRIVATE(QQuickLoader)
87 Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
88 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
89};
90
91QT_END_NAMESPACE
92
93QML_DECLARE_TYPE(QQuickLoader)
94
95#endif // QQUICKLOADER_P_H
96

source code of qtdeclarative/src/quick/items/qquickloader_p.h