This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
qiimagepicker.h
98 lines (73 loc) · 2.55 KB
/
qiimagepicker.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef QIIMAGEPICKER_H
#define QIIMAGEPICKER_H
#include <QQuickItem>
#include <QImage>
/// QIImagePicker provides a simple interface to access camera and camera roll via the UIImagePickerController
class QIImagePicker : public QQuickItem
{
Q_OBJECT
Q_ENUMS(SourceType)
Q_ENUMS(Status)
Q_PROPERTY(SourceType sourceType READ sourceType WRITE setSourceType NOTIFY sourceTypeChanged)
Q_PROPERTY(QImage image READ image WRITE setImage NOTIFY imageChanged)
Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged)
Q_PROPERTY(bool busy READ busy WRITE setBusy NOTIFY busyChanged)
Q_PROPERTY(QString mediaType READ mediaType WRITE setMediaType NOTIFY mediaTypeChanged)
Q_PROPERTY(QString mediaUrl READ mediaUrl WRITE setMediaUrl NOTIFY mediaUrlChanged)
Q_PROPERTY(QString referenceUrl READ referenceUrl WRITE setReferenceUrl NOTIFY referenceUrlChanged)
public:
enum SourceType {
PhotoLibrary,
Camera,
SavedPhotosAlbum
};
enum Status {
Null, // Nothing loaded
Running, // The view controller is running
Ready, // The image is ready
Saving // The image is saving
};
QIImagePicker(QQuickItem* parent = 0);
~QIImagePicker();
Q_INVOKABLE void show(bool animated = true);
Q_INVOKABLE void close(bool animated = true);
Q_INVOKABLE void save(QString fileName);
/// Save the stored image to tmp file.
Q_INVOKABLE void saveAsTemp();
Q_INVOKABLE void clear();
SourceType sourceType() const;
void setSourceType(const SourceType &sourceType);
QImage image() const;
void setImage(const QImage &image);
Status status() const;
void setStatus(const Status &status);
bool busy() const;
void setBusy(bool busy);
QString mediaType() const;
void setMediaType(const QString &mediaType);
QString mediaUrl() const;
void setMediaUrl(const QString &mediaUrl);
QString referenceUrl() const;
void setReferenceUrl(const QString &referenceUrl);
signals:
void sourceTypeChanged();
void imageChanged();
void statusChanged();
void busyChanged();
void referenceUrlChanged();
void mediaTypeChanged();
void mediaUrlChanged();
void ready();
void saved(QString url);
private:
Q_INVOKABLE void onReceived(QString name,QVariantMap data);
Q_INVOKABLE void endSave(QString fileName);
SourceType m_sourceType;
QImage m_image;
Status m_status;
QString m_mediaType;
QString m_mediaUrl;
QString m_referenceUrl;
bool m_busy;
};
#endif // QIIMAGEPICKER_H