Merge pull request from jherico/qml

Small QML fixes
This commit is contained in:
Brad Hefta-Gaub 2016-02-10 11:39:45 -08:00
commit 5120076add
2 changed files with 38 additions and 10 deletions
interface/resources/qml

View file

@ -19,12 +19,40 @@ Windows.Window {
property var channel;
// Don't destroy on close... otherwise the JS/C++ will have a dangling pointer
destroyOnCloseButton: false
property alias source: pageLoader.source
Loader {
id: pageLoader
objectName: "Loader"
focus: true
property var dialog: root
property var source;
property var component;
property var dynamicContent;
onSourceChanged: {
if (dynamicContent) {
dynamicContent.destroy();
dynamicContent = null;
}
component = Qt.createComponent(source);
console.log("Created component " + component + " from source " + source);
}
} // dialog
onComponentChanged: {
console.log("Component changed to " + component)
populate();
}
function populate() {
console.log("Populate called: dynamicContent " + dynamicContent + " component " + component);
if (!dynamicContent && component) {
if (component.status == Component.Error) {
console.log("Error loading component:", component.errorString());
} else if (component.status == Component.Ready) {
console.log("Building dynamic content");
dynamicContent = component.createObject(contentHolder);
} else {
console.log("Component not yet ready, connecting to status change");
component.statusChanged.connect(populate);
}
}
}
Item {
id: contentHolder
anchors.fill: parent
}
}

View file

@ -17,8 +17,8 @@ Fadable {
HifiConstants { id: hifi }
// The Window size is the size of the content, while the frame
// decorations can extend outside it.
implicitHeight: content.height
implicitWidth: content.width
implicitHeight: content ? content.height : 0
implicitWidth: content ? content.width : 0
x: -1; y: -1
enabled: visible