2
* Copyright 2014 Canonical Ltd.
4
* This file is part of ubuntu-html5-ui-toolkit.
6
* ubuntu-html5-ui-toolkit is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* ubuntu-html5-ui-toolkit is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
property string htmlIndexDirectory
26
// Cordova plugin instance
27
property var cordovaInstance: null
29
// the cordova qml instance was created successfully
32
// an error occured while creating the cordova instance
33
signal creationError();
35
function _tryCreateObject(statement, parent) {
38
result = Qt.createQmlObject(statement, parent);
45
function _getCordovaObjectCreationStatementFor(version, params) {
46
return 'import CordovaUbuntu '
49
+ ' anchors.fill: parent; '
54
function _tryCreateCordovaObject(version, params) {
55
var _params = params || '';
56
return _tryCreateObject(_getCordovaObjectCreationStatementFor(version, params), root);
59
function _ensureCordovaInitDone() {
60
if (cordovaInstance && htmlIndexDirectory.length !== 0) {
61
cordovaInstance.wwwDir = htmlIndexDirectory;
65
onHtmlIndexDirectoryChanged: _ensureCordovaInitDone()
67
Component.onCompleted: {
68
// selectively try to load cordova
71
var candidates = [{version: '3.4', paramString: 'contentFile: "index.html"'}];
72
for (var i = 0; i < candidates.length; ++i) {
73
cordova = _tryCreateCordovaObject(candidates[i].version,
74
candidates[i].paramString);
80
console.error('Cannot create CordovaView object.');
85
root.cordovaInstance = cordova;
87
_ensureCordovaInitDone();