/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/1.2/PageWrapperUtils.js is in qml-module-ubuntu-components 1.3.1918+16.04.20160404-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | /*
* Copyright 2012 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//.pragma library // FIXME: cannot refer to Component.Error if I use this.
// FIXME: ideally we would make this a stateless library, but that breaks applications
// that rely on accessing context variables in pages that were pushed on a PageStack
// by url (PageStack.push("FileName.qml")) because of a Qt bug:
// https://bugreports.qt-project.org/browse/QTBUG-31347
/*!
\internal
Initialize pageWrapper.object.
*/
function initPage(pageWrapper) {
var pageComponent;
if (pageWrapper.reference.createObject) {
// page reference is a component
pageComponent = pageWrapper.reference;
} else if (typeof pageWrapper.reference == "string") {
// page reference is a string (url)
pageComponent = Qt.createComponent(pageWrapper.reference);
}
var pageObject;
if (pageComponent) {
if (pageComponent.status === Component.Error) {
throw new Error("Error while loading page: " + pageComponent.errorString());
} else {
// create the object
if (pageWrapper.properties) {
// initialize the object with the given properties
pageObject = pageComponent.createObject(pageWrapper, pageWrapper.properties);
} else {
pageObject = pageComponent.createObject(pageWrapper);
}
pageWrapper.canDestroy = true;
}
} else {
// page reference is an object
pageObject = pageWrapper.reference;
pageObject.parent = pageWrapper;
pageWrapper.canDestroy = false;
// copy the properties to the page object
for (var prop in pageWrapper.properties) {
if (pageWrapper.properties.hasOwnProperty(prop)) {
pageObject[prop] = pageWrapper.properties[prop];
}
}
}
pageWrapper.object = pageObject;
return pageObject;
}
/*!
\internal
Create the page object if needed, and make the page object visible.
*/
function activate(pageWrapper) {
if (!pageWrapper.object) {
initPage(pageWrapper);
}
// Having the same page pushed multiple times on a stack changes
// the parent of the page object. Change it back here.
pageWrapper.object.parent = pageWrapper;
// Some page objects are invisible initially. Make visible.
pageWrapper.object.visible = true;
pageWrapper.active = true;
}
/*!
\internal
Hide page object.
*/
function deactivate(pageWrapper) {
pageWrapper.active = false;
}
/*!
\internal
Destroy the page object if pageWrapper.canDestroy is true.
Do nothing if pageWrapper.canDestroy is false.
*/
function destroyObject(pageWrapper) {
if (pageWrapper.canDestroy) {
pageWrapper.object.destroy();
pageWrapper.object = null;
pageWrapper.canDestroy = false;
}
}
|