diff options
Diffstat (limited to 'examples/qml/dynamicscene')
21 files changed, 0 insertions, 506 deletions
diff --git a/examples/qml/dynamicscene/CMakeLists.txt b/examples/qml/dynamicscene/CMakeLists.txt deleted file mode 100644 index b91ed5aca7..0000000000 --- a/examples/qml/dynamicscene/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(dynamicscene LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/dynamicscene") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) - -qt_add_executable(dynamicsceneexample WIN32 MACOSX_BUNDLE main.cpp) - -target_link_libraries(dynamicsceneexample PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick -) - -qt_add_qml_module(dynamicsceneexample - URI dynamicscene - AUTO_RESOURCE_PREFIX - QML_FILES - "GenericSceneItem.qml" - "PaletteItem.qml" - "PerspectiveItem.qml" - "Sun.qml" - "dynamicscene.qml" - "itemCreation.js" - RESOURCES - "images/NOTE" - "images/face-smile.png" - "images/moon.png" - "images/rabbit_brown.png" - "images/rabbit_bw.png" - "images/star.png" - "images/sun.png" - "images/tree_s.png" -) - -install(TARGETS dynamicsceneexample - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/qml/dynamicscene/GenericSceneItem.qml b/examples/qml/dynamicscene/GenericSceneItem.qml deleted file mode 100644 index 5ff3760bb7..0000000000 --- a/examples/qml/dynamicscene/GenericSceneItem.qml +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/qml/dynamicscene/PaletteItem.qml b/examples/qml/dynamicscene/PaletteItem.qml deleted file mode 100644 index ef03b8ce38..0000000000 --- a/examples/qml/dynamicscene/PaletteItem.qml +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: (mouse)=> Code.startDrag(mouse); - onPositionChanged: (mouse)=> Code.continueDrag(mouse); - onReleased: (mouse)=> Code.endDrag(mouse); - } -} diff --git a/examples/qml/dynamicscene/PerspectiveItem.qml b/examples/qml/dynamicscene/PerspectiveItem.qml deleted file mode 100644 index 8857b92376..0000000000 --- a/examples/qml/dynamicscene/PerspectiveItem.qml +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/qml/dynamicscene/Sun.qml b/examples/qml/dynamicscene/Sun.qml deleted file mode 100644 index e755563eba..0000000000 --- a/examples/qml/dynamicscene/Sun.qml +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick - -Image { - id: sun - - property bool created: false - property string image: "images/sun.png" - - source: image - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - // once item is created, start moving offscreen - dropYAnim.duration = (window.height + window.centerOffset - sun.y) * 16; - dropAnim.running = true; - } else { - window.activeSuns--; - } - } - - SequentialAnimation on y{ - id: dropAnim - running: false - NumberAnimation { - id: dropYAnim - to: (window.height / 2) + window.centerOffset - } - ScriptAction { - script: { sun.created = false; sun.destroy() } - } - } -} diff --git a/examples/qml/dynamicscene/doc/images/qml-dynamicscene-example.png b/examples/qml/dynamicscene/doc/images/qml-dynamicscene-example.png Binary files differdeleted file mode 100644 index 38260a7d3f..0000000000 --- a/examples/qml/dynamicscene/doc/images/qml-dynamicscene-example.png +++ /dev/null diff --git a/examples/qml/dynamicscene/doc/src/dynamicscene.qdoc b/examples/qml/dynamicscene/doc/src/dynamicscene.qdoc deleted file mode 100644 index a7a3351fdc..0000000000 --- a/examples/qml/dynamicscene/doc/src/dynamicscene.qdoc +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only -/*! - \title QML Example - Dynamic Scene - \example dynamicscene - \brief This example demonstrates creating components dynamically. - \image qml-dynamicscene-example.png -*/ - - diff --git a/examples/qml/dynamicscene/dynamicscene.pro b/examples/qml/dynamicscene/dynamicscene.pro deleted file mode 100644 index 29a3fa97e2..0000000000 --- a/examples/qml/dynamicscene/dynamicscene.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp - -RESOURCES += dynamicscene.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qml/dynamicscene -INSTALLS += target diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml deleted file mode 100644 index 62795703c5..0000000000 --- a/examples/qml/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Particles -import QtQuick.Controls - -Item { - id: window - - property int activeSuns: 0 - property int centerOffset: 72 - - height: 480; width: 320 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box 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(); - } - - Label { - 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 } - } - } - - Item { - id: scene - anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} - z: 10 - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -window.centerOffset; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - ParticleSystem { - id: particlesystem - anchors.fill: sky - - ImageParticle { - id: stars - source: "images/star.png" - groups: ["stars"] - opacity: .5 - } - - Emitter { - id: starsemitter - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - group: "stars" - } - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; topMargin: window.centerOffset; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - // top panel - Rectangle { - id: toolbox - - height: window.centerOffset * 2 - color: "white" - anchors { right: parent.right; top: parent.top; left: parent.left} - - Column { - anchors.centerIn: parent - spacing: 8 - - Label { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - source: "images/sun.png" - image: "images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - source: "images/moon.png" - image: "images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "images/tree_s.png" - image: "images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "images/rabbit_brown.png" - image: "images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "images/rabbit_bw.png" - image: "images/rabbit_bw.png" - } - } - } - - Label { text: "Active Suns: " + window.activeSuns } - } - } - - //Popup toolbox down the bottom - Rectangle { - id: popupToolbox - z: 1000 - width: parent.width - height: popupColumn.height + 16 - color: "white" - - property bool poppedUp: false - property int downY: window.height - (createButton.height + 16) - property int upY: window.height - (popupColumn.height + 16) - y: poppedUp ? upY : downY - Behavior on y { NumberAnimation {}} - - Column { - id: popupColumn - y: 8 - spacing: 8 - - Row { - height: createButton.height - spacing: 8 - Label { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } - Button { - id: popupButton - text: popupToolbox.poppedUp ? "Hide" : "Show" - onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp - } - Button { - id: createButton - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - - } - - Rectangle { - width: 360; height: 240 - - TextArea { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - selectByMouse: true - wrapMode: TextEdit.WordWrap - - text: "import QtQuick\nImage {\n id: smile\n x: 360 * Math.random()\n y: 40 * 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}" - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { - gradientStopA.color: "DeepSkyBlue" - gradientStopB.color: "SkyBlue" - stars.opacity: 0 - } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/qml/dynamicscene/dynamicscene.qmlproject b/examples/qml/dynamicscene/dynamicscene.qmlproject deleted file mode 100644 index 52ac474383..0000000000 --- a/examples/qml/dynamicscene/dynamicscene.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "dynamicscene.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qml/dynamicscene/dynamicscene.qrc b/examples/qml/dynamicscene/dynamicscene.qrc deleted file mode 100644 index f354fc469a..0000000000 --- a/examples/qml/dynamicscene/dynamicscene.qrc +++ /dev/null @@ -1,18 +0,0 @@ -<RCC> - <qresource prefix="/qt/qml/dynamicscene"> - <file>dynamicscene.qml</file> - <file>images/face-smile.png</file> - <file>images/moon.png</file> - <file>images/NOTE</file> - <file>images/rabbit_brown.png</file> - <file>images/rabbit_bw.png</file> - <file>images/star.png</file> - <file>images/sun.png</file> - <file>images/tree_s.png</file> - <file>GenericSceneItem.qml</file> - <file>itemCreation.js</file> - <file>PaletteItem.qml</file> - <file>PerspectiveItem.qml</file> - <file>Sun.qml</file> - </qresource> -</RCC> diff --git a/examples/qml/dynamicscene/images/NOTE b/examples/qml/dynamicscene/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/qml/dynamicscene/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/qml/dynamicscene/images/face-smile.png b/examples/qml/dynamicscene/images/face-smile.png Binary files differdeleted file mode 100644 index 3d66d72578..0000000000 --- a/examples/qml/dynamicscene/images/face-smile.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/moon.png b/examples/qml/dynamicscene/images/moon.png Binary files differdeleted file mode 100644 index 1c0d6066a8..0000000000 --- a/examples/qml/dynamicscene/images/moon.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/rabbit_brown.png b/examples/qml/dynamicscene/images/rabbit_brown.png Binary files differdeleted file mode 100644 index ebfdeed332..0000000000 --- a/examples/qml/dynamicscene/images/rabbit_brown.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/rabbit_bw.png b/examples/qml/dynamicscene/images/rabbit_bw.png Binary files differdeleted file mode 100644 index 7bff9b92ca..0000000000 --- a/examples/qml/dynamicscene/images/rabbit_bw.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/star.png b/examples/qml/dynamicscene/images/star.png Binary files differdeleted file mode 100644 index bdcd36909d..0000000000 --- a/examples/qml/dynamicscene/images/star.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/sun.png b/examples/qml/dynamicscene/images/sun.png Binary files differdeleted file mode 100644 index c5fd36ed39..0000000000 --- a/examples/qml/dynamicscene/images/sun.png +++ /dev/null diff --git a/examples/qml/dynamicscene/images/tree_s.png b/examples/qml/dynamicscene/images/tree_s.png Binary files differdeleted file mode 100644 index 6eac35a729..0000000000 --- a/examples/qml/dynamicscene/images/tree_s.png +++ /dev/null diff --git a/examples/qml/dynamicscene/itemCreation.js b/examples/qml/dynamicscene/itemCreation.js deleted file mode 100644 index 2829a83410..0000000000 --- a/examples/qml/dynamicscene/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/qml/dynamicscene/main.cpp b/examples/qml/dynamicscene/main.cpp deleted file mode 100644 index e46981848a..0000000000 --- a/examples/qml/dynamicscene/main.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#include "../../quick/shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(dynamicscene/dynamicscene) |