Thu, 04 Jun 2015 14:50:33 +0200
Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.
michael@0 | 1 | /* |
michael@0 | 2 | * |
michael@0 | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 4 | * you may not use this file except in compliance with the License. |
michael@0 | 5 | * You may obtain a copy of the License at |
michael@0 | 6 | * |
michael@0 | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 8 | * |
michael@0 | 9 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 12 | * See the License for the specific language governing permissions and |
michael@0 | 13 | * limitations under the License. |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | #ifndef NOTIFICATION_H |
michael@0 | 17 | #define NOTIFICATION_H |
michael@0 | 18 | |
michael@0 | 19 | #include <QtQuick> |
michael@0 | 20 | #include <QMediaPlayer> |
michael@0 | 21 | #include <cplugin.h> |
michael@0 | 22 | #include <cordova.h> |
michael@0 | 23 | |
michael@0 | 24 | class Dialogs: public CPlugin { |
michael@0 | 25 | Q_OBJECT |
michael@0 | 26 | public: |
michael@0 | 27 | explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) { |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | virtual const QString fullName() override { |
michael@0 | 31 | return Dialogs::fullID(); |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | virtual const QString shortName() override { |
michael@0 | 35 | return "Notification"; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | static const QString fullID() { |
michael@0 | 39 | return "Notification"; |
michael@0 | 40 | } |
michael@0 | 41 | public slots: |
michael@0 | 42 | void beep(int scId, int ecId, int times); |
michael@0 | 43 | void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel); |
michael@0 | 44 | void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels); |
michael@0 | 45 | void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText); |
michael@0 | 46 | |
michael@0 | 47 | void notificationDialogButtonPressed(int buttonId, const QString &text, bool prompt) { |
michael@0 | 48 | if (prompt) { |
michael@0 | 49 | QVariantMap res; |
michael@0 | 50 | res.insert("buttonIndex", buttonId); |
michael@0 | 51 | res.insert("input1", text); |
michael@0 | 52 | this->cb(_alertCallback, res); |
michael@0 | 53 | } else { |
michael@0 | 54 | this->cb(_alertCallback, buttonId); |
michael@0 | 55 | } |
michael@0 | 56 | _alertCallback = 0; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | private: |
michael@0 | 60 | int _alertCallback; |
michael@0 | 61 | QMediaPlayer _player; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | #endif |