-
Notifications
You must be signed in to change notification settings - Fork 0
/
speedyimage.h
62 lines (49 loc) · 1.73 KB
/
speedyimage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include <QQuickItem>
#include <memory>
class SpeedyImagePrivate;
class SpeedyImage : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
Q_PROPERTY(QSize loadingSize READ loadingSize WRITE setLoadingSize NOTIFY loadingSizeChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QSize imageSize READ imageSize NOTIFY imageSizeChanged)
Q_PROPERTY(QSizeF paintedSize READ paintedSize NOTIFY paintedSizeChanged)
public:
enum Status {
Null,
Ready,
Loading,
Error
};
Q_ENUM(Status)
explicit SpeedyImage(QQuickItem *parent = nullptr);
virtual ~SpeedyImage();
QString source() const;
void setSource(const QString &source);
// XXX Change zero dimensions of loadingSize to the actual size, as soon as imageSize is
// available. Because it's constant, this isn't problematic, and then there is something
// safe to bind to.
QSize loadingSize() const;
void setLoadingSize(QSize size);
Status status() const;
QSize imageSize() const;
QSizeF paintedSize() const;
signals:
void sourceChanged();
void loadingSizeChanged();
void statusChanged();
void imageSizeChanged();
void paintedSizeChanged();
protected:
virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
#else
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
#endif
virtual void componentComplete();
private:
std::shared_ptr<SpeedyImagePrivate> d;
};