blob: 8bfdba3061d502935170fc5be3ec951bee50d0a2 (
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
56
57
58
59
|
var dynamicObject = null;
var fourthBox = null;
var component = null;
var started = false;
function createQml(p) {
return createQmlObject('DynRect {}', p, '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 == null) {
dynamicObject = component.createObject();
dynamicObject.parent = targetItem;
} else if (component.isError) {
dynamicObject = null;
print("error creating component");
print(component.errorsString());
}
}
function createWithComponent() {
if (component != null) {
return finishCreation();
}
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;
}
|