From 4159792b8e646580cf45fe72902b356c23acd9e0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 31 Aug 2021 13:32:26 +0200 Subject: Fix dialcontrol example to use a QML module Also move the QML files out of the "content" subdirectory in order to avoid the directory import. Change-Id: I84a1f5ef1a45e5098ec3213c6fbce06346f3606a Reviewed-by: Oliver Eftevaag Reviewed-by: Andrei Golubev Reviewed-by: Shawn Rutledge (cherry picked from commit 2dfb912058ecb865f2ed5becad04756b51bfbc7b) Reviewed-by: Qt Cherry-pick Bot --- .../quick/customitems/dialcontrol/CMakeLists.txt | 39 ++++----- examples/quick/customitems/dialcontrol/Dial.qml | 96 +++++++++++++++++++++ .../quick/customitems/dialcontrol/QuitButton.qml | 61 +++++++++++++ .../quick/customitems/dialcontrol/background.png | Bin 0 -> 35876 bytes .../quick/customitems/dialcontrol/content/Dial.qml | 96 --------------------- .../customitems/dialcontrol/content/QuitButton.qml | 61 ------------- .../customitems/dialcontrol/content/background.png | Bin 35876 -> 0 bytes .../customitems/dialcontrol/content/needle.png | Bin 342 -> 0 bytes .../dialcontrol/content/needle_shadow.png | Bin 632 -> 0 bytes .../customitems/dialcontrol/content/overlay.png | Bin 3564 -> 0 bytes .../quick/customitems/dialcontrol/content/quit.png | Bin 583 -> 0 bytes .../quick/customitems/dialcontrol/dialcontrol.qml | 1 - .../quick/customitems/dialcontrol/dialcontrol.qrc | 16 ++-- examples/quick/customitems/dialcontrol/main.cpp | 2 +- examples/quick/customitems/dialcontrol/needle.png | Bin 0 -> 342 bytes .../customitems/dialcontrol/needle_shadow.png | Bin 0 -> 632 bytes examples/quick/customitems/dialcontrol/overlay.png | Bin 0 -> 3564 bytes examples/quick/customitems/dialcontrol/quit.png | Bin 0 -> 583 bytes 18 files changed, 183 insertions(+), 189 deletions(-) create mode 100644 examples/quick/customitems/dialcontrol/Dial.qml create mode 100644 examples/quick/customitems/dialcontrol/QuitButton.qml create mode 100644 examples/quick/customitems/dialcontrol/background.png delete mode 100644 examples/quick/customitems/dialcontrol/content/Dial.qml delete mode 100644 examples/quick/customitems/dialcontrol/content/QuitButton.qml delete mode 100644 examples/quick/customitems/dialcontrol/content/background.png delete mode 100644 examples/quick/customitems/dialcontrol/content/needle.png delete mode 100644 examples/quick/customitems/dialcontrol/content/needle_shadow.png delete mode 100644 examples/quick/customitems/dialcontrol/content/overlay.png delete mode 100644 examples/quick/customitems/dialcontrol/content/quit.png create mode 100644 examples/quick/customitems/dialcontrol/needle.png create mode 100644 examples/quick/customitems/dialcontrol/needle_shadow.png create mode 100644 examples/quick/customitems/dialcontrol/overlay.png create mode 100644 examples/quick/customitems/dialcontrol/quit.png (limited to 'examples') diff --git a/examples/quick/customitems/dialcontrol/CMakeLists.txt b/examples/quick/customitems/dialcontrol/CMakeLists.txt index 4c859f1082..dfc69c3c67 100644 --- a/examples/quick/customitems/dialcontrol/CMakeLists.txt +++ b/examples/quick/customitems/dialcontrol/CMakeLists.txt @@ -20,41 +20,36 @@ find_package(Qt6 COMPONENTS Gui) find_package(Qt6 COMPONENTS Quick) find_package(Qt6 COMPONENTS Qml) -qt_add_executable(dialcontrol +qt_add_executable(dialcontrolexample main.cpp ) -set_target_properties(dialcontrol PROPERTIES +set_target_properties(dialcontrolexample PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(dialcontrol PUBLIC +target_link_libraries(dialcontrolexample PUBLIC Qt::Core Qt::Gui Qt::Qml Qt::Quick ) - -# Resources: -set(dialcontrol_resource_files - "content/Dial.qml" - "content/QuitButton.qml" - "content/background.png" - "content/needle.png" - "content/needle_shadow.png" - "content/overlay.png" - "content/quit.png" - "dialcontrol.qml" -) - -qt6_add_resources(dialcontrol "dialcontrol" - PREFIX - "/" - FILES - ${dialcontrol_resource_files} +qt_add_qml_module(dialcontrolexample + URI dialcontrol + VERSION 1.0 + QML_FILES + "Dial.qml" + "QuitButton.qml" + "dialcontrol.qml" + RESOURCES + "background.png" + "needle.png" + "needle_shadow.png" + "overlay.png" + "quit.png" ) -install(TARGETS dialcontrol +install(TARGETS dialcontrolexample RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" diff --git a/examples/quick/customitems/dialcontrol/Dial.qml b/examples/quick/customitems/dialcontrol/Dial.qml new file mode 100644 index 0000000000..108b0e7410 --- /dev/null +++ b/examples/quick/customitems/dialcontrol/Dial.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 96 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 9; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 98; y: 33 + antialiasing: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 5; origin.y: 65 + //! [needle angle] + angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: .15 + } + } + //! [needle angle] + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/quick/customitems/dialcontrol/QuitButton.qml b/examples/quick/customitems/dialcontrol/QuitButton.qml new file mode 100644 index 0000000000..87dc159c5d --- /dev/null +++ b/examples/quick/customitems/dialcontrol/QuitButton.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/quick/customitems/dialcontrol/background.png b/examples/quick/customitems/dialcontrol/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/quick/customitems/dialcontrol/background.png differ diff --git a/examples/quick/customitems/dialcontrol/content/Dial.qml b/examples/quick/customitems/dialcontrol/content/Dial.qml deleted file mode 100644 index 108b0e7410..0000000000 --- a/examples/quick/customitems/dialcontrol/content/Dial.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 96 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 9; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 98; y: 33 - antialiasing: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 5; origin.y: 65 - //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - Behavior on angle { - SpringAnimation { - spring: 1.4 - damping: .15 - } - } - //! [needle angle] - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/quick/customitems/dialcontrol/content/QuitButton.qml b/examples/quick/customitems/dialcontrol/content/QuitButton.qml deleted file mode 100644 index 87dc159c5d..0000000000 --- a/examples/quick/customitems/dialcontrol/content/QuitButton.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/quick/customitems/dialcontrol/content/background.png b/examples/quick/customitems/dialcontrol/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/quick/customitems/dialcontrol/content/background.png and /dev/null differ diff --git a/examples/quick/customitems/dialcontrol/content/needle.png b/examples/quick/customitems/dialcontrol/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/quick/customitems/dialcontrol/content/needle.png and /dev/null differ diff --git a/examples/quick/customitems/dialcontrol/content/needle_shadow.png b/examples/quick/customitems/dialcontrol/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/quick/customitems/dialcontrol/content/needle_shadow.png and /dev/null differ diff --git a/examples/quick/customitems/dialcontrol/content/overlay.png b/examples/quick/customitems/dialcontrol/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/quick/customitems/dialcontrol/content/overlay.png and /dev/null differ diff --git a/examples/quick/customitems/dialcontrol/content/quit.png b/examples/quick/customitems/dialcontrol/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/quick/customitems/dialcontrol/content/quit.png and /dev/null differ diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qml b/examples/quick/customitems/dialcontrol/dialcontrol.qml index d0a623a72a..c6bff8f2c0 100644 --- a/examples/quick/customitems/dialcontrol/dialcontrol.qml +++ b/examples/quick/customitems/dialcontrol/dialcontrol.qml @@ -51,7 +51,6 @@ //! [imports] import QtQuick 2.2 import QtQuick.Window 2.1 -import "content" //! [imports] //! [0] diff --git a/examples/quick/customitems/dialcontrol/dialcontrol.qrc b/examples/quick/customitems/dialcontrol/dialcontrol.qrc index 6433d68bb8..9b9bd42f23 100644 --- a/examples/quick/customitems/dialcontrol/dialcontrol.qrc +++ b/examples/quick/customitems/dialcontrol/dialcontrol.qrc @@ -1,12 +1,12 @@ - + + Dial.qml + QuitButton.qml + background.png dialcontrol.qml - content/background.png - content/Dial.qml - content/needle_shadow.png - content/needle.png - content/overlay.png - content/quit.png - content/QuitButton.qml + needle.png + needle_shadow.png + overlay.png + quit.png diff --git a/examples/quick/customitems/dialcontrol/main.cpp b/examples/quick/customitems/dialcontrol/main.cpp index 6ebe203a70..3b925c3d8b 100644 --- a/examples/quick/customitems/dialcontrol/main.cpp +++ b/examples/quick/customitems/dialcontrol/main.cpp @@ -48,4 +48,4 @@ ** ****************************************************************************/ #include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(dialcontrol) +DECLARATIVE_EXAMPLE_MAIN(dialcontrol/dialcontrol) diff --git a/examples/quick/customitems/dialcontrol/needle.png b/examples/quick/customitems/dialcontrol/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/needle.png differ diff --git a/examples/quick/customitems/dialcontrol/needle_shadow.png b/examples/quick/customitems/dialcontrol/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/needle_shadow.png differ diff --git a/examples/quick/customitems/dialcontrol/overlay.png b/examples/quick/customitems/dialcontrol/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/quick/customitems/dialcontrol/overlay.png differ diff --git a/examples/quick/customitems/dialcontrol/quit.png b/examples/quick/customitems/dialcontrol/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/quick/customitems/dialcontrol/quit.png differ -- cgit v1.2.3