Updated Branches: refs/heads/master c83981a66 -> 036d217d1
Merge main.qml main_harmattan.qml to main_qt.qml; fixes compass undefine issue 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/036d217d Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/036d217d Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/036d217d Branch: refs/heads/master Commit: 036d217d19ca0eeecfa5aea798b5c43e4d5b90a4 Parents: c83981a Author: Longwei Su <l...@ics.com> Authored: Mon Apr 30 17:44:58 2012 -0400 Committer: Longwei Su <l...@ics.com> Committed: Mon Apr 30 17:44:58 2012 -0400 ---------------------------------------------------------------------- cordovaqt.pro | 5 +- main.cpp | 4 +- qml/main.qml | 1 + qml/main_harmattan.qml | 122 ------------------------------------------- qml/main_qt4.qml | 121 ++++++++++++++++++++++++++++++++++++++++++ www/basic.js | 9 ++- 6 files changed, 133 insertions(+), 129 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/036d217d/cordovaqt.pro ---------------------------------------------------------------------- diff --git a/cordovaqt.pro b/cordovaqt.pro index b1985f2..5b590ce 100644 --- a/cordovaqt.pro +++ b/cordovaqt.pro @@ -63,7 +63,7 @@ greaterThan(QT_MAJOR_VERSION, 4) { message("Qt4 build") message("Harmattan build") - OTHER_FILES += qml/main_harmattan.qml \ + OTHER_FILES += \ qml/cordova_wrapper.js QT += declarative dbus @@ -99,4 +99,5 @@ OTHER_FILES += \ qtc_packaging/debian_harmattan/copyright \ qtc_packaging/debian_harmattan/control \ qtc_packaging/debian_harmattan/compat \ - qtc_packaging/debian_harmattan/changelog + qtc_packaging/debian_harmattan/changelog \ + qml/main_qt4.qml http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/036d217d/main.cpp ---------------------------------------------------------------------- diff --git a/main.cpp b/main.cpp index 81d6a8f..580e2ab 100644 --- a/main.cpp +++ b/main.cpp @@ -65,10 +65,10 @@ int main(int argc, char *argv[]) view->setResizeMode(QDeclarativeView::SizeRootObjectToView); view->rootContext()->setContextProperty("cordova", Cordova::instance()); # ifdef MEEGO_EDITION_HARMATTAN - view->setSource(QUrl(QString("%1/qml/main_harmattan.qml").arg(Cordova::instance()->workingDir()))); + view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir()))); view->showFullScreen(); # else - view->setSource(QUrl(QString("%1/qml/main.qml").arg(Cordova::instance()->workingDir()))); + view->setSource(QUrl(QString("%1/qml/main_qt4.qml").arg(Cordova::instance()->workingDir()))); # if defined(Q_OS_SYMBIAN) || defined(QT_SIMULATOR) view->showFullScreen(); # else http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/036d217d/qml/main.qml ---------------------------------------------------------------------- diff --git a/qml/main.qml b/qml/main.qml index 0c8ebd6..5b5269f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,3 +1,4 @@ +//using main_qt4, remove me later import QtQuick 1.1 import QtWebKit 1.0 import "cordova_wrapper.js" as CordovaWrapper http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/036d217d/qml/main_harmattan.qml ---------------------------------------------------------------------- diff --git a/qml/main_harmattan.qml b/qml/main_harmattan.qml deleted file mode 100644 index 974044b..0000000 --- a/qml/main_harmattan.qml +++ /dev/null @@ -1,122 +0,0 @@ -import QtQuick 1.1 -import com.nokia.meego 1.0 -import QtWebKit 1.0 -import "cordova_wrapper.js" as CordovaWrapper - - - -PageStackWindow { - id: appWindow - initialPage: mainPage - showToolBar: false - - Page { - id: mainPage - - Flickable { - id: webFlickable - - anchors.fill: parent - - contentHeight: webView.height - contentWidth: webView.width - - boundsBehavior: "StopAtBounds" - clip: true - - WebView { - - id: webView - preferredWidth: mainPage.width - preferredHeight: mainPage.height - - url: cordova.mainUrl - settings.javascriptEnabled: true - 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) - } - 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 - onJavaScriptExecNeeded: { - console.log("onJavaScriptExecNeeded: " + js) - webView.evaluateJavaScript(js) - } - - onPluginWantsToBeAdded: { - console.log("onPluginWantsToBeAdded: " + pluginName) - 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/036d217d/qml/main_qt4.qml ---------------------------------------------------------------------- diff --git a/qml/main_qt4.qml b/qml/main_qt4.qml new file mode 100644 index 0000000..4255ed6 --- /dev/null +++ b/qml/main_qt4.qml @@ -0,0 +1,121 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 +import QtWebKit 1.0 +import "cordova_wrapper.js" as CordovaWrapper + + + +PageStackWindow { + id: appWindow + initialPage: mainPage + showToolBar: false + + Page { + id: mainPage + + Flickable { + id: webFlickable + + anchors.fill: parent + + contentHeight: webView.height + contentWidth: webView.width + + boundsBehavior: "StopAtBounds" + clip: true + + WebView { + + id: webView + preferredWidth: mainPage.width + preferredHeight: mainPage.height + + url: cordova.mainUrl + settings.javascriptEnabled: true + settings.localStorageDatabaseEnabled: true + settings.offlineStorageDatabaseEnabled: true + settings.localContentCanAccessRemoteUrls: true + javaScriptWindowObjects: [QtObject{ + 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 + onJavaScriptExecNeeded: { + console.log("onJavaScriptExecNeeded: " + js) + webView.evaluateJavaScript(js) + } + + onPluginWantsToBeAdded: { + console.log("onPluginWantsToBeAdded: " + pluginName) + 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/036d217d/www/basic.js ---------------------------------------------------------------------- diff --git a/www/basic.js b/www/basic.js index 1f47b49..c57342f 100644 --- a/www/basic.js +++ b/www/basic.js @@ -82,18 +82,21 @@ function test_alert_confirm() function getCurrentPosition() { + console.log("clicked position"); navigator.geolocation.getCurrentPosition( function( position ) { - get( "position_val" ).innerHTML = position.coords.latitude + " / " + position.coords.longitude; +// get( "position_val" ).innerHTML = position.coords.latitude + " / " + position.coords.longitude; + get( "position_val" ).innerHTML = " success "; }, function( error ) { - get( "position_val" ).innerHTML = error.code + ": " + error.message; +// get( "position_val" ).innerHTML = error.code + ": " + error.message; + get( "position_val" ).innerHTML = "error"; }, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true } ); } function getCurrentHeading() { navigator.compass.getCurrentHeading( function( heading ) { - get( "heading_val" ).innerHTML = heading.dir; + get( "heading_val" ).innerHTML = heading.magneticHeading; }, function( error ) { get( "heading_val" ).innerHTML = error.code + ": " + error.message;