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
qquickimagebase_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKIMAGEBASE_P_H
6#define QQUICKIMAGEBASE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
20#include <private/qtquickglobal_p.h>
21#include <QtGui/qcolorspace.h>
22
24
25class QQuickImageBasePrivate;
26class Q_QUICK_EXPORT QQuickImageBase : public QQuickImplicitSizeItem
27{
28 Q_OBJECT
29
30 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
31 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
32 Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
33 Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged)
34 Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged)
35 Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged)
36 Q_PROPERTY(bool mirrorVertically READ mirrorVertically WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged REVISION(6, 2))
37 Q_PROPERTY(bool retainWhileLoading READ retainWhileLoading WRITE setRetainWhileLoading NOTIFY retainWhileLoadingChanged REVISION(6, 8))
38 Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged REVISION(2, 14))
39 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged REVISION(2, 14))
40 Q_PROPERTY(QColorSpace colorSpace READ colorSpace WRITE setColorSpace NOTIFY colorSpaceChanged REVISION(2, 15))
41
42 QML_NAMED_ELEMENT(ImageBase);
43 QML_ADDED_IN_VERSION(2, 14)
44 QML_UNCREATABLE("ImageBase is an abstract base class.")
45
46public:
47 enum LoadPixmapOption {
48 NoOption = 0x0000,
49 HandleDPR = 0x0001,
50 UseProviderOptions = 0x0002
51 };
52
53 Q_DECLARE_FLAGS(LoadPixmapOptions, LoadPixmapOption)
54 Q_FLAG(LoadPixmapOptions)
55
56 QQuickImageBase(QQuickItem *parent=nullptr);
57 ~QQuickImageBase();
58 enum Status { Null, Ready, Loading, Error };
59 Q_ENUM(Status)
60 Status status() const;
61 qreal progress() const;
62
63 QUrl source() const;
64 virtual void setSource(const QUrl &url);
65
66 bool asynchronous() const;
67 void setAsynchronous(bool);
68
69 bool cache() const;
70 void setCache(bool);
71
72 QImage image() const;
73
74 virtual void setSourceSize(const QSize&);
75 QSize sourceSize() const;
76 void resetSourceSize();
77
78 QRectF sourceClipRect() const;
79 void setSourceClipRect(const QRectF &r);
80 void resetSourceClipRect();
81
82 virtual void setMirror(bool mirror);
83 bool mirror() const;
84
85 virtual void setMirrorVertically(bool mirror);
86 bool mirrorVertically() const;
87
88 virtual void setCurrentFrame(int frame);
89 virtual int currentFrame() const;
90
91 virtual int frameCount() const;
92
93 virtual void setAutoTransform(bool transform);
94 bool autoTransform() const;
95
96 QColorSpace colorSpace() const;
97 virtual void setColorSpace(const QColorSpace &colorSpace);
98
99 bool retainWhileLoading() const;
100 void setRetainWhileLoading(bool retain);
101
102 static void resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio);
103
104 // Use a virtual rather than a signal->signal to avoid the huge
105 // connect/conneciton overhead for this rare case.
106 virtual void emitAutoTransformBaseChanged() { }
107
108Q_SIGNALS:
109 void sourceChanged(const QUrl &);
110 void sourceSizeChanged();
111 void statusChanged(QQuickImageBase::Status);
112 void progressChanged(qreal progress);
113 void asynchronousChanged();
114 void cacheChanged();
115 void mirrorChanged();
116 Q_REVISION(2, 14) void currentFrameChanged();
117 Q_REVISION(2, 14) void frameCountChanged();
118 Q_REVISION(2, 15) void sourceClipRectChanged();
119 Q_REVISION(2, 15) void colorSpaceChanged();
120 Q_REVISION(6, 2) void mirrorVerticallyChanged();
121 Q_REVISION(6, 8) void retainWhileLoadingChanged();
122
123protected:
124 void loadEmptyUrl();
125 void loadPixmap(const QUrl &url, LoadPixmapOptions loadOptions = NoOption);
126 virtual void load();
127 void componentComplete() override;
128 virtual void pixmapChange();
129 void itemChange(ItemChange change, const ItemChangeData &value) override;
130 QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent);
131
132private Q_SLOTS:
133 virtual void requestFinished();
134 void requestProgress(qint64,qint64);
135
136private:
137 Q_DISABLE_COPY(QQuickImageBase)
138 Q_DECLARE_PRIVATE(QQuickImageBase)
139};
140
141QT_END_NAMESPACE
142
143#endif // QQUICKIMAGEBASE_P_H
QT_REQUIRE_CONFIG(quick_animatedimage)