You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/08/06 00:30:29 UTC
[1/3] git commit: ubuntu: proper message escaping before passing to
qml
Repository: cordova-plugin-dialogs
Updated Branches:
refs/heads/master c49e84f1f -> 0bb58f873
ubuntu: proper message escaping before passing to qml
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/4352ab97
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/4352ab97
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/4352ab97
Branch: refs/heads/master
Commit: 4352ab97d6fa32a15025fa4b2a64a424e2ca8d32
Parents: c49e84f
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Sat Jun 28 01:22:49 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Aug 5 05:44:58 2014 +0400
----------------------------------------------------------------------
src/ubuntu/notification.cpp | 38 +++++++++++++++++++++-----------------
src/ubuntu/notification.h | 3 ++-
2 files changed, 23 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/4352ab97/src/ubuntu/notification.cpp
----------------------------------------------------------------------
diff --git a/src/ubuntu/notification.cpp b/src/ubuntu/notification.cpp
index 77c5e25..d0adf89 100644
--- a/src/ubuntu/notification.cpp
+++ b/src/ubuntu/notification.cpp
@@ -17,17 +17,14 @@
#include <QApplication>
-#include <QMediaPlayer>
-#include <QMessageBox>
-
void Dialogs::beep(int scId, int ecId, int times) {
Q_UNUSED(scId)
Q_UNUSED(ecId)
Q_UNUSED(times)
- QMediaPlayer* player = new QMediaPlayer;
- player->setVolume(100);
- player->setMedia(QUrl::fromLocalFile("/usr/share/sounds/ubuntu/stereo/bell.ogg"));
- player->play();
+
+ _player.setVolume(100);
+ _player.setMedia(QUrl::fromLocalFile("/usr/share/sounds/ubuntu/stereo/bell.ogg"));
+ _player.play();
}
void Dialogs::alert(int scId, int ecId, const QString &message, const QString &title, const QString &buttonLabel) {
@@ -40,8 +37,10 @@ void Dialogs::alert(int scId, int ecId, const QString &message, const QString &t
void Dialogs::confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels) {
Q_UNUSED(ecId);
- //FIXME:
- assert(!_alertCallback);
+ if (_alertCallback) {
+ qCritical() << "can't open second dialog";
+ return;
+ }
_alertCallback = scId;
QString s1, s2, s3;
@@ -53,16 +52,20 @@ void Dialogs::confirm(int scId, int ecId, const QString &message, const QString
s3 = buttonLabels[2];
QString path = m_cordova->get_app_dir() + "/../qml/notification.qml";
- //FIXME:
- QString qml = QString("PopupUtils.open(\"%1\", root, { root: root, cordova: cordova, title: \"%2\", text: \"%3\", promptVisible: false, button1Text: \"%4\", button2Text: \"%5\", button3Text: \"%6\" })")
- .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3);
+ QString qml = QString("PopupUtils.open(%1, root, { root: root, cordova: cordova, title: %2, text: %3, promptVisible: false, button1Text: %4, button2Text: %5, button3Text: %6 })")
+ .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(title)).arg(CordovaInternal::format(message))
+ .arg(CordovaInternal::format(s1)).arg(CordovaInternal::format(s2)).arg(CordovaInternal::format(s3));
+
m_cordova->execQML(qml);
}
void Dialogs::prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText) {
- Q_UNUSED(ecId)
+ Q_UNUSED(ecId);
- assert(!_alertCallback);
+ if (_alertCallback) {
+ qCritical() << "can't open second dialog";
+ return;
+ }
_alertCallback = scId;
QString s1, s2, s3;
@@ -73,9 +76,10 @@ void Dialogs::prompt(int scId, int ecId, const QString &message, const QString &
if (buttonLabels.size() > 2)
s3 = buttonLabels[2];
QString path = m_cordova->get_app_dir() + "/../qml/notification.qml";
- 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\" })")
- .arg(path).arg(title).arg(message).arg(s1).arg(s2).arg(s3).arg(defaultText);
+ 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 })")
+ .arg(CordovaInternal::format(path)).arg(CordovaInternal::format(title)).arg(CordovaInternal::format(message))
+ .arg(CordovaInternal::format(s1)).arg(CordovaInternal::format(s2))
+ .arg(CordovaInternal::format(s3)).arg(CordovaInternal::format(defaultText));
- qDebug() << qml;
m_cordova->execQML(qml);
}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/4352ab97/src/ubuntu/notification.h
----------------------------------------------------------------------
diff --git a/src/ubuntu/notification.h b/src/ubuntu/notification.h
index 3173d99..9430554 100644
--- a/src/ubuntu/notification.h
+++ b/src/ubuntu/notification.h
@@ -17,6 +17,7 @@
#define NOTIFICATION_H
#include <QtQuick>
+#include <QMediaPlayer>
#include <cplugin.h>
#include <cordova.h>
@@ -56,8 +57,8 @@ public slots:
}
private:
- QQmlComponent *_component;
int _alertCallback;
+ QMediaPlayer _player;
};
#endif
[2/3] git commit: ubuntu: use TextField instead of TextInput
Posted by st...@apache.org.
ubuntu: use TextField instead of TextInput
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/3f8c964f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/3f8c964f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/3f8c964f
Branch: refs/heads/master
Commit: 3f8c964fa322eb553c0f90941d7e0d6aa7296fa1
Parents: 4352ab9
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Sat Jun 28 02:18:33 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Aug 5 05:45:04 2014 +0400
----------------------------------------------------------------------
src/ubuntu/notification.qml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/3f8c964f/src/ubuntu/notification.qml
----------------------------------------------------------------------
diff --git a/src/ubuntu/notification.qml b/src/ubuntu/notification.qml
index 8fd4885..41c08e9 100644
--- a/src/ubuntu/notification.qml
+++ b/src/ubuntu/notification.qml
@@ -30,9 +30,9 @@ Dialog {
property string button3Text
property bool promptVisible
property string defaultPromptText
- TextInput {// FIXME: swith to TextField(TextField should support visible property)
+
+ TextField {
id: prompt
- color: "white"
text: defaultPromptText
visible: promptVisible
focus: true
[3/3] git commit: ubuntu: pass proper arguments to prompt callback
Posted by st...@apache.org.
ubuntu: pass proper arguments to prompt callback
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/0bb58f87
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/0bb58f87
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/0bb58f87
Branch: refs/heads/master
Commit: 0bb58f8731d92b8f45ebc9c5d6a223396bfb96aa
Parents: 3f8c964
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Sat Jun 28 02:33:38 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Aug 5 05:45:09 2014 +0400
----------------------------------------------------------------------
src/ubuntu/notification.h | 4 ++--
src/ubuntu/notification.qml | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/0bb58f87/src/ubuntu/notification.h
----------------------------------------------------------------------
diff --git a/src/ubuntu/notification.h b/src/ubuntu/notification.h
index 9430554..5343073 100644
--- a/src/ubuntu/notification.h
+++ b/src/ubuntu/notification.h
@@ -44,8 +44,8 @@ public slots:
void confirm(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels);
void prompt(int scId, int ecId, const QString &message, const QString &title, const QStringList &buttonLabels, const QString &defaultText);
- void notificationDialogButtonPressed(int buttonId, const QString &text) {
- if (text.size()) {
+ void notificationDialogButtonPressed(int buttonId, const QString &text, bool prompt) {
+ if (prompt) {
QVariantMap res;
res.insert("buttonIndex", buttonId);
res.insert("input1", text);
http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/0bb58f87/src/ubuntu/notification.qml
----------------------------------------------------------------------
diff --git a/src/ubuntu/notification.qml b/src/ubuntu/notification.qml
index 41c08e9..5fdc7d3 100644
--- a/src/ubuntu/notification.qml
+++ b/src/ubuntu/notification.qml
@@ -41,7 +41,7 @@ Dialog {
text: button1Text
color: "orange"
onClicked: {
- root.exec("Notification", "notificationDialogButtonPressed", [1, prompt.text]);
+ root.exec("Notification", "notificationDialogButtonPressed", [1, prompt.text, promptVisible]);
PopupUtils.close(dialogue)
}
}
@@ -50,7 +50,7 @@ Dialog {
visible: button2Text.length > 0
color: "orange"
onClicked: {
- root.exec("Notification", "notificationDialogButtonPressed", [2, prompt.text]);
+ root.exec("Notification", "notificationDialogButtonPressed", [2, prompt.text, promptVisible]);
PopupUtils.close(dialogue)
}
}
@@ -58,7 +58,7 @@ Dialog {
text: button3Text
visible: button3Text.length > 0
onClicked: {
- root.exec("Notification", "notificationDialogButtonPressed", [3, prompt.text]);
+ root.exec("Notification", "notificationDialogButtonPressed", [3, prompt.text, promptVisible]);
PopupUtils.close(dialogue)
}
}