diff options
author | Lucie GĂ©rard <lucie.gerard@qt.io> | 2023-11-20 14:21:57 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-11-28 17:57:05 -0700 |
commit | 8dc2e3daf08327c6f70ac7c1c5862f726cbf74e7 (patch) | |
tree | 510f75f3cb7b7ec021367c3f48bf9294fc204d65 /examples/quick | |
parent | b77df9bbdd58c220ecb6ca66de67a52f6aa13539 (diff) |
Move undocumented quick examples to manual tests
- maskedmousearea ought to be redone with input handlers
- delegatechooser needs a realistic use case, not so ugly
- itemparticle hasn't been in working condition for some time,
due to its use of flickr API
- keep FlickrRssModel only in manual tests (broken for now)
- remove bogus copies of flipable example files from the
delegatemodel example which were added in
1fef24732bb5114392626a7fef956625a6cc66ac
- copy shared components that examples tend to depend on
into a shared directory for manual tests
Task-number: QTBUG-88470
Task-number: QTBUG-119117
Change-Id: Ide1918f5e1b6fcc3efd939825892bfd270cef586
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/quick')
42 files changed, 2 insertions, 1196 deletions
diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt index 4453239cc8..0ed9871e68 100644 --- a/examples/quick/CMakeLists.txt +++ b/examples/quick/CMakeLists.txt @@ -24,7 +24,6 @@ qt_internal_add_example(imageprovider) qt_internal_add_example(imageresponseprovider) qt_internal_add_example(window) add_subdirectory(particles) -qt_internal_add_example(delegatechooser) qt_internal_add_example(shapes) qt_internal_add_example(itemvariablerefreshrate) add_subdirectory(multieffect) @@ -49,7 +48,6 @@ set(reused_dir_targets window_shared shapes_shared imageelements_shared - delegatechooser_shared pointerhandlers_shared affectors_shared emitters_shared diff --git a/examples/quick/customitems/CMakeLists.txt b/examples/quick/customitems/CMakeLists.txt index 8fad896269..85cec4402f 100644 --- a/examples/quick/customitems/CMakeLists.txt +++ b/examples/quick/customitems/CMakeLists.txt @@ -4,4 +4,3 @@ qt_internal_add_example(dialcontrol) qt_internal_add_example(flipable) qt_internal_add_example(painteditem) -qt_internal_add_example(maskedmousearea) diff --git a/examples/quick/customitems/customitems.pro b/examples/quick/customitems/customitems.pro index 399c1dd126..3199bfc9ad 100644 --- a/examples/quick/customitems/customitems.pro +++ b/examples/quick/customitems/customitems.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS = \ - painteditem \ - maskedmousearea + painteditem EXAMPLE_FILES = \ dialcontrol \ diff --git a/examples/quick/customitems/maskedmousearea/CMakeLists.txt b/examples/quick/customitems/maskedmousearea/CMakeLists.txt deleted file mode 100644 index 9274fcdeee..0000000000 --- a/examples/quick/customitems/maskedmousearea/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(maskedmousearea LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/maskedmousearea") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) - -qt_add_executable(maskedmousearea - WIN32 - MACOSX_BUNDLE - main.cpp - maskedmousearea.cpp maskedmousearea.h -) - -target_link_libraries(maskedmousearea PRIVATE - Qt6::Core - Qt6::Gui - Qt6::Qml - Qt6::Quick -) - -qt_add_qml_module(maskedmousearea - URI Example - QML_FILES - maskedmousearea.qml - RESOURCES - images/cloud_1.png - images/cloud_2.png - images/moon.png - RESOURCE_PREFIX /customitems/maskedmousearea - NO_RESOURCE_TARGET_PATH -) - -install(TARGETS maskedmousearea - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/quick/customitems/maskedmousearea/images/cloud_1.png b/examples/quick/customitems/maskedmousearea/images/cloud_1.png Binary files differdeleted file mode 100644 index 9beb7e8442..0000000000 --- a/examples/quick/customitems/maskedmousearea/images/cloud_1.png +++ /dev/null diff --git a/examples/quick/customitems/maskedmousearea/images/cloud_2.png b/examples/quick/customitems/maskedmousearea/images/cloud_2.png Binary files differdeleted file mode 100644 index 981bbd2630..0000000000 --- a/examples/quick/customitems/maskedmousearea/images/cloud_2.png +++ /dev/null diff --git a/examples/quick/customitems/maskedmousearea/images/moon.png b/examples/quick/customitems/maskedmousearea/images/moon.png Binary files differdeleted file mode 100644 index 0a8037dd85..0000000000 --- a/examples/quick/customitems/maskedmousearea/images/moon.png +++ /dev/null diff --git a/examples/quick/customitems/maskedmousearea/main.cpp b/examples/quick/customitems/maskedmousearea/main.cpp deleted file mode 100644 index 6c19ac91f8..0000000000 --- a/examples/quick/customitems/maskedmousearea/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QGuiApplication> -#include <QQuickView> - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc,argv); - QQuickView view; - - view.setSource(QUrl("qrc:///customitems/maskedmousearea/maskedmousearea.qml")); - view.show(); - return QGuiApplication::exec(); -} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp b/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp deleted file mode 100644 index 21dbec8cdd..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "maskedmousearea.h" - -#include <QStyleHints> -#include <QGuiApplication> -#include <qqmlfile.h> - -MaskedMouseArea::MaskedMouseArea(QQuickItem *parent) - : QQuickItem(parent), - m_pressed(false), - m_alphaThreshold(0.0), - m_containsMouse(false) -{ - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::LeftButton); -} - -void MaskedMouseArea::setPressed(bool pressed) -{ - if (m_pressed != pressed) { - m_pressed = pressed; - emit pressedChanged(); - } -} - -void MaskedMouseArea::setContainsMouse(bool containsMouse) -{ - if (m_containsMouse != containsMouse) { - m_containsMouse = containsMouse; - emit containsMouseChanged(); - } -} - -void MaskedMouseArea::setMaskSource(const QUrl &source) -{ - if (m_maskSource != source) { - m_maskSource = source; - m_maskImage = QImage(QQmlFile::urlToLocalFileOrQrc(source)); - emit maskSourceChanged(); - } -} - -void MaskedMouseArea::setAlphaThreshold(qreal threshold) -{ - if (m_alphaThreshold != threshold) { - m_alphaThreshold = threshold; - emit alphaThresholdChanged(); - } -} - -bool MaskedMouseArea::contains(const QPointF &point) const -{ - if (!QQuickItem::contains(point) || m_maskImage.isNull()) - return false; - - QPoint p = point.toPoint(); - - if (p.x() < 0 || p.x() >= m_maskImage.width() || - p.y() < 0 || p.y() >= m_maskImage.height()) - return false; - - qreal r = qBound<int>(0, m_alphaThreshold * 255, 255); - return qAlpha(m_maskImage.pixel(p)) > r; -} - -void MaskedMouseArea::mousePressEvent(QMouseEvent *event) -{ - setPressed(true); - m_pressPoint = event->position().toPoint(); - emit pressed(); -} - -void MaskedMouseArea::mouseReleaseEvent(QMouseEvent *event) -{ - setPressed(false); - emit released(); - - const int threshold = qApp->styleHints()->startDragDistance(); - const bool isClick = (threshold >= qAbs(event->position().toPoint().x() - m_pressPoint.x()) && - threshold >= qAbs(event->position().toPoint().y() - m_pressPoint.y())); - - if (isClick) - emit clicked(); -} - -void MaskedMouseArea::mouseUngrabEvent() -{ - setPressed(false); - emit canceled(); -} - -void MaskedMouseArea::hoverEnterEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - setContainsMouse(true); -} - -void MaskedMouseArea::hoverLeaveEvent(QHoverEvent *event) -{ - Q_UNUSED(event); - setContainsMouse(false); -} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.h b/examples/quick/customitems/maskedmousearea/maskedmousearea.h deleted file mode 100644 index b235df2a98..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef MASKEDMOUSEAREA_H -#define MASKEDMOUSEAREA_H - -#include <QImage> -#include <QQuickItem> - - -class MaskedMouseArea : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged) - Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged) - Q_PROPERTY(QUrl maskSource READ maskSource WRITE setMaskSource NOTIFY maskSourceChanged) - Q_PROPERTY(qreal alphaThreshold READ alphaThreshold WRITE setAlphaThreshold NOTIFY alphaThresholdChanged) - QML_ELEMENT - -public: - MaskedMouseArea(QQuickItem *parent = nullptr); - - bool contains(const QPointF &point) const override; - - bool isPressed() const { return m_pressed; } - bool containsMouse() const { return m_containsMouse; } - - QUrl maskSource() const { return m_maskSource; } - void setMaskSource(const QUrl &source); - - qreal alphaThreshold() const { return m_alphaThreshold; } - void setAlphaThreshold(qreal threshold); - -signals: - void pressed(); - void released(); - void clicked(); - void canceled(); - void pressedChanged(); - void maskSourceChanged(); - void containsMouseChanged(); - void alphaThresholdChanged(); - -protected: - void setPressed(bool pressed); - void setContainsMouse(bool containsMouse); - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void hoverEnterEvent(QHoverEvent *event) override; - void hoverLeaveEvent(QHoverEvent *event) override; - void mouseUngrabEvent() override; - -private: - bool m_pressed; - QUrl m_maskSource; - QImage m_maskImage; - QPointF m_pressPoint; - qreal m_alphaThreshold; - bool m_containsMouse; -}; - -#endif diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.pro b/examples/quick/customitems/maskedmousearea/maskedmousearea.pro deleted file mode 100644 index c5cedf4e6e..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app - -QT += quick qml - -CONFIG += qmltypes -QML_IMPORT_NAME = Example -QML_IMPORT_MAJOR_VERSION = 1 - -HEADERS += maskedmousearea.h - -SOURCES += main.cpp \ - maskedmousearea.cpp - -RESOURCES += maskedmousearea.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/maskedmousearea -INSTALLS += target diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qml b/examples/quick/customitems/maskedmousearea/maskedmousearea.qml deleted file mode 100644 index df8de3dcb8..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.qml +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import Example - -Rectangle { - height: 480 - width: 320 - color: "black" - - Text { - text: qsTr("CLICK AND HOVER") - opacity: 0.6 - color: "white" - font.pixelSize: 20 - anchors.top: parent.top - anchors.horizontalCenter: parent.horizontalCenter - anchors.topMargin: 50 - } - - Image { - id: moon - anchors.centerIn: parent - scale: moonArea.pressed ? 1.1 : 1.0 - opacity: moonArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/moon.png") - - MaskedMouseArea { - id: moonArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: moon.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } - - Image { - id: rightCloud - anchors { - centerIn: moon - verticalCenterOffset: 30 - horizontalCenterOffset: 80 - } - scale: rightCloudArea.pressed ? 1.1 : 1.0 - opacity: rightCloudArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/cloud_2.png") - - MaskedMouseArea { - id: rightCloudArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: rightCloud.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } - - Image { - id: leftCloud - anchors { - centerIn: moon - verticalCenterOffset: 40 - horizontalCenterOffset: -80 - } - scale: leftCloudArea.pressed ? 1.1 : 1.0 - opacity: leftCloudArea.containsMouse ? 1.0 : 0.7 - source: Qt.resolvedUrl("images/cloud_1.png") - - MaskedMouseArea { - id: leftCloudArea - anchors.fill: parent - alphaThreshold: 0.4 - maskSource: leftCloud.source - } - - Behavior on opacity { - NumberAnimation { duration: 200 } - } - Behavior on scale { - NumberAnimation { duration: 100 } - } - } -} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject b/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject deleted file mode 100644 index 709c19866f..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "maskedmousearea.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/customitems/maskedmousearea/maskedmousearea.qrc b/examples/quick/customitems/maskedmousearea/maskedmousearea.qrc deleted file mode 100644 index 3cc3955e56..0000000000 --- a/examples/quick/customitems/maskedmousearea/maskedmousearea.qrc +++ /dev/null @@ -1,8 +0,0 @@ -<RCC> - <qresource prefix="/customitems/maskedmousearea"> - <file>maskedmousearea.qml</file> - <file>images/cloud_1.png</file> - <file>images/cloud_2.png</file> - <file>images/moon.png</file> - </qresource> -</RCC> diff --git a/examples/quick/delegatechooser/CMakeLists.txt b/examples/quick/delegatechooser/CMakeLists.txt deleted file mode 100644 index 0954fda17a..0000000000 --- a/examples/quick/delegatechooser/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(delegatechooser LANGUAGES CXX) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/delegatechooser") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) - -qt_standard_project_setup(REQUIRES 6.5) - -add_subdirectory("../shared" "shared") - -qt_add_executable(delegatechooserexample WIN32 MACOSX_BUNDLE main.cpp) - -target_link_libraries(delegatechooserexample PRIVATE - Qt6::Core - Qt6::Gui - Qt6::Qml - Qt6::Quick -) - -add_dependencies(delegatechooserexample delegatechooser_shared) - -qt_add_qml_module(delegatechooserexample - URI delegatechooser - QML_FILES - "delegatechooser.qml" -) - -install(TARGETS delegatechooserexample - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) - -bundle_shared(delegatechooserexample) diff --git a/examples/quick/delegatechooser/delegatechooser.pro b/examples/quick/delegatechooser/delegatechooser.pro deleted file mode 100644 index f06864ba89..0000000000 --- a/examples/quick/delegatechooser/delegatechooser.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -QT += quick qml - -SOURCES += main.cpp -RESOURCES += qml.qrc ../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/delegatechooser -INSTALLS += target diff --git a/examples/quick/delegatechooser/delegatechooser.qml b/examples/quick/delegatechooser/delegatechooser.qml deleted file mode 100644 index 9e7eff9fdc..0000000000 --- a/examples/quick/delegatechooser/delegatechooser.qml +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQml.Models -import QtQuick.Layouts -import Qt.labs.qmlmodels -import shared - -Rectangle { - visible: true - width: 640 - height: 640 - - ListModel { - id: listModel - ListElement { dataType: "rect"; color: "green" } - ListElement { dataType: "image" } - ListElement { dataType: "rect"; color: "green" } - ListElement { dataType: "image" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - } - - ListModel { - id: listModel2 - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "green" } - ListElement { dataType: "image" } - ListElement { dataType: "rect"; color: "green" } - ListElement { dataType: "image" } - ListElement { dataType: "rect"; color: "blue" } - ListElement { dataType: "rect"; color: "lightsteelblue" } - ListElement { dataType: "rect"; color: "fuchsia" } - ListElement { dataType: "rect"; color: "lime" } - } - - DelegateChooser { - id: fancyDelegate - role: "dataType" - DelegateChoice { - roleValue: "rect" - delegate: DelegateChooser { - DelegateChoice { - row: 0 - Rectangle { - width: parent.width - height: 50 - color: "red" - border.color: "black" - border.width: 1 - } - } - DelegateChoice { - Rectangle { - width: parent.width - height: 50 - color: model.color - border.color: "black" - border.width: 1 - } - } - } - } - DelegateChoice { - roleValue: "image" - delegate: Image { - width: parent.width - height: 100 - source: Images.qtLogo - fillMode: Image.PreserveAspectFit - } - } - } - - Item { - anchors.fill: parent - id: ite - RowLayout { - ListView { - Layout.preferredHeight: ite.height - Layout.preferredWidth: ite.width * 0.5 - model: listModel - delegate: fancyDelegate - } - ListView { - Layout.preferredHeight: ite.height - Layout.preferredWidth: ite.width * 0.5 - model: listModel2 - delegate: fancyDelegate - } - } - } -} diff --git a/examples/quick/delegatechooser/main.cpp b/examples/quick/delegatechooser/main.cpp deleted file mode 100644 index 7cccc7340b..0000000000 --- a/examples/quick/delegatechooser/main.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#include "../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(delegatechooser/delegatechooser) diff --git a/examples/quick/delegatechooser/qml.qrc b/examples/quick/delegatechooser/qml.qrc deleted file mode 100644 index 6128befab3..0000000000 --- a/examples/quick/delegatechooser/qml.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/qt/qml/delegatechooser"> - <file>delegatechooser.qml</file> - </qresource> -</RCC> diff --git a/examples/quick/particles/CMakeLists.txt b/examples/quick/particles/CMakeLists.txt index d34300510f..135bb48950 100644 --- a/examples/quick/particles/CMakeLists.txt +++ b/examples/quick/particles/CMakeLists.txt @@ -4,5 +4,4 @@ qt_internal_add_example(affectors) qt_internal_add_example(emitters) qt_internal_add_example(imageparticle) -qt_internal_add_example(itemparticle) qt_internal_add_example(system) diff --git a/examples/quick/particles/itemparticle/CMakeLists.txt b/examples/quick/particles/itemparticle/CMakeLists.txt deleted file mode 100644 index a2dcb8cf2f..0000000000 --- a/examples/quick/particles/itemparticle/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(itemparticle LANGUAGES CXX) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/particles/itemparticle") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) - -qt_standard_project_setup(REQUIRES 6.5) - -add_subdirectory("../../shared" "shared") - -qt_add_executable(itemparticleexample WIN32 MACOSX_BUNDLE - main.cpp -) - -target_link_libraries(itemparticleexample PRIVATE - Qt6::Core - Qt6::Gui - Qt6::Qml - Qt6::Quick -) - -add_dependencies(itemparticleexample itemparticle_shared) - -# Resources: -qt_add_qml_module(itemparticleexample - URI itemparticle - QML_FILES - "itemparticle.qml" - "delegates.qml" - "script.js" - RESOURCES - "images/rocket.png" -) - -install(TARGETS itemparticleexample - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) - -bundle_shared(itemparticleexample) diff --git a/examples/quick/particles/itemparticle/delegates.qml b/examples/quick/particles/itemparticle/delegates.qml deleted file mode 100644 index 35bbbc7132..0000000000 --- a/examples/quick/particles/itemparticle/delegates.qml +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Particles - -Rectangle { - id: root; - width: 360 - height: 600 - color: "black" - - function newPithySaying() { - switch (Math.floor(Math.random()*16)) { - case 0: return "Hello World"; - case 1: return "G'day Mate"; - case 2: return "Code Less"; - case 3: return "Create More"; - case 4: return "Deploy Everywhere"; - case 5: return "Qt Meta-object Language"; - case 6: return "Qt Magic Language"; - case 7: return "Fluid UIs"; - case 8: return "Touchable"; - case 9: return "How's it going?"; - case 10: return "Do you like text?"; - case 11: return "Enjoy!"; - case 12: return "ERROR: Out of pith"; - case 13: return "Punctuation Failure"; - case 14: return "I can go faster"; - case 15: return "I can go slower"; - default: return "OMGWTFBBQ"; - } - } - - ParticleSystem { - anchors.fill: parent - id: syssy - MouseArea { - anchors.fill: parent - onClicked: syssy.running = !syssy.running - } - Emitter { - anchors.centerIn: parent - emitRate: 1 - lifeSpan: 4800 - lifeSpanVariation: 1600 - velocity: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} - } - ItemParticle { - delegate: Text { - text: root.newPithySaying(); - color: "white" - font.pixelSize: 18 - font.bold: true - } - } - } -} diff --git a/examples/quick/particles/itemparticle/images/rocket.png b/examples/quick/particles/itemparticle/images/rocket.png Binary files differdeleted file mode 100644 index a171610b03..0000000000 --- a/examples/quick/particles/itemparticle/images/rocket.png +++ /dev/null diff --git a/examples/quick/particles/itemparticle/itemparticle.pro b/examples/quick/particles/itemparticle/itemparticle.pro deleted file mode 100644 index c0426cd032..0000000000 --- a/examples/quick/particles/itemparticle/itemparticle.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp -RESOURCES += \ - itemparticle.qrc \ - ../../shared/shared.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/particles/itemparticle -INSTALLS += target diff --git a/examples/quick/particles/itemparticle/itemparticle.qml b/examples/quick/particles/itemparticle/itemparticle.qml deleted file mode 100644 index 6655dde939..0000000000 --- a/examples/quick/particles/itemparticle/itemparticle.qml +++ /dev/null @@ -1,262 +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 shared -import "script.js" as Script - -Item { - id: root - width: 640 - height: 480 - Rectangle { - anchors.fill: parent - color: "black" - z: -1 - } - Item { - id: loading - Behavior on opacity {NumberAnimation {}} - anchors.fill: parent - Text { - anchors.centerIn: parent - text: "Loading" - color: "white" - } - } - ParticleSystem { - id: sys; - running: true - } - Emitter { - id: emitter - system: sys - height: parent.height - 132/2 - x: -132/2 - y: 132/2 - velocity: PointDirection { x: 32; xVariation: 8 } - emitRate: 0.5 - lifeSpan: Emitter.InfiniteLife - group: "photos" - } - Age { - system: sys - x: parent.width + 132/2 - height: parent.height - width: 1000 - } - ImageParticle { - system: sys - groups: ["fireworks"] - source: "qrc:///particleresources/star.png" - color: "lightsteelblue" - alpha: 0 - colorVariation: 0 - z: 1000 - } - ItemParticle { - id: mp - z: 0 - system: sys - fade: false - groups: ["photos"] - } - Component { - id: alertDelegate - Rectangle { - color: "DarkSlateGray" - border.width: 1 - border.color: "LightSteelBlue" - width: 144 - height: 132 - antialiasing: true - radius: 3 - NumberAnimation on scale { - running: true - loops: 1 - from: 0.2 - to: 1 - } - Image { - source: "images/rocket.png" - anchors.centerIn: parent - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: "A new ship has arrived!" - color: "LightSteelBlue" - } - } - } - property Item alertItem; - function alert() { - force.enabled = true; - alertItem = alertDelegate.createObject(root); - alertItem.x = root.width/2 - alertItem.width/2 - alertItem.y = root.height/2 - alertItem.height/2 - spawnFireworks.pulse(200); - stopAlert.start(); - } - focus: true - Keys.onSpacePressed: alert(); - Timer { - id: stopAlert - running: false - repeat: false - interval: 800 - onTriggered: { - force.enabled = false; - mp.take(root.alertItem, true); - centerEmitter.burst(1); - } - } - Attractor { - id: force - system: sys - pointX: root.width/2 - pointY: root.height/2 - strength: -10000 - enabled: false - anchors.centerIn: parent - width: parent.width/2 - height: parent.height/2 - groups:["photos"] - affectedParameter: Attractor.Position - } - Emitter { - id: centerEmitter - velocity: PointDirection { x: 32; xVariation: 8;} - emitRate: 0.5 - lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) - maximumEmitted: 20 - group: "photos" - system: sys - anchors.centerIn: parent - enabled: false - - //TODO: Zoom in effect - } - Emitter { - id: spawnFireworks - group: "fireworks" - system: sys - maximumEmitted: 400 - emitRate: 400 - lifeSpan: 2800 - x: parent.width/2 - y: parent.height/2 - 64 - width: 8 - height: 8 - enabled: false - size: 32 - endSize: 8 - velocity: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } - acceleration: PointDirection { y: 160 } - } - Item { x: -1000; y: -1000 //offscreen - Repeater {//Load them here, add to system on completed - model: flickrModel - delegate: theDelegate - } - } - FlickrRssModel { - id: flickrModel - tags: "particle,particles" - } - Component { - id: theDelegate - Image { - required property int index - required property string title - required property string media - required property string thumbnail - - id: image - antialiasing: true; - source: thumbnail - cache: true - property real depth: Math.random() - property real darken: 0.75 - z: Math.floor(depth * 100) - scale: (depth + 1) / 2 - sourceSize { - width: root.width - height: root.height - } - width: 132 - height: 132 - fillMode: Image.PreserveAspectFit - Rectangle { - // Darken based on depth - anchors.centerIn: parent - width: parent.paintedWidth + 1 - height: parent.paintedHeight + 1 - color: "black" - opacity: image.darken * (1 - image.depth) - antialiasing: true; - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottomMargin: Math.max(parent.paintedWidth, parent.paintedHeight) - Math.min(parent.width, parent.height) - width: parent.paintedWidth - 4 - horizontalAlignment: Text.AlignHCenter - elide: Text.ElideRight - text: image.title - color: "black" - } - ItemParticle.onDetached: mp.take(image); // respawns - onStatusChanged: if (image.status == Image.Ready) { - loading.opacity = 0; - mp.take(image); - } - function manage() - { - if (state == "selected") { - console.log("Taking " + index); - mp.freeze(image); - } else { - console.log("Returning " +index); - mp.unfreeze(image); - } - } - TapHandler { - gesturePolicy: TapHandler.ReleaseWithinBounds - onTapped: image.state = (image.state == "" ? "selected" : "") - } - states: State { - name: "selected" - ParentChange { - target: image - parent: root - } - PropertyChanges { - image { - source: image.media - x: 0 - y: 0 - width: root.width - height: root.height - z: 101 - opacity: 1 - rotation: 0 - darken: 0 - } - } - } - transitions: Transition { - to: "selected" - reversible: true - SequentialAnimation { - ScriptAction { script: image.manage() } - ParallelAnimation { - ParentAnimation {NumberAnimation { properties: "x,y" }} - PropertyAnimation { properties: "width, height, z, rotation, darken"; easing.type: Easing.InOutQuad } - } - } - } - } - } -} diff --git a/examples/quick/particles/itemparticle/itemparticle.qrc b/examples/quick/particles/itemparticle/itemparticle.qrc deleted file mode 100644 index d345d2a957..0000000000 --- a/examples/quick/particles/itemparticle/itemparticle.qrc +++ /dev/null @@ -1,8 +0,0 @@ -<RCC> - <qresource prefix="/qt/qml/itemparticle"> - <file>itemparticle.qml</file> - <file>delegates.qml</file> - <file>script.js</file> - <file>images/rocket.png</file> - </qresource> -</RCC> diff --git a/examples/quick/particles/itemparticle/main.cpp b/examples/quick/particles/itemparticle/main.cpp deleted file mode 100644 index 8baca3753c..0000000000 --- a/examples/quick/particles/itemparticle/main.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -#include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(itemparticle/itemparticle) diff --git a/examples/quick/particles/itemparticle/script.js b/examples/quick/particles/itemparticle/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/quick/particles/itemparticle/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/quick/particles/particles.pro b/examples/quick/particles/particles.pro index 7ef86618d5..62f7f35807 100644 --- a/examples/quick/particles/particles.pro +++ b/examples/quick/particles/particles.pro @@ -2,7 +2,6 @@ TEMPLATE = subdirs SUBDIRS += affectors \ emitters \ imageparticle \ - itemparticle \ system #Install shared images too diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index b20d92ddb4..7c07f69af9 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -23,7 +23,6 @@ SUBDIRS = quick-accessibility \ imageresponseprovider \ window \ particles \ - delegatechooser \ shapes \ itemvariablerefreshrate \ multieffect diff --git a/examples/quick/shared/CMakeLists.txt b/examples/quick/shared/CMakeLists.txt index 704d148025..b98b0b1ccd 100644 --- a/examples/quick/shared/CMakeLists.txt +++ b/examples/quick/shared/CMakeLists.txt @@ -21,7 +21,6 @@ qt_add_qml_module(${PROJECT_NAME}_shared QML_FILES "Button.qml" "CheckBox.qml" - "FlickrRssModel.qml" "Label.qml" "LauncherList.qml" "SimpleLauncherDelegate.qml" diff --git a/examples/quick/shared/FlickrRssModel.qml b/examples/quick/shared/FlickrRssModel.qml deleted file mode 100644 index e78d1ffa21..0000000000 --- a/examples/quick/shared/FlickrRssModel.qml +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick - -ListModel { - id: flickrImages - property string tags : "" - readonly property string queryUrl : "http://api.flickr.com/services/feeds/photos_public.gne?" - - function encodeParams(x) { - return encodeURIComponent(x.replace(" ",",")); - } - function fetchImages(format) { - var requestURL = queryUrl + (tags ? "tags="+encodeParams(tags)+"&" : "") + "format=" + format + "&nojsoncallback=1"; - var xhr = new XMLHttpRequest; - xhr.onreadystatechange = function() { - if (xhr.readyState === XMLHttpRequest.DONE) { - - if (xhr.status !== 200) { - console.log("Failed to get images from flickr. status code: " + xhr.status); - return; - } - - var jsonText = xhr.responseText; - var objArray = JSON.parse(jsonText.replace(/\'/g,"'")) - if (objArray.errors !== undefined) - console.log("Error fetching tweets: " + objArray.errors[0].message) - else { - for (var key in objArray.items) { - var rssItem = objArray.items[key]; - var jsonObject = "{ \"title\": \"" + rssItem.title +"\",\"media\": \"" + rssItem.media.m + "\", \"thumbnail\": \"" + rssItem.media.m.replace(/\_m\.jpg/,"_s.jpg") +"\"}" - flickrImages.append(JSON.parse(jsonObject)); - } - } - } - } - xhr.open("GET", requestURL, true); - xhr.send(); - } - Component.onCompleted: { - fetchImages("json"); - } -} - diff --git a/examples/quick/shared/qmldir b/examples/quick/shared/qmldir index 5ccdf60219..8a3d856a08 100644 --- a/examples/quick/shared/qmldir +++ b/examples/quick/shared/qmldir @@ -1,7 +1,6 @@ module shared Button 2.0 Button.qml CheckBox 2.1 CheckBox.qml -FlickrRssModel 2.0 FlickrRssModel.qml Label 2.0 Label.qml LauncherList 2.0 LauncherList.qml SimpleLauncherDelegate 2.0 SimpleLauncherDelegate.qml diff --git a/examples/quick/shared/shared.qrc b/examples/quick/shared/shared.qrc index 67f69c9c8d..054db1f352 100644 --- a/examples/quick/shared/shared.qrc +++ b/examples/quick/shared/shared.qrc @@ -2,7 +2,6 @@ <qresource prefix="/qt/qml/shared"> <file>Button.qml</file> <file>CheckBox.qml</file> - <file>FlickrRssModel.qml</file> <file>Images.qml</file> <file>Label.qml</file> <file>LauncherList.qml</file> diff --git a/examples/quick/views/CMakeLists.txt b/examples/quick/views/CMakeLists.txt index f48817a5af..29a5f438cd 100644 --- a/examples/quick/views/CMakeLists.txt +++ b/examples/quick/views/CMakeLists.txt @@ -37,7 +37,6 @@ qt_add_qml_module(viewsexample URI views QML_FILES "delegatemodel/dragselection.qml" - "delegatemodel/slideshow.qml" "gridview/gridview-example.qml" "listview/content/PetsModel.qml" "listview/content/PressAndHoldButton.qml" diff --git a/examples/quick/views/delegatemodel/delegatemodel.qmlproject b/examples/quick/views/delegatemodel/delegatemodel.qmlproject deleted file mode 100644 index e78ddcb187..0000000000 --- a/examples/quick/views/delegatemodel/delegatemodel.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.0 - -Project { - mainFile: "slideshow.qml" - importPaths: [ "../../" ] - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/views/delegatemodel/flipable.pro b/examples/quick/views/delegatemodel/flipable.pro deleted file mode 100644 index ba00bf792c..0000000000 --- a/examples/quick/views/delegatemodel/flipable.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp - -RESOURCES += flipable.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/flipable -INSTALLS += target diff --git a/examples/quick/views/delegatemodel/flipable.qrc b/examples/quick/views/delegatemodel/flipable.qrc deleted file mode 100644 index 7918ccf00e..0000000000 --- a/examples/quick/views/delegatemodel/flipable.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>flipable.qml</file> - <file>content/5_heart.png</file> - <file>content/9_club.png</file> - <file>content/back.png</file> - <file>content/Card.qml</file> - </qresource> -</RCC> diff --git a/examples/quick/views/delegatemodel/main.cpp b/examples/quick/views/delegatemodel/main.cpp deleted file mode 100644 index 8eb2fc72c3..0000000000 --- a/examples/quick/views/delegatemodel/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 "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(flipable) diff --git a/examples/quick/views/delegatemodel/slideshow.qml b/examples/quick/views/delegatemodel/slideshow.qml deleted file mode 100644 index 3e0c81f5d9..0000000000 --- a/examples/quick/views/delegatemodel/slideshow.qml +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQml.Models -import shared as Shared - -pragma ComponentBehavior: Bound - -Rectangle { - id: root - - property Item displayItem: null - - width: 300 - height: 400 - - color: "black" - - Shared.FlickrRssModel { - id: flickrModel - tags: "fjords,mountains" - } - DelegateModel { - id: visualModel - - model: flickrModel - delegate: Item { - id: delegateItem - - width: 76 - height: 76 - - required property string thumbnail - - Rectangle { - id: image - x: 0 - y: 0 - width: 76 - height: 76 - border.width: 1 - border.color: "white" - color: "black" - - Image { - anchors.fill: parent - anchors.leftMargin: 1 - anchors.topMargin: 1 - - source: delegateItem.thumbnail - fillMode: Image.PreserveAspectFit - } - - MouseArea { - id: clickArea - anchors.fill: parent - - onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null - } - - states: [ - State { - when: root.displayItem === delegateItem - name: "inDisplay"; - ParentChange { - target: image - parent: imageContainer - x: 75 - y: 75 - width: 150 - height: 150 - } - PropertyChanges { - image.z: 2 - delegateItem.DelegateModel.inItems: false - } - }, - State { - when: root.displayItem !== delegateItem - name: "inList"; - ParentChange { - target: image - parent: delegateItem - x: 2 - y: 2 - width: 75 - height: 75 - } - PropertyChanges { - image.z: 1 - delegateItem.DelegateModel.inItems: true - } - } - ] - - transitions: [ - Transition { - from: "inList" - SequentialAnimation { - PropertyAction { - target: delegateItem - property: "DelegateModel.inPersistedItems" - value: true - } - ParentAnimation { - target: image; - via: root - NumberAnimation { - target: image - properties: "x,y,width,height" - duration: 1000 - } - } - } - }, Transition { - from: "inDisplay" - SequentialAnimation { - ParentAnimation { - target: image - NumberAnimation { - target: image - properties: "x,y,width,height" - duration: 1000 - } - } - PropertyAction { - target: delegateItem - property: "DelegateModel.inPersistedItems" - value: false - } - } - } - ] - } - } - } - - - PathView { - id: imagePath - - anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } - model: visualModel - - pathItemCount: 7 - path: Path { - startX: -50; startY: 0 - PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } - PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } - } - } - - Item { - id: imageContainer - anchors { fill: parent; bottomMargin: 100 } - } -} diff --git a/examples/quick/views/views.qml b/examples/quick/views/views.qml index 1c47df4fcb..fb1e62b7e5 100644 --- a/examples/quick/views/views.qml +++ b/examples/quick/views/views.qml @@ -21,7 +21,6 @@ Item { addExample("PathView", "A simple PathView", Qt.resolvedUrl("pathview/pathview-example.qml")) addExample("ObjectModel", "Using a ObjectModel", Qt.resolvedUrl("objectmodel/objectmodel.qml")) addExample("Display Margins", "A ListView with display margins", Qt.resolvedUrl("listview/displaymargin.qml")) - addExample("DelegateModel", "A PathView using DelegateModel to instantiate delegates", Qt.resolvedUrl("delegatemodel/slideshow.qml")) addExample("Draggable Selections", "Enabling drag-and-drop on DelegateModel delegates", Qt.resolvedUrl("delegatemodel/dragselection.qml")) } } diff --git a/examples/quick/views/views.qrc b/examples/quick/views/views.qrc index 67e708ff93..9b16e81321 100644 --- a/examples/quick/views/views.qrc +++ b/examples/quick/views/views.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="/qt/qml/views"> + <file>gridview/gridview-example.qml</file> <file>gridview/pics/AddressBook_48.png</file> <file>gridview/pics/AudioPlayer_48.png</file> @@ -41,7 +42,6 @@ <file>pathview/pics/EMail_48.png</file> <file>pathview/pics/TodoList_48.png</file> <file>pathview/pics/VideoPlayer_48.png</file> - <file>delegatemodel/slideshow.qml</file> <file>delegatemodel/dragselection.qml</file> <file>objectmodel/objectmodel.qml</file> <file>views.qml</file> |