diff options
Diffstat (limited to 'examples')
11 files changed, 52 insertions, 34 deletions
diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js index 66ec292..6b483fd 100644 --- a/examples/declarative/dynamic/dynamic.js +++ b/examples/declarative/dynamic/dynamic.js @@ -1,51 +1,54 @@ -var sprite = null; +var dynamicObject = null; +var fourthBox = null; var component; var started = false; -function make(p) { +function createWithEvalQml(p) { return evalQml('Rect { color: "lightsteelblue"; width: 100;' + 'height: 100; id: newRect}','DynPart.qml'); } -function death() { - if(!(sprite==null)){ - sprite.destroy(); - sprite = null; +function destroyDynamicObject() { + if(!(dynamicObject==null)){ + dynamicObject.destroy(); + dynamicObject = null; } } -function spawn() {//Like create, but assumes instant readyness - if(sprite!=null)//Already made +function instantCreateWithComponent() {//Like create, but assumes instant readyness + if(dynamicObject!=null)//Already made return null; component = createComponent("dynamic.qml"); - sprite = component.createObject(); - if(sprite == null){ - print("err"); + dynamicObject = component.createObject(); + if(dynamicObject == null){ + print("error creating component"); }else{ - sprite.parent = targetItem; - return sprite; + dynamicObject.parent = targetItem; + return dynamicObject; } return null; } function finishCreation(){ if(component.isReady()){ - sprite = component.createObject(); - sprite.parent = targetItem; + dynamicObject = component.createObject(); + dynamicObject.parent = targetItem; }else if(component.isError()){ - sprite = null; + dynamicObject = null; + print("error creating component"); + print(component.errorsString()); } } -function create(){ +function createWithComponent(){ if(started!=false){ finishCreation();//Remakes if destroyed - return sprite; + return dynamicObject; } started = true; component = createComponent("dynamic.qml"); finishCreation(); - if(sprite != null){ - return sprite; + if(dynamicObject != null){ + return dynamicObject; } component.statusChanged.connect(finishCreation); return null; diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index ee81ff6..3e0c12e 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -1,16 +1,31 @@ Rect { id: page; width: 800; height: 800; color:"black" Script { source: "dynamic.js" } - property bool fourthBox: false; + property bool extendStars: false; Item { id: targetItem; x: 100; y: 100; } Item { id: targetItem2; x: 0; y: 300; } Rect { width: 100; height: 100; color: "green"; id: rect - MouseRegion { anchors.fill:parent; onClicked: {a = create();}} + MouseRegion { anchors.fill:parent; onClicked: {a = createWithComponent();}} } Rect { width: 100; height: 100; color: "red"; id: rect2; y:100; - MouseRegion { anchors.fill:parent; onClicked: {death();}} + MouseRegion { anchors.fill:parent; onClicked: {destroyDynamicObject();}} } Rect { width: 100; height: 100; color: "blue"; id: rect3; y:200; - MouseRegion { anchors.fill:parent; onClicked: {a = make(); if(a!=null){a.parent = targetItem2; fourthBox = true;}}} + MouseRegion { anchors.fill:parent; onClicked: + { + if(fourthBox == null) { + a = createWithEvalQml(); + if(a!=null) { + a.parent = targetItem2; + fourthBox = a; + extendStars = true; + } + } else { + fourthBox.destroy(); + fourthBox = null; + extendStars = false; + } + } + } } - Particles { x:0; y:0; count:20; lifeSpan:500; width:100; height: if(fourthBox){400;}else{300;} source:"star.png"} + Particles { x:0; y:0; count:20; lifeSpan:500; width:100; height: if(extendStars){400;}else{300;} source:"star.png"} } diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml index cad36bd..6195daa 100644 --- a/examples/declarative/listview/content/MediaButton.qml +++ b/examples/declarative/listview/content/MediaButton.qml @@ -15,7 +15,7 @@ Item { MouseRegion { id: MouseRegion anchors.fill: Image - onClicked: { Container.clicked.emit(); } + onClicked: { Container.clicked(); } } Text { font.bold: true diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml index 55a13a1..472fe60 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2/RemoveButton.qml @@ -60,7 +60,7 @@ Rect { //! [use signal] MouseRegion { anchors.fill: parent - onClicked: { toggle(); removeButton.confirmed.emit() } + onClicked: { toggle(); removeButton.confirmed() } } //! [use signal] } diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml index 353e440..084d8fd 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/FieldText.qml @@ -18,7 +18,7 @@ Rect { function confirm() { fieldText.text = textEdit.text; fieldText.state=''; - fieldText.confirmed.emit(); + fieldText.confirmed(); } function reset() { textEdit.text = fieldText.text; diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml index a9bf3ee..dc9c9b3 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/RemoveButton.qml @@ -58,7 +58,7 @@ Rect { opacity: 0 MouseRegion { anchors.fill: parent - onClicked: { toggle(); removeButton.confirmed.emit() } + onClicked: { toggle(); removeButton.confirmed() } } } Text { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml index cb2c368..cbb2a1f 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/FieldText.qml @@ -20,7 +20,7 @@ Rect { fieldText.text = textEdit.text; fieldText.state=''; contactDetails.mouseGrabbed=false; - fieldText.confirmed.emit(); + fieldText.confirmed(); } function reset() { textEdit.text = fieldText.text; diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml index 05146b7..57750a0 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/RemoveButton.qml @@ -63,7 +63,7 @@ Rect { opacity: 0 MouseRegion { anchors.fill: parent - onClicked: { toggle(); removeButton.confirmed.emit() } + onClicked: { toggle(); removeButton.confirmed() } } } Text { diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml index 09af769..629dce8 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Button.qml @@ -18,7 +18,7 @@ Item { MouseRegion { id: buttonMouseRegion anchors.fill: buttonRect - onClicked: { button.clicked.emit() } + onClicked: { button.clicked() } } states: [ State { diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml index 417c08a..133262a 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/FieldText.qml @@ -20,7 +20,7 @@ Rect { fieldText.text = textEdit.text; fieldText.state=''; contacts.mouseGrabbed=false; - fieldText.confirmed.emit(); + fieldText.confirmed(); } function reset() { textEdit.text = fieldText.text; diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml index a962eb3..005daaa 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/RemoveButton.qml @@ -61,7 +61,7 @@ Rect { opacity: 0 MouseRegion { anchors.fill: parent - onClicked: { toggle(); removeButton.confirmed.emit() } + onClicked: { toggle(); removeButton.confirmed() } } } Text { |