1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Touchgui/plugins/org.apache.cordova.dialogs/src/ubuntu/notification.h Thu Jun 04 14:50:33 2015 +0200 1.3 @@ -0,0 +1,64 @@ 1.4 +/* 1.5 + * 1.6 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.7 + * you may not use this file except in compliance with the License. 1.8 + * You may obtain a copy of the License at 1.9 + * 1.10 + * http://www.apache.org/licenses/LICENSE-2.0 1.11 + * 1.12 + * Unless required by applicable law or agreed to in writing, software 1.13 + * distributed under the License is distributed on an "AS IS" BASIS, 1.14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.15 + * See the License for the specific language governing permissions and 1.16 + * limitations under the License. 1.17 + */ 1.18 + 1.19 +#ifndef NOTIFICATION_H 1.20 +#define NOTIFICATION_H 1.21 + 1.22 +#include <QtQuick> 1.23 +#include <QMediaPlayer> 1.24 +#include <cplugin.h> 1.25 +#include <cordova.h> 1.26 + 1.27 +class Dialogs: public CPlugin { 1.28 + Q_OBJECT 1.29 +public: 1.30 + explicit Dialogs(Cordova *cordova): CPlugin(cordova), _alertCallback(0) { 1.31 + } 1.32 + 1.33 + virtual const QString fullName() override { 1.34 + return Dialogs::fullID(); 1.35 + } 1.36 + 1.37 + virtual const QString shortName() override { 1.38 + return "Notification"; 1.39 + } 1.40 + 1.41 + static const QString fullID() { 1.42 + return "Notification"; 1.43 + } 1.44 +public slots: 1.45 + void beep(int scId, int ecId, int times); 1.46 + void alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel); 1.47 + void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels); 1.48 + void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText); 1.49 + 1.50 + void notificationDialogButtonPressed(int buttonId, const QString &text, bool prompt) { 1.51 + if (prompt) { 1.52 + QVariantMap res; 1.53 + res.insert("buttonIndex", buttonId); 1.54 + res.insert("input1", text); 1.55 + this->cb(_alertCallback, res); 1.56 + } else { 1.57 + this->cb(_alertCallback, buttonId); 1.58 + } 1.59 + _alertCallback = 0; 1.60 + } 1.61 + 1.62 +private: 1.63 + int _alertCallback; 1.64 + QMediaPlayer _player; 1.65 +}; 1.66 + 1.67 +#endif