Touchgui/plugins/org.apache.cordova.dialogs/src/ubuntu/notification.h

Thu, 04 Jun 2015 14:50:33 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Jun 2015 14:50:33 +0200
changeset 0
e8ccd40d0ef6
permissions
-rw-r--r--

Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.

     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  */
    16 #ifndef NOTIFICATION_H
    17 #define NOTIFICATION_H
    19 #include <QtQuick>
    20 #include <QMediaPlayer>
    21 #include <cplugin.h>
    22 #include <cordova.h>
    24 class Dialogs: public CPlugin {
    25     Q_OBJECT
    26 public:
    27     explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) {
    28     }
    30     virtual const QString fullName() override {
    31         return Dialogs::fullID();
    32     }
    34     virtual const QString shortName() override {
    35         return "Notification";
    36     }
    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);
    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     }
    59 private:
    60     int _alertCallback;
    61     QMediaPlayer _player;
    62 };
    64 #endif

mercurial