From d1d1137a2cf78cce5c4a4d2898e319775e4602b5 Mon Sep 17 00:00:00 2001 From: Oliver Eftevaag Date: Thu, 12 Aug 2021 17:07:36 +0200 Subject: Replace custom button component with QQC2 buttons Now that we've moved qtquickcontrols2 into the qtdeclarative submodule. We want our examples to simply use qqc2 controls, rather than custom made buttons and other controls. This example used a custom made button component, which this patch will replace with qqc2. It will also use qqc2 in other places where it makes sense, like replacing a TextEdit with a qqc2 TextArea, and Text components with qqc2 Labels. Task-number: QTBUG-95733 Change-Id: Ic733cd592cd10ef2cf45058aaf08a0f6b2f5bd2c Reviewed-by: Mitch Curtis (cherry picked from commit dad9a15c9c5734334e6e3768eab096968515e36f) Reviewed-by: Qt Cherry-pick Bot --- examples/qml/CMakeLists.txt | 1 + examples/qml/dynamicscene/CMakeLists.txt | 67 +++++++++++++++++ examples/qml/dynamicscene/content/Button.qml | 87 ---------------------- .../qml/dynamicscene/content/GenericSceneItem.qml | 4 +- examples/qml/dynamicscene/content/PaletteItem.qml | 4 +- .../qml/dynamicscene/content/PerspectiveItem.qml | 4 +- examples/qml/dynamicscene/content/Sun.qml | 4 +- examples/qml/dynamicscene/dynamicscene.qml | 17 +++-- examples/qml/dynamicscene/dynamicscene.qrc | 1 - 9 files changed, 85 insertions(+), 104 deletions(-) create mode 100644 examples/qml/dynamicscene/CMakeLists.txt delete mode 100644 examples/qml/dynamicscene/content/Button.qml (limited to 'examples') diff --git a/examples/qml/CMakeLists.txt b/examples/qml/CMakeLists.txt index 61e550762d..9f32c37621 100644 --- a/examples/qml/CMakeLists.txt +++ b/examples/qml/CMakeLists.txt @@ -1,5 +1,6 @@ # Generated from qml.pro. +add_subdirectory(dynamicscene) add_subdirectory(referenceexamples) add_subdirectory(tutorials) qt_internal_add_example(shell) diff --git a/examples/qml/dynamicscene/CMakeLists.txt b/examples/qml/dynamicscene/CMakeLists.txt new file mode 100644 index 0000000000..9353c35427 --- /dev/null +++ b/examples/qml/dynamicscene/CMakeLists.txt @@ -0,0 +1,67 @@ +# Generated from dynamicscene.pro. + +cmake_minimum_required(VERSION 3.14) +project(dynamicscene LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(NOT DEFINED INSTALL_EXAMPLESDIR) + set(INSTALL_EXAMPLESDIR "examples") +endif() + +set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/qml/dynamicscene") + +find_package(Qt6 COMPONENTS Core) +find_package(Qt6 COMPONENTS Gui) +find_package(Qt6 COMPONENTS Quick) +find_package(Qt6 COMPONENTS Qml) + +qt_add_executable(dynamicscene + main.cpp +) +set_target_properties(dynamicscene PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) +target_link_libraries(dynamicscene PUBLIC + Qt::Core + Qt::Gui + Qt::Qml + Qt::Quick +) + + +# Resources: +set(dynamicscene_resource_files + "content/GenericSceneItem.qml" + "content/PaletteItem.qml" + "content/PerspectiveItem.qml" + "content/Sun.qml" + "content/images/NOTE" + "content/images/face-smile.png" + "content/images/moon.png" + "content/images/rabbit_brown.png" + "content/images/rabbit_bw.png" + "content/images/star.png" + "content/images/sun.png" + "content/images/tree_s.png" + "content/itemCreation.js" + "dynamicscene.qml" +) + +qt6_add_resources(dynamicscene "dynamicscene" + PREFIX + "/" + FILES + ${dynamicscene_resource_files} +) + +install(TARGETS dynamicscene + RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" + LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" +) diff --git a/examples/qml/dynamicscene/content/Button.qml b/examples/qml/dynamicscene/content/Button.qml deleted file mode 100644 index d558ef7608..0000000000 --- a/examples/qml/dynamicscene/content/Button.qml +++ /dev/null @@ -1,87 +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 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - antialiasing: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? "#eeeeee" : "#888888" - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? "#888888" : "#333333" - } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - } -} diff --git a/examples/qml/dynamicscene/content/GenericSceneItem.qml b/examples/qml/dynamicscene/content/GenericSceneItem.qml index 3c83169c7a..bc09fd5817 100644 --- a/examples/qml/dynamicscene/content/GenericSceneItem.qml +++ b/examples/qml/dynamicscene/content/GenericSceneItem.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick Image { property bool created: false diff --git a/examples/qml/dynamicscene/content/PaletteItem.qml b/examples/qml/dynamicscene/content/PaletteItem.qml index ca734a5dba..d6df4be870 100644 --- a/examples/qml/dynamicscene/content/PaletteItem.qml +++ b/examples/qml/dynamicscene/content/PaletteItem.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick import "itemCreation.js" as Code Image { diff --git a/examples/qml/dynamicscene/content/PerspectiveItem.qml b/examples/qml/dynamicscene/content/PerspectiveItem.qml index a712358000..d02a188043 100644 --- a/examples/qml/dynamicscene/content/PerspectiveItem.qml +++ b/examples/qml/dynamicscene/content/PerspectiveItem.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick Image { id: rootItem diff --git a/examples/qml/dynamicscene/content/Sun.qml b/examples/qml/dynamicscene/content/Sun.qml index 0e70f3b5db..062a6065e0 100644 --- a/examples/qml/dynamicscene/content/Sun.qml +++ b/examples/qml/dynamicscene/content/Sun.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,7 +48,7 @@ ** ****************************************************************************/ -import QtQuick 2.0 +import QtQuick Image { id: sun diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml index d197b95235..43b4784b13 100644 --- a/examples/qml/dynamicscene/dynamicscene.qml +++ b/examples/qml/dynamicscene/dynamicscene.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,8 +48,9 @@ ** ****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 +import QtQuick +import QtQuick.Particles +import QtQuick.Controls import "content" Item { @@ -82,7 +83,7 @@ Item { dialogAnim.start(); } - Text { + Label { id: dialogText x: 3; y: 3 font.pixelSize: 14 @@ -156,7 +157,7 @@ Item { anchors.centerIn: parent spacing: 8 - Text { text: "Drag an item into the scene." } + Label { text: "Drag an item into the scene." } Rectangle { width: palette.width + 10; height: palette.height + 10 @@ -200,7 +201,7 @@ Item { } } - Text { text: "Active Suns: " + window.activeSuns } + Label { text: "Active Suns: " + window.activeSuns } } } @@ -226,7 +227,7 @@ Item { Row { height: createButton.height spacing: 8 - Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Label { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } Button { id: popupButton text: popupToolbox.poppedUp ? "Hide" : "Show" @@ -249,7 +250,7 @@ Item { Rectangle { width: 360; height: 240 - TextEdit { + TextArea { id: qmlText anchors.fill: parent; anchors.margins: 5 readOnly: false diff --git a/examples/qml/dynamicscene/dynamicscene.qrc b/examples/qml/dynamicscene/dynamicscene.qrc index ac9baa4941..ad14d313f4 100644 --- a/examples/qml/dynamicscene/dynamicscene.qrc +++ b/examples/qml/dynamicscene/dynamicscene.qrc @@ -9,7 +9,6 @@ content/images/star.png content/images/sun.png content/images/tree_s.png - content/Button.qml content/GenericSceneItem.qml content/itemCreation.js content/PaletteItem.qml -- cgit v1.2.3