1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | #ifndef NOTIFICATION_H
|
17 | #define NOTIFICATION_H
|
18 |
|
19 | #include <QtQuick>
|
20 | #include <QMediaPlayer>
|
21 | #include <cplugin.h>
|
22 | #include <cordova.h>
|
23 |
|
24 | class Dialogs: public CPlugin {
|
25 | Q_OBJECT
|
26 | public:
|
27 | explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) {
|
28 | }
|
29 |
|
30 | virtual const QString fullName() override {
|
31 | return Dialogs::fullID();
|
32 | }
|
33 |
|
34 | virtual const QString shortName() override {
|
35 | return "Notification";
|
36 | }
|
37 |
|
38 | static const QString fullID() {
|
39 | return "Notification";
|
40 | }
|
41 | public slots:
|
42 | void beep(int scId, int ecId, int times);
|
43 | void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel);
|
44 | void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels);
|
45 | void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText);
|
46 |
|
47 | void notificationDialogButtonPressed(int buttonId, const QString &text, bool prompt) {
|
48 | if (prompt) {
|
49 | QVariantMap res;
|
50 | res.insert("buttonIndex", buttonId);
|
51 | res.insert("input1", text);
|
52 | this->cb(_alertCallback, res);
|
53 | } else {
|
54 | this->cb(_alertCallback, buttonId);
|
55 | }
|
56 | _alertCallback = 0;
|
57 | }
|
58 |
|
59 | private:
|
60 | int _alertCallback;
|
61 | QMediaPlayer _player;
|
62 | };
|
63 |
|
64 | #endif
|