From f37e9d787bd418d8f75997a8d46c1c42e842c673 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 30 Oct 2009 13:36:19 +1000 Subject: cleanup --- examples/declarative/connections/Button.qml | 12 --- examples/declarative/connections/bg1.jpg | Bin 23771 -> 0 bytes examples/declarative/connections/connections.qml | 9 ++- .../declarative/connections/content/Button.qml | 12 +++ examples/declarative/connections/content/bg1.jpg | Bin 0 -> 23771 bytes .../connections/content/rotate-left.png | Bin 0 -> 3061 bytes .../connections/content/rotate-right.png | Bin 0 -> 3115 bytes examples/declarative/connections/rotate-left.png | Bin 3061 -> 0 bytes examples/declarative/connections/rotate-right.png | Bin 3115 -> 0 bytes examples/declarative/dynamic/Button.qml | 24 ------ examples/declarative/dynamic/GenericItem.qml | 13 ---- examples/declarative/dynamic/PaletteItem.qml | 13 ---- examples/declarative/dynamic/PerspectiveItem.qml | 12 --- examples/declarative/dynamic/Sun.qml | 24 ------ examples/declarative/dynamic/dynamic.qml | 11 +-- examples/declarative/dynamic/itemCreation.js | 81 -------------------- examples/declarative/dynamic/qml/Button.qml | 24 ++++++ examples/declarative/dynamic/qml/GenericItem.qml | 13 ++++ examples/declarative/dynamic/qml/PaletteItem.qml | 13 ++++ .../declarative/dynamic/qml/PerspectiveItem.qml | 12 +++ examples/declarative/dynamic/qml/Sun.qml | 24 ++++++ examples/declarative/dynamic/qml/itemCreation.js | 82 +++++++++++++++++++++ 22 files changed, 191 insertions(+), 188 deletions(-) delete mode 100644 examples/declarative/connections/Button.qml delete mode 100644 examples/declarative/connections/bg1.jpg create mode 100644 examples/declarative/connections/content/Button.qml create mode 100644 examples/declarative/connections/content/bg1.jpg create mode 100644 examples/declarative/connections/content/rotate-left.png create mode 100644 examples/declarative/connections/content/rotate-right.png delete mode 100644 examples/declarative/connections/rotate-left.png delete mode 100644 examples/declarative/connections/rotate-right.png delete mode 100644 examples/declarative/dynamic/Button.qml delete mode 100644 examples/declarative/dynamic/GenericItem.qml delete mode 100644 examples/declarative/dynamic/PaletteItem.qml delete mode 100644 examples/declarative/dynamic/PerspectiveItem.qml delete mode 100644 examples/declarative/dynamic/Sun.qml delete mode 100644 examples/declarative/dynamic/itemCreation.js create mode 100644 examples/declarative/dynamic/qml/Button.qml create mode 100644 examples/declarative/dynamic/qml/GenericItem.qml create mode 100644 examples/declarative/dynamic/qml/PaletteItem.qml create mode 100644 examples/declarative/dynamic/qml/PerspectiveItem.qml create mode 100644 examples/declarative/dynamic/qml/Sun.qml create mode 100644 examples/declarative/dynamic/qml/itemCreation.js diff --git a/examples/declarative/connections/Button.qml b/examples/declarative/connections/Button.qml deleted file mode 100644 index 1d46acc..0000000 --- a/examples/declarative/connections/Button.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Item { - id: button - width: 48; height: 48 - - property alias image: icon.source - signal clicked - - Image { id: icon } - MouseRegion { anchors.fill: icon; onClicked: button.clicked() } -} diff --git a/examples/declarative/connections/bg1.jpg b/examples/declarative/connections/bg1.jpg deleted file mode 100644 index dfc7cee..0000000 Binary files a/examples/declarative/connections/bg1.jpg and /dev/null differ diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml index 5dc211e..07f71bb 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections.qml @@ -1,7 +1,8 @@ import Qt 4.6 +import "content" Rectangle { - id: window; color: "#343434" + id: window; color: "#646464" width: 640; height: 480 function turnLeft() { @@ -12,16 +13,16 @@ Rectangle { } Image { - id: image; source: "bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center + id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } } } Button { - id: leftButton; image: "rotate-left.png" + id: leftButton; image: "content/rotate-left.png" anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 } } Button { - id: rightButton; image: "rotate-right.png" + id: rightButton; image: "content/rotate-right.png" anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 } } diff --git a/examples/declarative/connections/content/Button.qml b/examples/declarative/connections/content/Button.qml new file mode 100644 index 0000000..1d46acc --- /dev/null +++ b/examples/declarative/connections/content/Button.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Item { + id: button + width: 48; height: 48 + + property alias image: icon.source + signal clicked + + Image { id: icon } + MouseRegion { anchors.fill: icon; onClicked: button.clicked() } +} diff --git a/examples/declarative/connections/content/bg1.jpg b/examples/declarative/connections/content/bg1.jpg new file mode 100644 index 0000000..dfc7cee Binary files /dev/null and b/examples/declarative/connections/content/bg1.jpg differ diff --git a/examples/declarative/connections/content/rotate-left.png b/examples/declarative/connections/content/rotate-left.png new file mode 100644 index 0000000..c30387e Binary files /dev/null and b/examples/declarative/connections/content/rotate-left.png differ diff --git a/examples/declarative/connections/content/rotate-right.png b/examples/declarative/connections/content/rotate-right.png new file mode 100644 index 0000000..1b05674 Binary files /dev/null and b/examples/declarative/connections/content/rotate-right.png differ diff --git a/examples/declarative/connections/rotate-left.png b/examples/declarative/connections/rotate-left.png deleted file mode 100644 index c30387e..0000000 Binary files a/examples/declarative/connections/rotate-left.png and /dev/null differ diff --git a/examples/declarative/connections/rotate-right.png b/examples/declarative/connections/rotate-right.png deleted file mode 100644 index 1b05674..0000000 Binary files a/examples/declarative/connections/rotate-right.png and /dev/null differ diff --git a/examples/declarative/dynamic/Button.qml b/examples/declarative/dynamic/Button.qml deleted file mode 100644 index 0b8b6db..0000000 --- a/examples/declarative/dynamic/Button.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: container - - property var text - signal clicked - - SystemPalette { id: activePalette; colorGroup: Qt.Active } - height: text.height + 10 - width: text.width + 20 - border.width: 1 - radius: 4 - gradient: Gradient { - GradientStop { position: 0.0; - color: if(!mr.pressed){activePalette.light;}else{activePalette.button;} - } - GradientStop { position: 1.0; - color: if(!mr.pressed){activePalette.button;}else{activePalette.dark;} - } - } - MouseRegion { id:mr; anchors.fill: parent; onClicked: container.clicked() } - Text { id: text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text; color: activePalette.buttonText } -} diff --git a/examples/declarative/dynamic/GenericItem.qml b/examples/declarative/dynamic/GenericItem.qml deleted file mode 100644 index 10e3dba..0000000 --- a/examples/declarative/dynamic/GenericItem.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 - -Item{ - property bool created: false - property string image - width: imageItem.width - height: imageItem.height - z: 2 - Image{ - id: imageItem - source: image; - } -} diff --git a/examples/declarative/dynamic/PaletteItem.qml b/examples/declarative/dynamic/PaletteItem.qml deleted file mode 100644 index bb6036d..0000000 --- a/examples/declarative/dynamic/PaletteItem.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.6 - -GenericItem { - id: itemButton - property string file - Script { source: "itemCreation.js" } - MouseRegion { - anchors.fill: parent; - onPressed: startDrag(mouse); - onPositionChanged: moveDrag(mouse); - onReleased: endDrag(mouse); - } -} diff --git a/examples/declarative/dynamic/PerspectiveItem.qml b/examples/declarative/dynamic/PerspectiveItem.qml deleted file mode 100644 index 9e09dd2..0000000 --- a/examples/declarative/dynamic/PerspectiveItem.qml +++ /dev/null @@ -1,12 +0,0 @@ -import Qt 4.6 - -Image { - id: tree - property bool created: false - opacity: y+height > window.height/2 ? 1 : 0.25 - onCreatedChanged: if (created && y+height<=window.height/2) { tree.destroy() } - scale: y+height > window.height/2 ? (y+height-250)*0.01 : 1 - transformOrigin: "Center" - source: image; - z: y -} diff --git a/examples/declarative/dynamic/Sun.qml b/examples/declarative/dynamic/Sun.qml deleted file mode 100644 index a9f5d40..0000000 --- a/examples/declarative/dynamic/Sun.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.6 - -Image { - id: sun - property bool created: false - property string image: "images/sun.png" - onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;} - - source: image; - z: 1 - - //x and y get set when instantiated - //head offscreen - y: NumberAnimation { - to: parent.height; - duration: 10000; - running: created - } - - states: State { - name: "OffScreen"; when: created && y > window.height/2;//Below the ground - StateChangeScript { script: { sun.created = false; sun.destroy() } } - } -} diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 9bfab0e..0166b4c 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import "qml" Item { id: window @@ -71,26 +72,26 @@ Item { PaletteItem{ anchors.verticalCenter: parent.verticalCenter file: "Sun.qml"; - image: "images/sun.png" + image: "../images/sun.png" } PaletteItem{ file: "GenericItem.qml" - image: "images/moon.png" + image: "../images/moon.png" } PaletteItem{ anchors.verticalCenter: parent.verticalCenter file: "PerspectiveItem.qml" - image: "images/tree_s.png" + image: "../images/tree_s.png" } PaletteItem{ anchors.verticalCenter: parent.verticalCenter file: "PerspectiveItem.qml" - image: "images/rabbit_brown.png" + image: "../images/rabbit_brown.png" } PaletteItem{ anchors.verticalCenter: parent.verticalCenter file: "PerspectiveItem.qml" - image: "images/rabbit_bw.png" + image: "../images/rabbit_bw.png" } } Text{ text: "Active Suns: " + activeSuns } diff --git a/examples/declarative/dynamic/itemCreation.js b/examples/declarative/dynamic/itemCreation.js deleted file mode 100644 index 06e67c5..0000000 --- a/examples/declarative/dynamic/itemCreation.js +++ /dev/null @@ -1,81 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var startingZ; -//Until QT-2385 is resolved we need to convert to scene coordinates manually -var xOffset; -var yOffset; -function setSceneOffset() -{ - xOffset = 0; - yOffset = 0; - var p = itemButton; - while(p != window){ - xOffset += p.x; - yOffset += p.y; - p = p.parent; - } -} - -function startDrag(mouse) -{ - setSceneOffset(); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asyncronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) //Already loaded the component - createItem(); - - itemComponent = createComponent(itemButton.file); - if(itemComponent.isLoading){ - component.statusChanged.connect(finishCreation); - }else{//Depending on the content, it can be ready or error immediately - createItem(); - } -} - -function createItem() { - if (itemComponent.isReady && draggedItem == null) { - draggedItem = itemComponent.createObject(); - draggedItem.parent = window; - draggedItem.image = itemButton.image; - draggedItem.x = xOffset; - draggedItem.y = yOffset; - startingZ = draggedItem.z; - draggedItem.z = 4;//On top - } else if (itemComponent.isError) { - draggedItem = null; - print("error creating component"); - print(component.errorsString()); - } -} - -function moveDrag(mouse) -{ - if(draggedItem == null) - return; - - draggedItem.x = mouse.x + xOffset - startingMouse.x; - draggedItem.y = mouse.y + yOffset - startingMouse.y; -} - -function endDrag(mouse) -{ - if(draggedItem == null) - return; - - if(draggedItem.x + draggedItem.width > toolbox.x){ //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - }else{ - draggedItem.z = startingZ; - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml new file mode 100644 index 0000000..2769cd8 --- /dev/null +++ b/examples/declarative/dynamic/qml/Button.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +Rectangle { + id: container + + property var text + signal clicked + + SystemPalette { id: activePalette; colorGroup: Qt.Active } + height: text.height + 10 + width: text.width + 20 + border.width: 1 + radius: 4; smooth: true + gradient: Gradient { + GradientStop { position: 0.0; + color: if(!mr.pressed){activePalette.light;}else{activePalette.button;} + } + GradientStop { position: 1.0; + color: if(!mr.pressed){activePalette.button;}else{activePalette.dark;} + } + } + MouseRegion { id:mr; anchors.fill: parent; onClicked: container.clicked() } + Text { id: text; anchors.centerIn:parent; font.pointSize: 10; text: parent.text; color: activePalette.buttonText } +} diff --git a/examples/declarative/dynamic/qml/GenericItem.qml b/examples/declarative/dynamic/qml/GenericItem.qml new file mode 100644 index 0000000..10e3dba --- /dev/null +++ b/examples/declarative/dynamic/qml/GenericItem.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Item{ + property bool created: false + property string image + width: imageItem.width + height: imageItem.height + z: 2 + Image{ + id: imageItem + source: image; + } +} diff --git a/examples/declarative/dynamic/qml/PaletteItem.qml b/examples/declarative/dynamic/qml/PaletteItem.qml new file mode 100644 index 0000000..bb6036d --- /dev/null +++ b/examples/declarative/dynamic/qml/PaletteItem.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +GenericItem { + id: itemButton + property string file + Script { source: "itemCreation.js" } + MouseRegion { + anchors.fill: parent; + onPressed: startDrag(mouse); + onPositionChanged: moveDrag(mouse); + onReleased: endDrag(mouse); + } +} diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml new file mode 100644 index 0000000..9e09dd2 --- /dev/null +++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Image { + id: tree + property bool created: false + opacity: y+height > window.height/2 ? 1 : 0.25 + onCreatedChanged: if (created && y+height<=window.height/2) { tree.destroy() } + scale: y+height > window.height/2 ? (y+height-250)*0.01 : 1 + transformOrigin: "Center" + source: image; + z: y +} diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml new file mode 100644 index 0000000..796a370 --- /dev/null +++ b/examples/declarative/dynamic/qml/Sun.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +Image { + id: sun + property bool created: false + property string image: "../images/sun.png" + onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;} + + source: image; + z: 1 + + //x and y get set when instantiated + //head offscreen + y: NumberAnimation { + to: parent.height; + duration: 10000; + running: created + } + + states: State { + name: "OffScreen"; when: created && y > window.height / 2;//Below the ground + StateChangeScript { script: { sun.created = false; sun.destroy() } } + } +} diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js new file mode 100644 index 0000000..b3e8ba5 --- /dev/null +++ b/examples/declarative/dynamic/qml/itemCreation.js @@ -0,0 +1,82 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var startingZ; +//Until QT-2385 is resolved we need to convert to scene coordinates manually +var xOffset; +var yOffset; +function setSceneOffset() +{ + xOffset = 0; + yOffset = 0; + var p = itemButton; + while(p != window){ + xOffset += p.x; + yOffset += p.y; + p = p.parent; + } +} + +function startDrag(mouse) +{ + setSceneOffset(); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asyncronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) //Already loaded the component + createItem(); + + itemComponent = createComponent(itemButton.file); + print(itemButton.file) + if(itemComponent.isLoading){ + component.statusChanged.connect(finishCreation); + }else{//Depending on the content, it can be ready or error immediately + createItem(); + } +} + +function createItem() { + if (itemComponent.isReady && draggedItem == null) { + draggedItem = itemComponent.createObject(); + draggedItem.parent = window; + draggedItem.image = itemButton.image; + draggedItem.x = xOffset; + draggedItem.y = yOffset; + startingZ = draggedItem.z; + draggedItem.z = 4;//On top + } else if (itemComponent.isError) { + draggedItem = null; + print("error creating component"); + print(component.errorsString()); + } +} + +function moveDrag(mouse) +{ + if(draggedItem == null) + return; + + draggedItem.x = mouse.x + xOffset - startingMouse.x; + draggedItem.y = mouse.y + yOffset - startingMouse.y; +} + +function endDrag(mouse) +{ + if(draggedItem == null) + return; + + if(draggedItem.x + draggedItem.width > toolbox.x){ //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + }else{ + draggedItem.z = startingZ; + draggedItem.created = true; + draggedItem = null; + } +} + -- cgit v0.12