diff options
author | Lucie Gérard <[email protected]> | 2023-11-20 14:21:57 +0100 |
---|---|---|
committer | Shawn Rutledge <[email protected]> | 2023-11-28 17:57:05 -0700 |
commit | 8dc2e3daf08327c6f70ac7c1c5862f726cbf74e7 (patch) | |
tree | 510f75f3cb7b7ec021367c3f48bf9294fc204d65 /examples/quick/customitems | |
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 <[email protected]>
Diffstat (limited to 'examples/quick/customitems')
-rw-r--r-- | examples/quick/customitems/CMakeLists.txt | 1 | ||||
-rw-r--r-- | examples/quick/customitems/customitems.pro | 3 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/CMakeLists.txt | 47 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/images/cloud_1.png | bin | 49395 -> 0 bytes | |||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/images/cloud_2.png | bin | 32288 -> 0 bytes | |||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/images/moon.png | bin | 13263 -> 0 bytes | |||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/main.cpp | 15 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.cpp | 104 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.h | 62 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.pro | 17 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.qml | 95 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.qmlproject | 16 | ||||
-rw-r--r-- | examples/quick/customitems/maskedmousearea/maskedmousearea.qrc | 8 |
13 files changed, 1 insertions, 367 deletions
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> |