blob: 6b483fde08601efaaa87b6a912889f7137096e1c (
plain)
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
|
var dynamicObject = null;
var fourthBox = null;
var component;
var started = false;
function createWithEvalQml(p) {
return evalQml('Rect { color: "lightsteelblue"; width: 100;'
+ 'height: 100; id: newRect}','DynPart.qml');
}
function destroyDynamicObject() {
if(!(dynamicObject==null)){
dynamicObject.destroy();
dynamicObject = null;
}
}
function instantCreateWithComponent() {//Like create, but assumes instant readyness
if(dynamicObject!=null)//Already made
return null;
component = createComponent("dynamic.qml");
dynamicObject = component.createObject();
if(dynamicObject == null){
print("error creating component");
}else{
dynamicObject.parent = targetItem;
return dynamicObject;
}
return null;
}
function finishCreation(){
if(component.isReady()){
dynamicObject = component.createObject();
dynamicObject.parent = targetItem;
}else if(component.isError()){
dynamicObject = null;
print("error creating component");
print(component.errorsString());
}
}
function createWithComponent(){
if(started!=false){
finishCreation();//Remakes if destroyed
return dynamicObject;
}
started = true;
component = createComponent("dynamic.qml");
finishCreation();
if(dynamicObject != null){
return dynamicObject;
}
component.statusChanged.connect(finishCreation);
return null;
}
|