incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From long...@apache.org
Subject qt commit: Notification rework for Harmattan
Date Wed, 14 Mar 2012 14:44:09 GMT
Updated Branches:
  refs/heads/master 4d041b664 -> 7ba449ce9


Notification rework for Harmattan


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/7ba449ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/7ba449ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/7ba449ce

Branch: refs/heads/master
Commit: 7ba449ce96fcfc7c7db0490b17732c397bff1c3b
Parents: 4d041b6
Author: Longwei Su <longwei.su@gmail.com>
Authored: Wed Mar 14 10:41:23 2012 -0400
Committer: Longwei Su <longwei.su@gmail.com>
Committed: Wed Mar 14 10:41:23 2012 -0400

----------------------------------------------------------------------
 cordovaqt.pro                |    4 +-
 qml/main.qml                 |    1 +
 qml/main_harmattan.qml       |   71 ++++++++++++++++++++++++++++++++----
 src/plugins/compass.cpp      |    1 -
 src/plugins/notification.cpp |   11 +++---
 www/basic.js                 |    6 ++--
 www/js/notification.js       |   32 +++++++---------
 7 files changed, 89 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/cordovaqt.pro
----------------------------------------------------------------------
diff --git a/cordovaqt.pro b/cordovaqt.pro
index 7553de1..ff5c6b5 100644
--- a/cordovaqt.pro
+++ b/cordovaqt.pro
@@ -59,7 +59,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
     QT += declarative
     QT += webkit
     CONFIG += mobility qdeclarative-boostable
-    MOBILITY += feedback location systeminfo sensors
+    MOBILITY += feedback location systeminfo sensors multimedia
 } else {
     message("Qt4 build")
     message("Non-harmattan build")
@@ -74,7 +74,7 @@ greaterThan(QT_MAJOR_VERSION, 4) {
     QT += declarative
     QT += webkit
     CONFIG += mobility
-    MOBILITY += feedback location systeminfo sensors
+    MOBILITY += feedback location systeminfo sensors multimedia
 }
 
 # Please do not modify the following two lines. Required for deployment.

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/qml/main.qml
----------------------------------------------------------------------
diff --git a/qml/main.qml b/qml/main.qml
index eea7a02..0c8ebd6 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -24,6 +24,7 @@ Flickable {
         settings.localStorageDatabaseEnabled: true
         settings.offlineStorageDatabaseEnabled: true
         settings.localContentCanAccessRemoteUrls: true
+        settings.developerExtrasEnabled: true
         javaScriptWindowObjects: [QtObject{
             WebView.windowObjectName: "qmlWrapper"
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/qml/main_harmattan.qml
----------------------------------------------------------------------
diff --git a/qml/main_harmattan.qml b/qml/main_harmattan.qml
index 6ee533f..974044b 100644
--- a/qml/main_harmattan.qml
+++ b/qml/main_harmattan.qml
@@ -35,17 +35,26 @@ PageStackWindow {
                 settings.localStorageDatabaseEnabled: true
                 settings.offlineStorageDatabaseEnabled: true
                 settings.localContentCanAccessRemoteUrls: true
+                settings.developerExtrasEnabled: true
                 javaScriptWindowObjects: [QtObject{
-                    WebView.windowObjectName: "qmlWrapper"
-
-                    function callPluginFunction(pluginName, functionName, parameters) {
-                        parameters = eval("("+parameters+")")
-                        CordovaWrapper.execMethodOld(pluginName, functionName, parameters)
-                    }
-                }]
+                        WebView.windowObjectName: "qmlWrapper"
+
+                        function callPluginFunction(pluginName, functionName, parameters)
{
+                            parameters = eval("("+parameters+")")
+                            CordovaWrapper.execMethodOld(pluginName, functionName, parameters)
+                        }
+                        function callConfirm(message){
+                            comfirmText.text = message;
+                            myConfirm.open();
+                        }
+                    }]
 
                 onLoadFinished: cordova.loadFinished(true)
                 onLoadFailed: cordova.loadFinished(false)
+                onAlert: {
+                    alertText.text = message
+                    myalert.open()
+                }
 
                 Connections {
                     target: cordova
@@ -59,9 +68,55 @@ PageStackWindow {
                         CordovaWrapper.addPlugin(pluginName, pluginObject)
                     }
                 }
+
+                Dialog {
+                    id: myalert
+                    content:Item {
+                        height: 50
+                        width: parent.width
+                        Text {
+                            id: alertText
+                            font.pixelSize: 22
+                            anchors.centerIn: parent
+                            color: "white"
+                            text: "Hello"
+                        }
+                    }
+
+                    buttons: ButtonRow {
+                        style: ButtonStyle { }
+                        anchors.horizontalCenter: parent.horizontalCenter
+                        Button {text: "OK"; onClicked: myalert.accept()}
+                    }
+                }
+
+                Dialog {
+                    id: myConfirm
+                    property string js: "Notification.Callback"
+                    content:Item {
+                        height: 50
+                        width: parent.width
+                        Text {
+                            id: comfirmText
+                            font.pixelSize: 22
+                            anchors.centerIn: parent
+                            color: "white"
+                            text: "confirm"
+                        }
+                    }
+
+                    buttons: ButtonRow {
+                        style: ButtonStyle { }
+                        anchors.horizontalCenter: parent.horizontalCenter
+                        Button {text: "OK"; onClicked:myConfirm.accept()}
+                        Button {text: "Cancel"; onClicked:myConfirm.reject()}
+                    }
+                    onAccepted: cordova.execJS(js + "(1)")
+                    onRejected: cordova.execJS(js + "(2)")
+                }
             }
-        }
 
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/src/plugins/compass.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/compass.cpp b/src/plugins/compass.cpp
index 54571ff..8cd9142 100644
--- a/src/plugins/compass.cpp
+++ b/src/plugins/compass.cpp
@@ -16,7 +16,6 @@
 
 #include "compass.h"
 #include "../pluginregistry.h"
-#include <QCompass>
 
 Compass* Compass::m_compass = new Compass();
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/src/plugins/notification.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/notification.cpp b/src/plugins/notification.cpp
index 6294b0c..23eda1e 100644
--- a/src/plugins/notification.cpp
+++ b/src/plugins/notification.cpp
@@ -20,7 +20,7 @@
 
 #include <QApplication>
 #include <QFeedbackHapticsEffect>
-
+#include <QtMultimediaKit/QMediaPlayer>
 #include <QDebug>
 
 #ifdef QTM_NAMESPACE
@@ -43,10 +43,11 @@ Notification::Notification() : CPlugin(){
 void Notification::beep( int scId, int ecId, int p_times ) {
     Q_UNUSED(scId)
     Q_UNUSED(ecId)
-
-    for( int i = 0; i < p_times; i++ ) {
-        QApplication::beep();
-    }
+    Q_UNUSED(p_times)
+    QMediaPlayer* player = new QMediaPlayer;
+    player->setVolume(100);
+    player->setMedia(QUrl::fromLocalFile("/usr/share/sounds/ui-tones/snd_default_beep.wav"));
+    player->play();
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/www/basic.js
----------------------------------------------------------------------
diff --git a/www/basic.js b/www/basic.js
index 3ce3f66..0122382 100644
--- a/www/basic.js
+++ b/www/basic.js
@@ -47,9 +47,9 @@ function test_alert_confirm()
                                  }, "title", "buttonName");
     navigator.notification.confirm("This is a confirm.",
                                    function onConfirm(button) {
-                                       if ( button === 0) {
-                                           alert('User input: No');
-                                       } else {alert('User input: Yes');}
+                                       if ( button === 1) {
+                                           alert('User input: YES');
+                                       } else if( button === 2) {alert('User input: No');}
                                    }, "title", "buttonName");
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/7ba449ce/www/js/notification.js
----------------------------------------------------------------------
diff --git a/www/js/notification.js b/www/js/notification.js
index 22ce934..38a014b 100644
--- a/www/js/notification.js
+++ b/www/js/notification.js
@@ -21,33 +21,29 @@
 function Notification() {
 }
 
+Notification.Callback = function() {};
+
 Notification.prototype.alert = function( message, alertCallback, title, buttonNamne ) {
-    alert( message );
-    alertCallback();
-}
+            alert( message );
+            alertCallback();
+        }
 
 Notification.prototype.confirm = function( message, confirmCallback, title, buttonLabels
) {
-    var result = confirm( message );
-    if( result ) {
-        result = 1;
-    }
-    else {
-        result = 0;
-    }
-    confirmCallback(result);
-}
+            Notification.Callback = confirmCallback;
+            window.qmlWrapper.callConfirm(message);
+        }
 
 Notification.prototype.beep = function( times ) {
-    Cordova.exec( null, null, "com.cordova.Notification", "beep", [times] );
-}
+            Cordova.exec( null, null, "com.cordova.Notification", "beep", [times] );
+        }
 
 Notification.prototype.vibrate = function( milliseconds ) {
-    Cordova.exec( null, null, "com.cordova.Notification", "vibrate", [milliseconds] );
-}
+            Cordova.exec( null, null, "com.cordova.Notification", "vibrate", [milliseconds]
);
+        }
 
 /**
  * Add the notification object to the navigator
  */
 Cordova.addConstructor( "com.cordova.Notification", function () {
-                            navigator.notification = new Notification();
-                        } );
+                           navigator.notification = new Notification();
+                       } );


Mime
View raw message