michael@0: /* michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #include "notification.h" michael@0: michael@0: #include michael@0: michael@0: void Dialogs::beep(int scId, int ecId, int times) { michael@0: Q_UNUSED(scId) michael@0: Q_UNUSED(ecId) michael@0: Q_UNUSED(times) michael@0: michael@0: _player.setVolume(100); michael@0: _player.setMedia(QUrl::fromLocalFile("/usr/share/sounds/ubuntu/stereo/bell.ogg")); michael@0: _player.play(); michael@0: } michael@0: michael@0: void Dialogs::alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel) { michael@0: QStringList list; michael@0: list.append(buttonLabel); michael@0: michael@0: confirm(scId, ecId, message, title, list); michael@0: } michael@0: michael@0: void Dialogs::confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels) { michael@0: Q_UNUSED(ecId); michael@0: michael@0: if (_alertCallback) { michael@0: qCritical() << "can't open second dialog"; michael@0: return; michael@0: } michael@0: _alertCallback = scId; michael@0: michael@0: QString s1, s2, s3; michael@0: if (buttonLabels.size() > 0) michael@0: s1 = buttonLabels[0]; michael@0: if (buttonLabels.size() > 1) michael@0: s2 = buttonLabels[1]; michael@0: if (buttonLabels.size() > 2) michael@0: s3 = buttonLabels[2]; michael@0: michael@0: QString path = m_cordova->get_app_dir() + "/../qml/notification.qml"; michael@0: QString qml = QString("PopupUtils.open(%1, root, { root: root, cordova: cordova, title: %2, text: %3, promptVisible: false, button1Text: %4, button2Text: %5, button3Text: %6 })") michael@0: .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(title)).arg(CordovaInternal::format(message)) michael@0: .arg(CordovaInternal::format(s1)).arg(CordovaInternal::format(s2)).arg(CordovaInternal::format(s3)); michael@0: michael@0: m_cordova->execQML(qml); michael@0: } michael@0: michael@0: void Dialogs::prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText) { michael@0: Q_UNUSED(ecId); michael@0: michael@0: if (_alertCallback) { michael@0: qCritical() << "can't open second dialog"; michael@0: return; michael@0: } michael@0: _alertCallback = scId; michael@0: michael@0: QString s1, s2, s3; michael@0: if (buttonLabels.size() > 0) michael@0: s1 = buttonLabels[0]; michael@0: if (buttonLabels.size() > 1) michael@0: s2 = buttonLabels[1]; michael@0: if (buttonLabels.size() > 2) michael@0: s3 = buttonLabels[2]; michael@0: QString path = m_cordova->get_app_dir() + "/../qml/notification.qml"; michael@0: QString qml = QString("PopupUtils.open(%1, root, { root: root, cordova: cordova, title: %2, text: %3, promptVisible: true, defaultPromptText: %7, button1Text: %4, button2Text: %5, button3Text: %6 })") michael@0: .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(title)).arg(CordovaInternal::format(message)) michael@0: .arg(CordovaInternal::format(s1)).arg(CordovaInternal::format(s2)) michael@0: .arg(CordovaInternal::format(s3)).arg(CordovaInternal::format(defaultText)); michael@0: michael@0: m_cordova->execQML(qml); michael@0: }