|
1 /* |
|
2 * |
|
3 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 * you may not use this file except in compliance with the License. |
|
5 * You may obtain a copy of the License at |
|
6 * |
|
7 * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 * |
|
9 * Unless required by applicable law or agreed to in writing, software |
|
10 * distributed under the License is distributed on an "AS IS" BASIS, |
|
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 * See the License for the specific language governing permissions and |
|
13 * limitations under the License. |
|
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 |