main_qt5.qml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import QtQuick 2.0
  2. import QtWebKit 3.0
  3. import QtWebKit.experimental 1.0
  4. import "cordova_wrapper.js" as CordovaWrapper
  5. WebView {
  6. id: webView
  7. width: 854
  8. height: 480
  9. experimental.preferences.navigatorQtObjectEnabled: true
  10. experimental.onMessageReceived: {
  11. console.log("WebView received Message: " + message.data)
  12. CordovaWrapper.messageHandler(message)
  13. }
  14. //Uncomment when it will be available
  15. //experimental.setFlickableViewportEnabled: false
  16. //experimental.useTraditionalDesktopBehaviour: true
  17. Component.onCompleted: {
  18. webView.url = cordova.mainUrl
  19. }
  20. //TODO: check here for errors
  21. onLoadingChanged: cordova.loadFinished(true)
  22. // onLoadSucceeded: cordova.loadFinished(true)
  23. // onLoadFailed: cordova.loadFinished(false)
  24. Connections {
  25. target: cordova
  26. onJavaScriptExecNeeded: {
  27. webView.experimental.postMessage(JSON.stringify({messageType: "evalJS", jsData: js}))
  28. }
  29. onPluginWantsToBeAdded: {
  30. CordovaWrapper.addPlugin(pluginName, pluginObject)
  31. }
  32. }
  33. }