diff options
Diffstat (limited to 'examples/declarative/dynamic')
16 files changed, 0 insertions, 346 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml deleted file mode 100644 index 0e6e197aac..0000000000 --- a/examples/declarative/dynamic/dynamic.qml +++ /dev/null @@ -1,157 +0,0 @@ -import Qt 4.7 -import Qt.labs.particles 1.0 -import "qml" - -Item { - id: window - //This is a desktop-sized example - width: 1024; height: 512 - property int activeSuns: 0 - - //This is the message that pops up when there's an error - Rectangle{ - id: dialog - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6 - height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - Text{ - id: dialogText - x:3 - y:3 - font.pixelSize: 14 - } - SequentialAnimation{ - id: dialogAnim - NumberAnimation{target: dialog; property:"opacity"; to: 1; duration: 1000} - PauseAnimation{duration: 5000} - NumberAnimation{target: dialog; property:"opacity"; to: 0; duration: 1000} - } - } - - // sky - Rectangle { id: sky - anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: stopA; position: 0.0; color: "#0E1533" } - GradientStop { id: stopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - Particles { - id: stars - x: 0; y: 0; width: parent.width; height: parent.height / 2 - source: "images/star.png"; angleDeviation: 360; velocity: 0 - velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 - opacity: 1 - } - - // ground, which has a z such that the sun can set behind it - Rectangle { - id: ground - z: 2 - anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - //Day state, for when you place a sun - states: State { - name: "Day"; when: window.activeSuns > 0 - PropertyChanges { target: stopA; color: "DeepSkyBlue"} - PropertyChanges { target: stopB; color: "SkyBlue"} - PropertyChanges { target: stars; opacity: 0 } - } - - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - - SystemPalette { id: activePalette } - - // toolbox - Rectangle { - id: toolbox - z: 3 //Above ground - color: activePalette.window; - width: 480 - anchors { right: parent.right; top:parent.top; bottom: parent.bottom } - Rectangle { //Not a child of any positioner - border.color: "black"; - width: toolRow.width + 4 - height: toolRow.height + 4 - x: toolboxPositioner.x + toolRow.x - 2 - y: toolboxPositioner.y + toolRow.y - 2 - } - Column { - id: toolboxPositioner - anchors.centerIn: parent - spacing: 8 - Text { text: "Drag an item into the scene." } - Row { - id: toolRow - spacing: 8; - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "Sun.qml"; - image: "../images/sun.png" - } - PaletteItem { - file: "GenericItem.qml" - image: "../images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - file: "PerspectiveItem.qml" - image: "../images/rabbit_bw.png" - } - } - Text { text: "Active Suns: " + activeSuns } - Rectangle { width: 440; height: 1; color: "black" } - Text { text: "Arbitrary QML: " } - TextEdit { - id: qmlText - width: 460 - height: 220 - readOnly: false - focusOnPress: true - font.pixelSize: 14 - - text: "import Qt 4.7\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - Button { - text: "Create" - function makeCustom() { - try{ - Qt.createQmlObject(qmlText.text, window, 'CustomObject'); - }catch(err){ - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message ); - } - } - onClicked: makeCustom(); - } - } - } - -} diff --git a/examples/declarative/dynamic/dynamic.qmlproject b/examples/declarative/dynamic/dynamic.qmlproject deleted file mode 100644 index d4909f8685..0000000000 --- a/examples/declarative/dynamic/dynamic.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - /* List of plugin directories passed to QML runtime */ - // importPaths: [ " ../exampleplugin " ] -} diff --git a/examples/declarative/dynamic/images/NOTE b/examples/declarative/dynamic/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/declarative/dynamic/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/dynamic/images/face-smile.png b/examples/declarative/dynamic/images/face-smile.png Binary files differdeleted file mode 100644 index 3d66d72578..0000000000 --- a/examples/declarative/dynamic/images/face-smile.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/moon.png b/examples/declarative/dynamic/images/moon.png Binary files differdeleted file mode 100644 index 1c0d6066a8..0000000000 --- a/examples/declarative/dynamic/images/moon.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/rabbit_brown.png b/examples/declarative/dynamic/images/rabbit_brown.png Binary files differdeleted file mode 100644 index ebfdeed332..0000000000 --- a/examples/declarative/dynamic/images/rabbit_brown.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/rabbit_bw.png b/examples/declarative/dynamic/images/rabbit_bw.png Binary files differdeleted file mode 100644 index 7bff9b92ca..0000000000 --- a/examples/declarative/dynamic/images/rabbit_bw.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/star.png b/examples/declarative/dynamic/images/star.png Binary files differdeleted file mode 100644 index 27ef924267..0000000000 --- a/examples/declarative/dynamic/images/star.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/sun.png b/examples/declarative/dynamic/images/sun.png Binary files differdeleted file mode 100644 index 7713ca5ce7..0000000000 --- a/examples/declarative/dynamic/images/sun.png +++ /dev/null diff --git a/examples/declarative/dynamic/images/tree_s.png b/examples/declarative/dynamic/images/tree_s.png Binary files differdeleted file mode 100644 index 6eac35a729..0000000000 --- a/examples/declarative/dynamic/images/tree_s.png +++ /dev/null diff --git a/examples/declarative/dynamic/qml/Button.qml b/examples/declarative/dynamic/qml/Button.qml deleted file mode 100644 index 53588bb04c..0000000000 --- a/examples/declarative/dynamic/qml/Button.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.7 - -Rectangle { - id: container - - property variant text - signal clicked - - SystemPalette { id: activePalette } - 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;} - } - } - MouseArea { 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 deleted file mode 100644 index faac06d715..0000000000 --- a/examples/declarative/dynamic/qml/GenericItem.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.7 - -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 deleted file mode 100644 index e8f2ed42f7..0000000000 --- a/examples/declarative/dynamic/qml/PaletteItem.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt 4.7 -import "itemCreation.js" as Code - -GenericItem { - id: itemButton - property string file - MouseArea { - anchors.fill: parent; - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.moveDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml deleted file mode 100644 index 3cbe64a247..0000000000 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ /dev/null @@ -1,16 +0,0 @@ -import Qt 4.7 - -Image { - id: tree - property bool created: false - property double scaleFactor: Math.max((y+height-250)*0.01, 0.3) - property double scaledBottom: y + (height+height*scaleFactor)/2 - property bool onLand: scaledBottom > window.height/2 - property string image //Needed for compatibility with GenericItem - opacity: onLand ? 1 : 0.25 - onCreatedChanged: if (created && !onLand) { tree.destroy() } else { z = scaledBottom } - scale: scaleFactor - transformOrigin: "Center" - source: image; smooth: true - onYChanged: z = scaledBottom -} diff --git a/examples/declarative/dynamic/qml/Sun.qml b/examples/declarative/dynamic/qml/Sun.qml deleted file mode 100644 index 362796402a..0000000000 --- a/examples/declarative/dynamic/qml/Sun.qml +++ /dev/null @@ -1,24 +0,0 @@ -import Qt 4.7 - -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 - NumberAnimation on y { - to: window.height / 2; - running: created - onRunningChanged: if (running) duration = (window.height - sun.y) * 10; else state = "OffScreen"; - } - - states: State { - name: "OffScreen"; - StateChangeScript { script: { sun.created = false; sun.destroy() } } - } -} diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js deleted file mode 100644 index 98d48a8c53..0000000000 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ /dev/null @@ -1,82 +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 = Qt.createComponent(itemButton.file); - //console.log(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; - console.log("error creating component"); - console.log(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; - } -} - |