123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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.offlineWebApplicationCacheEnabled : true
- settings.pluginsEnabled : 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();
- }
- }]
- onUrlChanged: { console.log("url changing..")}
- 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)")
- }
- }
- }
- }
- }
|