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 Q_QUICK_EXPORT QQuickLoader : public QQuickImplicitSizeItem
24{
25 Q_OBJECT
26
27 Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
28 Q_PROPERTY(QUrl source READ source WRITE setSourceWithoutResolve NOTIFY sourceChanged)
29 Q_PROPERTY(QQmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceComponentChanged)
30 Q_PROPERTY(QObject *item READ item NOTIFY itemChanged)
31 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
32 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
33 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
34 QML_NAMED_ELEMENT(Loader)
35 QML_ADDED_IN_VERSION(2, 0)
36
37public:
38 QQuickLoader(QQuickItem *parent = nullptr);
39 virtual ~QQuickLoader();
40
41 bool active() const;
42 void setActive(bool newVal);
43
44 Q_INVOKABLE void setSource(const QUrl &source, QJSValue initialProperties);
45 Q_INVOKABLE void setSource(const QUrl &source);
46
47 QUrl source() const;
48 void setSourceWithoutResolve(const QUrl &source);
49
50 QQmlComponent *sourceComponent() const;
51 void setSourceComponent(QQmlComponent *);
52 void resetSourceComponent();
53
54 enum Status { Null, Ready, Loading, Error };
55 Q_ENUM(Status)
56 Status status() const;
57 qreal progress() const;
58
59 bool asynchronous() const;
60 void setAsynchronous(bool a);
61
62 QObject *item() const;
63
64Q_SIGNALS:
65 void itemChanged();
66 void activeChanged();
67 void sourceChanged();
68 void sourceComponentChanged();
69 void statusChanged();
70 void progressChanged();
71 void loaded();
72 void asynchronousChanged();
73
74protected:
75 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
76 void componentComplete() override;
77 void itemChange(ItemChange change, const ItemChangeData &value) override;
78
79private:
80 QUrl setSourceUrlHelper(const QUrl &unresolvedUrl);
81 void setSource(const QUrl &sourceUrl, bool needsClear);
82 void loadFromSource();
83 void loadFromSourceComponent();
84 Q_DISABLE_COPY(QQuickLoader)
85 Q_DECLARE_PRIVATE(QQuickLoader)
86 Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded())
87 Q_PRIVATE_SLOT(d_func(), void _q_updateSize())
88};
89
90QT_END_NAMESPACE
91
92#endif // QQUICKLOADER_P_H
93

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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