This repository has been archived by the owner on Mar 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
filechooser.h
75 lines (59 loc) · 1.76 KB
/
filechooser.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
#ifndef FILECHOOSER_H
#define FILECHOOSER_H
#include <QObject>
#include <QUrl>
class FileChooser : public QObject
{
Q_OBJECT
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
Q_PROPERTY(QUrl contentUrl READ contentUrl WRITE setContentUrl NOTIFY contentUrlChanged)
Q_PROPERTY(ChooserType type READ type WRITE setType NOTIFY typeChanged)
Q_PROPERTY(QString mimeType READ mimeType WRITE setMimeType NOTIFY mimeTypeChanged)
Q_PROPERTY(ChooserFlags chooserFlags READ chooserFlags WRITE setChooserFlags NOTIFY chooserFlagsChanged)
public:
enum ChooserType {
GetContent = 0,
OpenDocument = 1,
CreateDocument = 2
};
Q_ENUM(ChooserType)
enum ChooserFlag {
OpenableFlag = 0x01,
LocalOnlyFlag = 0x02,
AlwaysGrantWriteFlag = 0x04,
PersistPermissionsFlag = 0x08
};
Q_DECLARE_FLAGS(ChooserFlags, ChooserFlag)
Q_FLAG(ChooserFlags)
explicit FileChooser(QObject *parent = nullptr);
QString title() const;
QUrl contentUrl() const;
ChooserType type() const;
QString mimeType() const;
ChooserFlags chooserFlags() const;
public slots:
void open();
void setTitle(QString title);
void setContentUrl(QUrl contentUrl);
void setType(ChooserType type);
void setMimeType(QString mimeType);
void setChooserFlags(ChooserFlags chooserFlags);
signals:
void accepted();
void rejected();
void titleChanged(QString title);
void contentUrlChanged(QUrl contentUrl);
void typeChanged(ChooserType type);
void mimeTypeChanged(QString mimeType);
void chooserFlagsChanged(ChooserFlags chooserFlags);
private slots:
void onDispatched(const QString &message, const QVariantMap &data);
private:
static const QString ContentChoosenMessage;
QString _title;
QUrl _contentUrl;
ChooserType _type;
QString _mimeType;
ChooserFlags _flags;
};
#endif // FILECHOOSER_H