diff options
Diffstat (limited to 'examples/widgets/painting')
73 files changed, 848 insertions, 5890 deletions
diff --git a/examples/widgets/painting/.prev_CMakeLists.txt b/examples/widgets/painting/.prev_CMakeLists.txt deleted file mode 100644 index 2ef5da303a..0000000000 --- a/examples/widgets/painting/.prev_CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Generated from painting.pro. - -add_subdirectory(basicdrawing) -add_subdirectory(concentriccircles) -add_subdirectory(affine) -add_subdirectory(composition) -add_subdirectory(deform) -add_subdirectory(gradients) -add_subdirectory(pathstroke) -add_subdirectory(imagecomposition) -add_subdirectory(painterpaths) -add_subdirectory(transformations) -add_subdirectory(fontsampler) diff --git a/examples/widgets/painting/CMakeLists.txt b/examples/widgets/painting/CMakeLists.txt index 8a106982cf..8a0b625e4d 100644 --- a/examples/widgets/painting/CMakeLists.txt +++ b/examples/widgets/painting/CMakeLists.txt @@ -1,14 +1,12 @@ -# Generated from painting.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -add_subdirectory(shared) # special case -add_subdirectory(basicdrawing) -add_subdirectory(concentriccircles) -add_subdirectory(affine) -# add_subdirectory(composition) # special case FIXME: Seems buggy wrt. usesOpenGL function -add_subdirectory(deform) -add_subdirectory(gradients) -add_subdirectory(pathstroke) -add_subdirectory(imagecomposition) -add_subdirectory(painterpaths) -add_subdirectory(transformations) -add_subdirectory(fontsampler) +qt_internal_add_example(basicdrawing) +qt_internal_add_example(affine) +qt_internal_add_example(composition) +qt_internal_add_example(deform) +qt_internal_add_example(gradients) +qt_internal_add_example(pathstroke) +qt_internal_add_example(imagecomposition) +qt_internal_add_example(painterpaths) +qt_internal_add_example(transformations) diff --git a/examples/widgets/painting/affine/.prev_CMakeLists.txt b/examples/widgets/painting/affine/.prev_CMakeLists.txt deleted file mode 100644 index 948456d821..0000000000 --- a/examples/widgets/painting/affine/.prev_CMakeLists.txt +++ /dev/null @@ -1,215 +0,0 @@ -# Generated from affine.pro. - -cmake_minimum_required(VERSION 3.14) -project(affine LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/affine") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(affine - ../shared/arthurstyle.cpp ../shared/arthurstyle.h - ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - ../shared/hoverpoints.cpp ../shared/hoverpoints.h - main.cpp - xform.cpp xform.h -) -target_include_directories(affine PUBLIC - ../shared -) - -target_link_libraries(affine PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" -) -set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" -) - -qt6_add_resources(affine "shared" - PREFIX - "/res" - BASE - "../shared" - FILES - ${shared_resource_files} -) -set(affine_resource_files - "bg1.jpg" - "xform.cpp" - "xform.html" -) - -qt6_add_resources(affine "affine" - PREFIX - "/res/affine" - FILES - ${affine_resource_files} -) - -if(QT_FEATURE_opengl) - target_sources(affine PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(affine PUBLIC - Qt::OpenGL - ) -endif() - -install(TARGETS affine - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/affine/CMakeLists.txt b/examples/widgets/painting/affine/CMakeLists.txt index 56e862d20f..dd39086620 100644 --- a/examples/widgets/painting/affine/CMakeLists.txt +++ b/examples/widgets/painting/affine/CMakeLists.txt @@ -1,182 +1,74 @@ -# Generated from affine.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(affine LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/affine") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(affine - # special case: remove files from ../shared +qt_add_executable(affine main.cpp xform.cpp xform.h ) -target_include_directories(affine PUBLIC - ../shared -) -target_link_libraries(affine PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared # special case +set_target_properties(affine PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +if(NOT TARGET painting_shared::painting_shared) + include(../shared/use_lib.cmake) +endif() -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" +target_link_libraries(affine PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) + +# Resources: set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" + "../shared/images/button_normal_cap_left.png" + "../shared/images/button_normal_cap_right.png" + "../shared/images/button_normal_stretch.png" + "../shared/images/button_pressed_cap_left.png" + "../shared/images/button_pressed_cap_right.png" + "../shared/images/button_pressed_stretch.png" + "../shared/images/frame_bottom.png" + "../shared/images/frame_bottomleft.png" + "../shared/images/frame_bottomright.png" + "../shared/images/frame_left.png" + "../shared/images/frame_right.png" + "../shared/images/frame_top.png" + "../shared/images/frame_topleft.png" + "../shared/images/frame_topright.png" + "../shared/images/groupframe_bottom_left.png" + "../shared/images/groupframe_bottom_right.png" + "../shared/images/groupframe_bottom_stretch.png" + "../shared/images/groupframe_left_stretch.png" + "../shared/images/groupframe_right_stretch.png" + "../shared/images/groupframe_top_stretch.png" + "../shared/images/groupframe_topleft.png" + "../shared/images/groupframe_topright.png" + "../shared/images/line_dash_dot.png" + "../shared/images/line_dash_dot_dot.png" + "../shared/images/line_dashed.png" + "../shared/images/line_dotted.png" + "../shared/images/line_solid.png" + "../shared/images/radiobutton-on.png" + "../shared/images/radiobutton_off.png" + "../shared/images/radiobutton_on.png" + "../shared/images/slider_bar.png" + "../shared/images/slider_thumb_on.png" + "../shared/images/title_cap_left.png" + "../shared/images/title_cap_right.png" + "../shared/images/title_stretch.png" ) -qt6_add_resources(affine "shared" +qt_add_resources(affine "shared" PREFIX "/res" BASE @@ -184,31 +76,29 @@ qt6_add_resources(affine "shared" FILES ${shared_resource_files} ) + set(affine_resource_files "bg1.jpg" "xform.cpp" "xform.html" ) -qt6_add_resources(affine "affine" +qt_add_resources(affine "affine" PREFIX "/res/affine" FILES ${affine_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(affine PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(affine PUBLIC - Qt::OpenGL - ) -endif() - install(TARGETS affine - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET affine + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp index 641fc5c204..1f9c2399c9 100644 --- a/examples/widgets/painting/affine/main.cpp +++ b/examples/widgets/painting/affine/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "xform.h" @@ -54,10 +7,6 @@ int main(int argc, char **argv) { - Q_INIT_RESOURCE(affine); -#ifdef Q_OS_ANDROID - qputenv("QT_SCALE_FACTOR", "2"); -#endif QApplication app(argc, argv); XFormWidget xformWidget(nullptr); diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index d7ed2125d2..5754490eed 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "xform.h" #include "hoverpoints.h" @@ -58,27 +11,22 @@ const int alpha = 155; XFormView::XFormView(QWidget *parent) - : ArthurFrame(parent) + : ArthurFrame(parent), + m_pixmap(QPixmap(":res/affine/bg1.jpg")) { setAttribute(Qt::WA_MouseTracking); - m_type = VectorType; - m_rotation = 0.0; - m_scale = 1.0; - m_shear = 0.0; - - m_pixmap = QPixmap(":res/affine/bg1.jpg"); - pts = new HoverPoints(this, HoverPoints::CircleShape); - pts->setConnectionType(HoverPoints::LineConnection); - pts->setEditable(false); - pts->setPointSize(QSize(15, 15)); - pts->setShapeBrush(QBrush(QColor(151, 0, 0, alpha))); - pts->setShapePen(QPen(QColor(255, 100, 50, alpha))); - pts->setConnectionPen(QPen(QColor(151, 0, 0, 50))); - pts->setBoundingRect(QRectF(0, 0, 500, 500)); - ctrlPoints << QPointF(250, 250) << QPointF(350, 250); - pts->setPoints(ctrlPoints); - connect(pts, &HoverPoints::pointsChanged, - this,&XFormView::updateCtrlPoints); + + m_hoverPoints = new HoverPoints(this, HoverPoints::CircleShape); + m_hoverPoints->setConnectionType(HoverPoints::LineConnection); + m_hoverPoints->setEditable(false); + m_hoverPoints->setPointSize(QSize(15, 15)); + m_hoverPoints->setShapeBrush(QBrush(QColor(151, 0, 0, alpha))); + m_hoverPoints->setShapePen(QPen(QColor(255, 100, 50, alpha))); + m_hoverPoints->setConnectionPen(QPen(QColor(151, 0, 0, 50))); + m_hoverPoints->setBoundingRect(QRectF(0, 0, 500, 500)); + m_hoverPoints->setPoints(m_controlPoints); + connect(m_hoverPoints, &HoverPoints::pointsChanged, + this, &XFormView::updateControlPoints); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } @@ -122,7 +70,7 @@ void XFormView::mousePressEvent(QMouseEvent *) void XFormView::resizeEvent(QResizeEvent *e) { - pts->setBoundingRect(rect()); + m_hoverPoints->setBoundingRect(rect()); ArthurFrame::resizeEvent(e); } @@ -145,24 +93,24 @@ void XFormView::paint(QPainter *p) p->restore(); } -void XFormView::updateCtrlPoints(const QPolygonF &points) +void XFormView::updateControlPoints(const QPolygonF &points) { - QPointF trans = points.at(0) - ctrlPoints.at(0); + QPointF trans = points.at(0) - m_controlPoints.at(0); if (qAbs(points.at(0).x() - points.at(1).x()) < 10 && qAbs(points.at(0).y() - points.at(1).y()) < 10) - pts->setPoints(ctrlPoints); + m_hoverPoints->setPoints(m_controlPoints); if (!trans.isNull()) { - ctrlPoints[0] = points.at(0); - ctrlPoints[1] += trans; - pts->setPoints(ctrlPoints); + m_controlPoints[0] = points.at(0); + m_controlPoints[1] += trans; + m_hoverPoints->setPoints(m_controlPoints); } - ctrlPoints = points; + m_controlPoints = points; - QLineF line(ctrlPoints.at(0), ctrlPoints.at(1)); + QLineF line(m_controlPoints.at(0), m_controlPoints.at(1)); m_rotation = 360 - QLineF(0, 0, 1, 0).angleTo(line); if (trans.isNull()) - emit rotationChanged(int(m_rotation*10)); + emit rotationChanged(int(m_rotation * 10)); } void XFormView::setVectorType() @@ -222,12 +170,12 @@ void XFormView::setRotation(qreal r) qreal old_rot = m_rotation; m_rotation = r; - QPointF center(pts->points().at(0)); + QPointF center(m_hoverPoints->points().at(0)); QTransform m; m.translate(center.x(), center.y()); m.rotate(m_rotation - old_rot); m.translate(-center.x(), -center.y()); - pts->setPoints(pts->points() * m); + m_hoverPoints->setPoints(m_hoverPoints->points() * m); update(); } @@ -235,12 +183,12 @@ void XFormView::setRotation(qreal r) void XFormView::timerEvent(QTimerEvent *e) { if (e->timerId() == timer.timerId()) { - QPointF center(pts->points().at(0)); + QPointF center(m_hoverPoints->points().at(0)); QTransform m; m.translate(center.x(), center.y()); m.rotate(0.2); m.translate(-center.x(), -center.y()); - pts->setPoints(pts->points() * m); + m_hoverPoints->setPoints(m_hoverPoints->points() * m); setUpdatesEnabled(false); static qreal scale_inc = 0.003; @@ -253,7 +201,7 @@ void XFormView::timerEvent(QTimerEvent *e) shear_inc = -shear_inc; setUpdatesEnabled(true); - pts->firePointChange(); + m_hoverPoints->firePointChange(); } } @@ -271,16 +219,15 @@ void XFormView::reset() emit rotationChanged(0); emit scaleChanged(1000); emit shearChanged(0); - ctrlPoints = QPolygonF(); - ctrlPoints << QPointF(250, 250) << QPointF(350, 250); - pts->setPoints(ctrlPoints); - pts->firePointChange(); + m_controlPoints = {{250, 250}, {350, 250}}; + m_hoverPoints->setPoints(m_controlPoints); + m_hoverPoints->firePointChange(); } void XFormView::drawPixmapType(QPainter *painter) { QPointF center(m_pixmap.width() / qreal(2), m_pixmap.height() / qreal(2)); - painter->translate(ctrlPoints.at(0) - center); + painter->translate(m_controlPoints.at(0) - center); painter->translate(center); painter->rotate(m_rotation); @@ -289,9 +236,11 @@ void XFormView::drawPixmapType(QPainter *painter) painter->translate(-center); painter->drawPixmap(QPointF(0, 0), m_pixmap); - painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); + painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, + Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); painter->setBrush(Qt::NoBrush); - painter->drawRect(QRectF(0, 0, m_pixmap.width(), m_pixmap.height()).adjusted(-2, -2, 2, 2)); + painter->drawRect(QRectF(0, 0, m_pixmap.width(), + m_pixmap.height()).adjusted(-2, -2, 2, 2)); } void XFormView::drawTextType(QPainter *painter) @@ -306,7 +255,7 @@ void XFormView::drawTextType(QPainter *painter) QFontMetrics fm(f); QRectF br(fm.boundingRect(m_text)); QPointF center(br.center()); - painter->translate(ctrlPoints.at(0) - center); + painter->translate(m_controlPoints.at(0) - center); painter->translate(center); painter->rotate(m_rotation); @@ -316,7 +265,8 @@ void XFormView::drawTextType(QPainter *painter) painter->fillPath(path, Qt::black); - painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); + painter->setPen(QPen(QColor(255, 0, 0, alpha), 0.25, + Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin)); painter->setBrush(Qt::NoBrush); painter->drawRect(br.adjusted(-1, -1, 1, 1)); } @@ -324,7 +274,7 @@ void XFormView::drawTextType(QPainter *painter) void XFormView::drawVectorType(QPainter *painter) { QPainterPath path; - painter->translate(ctrlPoints.at(0) - QPointF(250,250)); + painter->translate(m_controlPoints.at(0) - QPointF(250,250)); painter->scale(0.77, 0.77); painter->translate(98.9154 + 30 , -217.691 - 20); @@ -339,10 +289,10 @@ void XFormView::drawVectorType(QPainter *painter) painter->setPen(Qt::NoPen); path.moveTo(120, 470); - path.lineTo(60+245, 470); - path.lineTo(60+245, 470+350); - path.lineTo(60, 470+350); - path.lineTo(60, 470+80); + path.lineTo(60 + 245, 470); + path.lineTo(60 + 245, 470 + 350); + path.lineTo(60, 470 + 350); + path.lineTo(60, 470 + 80); painter->setBrush(Qt::white); painter->drawPath(path); @@ -827,12 +777,6 @@ XFormWidget::XFormWidget(QWidget *parent) QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(view->usesOpenGL()); -#endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); @@ -862,9 +806,6 @@ XFormWidget::XFormWidget(QWidget *parent) mainGroupLayout->addWidget(resetButton); mainGroupLayout->addWidget(animateButton); mainGroupLayout->addWidget(showSourceButton); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif mainGroupLayout->addWidget(whatsThisButton); mainGroup->setLayout(mainGroupLayout); @@ -902,9 +843,6 @@ XFormWidget::XFormWidget(QWidget *parent) connect(view, &XFormView::descriptionEnabledChanged, view->hoverPoints(), &HoverPoints::setDisabled); connect(view, &XFormView::descriptionEnabledChanged, whatsThisButton, &QPushButton::setChecked); connect(showSourceButton, &QPushButton::clicked, view, &XFormView::showSource); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QPushButton::clicked, view, &XFormView::enableOpenGL); -#endif view->loadSourceFile(":res/affine/xform.cpp"); view->loadDescription(":res/affine/xform.html"); diff --git a/examples/widgets/painting/affine/xform.h b/examples/widgets/painting/affine/xform.h index 1dce3b26da..20bf8102ce 100644 --- a/examples/widgets/painting/affine/xform.h +++ b/examples/widgets/painting/affine/xform.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef XFORM_H #define XFORM_H @@ -88,7 +41,7 @@ public: void mousePressEvent(QMouseEvent *e) override; void resizeEvent(QResizeEvent *e) override; - HoverPoints *hoverPoints() { return pts; } + HoverPoints *hoverPoints() { return m_hoverPoints; } bool animation() const { return timer.isActive(); } qreal shear() const { return m_shear; } @@ -104,7 +57,7 @@ public: public slots: void setAnimation(bool animate); - void updateCtrlPoints(const QPolygonF &); + void updateControlPoints(const QPolygonF &); void changeRotation(int rotation); void changeScale(int scale); void changeShear(int shear); @@ -130,12 +83,12 @@ protected: #endif private: - QPolygonF ctrlPoints; - HoverPoints *pts; - qreal m_rotation; - qreal m_scale; - qreal m_shear; - XFormType m_type; + QPolygonF m_controlPoints{{250, 250}, {350, 250}}; + HoverPoints *m_hoverPoints; + qreal m_rotation = 0; + qreal m_scale = 1; + qreal m_shear = 0; + XFormType m_type = VectorType; QPixmap m_pixmap; QString m_text; QBasicTimer timer; diff --git a/examples/widgets/painting/basicdrawing/CMakeLists.txt b/examples/widgets/painting/basicdrawing/CMakeLists.txt index b7d4f0a24a..c3fb855709 100644 --- a/examples/widgets/painting/basicdrawing/CMakeLists.txt +++ b/examples/widgets/painting/basicdrawing/CMakeLists.txt @@ -1,31 +1,29 @@ -# Generated from basicdrawing.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(basicdrawing LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/basicdrawing") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(basicdrawing +qt_add_executable(basicdrawing main.cpp renderarea.cpp renderarea.h window.cpp window.h ) -target_link_libraries(basicdrawing PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +set_target_properties(basicdrawing PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +target_link_libraries(basicdrawing PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) # Resources: set(basicdrawing_resource_files @@ -33,7 +31,7 @@ set(basicdrawing_resource_files "images/qt-logo.png" ) -qt6_add_resources(basicdrawing "basicdrawing" +qt_add_resources(basicdrawing "basicdrawing" PREFIX "/" FILES @@ -41,7 +39,14 @@ qt6_add_resources(basicdrawing "basicdrawing" ) install(TARGETS basicdrawing - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET basicdrawing + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/basicdrawing/main.cpp b/examples/widgets/painting/basicdrawing/main.cpp index 7b927f35c9..1d8fd919b2 100644 --- a/examples/widgets/painting/basicdrawing/main.cpp +++ b/examples/widgets/painting/basicdrawing/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" @@ -54,8 +7,6 @@ int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(basicdrawing); - QApplication app(argc, argv); Window window; window.show(); diff --git a/examples/widgets/painting/basicdrawing/renderarea.cpp b/examples/widgets/painting/basicdrawing/renderarea.cpp index 09d610ee95..d32abb5206 100644 --- a/examples/widgets/painting/basicdrawing/renderarea.cpp +++ b/examples/widgets/painting/basicdrawing/renderarea.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "renderarea.h" diff --git a/examples/widgets/painting/basicdrawing/renderarea.h b/examples/widgets/painting/basicdrawing/renderarea.h index 5f85aa7f96..dfc7d0752b 100644 --- a/examples/widgets/painting/basicdrawing/renderarea.h +++ b/examples/widgets/painting/basicdrawing/renderarea.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef RENDERAREA_H #define RENDERAREA_H diff --git a/examples/widgets/painting/basicdrawing/window.cpp b/examples/widgets/painting/basicdrawing/window.cpp index 0a035cc299..9699e71605 100644 --- a/examples/widgets/painting/basicdrawing/window.cpp +++ b/examples/widgets/painting/basicdrawing/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "renderarea.h" #include "window.h" diff --git a/examples/widgets/painting/basicdrawing/window.h b/examples/widgets/painting/basicdrawing/window.h index 7551783a8b..d2035c5b0b 100644 --- a/examples/widgets/painting/basicdrawing/window.h +++ b/examples/widgets/painting/basicdrawing/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/painting/composition/.prev_CMakeLists.txt b/examples/widgets/painting/composition/.prev_CMakeLists.txt deleted file mode 100644 index c5b1d12e4a..0000000000 --- a/examples/widgets/painting/composition/.prev_CMakeLists.txt +++ /dev/null @@ -1,216 +0,0 @@ -# Generated from composition.pro. - -cmake_minimum_required(VERSION 3.14) -project(composition LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/composition") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(composition - ../shared/arthurstyle.cpp ../shared/arthurstyle.h - ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - ../shared/hoverpoints.cpp ../shared/hoverpoints.h - composition.cpp composition.h - main.cpp -) -target_include_directories(composition PUBLIC - ../shared -) - -target_link_libraries(composition PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" -) -set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" -) - -qt6_add_resources(composition "shared" - PREFIX - "/res" - BASE - "../shared" - FILES - ${shared_resource_files} -) -set(composition_resource_files - "composition.cpp" - "composition.html" - "flower.jpg" - "flower_alpha.jpg" -) - -qt6_add_resources(composition "composition" - PREFIX - "/res/composition" - FILES - ${composition_resource_files} -) - -if(QT_FEATURE_opengl) - target_sources(composition PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(composition PUBLIC - Qt::OpenGL - ) -endif() - -install(TARGETS composition - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/composition/CMakeLists.txt b/examples/widgets/painting/composition/CMakeLists.txt index 89e356b7ae..b88ee42e41 100644 --- a/examples/widgets/painting/composition/CMakeLists.txt +++ b/examples/widgets/painting/composition/CMakeLists.txt @@ -1,182 +1,74 @@ -# Generated from composition.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(composition LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/composition") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(composition - # special case: remove files from ../shared +qt_add_executable(composition composition.cpp composition.h main.cpp ) -target_include_directories(composition PUBLIC - ../shared -) -target_link_libraries(composition PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared # special case +set_target_properties(composition PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +if(NOT TARGET painting_shared::painting_shared) + include(../shared/use_lib.cmake) +endif() -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" +target_link_libraries(composition PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) + +# Resources: set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" + "../shared/images/button_normal_cap_left.png" + "../shared/images/button_normal_cap_right.png" + "../shared/images/button_normal_stretch.png" + "../shared/images/button_pressed_cap_left.png" + "../shared/images/button_pressed_cap_right.png" + "../shared/images/button_pressed_stretch.png" + "../shared/images/frame_bottom.png" + "../shared/images/frame_bottomleft.png" + "../shared/images/frame_bottomright.png" + "../shared/images/frame_left.png" + "../shared/images/frame_right.png" + "../shared/images/frame_top.png" + "../shared/images/frame_topleft.png" + "../shared/images/frame_topright.png" + "../shared/images/groupframe_bottom_left.png" + "../shared/images/groupframe_bottom_right.png" + "../shared/images/groupframe_bottom_stretch.png" + "../shared/images/groupframe_left_stretch.png" + "../shared/images/groupframe_right_stretch.png" + "../shared/images/groupframe_top_stretch.png" + "../shared/images/groupframe_topleft.png" + "../shared/images/groupframe_topright.png" + "../shared/images/line_dash_dot.png" + "../shared/images/line_dash_dot_dot.png" + "../shared/images/line_dashed.png" + "../shared/images/line_dotted.png" + "../shared/images/line_solid.png" + "../shared/images/radiobutton-on.png" + "../shared/images/radiobutton_off.png" + "../shared/images/radiobutton_on.png" + "../shared/images/slider_bar.png" + "../shared/images/slider_thumb_on.png" + "../shared/images/title_cap_left.png" + "../shared/images/title_cap_right.png" + "../shared/images/title_stretch.png" ) -qt6_add_resources(composition "shared" +qt_add_resources(composition "shared" PREFIX "/res" BASE @@ -184,6 +76,7 @@ qt6_add_resources(composition "shared" FILES ${shared_resource_files} ) + set(composition_resource_files "composition.cpp" "composition.html" @@ -191,25 +84,22 @@ set(composition_resource_files "flower_alpha.jpg" ) -qt6_add_resources(composition "composition" +qt_add_resources(composition "composition" PREFIX "/res/composition" FILES ${composition_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(composition PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(composition PUBLIC - Qt::OpenGL - ) -endif() - install(TARGETS composition - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET composition + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/composition/composition.cpp b/examples/widgets/painting/composition/composition.cpp index a220fb42fa..b4fb4fa3f7 100644 --- a/examples/widgets/painting/composition/composition.cpp +++ b/examples/widgets/painting/composition/composition.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "composition.h" #include <QBoxLayout> @@ -57,11 +10,6 @@ #include <QMouseEvent> #include <qmath.h> -#if QT_CONFIG(opengl) -#include <QOpenGLFunctions> -#include <QOpenGLWindow> -#endif - const int animationInterval = 15; // update every 16 ms = ~60FPS CompositionWidget::CompositionWidget(QWidget *parent) @@ -141,12 +89,6 @@ CompositionWidget::CompositionWidget(QWidget *parent) QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(view->usesOpenGL()); -#endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); @@ -168,9 +110,6 @@ CompositionWidget::CompositionWidget(QWidget *parent) mainGroupLayout->addWidget(animateButton); mainGroupLayout->addWidget(whatsThisButton); mainGroupLayout->addWidget(showSourceButton); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif QGridLayout *modesLayout = new QGridLayout(modesGroup); modesLayout->addWidget(rbClear, 0, 0); @@ -212,9 +151,6 @@ CompositionWidget::CompositionWidget(QWidget *parent) connect(whatsThisButton, &QAbstractButton::clicked, view, &ArthurFrame::setDescriptionEnabled); connect(view, &ArthurFrame::descriptionEnabledChanged, whatsThisButton, &QAbstractButton::setChecked); connect(showSourceButton, &QAbstractButton::clicked, view, &ArthurFrame::showSource); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QAbstractButton::clicked, view, &ArthurFrame::enableOpenGL); -#endif connect(animateButton, &QAbstractButton::toggled, view, &CompositionRenderer::setAnimationEnabled); circleColorSlider->setValue(270); @@ -264,9 +200,6 @@ CompositionRenderer::CompositionRenderer(QWidget *parent) m_circle_pos = QPoint(200, 100); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -#if QT_CONFIG(opengl) - m_pbuffer_size = 1024; -#endif } CompositionRenderer::~CompositionRenderer() @@ -359,86 +292,25 @@ void CompositionRenderer::drawSource(QPainter &p) void CompositionRenderer::paint(QPainter *painter) { -#if QT_CONFIG(opengl) - if (usesOpenGL() && glWindow()->isValid()) { - - if (!m_blitter.isCreated()) - m_blitter.create(); - - int new_pbuf_size = m_pbuffer_size; - while (size().width() > new_pbuf_size || size().height() > new_pbuf_size) - new_pbuf_size *= 2; - - while (size().width() < new_pbuf_size/2 && size().height() < new_pbuf_size/2) - new_pbuf_size /= 2; - - if (!m_fbo || new_pbuf_size != m_pbuffer_size) { - m_fbo.reset(new QFboPaintDevice(QSize(new_pbuf_size, new_pbuf_size), false, false)); - m_pbuffer_size = new_pbuf_size; - } - - if (size() != m_previous_size) { - m_previous_size = size(); - QPainter p(m_fbo.get()); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(QRect(QPoint(0, 0), size()), Qt::transparent); - p.setCompositionMode(QPainter::CompositionMode_SourceOver); - drawBase(p); - p.end(); - m_base_tex = m_fbo->takeTexture(); - } - - painter->beginNativePainting(); - { - QPainter p(m_fbo.get()); - p.beginNativePainting(); - m_blitter.bind(); - const QRect targetRect(QPoint(0, 0), m_fbo->size()); - const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), m_fbo->size())); - m_blitter.blit(m_base_tex, target, QOpenGLTextureBlitter::OriginBottomLeft); - m_blitter.release(); - p.endNativePainting(); - drawSource(p); - p.end(); - m_compositing_tex = m_fbo->takeTexture(); - } - painter->endNativePainting(); - - painter->beginNativePainting(); - auto *funcs = QOpenGLContext::currentContext()->functions(); - funcs->glEnable(GL_BLEND); - funcs->glBlendEquation(GL_FUNC_ADD); - funcs->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - m_blitter.bind(); - const QRect targetRect(QPoint(0, 0), m_fbo->size()); - const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), size())); - m_blitter.blit(m_compositing_tex, target, QOpenGLTextureBlitter::OriginBottomLeft); - m_blitter.release(); - painter->endNativePainting(); - } else -#endif - { - // using a QImage - if (m_buffer.size() != size()) { - m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); - m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); + if (m_buffer.size() != size()) { + m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); + m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied); - m_base_buffer.fill(0); + m_base_buffer.fill(0); - QPainter p(&m_base_buffer); + QPainter p(&m_base_buffer); - drawBase(p); - } - - memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.sizeInBytes()); + drawBase(p); + } - { - QPainter p(&m_buffer); - drawSource(p); - } + memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.sizeInBytes()); - painter->drawImage(0, 0, m_buffer); + { + QPainter p(&m_buffer); + drawSource(p); } + + painter->drawImage(0, 0, m_buffer); } void CompositionRenderer::mousePressEvent(QMouseEvent *e) @@ -486,12 +358,6 @@ void CompositionRenderer::setCirclePos(const QPointF &pos) const QRect oldRect = rectangle_around(m_circle_pos).toAlignedRect(); m_circle_pos = pos; const QRect newRect = rectangle_around(m_circle_pos).toAlignedRect(); -#if QT_CONFIG(opengl) - if (usesOpenGL()) { - update(); - return; - } -#endif update(oldRect | newRect); } diff --git a/examples/widgets/painting/composition/composition.h b/examples/widgets/painting/composition/composition.h index 52ca7919b0..6a5206da08 100644 --- a/examples/widgets/painting/composition/composition.h +++ b/examples/widgets/painting/composition/composition.h @@ -1,63 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef COMPOSITION_H #define COMPOSITION_H #include "arthurwidgets.h" -#if QT_CONFIG(opengl) -#include "fbopaintdevice.h" -#include <QOpenGLTextureBlitter> -#endif - #include <QPainter> #include <QEvent> @@ -190,15 +138,6 @@ private: ObjectType m_current_object; bool m_animation_enabled; int m_animationTimer; - -#if QT_CONFIG(opengl) - std::unique_ptr<QFboPaintDevice> m_fbo; - int m_pbuffer_size; // width==height==size of pbuffer - uint m_base_tex; - uint m_compositing_tex; - QSize m_previous_size; - QOpenGLTextureBlitter m_blitter; -#endif }; #endif // COMPOSITION_H diff --git a/examples/widgets/painting/composition/main.cpp b/examples/widgets/painting/composition/main.cpp index 1ffa29dddc..bc468d0424 100644 --- a/examples/widgets/painting/composition/main.cpp +++ b/examples/widgets/painting/composition/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "composition.h" diff --git a/examples/widgets/painting/concentriccircles/CMakeLists.txt b/examples/widgets/painting/concentriccircles/CMakeLists.txt deleted file mode 100644 index 44d907f12f..0000000000 --- a/examples/widgets/painting/concentriccircles/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Generated from concentriccircles.pro. - -cmake_minimum_required(VERSION 3.14) -project(concentriccircles LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/concentriccircles") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(concentriccircles - circlewidget.cpp circlewidget.h - main.cpp - window.cpp window.h -) -target_link_libraries(concentriccircles PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS concentriccircles - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/concentriccircles/circlewidget.cpp b/examples/widgets/painting/concentriccircles/circlewidget.cpp deleted file mode 100644 index 639f9e5e4e..0000000000 --- a/examples/widgets/painting/concentriccircles/circlewidget.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include "circlewidget.h" - -#include <QPainter> - -#include <stdlib.h> - -//! [0] -CircleWidget::CircleWidget(QWidget *parent) - : QWidget(parent) -{ - floatBased = false; - antialiased = false; - frameNo = 0; - - setBackgroundRole(QPalette::Base); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -} -//! [0] - -//! [1] -void CircleWidget::setFloatBased(bool floatBased) -{ - this->floatBased = floatBased; - update(); -} -//! [1] - -//! [2] -void CircleWidget::setAntialiased(bool antialiased) -{ - this->antialiased = antialiased; - update(); -} -//! [2] - -//! [3] -QSize CircleWidget::minimumSizeHint() const -{ - return QSize(50, 50); -} -//! [3] - -//! [4] -QSize CircleWidget::sizeHint() const -{ - return QSize(180, 180); -} -//! [4] - -//! [5] -void CircleWidget::nextAnimationFrame() -{ - ++frameNo; - update(); -} -//! [5] - -//! [6] -void CircleWidget::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, antialiased); - painter.translate(width() / 2, height() / 2); -//! [6] - -//! [7] - for (int diameter = 0; diameter < 256; diameter += 9) { - int delta = abs((frameNo % 128) - diameter / 2); - int alpha = 255 - (delta * delta) / 4 - diameter; -//! [7] //! [8] - if (alpha > 0) { - painter.setPen(QPen(QColor(0, diameter / 2, 127, alpha), 3)); - - if (floatBased) - painter.drawEllipse(QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter)); - else - painter.drawEllipse(QRect(-diameter / 2, -diameter / 2, diameter, diameter)); - } - } -} -//! [8] diff --git a/examples/widgets/painting/concentriccircles/circlewidget.h b/examples/widgets/painting/concentriccircles/circlewidget.h deleted file mode 100644 index 79fd5c71da..0000000000 --- a/examples/widgets/painting/concentriccircles/circlewidget.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#ifndef CIRCLEWIDGET_H -#define CIRCLEWIDGET_H - -#include <QWidget> - -//! [0] -class CircleWidget : public QWidget -{ - Q_OBJECT - -public: - CircleWidget(QWidget *parent = 0); - - void setFloatBased(bool floatBased); - void setAntialiased(bool antialiased); - - QSize minimumSizeHint() const override; - QSize sizeHint() const override; - -public slots: - void nextAnimationFrame(); - -protected: - void paintEvent(QPaintEvent *event) override; - -private: - bool floatBased; - bool antialiased; - int frameNo; -}; -//! [0] - -#endif // CIRCLEWIDGET_H diff --git a/examples/widgets/painting/concentriccircles/concentriccircles.pro b/examples/widgets/painting/concentriccircles/concentriccircles.pro deleted file mode 100644 index 844c01a9c2..0000000000 --- a/examples/widgets/painting/concentriccircles/concentriccircles.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += widgets - -HEADERS = circlewidget.h \ - window.h -SOURCES = circlewidget.cpp \ - main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/painting/concentriccircles -INSTALLS += target diff --git a/examples/widgets/painting/concentriccircles/main.cpp b/examples/widgets/painting/concentriccircles/main.cpp deleted file mode 100644 index 00456195d9..0000000000 --- a/examples/widgets/painting/concentriccircles/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include "window.h" - -#include <QApplication> - -int main(int argc, char *argv[]) -{ -#ifdef Q_OS_ANDROID - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/painting/concentriccircles/window.cpp b/examples/widgets/painting/concentriccircles/window.cpp deleted file mode 100644 index 45258e0bc4..0000000000 --- a/examples/widgets/painting/concentriccircles/window.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include "circlewidget.h" -#include "window.h" - -#include <QtWidgets> - -//! [0] -Window::Window() -{ - aliasedLabel = createLabel(tr("Aliased")); - antialiasedLabel = createLabel(tr("Antialiased")); - intLabel = createLabel(tr("Int")); - floatLabel = createLabel(tr("Float")); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(aliasedLabel, 0, 1); - layout->addWidget(antialiasedLabel, 0, 2); - layout->addWidget(intLabel, 1, 0); - layout->addWidget(floatLabel, 2, 0); -//! [0] - -//! [1] - QTimer *timer = new QTimer(this); - - for (int i = 0; i < 2; ++i) { - for (int j = 0; j < 2; ++j) { - circleWidgets[i][j] = new CircleWidget; - circleWidgets[i][j]->setAntialiased(j != 0); - circleWidgets[i][j]->setFloatBased(i != 0); - - connect(timer, &QTimer::timeout, - circleWidgets[i][j], &CircleWidget::nextAnimationFrame); - - layout->addWidget(circleWidgets[i][j], i + 1, j + 1); - } - } -//! [1] //! [2] - timer->start(100); - setLayout(layout); - - setWindowTitle(tr("Concentric Circles")); -} -//! [2] - -//! [3] -QLabel *Window::createLabel(const QString &text) -{ - QLabel *label = new QLabel(text); - label->setAlignment(Qt::AlignCenter); - label->setMargin(2); - label->setFrameStyle(QFrame::Box | QFrame::Sunken); - return label; -} -//! [3] diff --git a/examples/widgets/painting/concentriccircles/window.h b/examples/widgets/painting/concentriccircles/window.h deleted file mode 100644 index 461e03b6f2..0000000000 --- a/examples/widgets/painting/concentriccircles/window.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE -class CircleWidget; - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(); - -private: - QLabel *createLabel(const QString &text); - - QLabel *aliasedLabel; - QLabel *antialiasedLabel; - QLabel *intLabel; - QLabel *floatLabel; - CircleWidget *circleWidgets[2][2]; -}; -//! [0] - -#endif // WINDOW_H diff --git a/examples/widgets/painting/deform/.prev_CMakeLists.txt b/examples/widgets/painting/deform/.prev_CMakeLists.txt deleted file mode 100644 index 4a223487ab..0000000000 --- a/examples/widgets/painting/deform/.prev_CMakeLists.txt +++ /dev/null @@ -1,214 +0,0 @@ -# Generated from deform.pro. - -cmake_minimum_required(VERSION 3.14) -project(deform LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/deform") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(deform - ../shared/arthurstyle.cpp ../shared/arthurstyle.h - ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - ../shared/hoverpoints.cpp ../shared/hoverpoints.h - main.cpp - pathdeform.cpp pathdeform.h -) -target_include_directories(deform PUBLIC - ../shared -) - -target_link_libraries(deform PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" -) -set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" -) - -qt6_add_resources(deform "shared" - PREFIX - "/res" - BASE - "../shared" - FILES - ${shared_resource_files} -) -set(deform_resource_files - "pathdeform.cpp" - "pathdeform.html" -) - -qt6_add_resources(deform "deform" - PREFIX - "/res/deform" - FILES - ${deform_resource_files} -) - -if(QT_FEATURE_opengl) - target_sources(deform PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(deform PUBLIC - Qt::OpenGL - ) -endif() - -install(TARGETS deform - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/deform/CMakeLists.txt b/examples/widgets/painting/deform/CMakeLists.txt index 79c14d2196..1038df03ad 100644 --- a/examples/widgets/painting/deform/CMakeLists.txt +++ b/examples/widgets/painting/deform/CMakeLists.txt @@ -1,182 +1,74 @@ -# Generated from deform.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(deform LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/deform") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(deform - # special case: remove files from ../shared +qt_add_executable(deform main.cpp pathdeform.cpp pathdeform.h ) -target_include_directories(deform PUBLIC - ../shared -) -target_link_libraries(deform PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared # special case +set_target_properties(deform PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +if(NOT TARGET painting_shared::painting_shared) + include(../shared/use_lib.cmake) +endif() -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" +target_link_libraries(deform PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) + +# Resources: set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" + "../shared/images/button_normal_cap_left.png" + "../shared/images/button_normal_cap_right.png" + "../shared/images/button_normal_stretch.png" + "../shared/images/button_pressed_cap_left.png" + "../shared/images/button_pressed_cap_right.png" + "../shared/images/button_pressed_stretch.png" + "../shared/images/frame_bottom.png" + "../shared/images/frame_bottomleft.png" + "../shared/images/frame_bottomright.png" + "../shared/images/frame_left.png" + "../shared/images/frame_right.png" + "../shared/images/frame_top.png" + "../shared/images/frame_topleft.png" + "../shared/images/frame_topright.png" + "../shared/images/groupframe_bottom_left.png" + "../shared/images/groupframe_bottom_right.png" + "../shared/images/groupframe_bottom_stretch.png" + "../shared/images/groupframe_left_stretch.png" + "../shared/images/groupframe_right_stretch.png" + "../shared/images/groupframe_top_stretch.png" + "../shared/images/groupframe_topleft.png" + "../shared/images/groupframe_topright.png" + "../shared/images/line_dash_dot.png" + "../shared/images/line_dash_dot_dot.png" + "../shared/images/line_dashed.png" + "../shared/images/line_dotted.png" + "../shared/images/line_solid.png" + "../shared/images/radiobutton-on.png" + "../shared/images/radiobutton_off.png" + "../shared/images/radiobutton_on.png" + "../shared/images/slider_bar.png" + "../shared/images/slider_thumb_on.png" + "../shared/images/title_cap_left.png" + "../shared/images/title_cap_right.png" + "../shared/images/title_stretch.png" ) -qt6_add_resources(deform "shared" +qt_add_resources(deform "shared" PREFIX "/res" BASE @@ -184,30 +76,28 @@ qt6_add_resources(deform "shared" FILES ${shared_resource_files} ) + set(deform_resource_files "pathdeform.cpp" "pathdeform.html" ) -qt6_add_resources(deform "deform" +qt_add_resources(deform "deform" PREFIX "/res/deform" FILES ${deform_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(deform PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(deform PUBLIC - Qt::OpenGL - ) -endif() - install(TARGETS deform - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET deform + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/deform/main.cpp b/examples/widgets/painting/deform/main.cpp index 28e3d6823d..5ac5b4cc3f 100644 --- a/examples/widgets/painting/deform/main.cpp +++ b/examples/widgets/painting/deform/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "pathdeform.h" @@ -54,8 +7,6 @@ int main(int argc, char **argv) { - Q_INIT_RESOURCE(deform); - QApplication app(argc, argv); bool smallScreen = QApplication::arguments().contains("-small-screen"); diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp index acf0191260..f2c67c1587 100644 --- a/examples/widgets/painting/deform/pathdeform.cpp +++ b/examples/widgets/painting/deform/pathdeform.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "pathdeform.h" @@ -108,13 +61,6 @@ void PathDeformControls::layoutForDesktop() QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); -#endif - QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); @@ -129,9 +75,6 @@ void PathDeformControls::layoutForDesktop() mainGroupLayout->addWidget(textGroup); mainGroupLayout->addWidget(animateButton); mainGroupLayout->addStretch(1); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif mainGroupLayout->addWidget(showSourceButton); mainGroupLayout->addWidget(whatsThisButton); @@ -155,9 +98,6 @@ void PathDeformControls::layoutForDesktop() connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity); connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize); connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL); -#endif connect(textInput, &QLineEdit::textChanged, m_renderer, &PathDeformRenderer::setText); connect(m_renderer, &ArthurFrame::descriptionEnabledChanged, @@ -198,13 +138,6 @@ void PathDeformControls::layoutForSmallScreen() QPushButton *animateButton = new QPushButton(tr("Animated"), mainGroup); animateButton->setCheckable(true); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(mainGroup); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); -#endif - QPushButton *quitButton = new QPushButton(tr("Quit"), mainGroup); QPushButton *okButton = new QPushButton(tr("OK"), mainGroup); @@ -218,9 +151,6 @@ void PathDeformControls::layoutForSmallScreen() mainGroupLayout->addWidget(fontSizeLabel, 2, 0, Qt::AlignRight); mainGroupLayout->addWidget(fontSizeSlider, 2, 1); mainGroupLayout->addWidget(animateButton, 3,0, 1,2); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton, 4,0, 1,2); -#endif QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(mainGroup); @@ -234,10 +164,6 @@ void PathDeformControls::layoutForSmallScreen() connect(deformSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setIntensity); connect(fontSizeSlider, &QAbstractSlider::valueChanged, m_renderer, &PathDeformRenderer::setFontSize); connect(animateButton, &QAbstractButton::clicked, m_renderer, &PathDeformRenderer::setAnimated); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL); -#endif - animateButton->animateClick(); deformSlider->setValue(80); @@ -427,7 +353,6 @@ void PathDeformRenderer::setAnimated(bool animated) void PathDeformRenderer::timerEvent(QTimerEvent *e) { - if (e->timerId() == m_repaintTimer.timerId()) { if (QLineF(QPointF(0,0), m_direction).length() > 1) @@ -461,27 +386,14 @@ void PathDeformRenderer::timerEvent(QTimerEvent *e) m_pos.setY(height() - m_radius); } -#if QT_CONFIG(opengl) - if (usesOpenGL()) { - update(); - } else -#endif - { - QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); - update(rectAfter | rectBefore); - } + QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); + update(rectAfter | rectBefore); } -// else if (e->timerId() == m_fpsTimer.timerId()) { -// printf("fps: %d\n", m_fpsCounter); -// emit frameRate(m_fpsCounter); -// m_fpsCounter = 0; - -// } } void PathDeformRenderer::mousePressEvent(QMouseEvent *e) { - if (m_show_doc) { + if (m_showDoc) { setDescriptionEnabled(false); return; } @@ -525,15 +437,8 @@ void PathDeformRenderer::mouseMoveEvent(QMouseEvent *e) m_direction = (m_direction + dir) / 2; } m_pos = e->position().toPoint() + m_offset; -#if QT_CONFIG(opengl) - if (usesOpenGL()) { - update(); - } else -#endif - { - QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); - update(rectBefore | rectAfter); - } + QRect rectAfter = circle_bounds(m_pos, m_radius, m_fontSize); + update(rectBefore | rectAfter); } } @@ -617,27 +522,13 @@ void PathDeformRenderer::setRadius(int radius) qreal max = qMax(m_radius, (qreal)radius); m_radius = radius; generateLensPixmap(); - if (!m_animated || m_radius < max) { -#if QT_CONFIG(opengl) - if (usesOpenGL()){ - update(); - return; - } -#endif + if (!m_animated || m_radius < max) update(circle_bounds(m_pos, max, m_fontSize)); - } } void PathDeformRenderer::setIntensity(int intensity) { m_intensity = intensity; - if (!m_animated) { -#if QT_CONFIG(opengl) - if (usesOpenGL()) { - update(); - return; - } -#endif + if (!m_animated) update(circle_bounds(m_pos, m_radius, m_fontSize)); - } } diff --git a/examples/widgets/painting/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h index 0314755b34..5fa279e6de 100644 --- a/examples/widgets/painting/deform/pathdeform.h +++ b/examples/widgets/painting/deform/pathdeform.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef PATHDEFORM_H #define PATHDEFORM_H diff --git a/examples/widgets/painting/fontsampler/CMakeLists.txt b/examples/widgets/painting/fontsampler/CMakeLists.txt deleted file mode 100644 index 11ad8a3242..0000000000 --- a/examples/widgets/painting/fontsampler/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Generated from fontsampler.pro. - -cmake_minimum_required(VERSION 3.14) -project(fontsampler LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/fontsampler") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(fontsampler - main.cpp - mainwindow.cpp mainwindow.h - mainwindowbase.ui -) -target_link_libraries(fontsampler PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -if(TARGET Qt::PrintSupport) - target_link_libraries(fontsampler PUBLIC - Qt::PrintSupport - ) -endif() - -install(TARGETS fontsampler - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/fontsampler/fontsampler.pro b/examples/widgets/painting/fontsampler/fontsampler.pro deleted file mode 100644 index 5d3461f4b8..0000000000 --- a/examples/widgets/painting/fontsampler/fontsampler.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) -qtHaveModule(printsupport): QT += printsupport - -FORMS = mainwindowbase.ui -HEADERS = mainwindow.h -SOURCES = main.cpp \ - mainwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/painting/fontsampler -INSTALLS += target diff --git a/examples/widgets/painting/fontsampler/main.cpp b/examples/widgets/painting/fontsampler/main.cpp deleted file mode 100644 index cec6929827..0000000000 --- a/examples/widgets/painting/fontsampler/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include <QApplication> - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ -#ifdef Q_OS_ANDROID - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/painting/fontsampler/mainwindow.cpp b/examples/widgets/painting/fontsampler/mainwindow.cpp deleted file mode 100644 index b3304b4b6d..0000000000 --- a/examples/widgets/painting/fontsampler/mainwindow.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#include <QtWidgets> -#if defined(QT_PRINTSUPPORT_LIB) -#include <QtPrintSupport/qtprintsupportglobal.h> -#if QT_CONFIG(printdialog) -#include <QPrinter> -#include <QPrintDialog> -#if QT_CONFIG(printpreviewdialog) -#include <QPrintPreviewDialog> -#endif -#endif -#endif - -#include "mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - setupUi(this); - - sampleSizes << 32 << 24 << 16 << 14 << 12 << 8 << 4 << 2 << 1; - markedCount = 0; - setupFontTree(); - - connect(quitAction, &QAction::triggered, - qApp, &QApplication::quit); - connect(fontTree, &QTreeWidget::currentItemChanged, - this, &MainWindow::showFont); - connect(fontTree, &QTreeWidget::itemChanged, - this, &MainWindow::updateStyles); - - fontTree->topLevelItem(0)->setSelected(true); - showFont(fontTree->topLevelItem(0)); -} - -void MainWindow::setupFontTree() -{ - QFontDatabase database; - fontTree->setColumnCount(1); - fontTree->setHeaderLabels({ tr("Font") }); - - const QStringList fontFamilies = database.families(); - for (const QString &family : fontFamilies) { - const QStringList styles = database.styles(family); - if (styles.isEmpty()) - continue; - - QTreeWidgetItem *familyItem = new QTreeWidgetItem(fontTree); - familyItem->setText(0, family); - familyItem->setCheckState(0, Qt::Unchecked); - familyItem->setFlags(familyItem->flags() | Qt::ItemIsAutoTristate); - - for (const QString &style : styles) { - QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem); - styleItem->setText(0, style); - styleItem->setCheckState(0, Qt::Unchecked); - styleItem->setData(0, Qt::UserRole, QVariant(database.weight(family, style))); - styleItem->setData(0, Qt::UserRole + 1, QVariant(database.italic(family, style))); - } - } -} - -void MainWindow::on_clearAction_triggered() -{ - const QList<QTreeWidgetItem *> items = fontTree->selectedItems(); - for (QTreeWidgetItem *item : items) - item->setSelected(false); - fontTree->currentItem()->setSelected(true); -} - -void MainWindow::on_markAction_triggered() -{ - markUnmarkFonts(Qt::Checked); -} - -void MainWindow::on_unmarkAction_triggered() -{ - markUnmarkFonts(Qt::Unchecked); -} - -void MainWindow::markUnmarkFonts(Qt::CheckState state) -{ - const QList<QTreeWidgetItem *> items = fontTree->selectedItems(); - for (QTreeWidgetItem *item : items) { - if (item->checkState(0) != state) - item->setCheckState(0, state); - } -} - -void MainWindow::showFont(QTreeWidgetItem *item) -{ - if (!item) - return; - - QString family; - QString style; - int weight; - bool italic; - - if (item->parent()) { - family = item->parent()->text(0); - style = item->text(0); - weight = item->data(0, Qt::UserRole).toInt(); - italic = item->data(0, Qt::UserRole + 1).toBool(); - } else { - family = item->text(0); - style = item->child(0)->text(0); - weight = item->child(0)->data(0, Qt::UserRole).toInt(); - italic = item->child(0)->data(0, Qt::UserRole + 1).toBool(); - } - - QString oldText = textEdit->toPlainText().trimmed(); - bool modified = textEdit->document()->isModified(); - textEdit->clear(); - QFont font(family, 32, weight, italic); - font.setStyleName(style); - textEdit->document()->setDefaultFont(font); - - QTextCursor cursor = textEdit->textCursor(); - QTextBlockFormat blockFormat; - blockFormat.setAlignment(Qt::AlignCenter); - cursor.insertBlock(blockFormat); - - if (modified) - cursor.insertText(QString(oldText)); - else - cursor.insertText(QString("%1 %2").arg(family).arg(style)); - - textEdit->document()->setModified(modified); -} - -void MainWindow::updateStyles(QTreeWidgetItem *item, int column) -{ - if (!item || column != 0) - return; - - Qt::CheckState state = item->checkState(0); - QTreeWidgetItem *parent = item->parent(); - - if (parent) { - // Only count style items. - if (state == Qt::Checked) - ++markedCount; - else - --markedCount; - } - - printAction->setEnabled(markedCount > 0); - printPreviewAction->setEnabled(markedCount > 0); -} - -QMap<QString, StyleItems> MainWindow::currentPageMap() -{ - QMap<QString, StyleItems> pageMap; - - for (int row = 0; row < fontTree->topLevelItemCount(); ++row) { - QTreeWidgetItem *familyItem = fontTree->topLevelItem(row); - QString family; - - if (familyItem->checkState(0) == Qt::Checked) { - family = familyItem->text(0); - pageMap[family] = StyleItems(); - } - - for (int childRow = 0; childRow < familyItem->childCount(); ++childRow) { - QTreeWidgetItem *styleItem = familyItem->child(childRow); - if (styleItem->checkState(0) == Qt::Checked) - pageMap[family].append(styleItem); - } - } - - return pageMap; -} - -void MainWindow::on_printAction_triggered() -{ -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) - pageMap = currentPageMap(); - - if (pageMap.count() == 0) - return; - - QPrinter printer(QPrinter::HighResolution); - QPrintDialog dialog(&printer, this); - if (dialog.exec() != QDialog::Accepted) - return; - - int from = printer.fromPage(); - int to = printer.toPage(); - if (from <= 0 && to <= 0) - printer.setFromTo(1, pageMap.keys().count()); - - printDocument(&printer); -#endif -} - -void MainWindow::printDocument(QPrinter *printer) -{ -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) - printer->setFromTo(1, pageMap.count()); - - QProgressDialog progress(tr("Preparing font samples..."), tr("&Cancel"), - 0, pageMap.count(), this); - progress.setWindowModality(Qt::ApplicationModal); - progress.setWindowTitle(tr("Font Sampler")); - progress.setMinimum(printer->fromPage() - 1); - progress.setMaximum(printer->toPage()); - - QPainter painter; - painter.begin(printer); - bool firstPage = true; - - for (int page = printer->fromPage(); page <= printer->toPage(); ++page) { - - if (!firstPage) - printer->newPage(); - - qApp->processEvents(); - if (progress.wasCanceled()) - break; - - printPage(page - 1, &painter, printer); - progress.setValue(page); - firstPage = false; - } - - painter.end(); -#endif -} - -void MainWindow::on_printPreviewAction_triggered() -{ -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog) - pageMap = currentPageMap(); - - if (pageMap.count() == 0) - return; - - QPrinter printer(QPrinter::HighResolution); - QPrintPreviewDialog preview(&printer, this); - connect(&preview, &QPrintPreviewDialog::paintRequested, - this, &MainWindow::printDocument); - preview.exec(); -#endif -} - -void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer) -{ -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) - const QString family = (pageMap.begin() + index).key(); - const StyleItems items = pageMap.value(family); - - // Find the dimensions of the text on each page. - qreal width = 0.0; - qreal height = 0.0; - for (const QTreeWidgetItem *item : items) { - QString style = item->text(0); - int weight = item->data(0, Qt::UserRole).toInt(); - bool italic = item->data(0, Qt::UserRole + 1).toBool(); - - // Calculate the maximum width and total height of the text. - for (int size : qAsConst(sampleSizes)) { - QFont font(family, size, weight, italic); - font.setStyleName(style); - font = QFont(font, painter->device()); - QFontMetricsF fontMetrics(font); - QRectF rect = fontMetrics.boundingRect( - QString("%1 %2").arg(family).arg(style)); - width = qMax(rect.width(), width); - height += rect.height(); - } - } - - qreal xScale = printer->pageRect().width() / width; - qreal yScale = printer->pageRect().height() / height; - qreal scale = qMin(xScale, yScale); - - qreal remainingHeight = printer->pageRect().height()/scale - height; - qreal spaceHeight = (remainingHeight / 4.0) / (items.count() + 1); - qreal interLineHeight = (remainingHeight / 4.0) / (sampleSizes.count() * items.count()); - - painter->save(); - painter->translate(printer->pageRect().width() / 2.0, printer->pageRect().height() / 2.0); - painter->scale(scale, scale); - painter->setBrush(QBrush(Qt::black)); - - qreal x = -width / 2.0; - qreal y = -height / 2.0 - remainingHeight / 4.0 + spaceHeight; - - for (const QTreeWidgetItem *item : items) { - QString style = item->text(0); - int weight = item->data(0, Qt::UserRole).toInt(); - bool italic = item->data(0, Qt::UserRole + 1).toBool(); - - // Draw each line of text. - for (int size : qAsConst(sampleSizes)) { - QFont font(family, size, weight, italic); - font.setStyleName(style); - font = QFont(font, painter->device()); - QFontMetricsF fontMetrics(font); - QRectF rect = fontMetrics.boundingRect(QString("%1 %2").arg( - font.family()).arg(style)); - y += rect.height(); - painter->setFont(font); - painter->drawText(QPointF(x, y), QString("%1 %2").arg(family).arg(style)); - y += interLineHeight; - } - y += spaceHeight; - } - - painter->restore(); -#endif -} diff --git a/examples/widgets/painting/fontsampler/mainwindow.h b/examples/widgets/painting/fontsampler/mainwindow.h deleted file mode 100644 index 34e54440d4..0000000000 --- a/examples/widgets/painting/fontsampler/mainwindow.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include "ui_mainwindowbase.h" - -#if defined(QT_PRINTSUPPORT_LIB) -#include <QtPrintSupport/qtprintsupportglobal.h> -#endif -QT_BEGIN_NAMESPACE -class QPrinter; -class QTextEdit; -class QTreeWidget; -class QTreeWidgetItem; -QT_END_NAMESPACE - -typedef QList<QTreeWidgetItem *> StyleItems; - -class MainWindow : public QMainWindow, private Ui::MainWindowBase -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - -public slots: - void on_clearAction_triggered(); - void on_markAction_triggered(); - void on_unmarkAction_triggered(); - void on_printAction_triggered(); - void on_printPreviewAction_triggered(); - void printDocument(QPrinter *printer); - void printPage(int index, QPainter *painter, QPrinter *printer); - void showFont(QTreeWidgetItem *item); - void updateStyles(QTreeWidgetItem *item, int column); - -private: - QMap<QString, StyleItems> currentPageMap(); - void markUnmarkFonts(Qt::CheckState state); - void setupFontTree(); - - QList<int> sampleSizes; - QMap<QString, StyleItems> pageMap; - int markedCount; -}; - -#endif // MAINWINDOW_H diff --git a/examples/widgets/painting/fontsampler/mainwindowbase.ui b/examples/widgets/painting/fontsampler/mainwindowbase.ui deleted file mode 100644 index 1a95ebd6d1..0000000000 --- a/examples/widgets/painting/fontsampler/mainwindowbase.ui +++ /dev/null @@ -1,142 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindowBase</class> - <widget class="QMainWindow" name="MainWindowBase"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>345</height> - </rect> - </property> - <property name="windowTitle"> - <string>Font Sampler</string> - </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="QTextEdit" name="textEdit"/> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>18</height> - </rect> - </property> - <widget class="QMenu" name="menu_Selection"> - <property name="title"> - <string>&Selection</string> - </property> - <addaction name="markAction"/> - <addaction name="unmarkAction"/> - <addaction name="clearAction"/> - </widget> - <widget class="QMenu" name="menu_File"> - <property name="title"> - <string>&File</string> - </property> - <addaction name="printPreviewAction"/> - <addaction name="printAction"/> - <addaction name="quitAction"/> - </widget> - <addaction name="menu_File"/> - <addaction name="menu_Selection"/> - </widget> - <widget class="QStatusBar" name="statusbar"/> - <widget class="QDockWidget" name="dockWidget"> - <property name="features"> - <set>QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable</set> - </property> - <property name="windowTitle"> - <string>Available Fonts</string> - </property> - <attribute name="dockWidgetArea"> - <number>1</number> - </attribute> - <widget class="QWidget" name="dockWidgetContents"> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="QTreeWidget" name="fontTree"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - </widget> - <action name="printAction"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>&Print...</string> - </property> - <property name="shortcut"> - <string>Ctrl+P</string> - </property> - </action> - <action name="quitAction"> - <property name="text"> - <string>E&xit</string> - </property> - <property name="shortcut"> - <string>Ctrl+Q</string> - </property> - </action> - <action name="markAction"> - <property name="text"> - <string>&Mark</string> - </property> - <property name="shortcut"> - <string>Ctrl+M</string> - </property> - </action> - <action name="unmarkAction"> - <property name="text"> - <string>&Unmark</string> - </property> - <property name="shortcut"> - <string>Ctrl+U</string> - </property> - </action> - <action name="clearAction"> - <property name="text"> - <string>&Clear</string> - </property> - </action> - <action name="printPreviewAction"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Print Preview...</string> - </property> - </action> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/widgets/painting/gradients/.prev_CMakeLists.txt b/examples/widgets/painting/gradients/.prev_CMakeLists.txt deleted file mode 100644 index f28694a96b..0000000000 --- a/examples/widgets/painting/gradients/.prev_CMakeLists.txt +++ /dev/null @@ -1,214 +0,0 @@ -# Generated from gradients.pro. - -cmake_minimum_required(VERSION 3.14) -project(gradients LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/gradients") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(gradients - ../shared/arthurstyle.cpp ../shared/arthurstyle.h - ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - ../shared/hoverpoints.cpp ../shared/hoverpoints.h - gradients.cpp gradients.h - main.cpp -) -target_include_directories(gradients PUBLIC - ../shared -) - -target_link_libraries(gradients PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" -) -set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" -) - -qt6_add_resources(gradients "shared" - PREFIX - "/res" - BASE - "../shared" - FILES - ${shared_resource_files} -) -set(gradients_resource_files - "gradients.cpp" - "gradients.html" -) - -qt6_add_resources(gradients "gradients" - PREFIX - "/res/gradients" - FILES - ${gradients_resource_files} -) - -if(QT_FEATURE_opengl) - target_sources(gradients PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(gradients PUBLIC - Qt::OpenGL - ) -endif() - -install(TARGETS gradients - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/painting/gradients/CMakeLists.txt b/examples/widgets/painting/gradients/CMakeLists.txt index 0b6c06e5b9..39cc44ed8f 100644 --- a/examples/widgets/painting/gradients/CMakeLists.txt +++ b/examples/widgets/painting/gradients/CMakeLists.txt @@ -1,182 +1,74 @@ -# Generated from gradients.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(gradients LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/gradients") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(gradients - # special case: remove files from ../shared +qt_add_executable(gradients gradients.cpp gradients.h main.cpp ) -target_include_directories(gradients PUBLIC - ../shared -) -target_link_libraries(gradients PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared # special case +set_target_properties(gradients PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +if(NOT TARGET painting_shared::painting_shared) + include(../shared/use_lib.cmake) +endif() -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" +target_link_libraries(gradients PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) + +# Resources: set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" + "../shared/images/button_normal_cap_left.png" + "../shared/images/button_normal_cap_right.png" + "../shared/images/button_normal_stretch.png" + "../shared/images/button_pressed_cap_left.png" + "../shared/images/button_pressed_cap_right.png" + "../shared/images/button_pressed_stretch.png" + "../shared/images/frame_bottom.png" + "../shared/images/frame_bottomleft.png" + "../shared/images/frame_bottomright.png" + "../shared/images/frame_left.png" + "../shared/images/frame_right.png" + "../shared/images/frame_top.png" + "../shared/images/frame_topleft.png" + "../shared/images/frame_topright.png" + "../shared/images/groupframe_bottom_left.png" + "../shared/images/groupframe_bottom_right.png" + "../shared/images/groupframe_bottom_stretch.png" + "../shared/images/groupframe_left_stretch.png" + "../shared/images/groupframe_right_stretch.png" + "../shared/images/groupframe_top_stretch.png" + "../shared/images/groupframe_topleft.png" + "../shared/images/groupframe_topright.png" + "../shared/images/line_dash_dot.png" + "../shared/images/line_dash_dot_dot.png" + "../shared/images/line_dashed.png" + "../shared/images/line_dotted.png" + "../shared/images/line_solid.png" + "../shared/images/radiobutton-on.png" + "../shared/images/radiobutton_off.png" + "../shared/images/radiobutton_on.png" + "../shared/images/slider_bar.png" + "../shared/images/slider_thumb_on.png" + "../shared/images/title_cap_left.png" + "../shared/images/title_cap_right.png" + "../shared/images/title_stretch.png" ) -qt6_add_resources(gradients "shared" +qt_add_resources(gradients "shared" PREFIX "/res" BASE @@ -184,30 +76,28 @@ qt6_add_resources(gradients "shared" FILES ${shared_resource_files} ) + set(gradients_resource_files "gradients.cpp" "gradients.html" ) -qt6_add_resources(gradients "gradients" +qt_add_resources(gradients "gradients" PREFIX "/res/gradients" FILES ${gradients_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(gradients PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(gradients PUBLIC - Qt::OpenGL - ) -endif() - install(TARGETS gradients - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET gradients + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index 76d5818d32..5ed3d764d1 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "gradients.h" #include "hoverpoints.h" @@ -105,6 +58,8 @@ uint ShadeWidget::colorAt(int x) for (int i = 1; i < pts.size(); ++i) { if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) { QLineF l(pts.at(i - 1), pts.at(i)); + if (qIsNull(l.dx())) + continue; l.setLength(l.length() * ((x - l.x1()) / l.dx())); return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))), qRound(qMin(l.y2(), qreal(m_shade.height() - 1)))); @@ -318,12 +273,6 @@ GradientWidget::GradientWidget(QWidget *parent) QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); -#endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); @@ -337,9 +286,6 @@ GradientWidget::GradientWidget(QWidget *parent) mainGroupLayout->addWidget(defaultsGroup); mainGroupLayout->addStretch(1); mainGroupLayout->addWidget(showSourceButton); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif mainGroupLayout->addWidget(whatsThisButton); QVBoxLayout *editorGroupLayout = new QVBoxLayout(editorGroup); @@ -415,11 +361,6 @@ GradientWidget::GradientWidget(QWidget *parent) connect(showSourceButton, &QPushButton::clicked, m_renderer, &GradientRenderer::showSource); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, QOverload<bool>::of(&QPushButton::clicked), - m_renderer, &ArthurFrame::enableOpenGL); -#endif - connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked), m_renderer, &ArthurFrame::setDescriptionEnabled); connect(whatsThisButton, QOverload<bool>::of(&QPushButton::clicked), @@ -579,7 +520,7 @@ void GradientRenderer::paint(QPainter *p) g = QConicalGradient(pts.at(0), angle); } - for (const auto &stop : qAsConst(m_stops)) + for (const auto &stop : std::as_const(m_stops)) g.setColorAt(stop.first, stop.second); g.setSpread(m_spread); diff --git a/examples/widgets/painting/gradients/gradients.h b/examples/widgets/painting/gradients/gradients.h index 45ef5d0f93..227424b7b4 100644 --- a/examples/widgets/painting/gradients/gradients.h +++ b/examples/widgets/painting/gradients/gradients.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef GRADIENTS_H #define GRADIENTS_H diff --git a/examples/widgets/painting/gradients/main.cpp b/examples/widgets/painting/gradients/main.cpp index 7ffb0326e9..c1e2297512 100644 --- a/examples/widgets/painting/gradients/main.cpp +++ b/examples/widgets/painting/gradients/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "gradients.h" @@ -54,11 +7,6 @@ int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(gradients); -#ifdef Q_OS_ANDROID - qputenv("QT_SCALE_FACTOR", "2"); -#endif - QApplication app(argc, argv); GradientWidget gradientWidget; diff --git a/examples/widgets/painting/imagecomposition/CMakeLists.txt b/examples/widgets/painting/imagecomposition/CMakeLists.txt index 1b3d06da8f..eea0c24173 100644 --- a/examples/widgets/painting/imagecomposition/CMakeLists.txt +++ b/examples/widgets/painting/imagecomposition/CMakeLists.txt @@ -1,30 +1,28 @@ -# Generated from imagecomposition.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(imagecomposition LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/imagecomposition") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(imagecomposition +qt_add_executable(imagecomposition imagecomposer.cpp imagecomposer.h main.cpp ) -target_link_libraries(imagecomposition PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +set_target_properties(imagecomposition PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +target_link_libraries(imagecomposition PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) # Resources: set(imagecomposition_resource_files @@ -32,7 +30,7 @@ set(imagecomposition_resource_files "images/checker.png" ) -qt6_add_resources(imagecomposition "imagecomposition" +qt_add_resources(imagecomposition "imagecomposition" PREFIX "/" FILES @@ -40,7 +38,14 @@ qt6_add_resources(imagecomposition "imagecomposition" ) install(TARGETS imagecomposition - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET imagecomposition + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/imagecomposition/imagecomposer.cpp b/examples/widgets/painting/imagecomposition/imagecomposer.cpp index f0935147cf..611a44b6b5 100644 --- a/examples/widgets/painting/imagecomposition/imagecomposer.cpp +++ b/examples/widgets/painting/imagecomposition/imagecomposer.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "imagecomposer.h" diff --git a/examples/widgets/painting/imagecomposition/imagecomposer.h b/examples/widgets/painting/imagecomposition/imagecomposer.h index 7aa75bbc52..1d6a3072fe 100644 --- a/examples/widgets/painting/imagecomposition/imagecomposer.h +++ b/examples/widgets/painting/imagecomposition/imagecomposer.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef IMAGECOMPOSER_H #define IMAGECOMPOSER_H diff --git a/examples/widgets/painting/imagecomposition/main.cpp b/examples/widgets/painting/imagecomposition/main.cpp index 89502df708..a3cf65a344 100644 --- a/examples/widgets/painting/imagecomposition/main.cpp +++ b/examples/widgets/painting/imagecomposition/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "imagecomposer.h" @@ -55,8 +8,6 @@ //! [0] int main(int argc, char *argv[]) { - Q_INIT_RESOURCE(imagecomposition); - QApplication app(argc, argv); ImageComposer composer; composer.show(); diff --git a/examples/widgets/painting/painterpaths/CMakeLists.txt b/examples/widgets/painting/painterpaths/CMakeLists.txt index 7ae6f0a016..46f7948277 100644 --- a/examples/widgets/painting/painterpaths/CMakeLists.txt +++ b/examples/widgets/painting/painterpaths/CMakeLists.txt @@ -1,39 +1,45 @@ -# Generated from painterpaths.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(painterpaths LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/painterpaths") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(painterpaths +qt_add_executable(painterpaths main.cpp renderarea.cpp renderarea.h window.cpp window.h ) -target_link_libraries(painterpaths PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +set_target_properties(painterpaths PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(painterpaths PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) if(UNIX AND NOT APPLE AND NOT HAIKU AND NOT INTEGRITY AND NOT VXWORKS) - target_link_libraries(painterpaths PUBLIC + target_link_libraries(painterpaths PRIVATE m ) endif() install(TARGETS painterpaths - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET painterpaths + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/painterpaths/main.cpp b/examples/widgets/painting/painterpaths/main.cpp index d9fa2879c4..1d8fd919b2 100644 --- a/examples/widgets/painting/painterpaths/main.cpp +++ b/examples/widgets/painting/painterpaths/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" diff --git a/examples/widgets/painting/painterpaths/renderarea.cpp b/examples/widgets/painting/painterpaths/renderarea.cpp index 9a5cd3ee87..2d10e0e186 100644 --- a/examples/widgets/painting/painterpaths/renderarea.cpp +++ b/examples/widgets/painting/painterpaths/renderarea.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "renderarea.h" diff --git a/examples/widgets/painting/painterpaths/renderarea.h b/examples/widgets/painting/painterpaths/renderarea.h index 4b3ea5a397..befbdda54a 100644 --- a/examples/widgets/painting/painterpaths/renderarea.h +++ b/examples/widgets/painting/painterpaths/renderarea.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef RENDERAREA_H #define RENDERAREA_H diff --git a/examples/widgets/painting/painterpaths/window.cpp b/examples/widgets/painting/painterpaths/window.cpp index 07d3c5aaa8..01b62d6988 100644 --- a/examples/widgets/painting/painterpaths/window.cpp +++ b/examples/widgets/painting/painterpaths/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "renderarea.h" #include "window.h" @@ -203,7 +156,7 @@ Window::Window() connect(penColorComboBox, &QComboBox::activated, this, &Window::penColorChanged); - for (RenderArea *area : qAsConst(renderAreas)) { + for (RenderArea *area : std::as_const(renderAreas)) { connect(penWidthSpinBox, &QSpinBox::valueChanged, area, &RenderArea::setPenWidth); connect(rotationAngleSpinBox, &QSpinBox::valueChanged, @@ -214,7 +167,7 @@ Window::Window() QGridLayout *topLayout = new QGridLayout; int i = 0; - for (RenderArea *area : qAsConst(renderAreas)) { + for (RenderArea *area : std::as_const(renderAreas)) { topLayout->addWidget(area, i / 3, i % 3); ++i; } @@ -251,7 +204,7 @@ void Window::fillRuleChanged() { Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt(); - for (RenderArea *area : qAsConst(renderAreas)) + for (RenderArea *area : std::as_const(renderAreas)) area->setFillRule(rule); } //! [19] @@ -262,7 +215,7 @@ void Window::fillGradientChanged() QColor color1 = qvariant_cast<QColor>(currentItemData(fillColor1ComboBox)); QColor color2 = qvariant_cast<QColor>(currentItemData(fillColor2ComboBox)); - for (RenderArea *area : qAsConst(renderAreas)) + for (RenderArea *area : std::as_const(renderAreas)) area->setFillGradient(color1, color2); } //! [20] @@ -272,7 +225,7 @@ void Window::penColorChanged() { QColor color = qvariant_cast<QColor>(currentItemData(penColorComboBox)); - for (RenderArea *area : qAsConst(renderAreas)) + for (RenderArea *area : std::as_const(renderAreas)) area->setPenColor(color); } //! [21] diff --git a/examples/widgets/painting/painterpaths/window.h b/examples/widgets/painting/painterpaths/window.h index 6a5a5953df..55ac38653c 100644 --- a/examples/widgets/painting/painterpaths/window.h +++ b/examples/widgets/painting/painterpaths/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/painting/painting.pro b/examples/widgets/painting/painting.pro index a9749a560d..1dfd660f77 100644 --- a/examples/widgets/painting/painting.pro +++ b/examples/widgets/painting/painting.pro @@ -1,6 +1,5 @@ TEMPLATE = subdirs SUBDIRS = basicdrawing \ - concentriccircles \ affine \ composition \ deform \ @@ -8,8 +7,7 @@ SUBDIRS = basicdrawing \ pathstroke \ imagecomposition \ painterpaths \ - transformations \ - fontsampler + transformations EXAMPLE_FILES = \ shared diff --git a/examples/widgets/painting/pathstroke/CMakeLists.txt b/examples/widgets/painting/pathstroke/CMakeLists.txt index 9f5c24fe88..5c995617eb 100644 --- a/examples/widgets/painting/pathstroke/CMakeLists.txt +++ b/examples/widgets/painting/pathstroke/CMakeLists.txt @@ -1,183 +1,74 @@ -# Generated from pathstroke.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(pathstroke LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/pathstroke") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(pathstroke - ../shared/arthurstyle.cpp ../shared/arthurstyle.h - ../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - ../shared/hoverpoints.cpp ../shared/hoverpoints.h +qt_add_executable(pathstroke main.cpp pathstroke.cpp pathstroke.h ) -target_include_directories(pathstroke PUBLIC - ../shared -) -target_link_libraries(pathstroke PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets +set_target_properties(pathstroke PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE ) +if(NOT TARGET painting_shared::painting_shared) + include(../shared/use_lib.cmake) +endif() -# Resources: -set_source_files_properties("../shared/images/button_normal_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_left.png" -) -set_source_files_properties("../shared/images/button_normal_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_cap_right.png" -) -set_source_files_properties("../shared/images/button_normal_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_normal_stretch.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_left.png" -) -set_source_files_properties("../shared/images/button_pressed_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_cap_right.png" -) -set_source_files_properties("../shared/images/button_pressed_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/button_pressed_stretch.png" -) -set_source_files_properties("../shared/images/frame_bottom.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottom.png" -) -set_source_files_properties("../shared/images/frame_bottomleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomleft.png" -) -set_source_files_properties("../shared/images/frame_bottomright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_bottomright.png" -) -set_source_files_properties("../shared/images/frame_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_left.png" -) -set_source_files_properties("../shared/images/frame_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_right.png" -) -set_source_files_properties("../shared/images/frame_top.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_top.png" -) -set_source_files_properties("../shared/images/frame_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topleft.png" -) -set_source_files_properties("../shared/images/frame_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/frame_topright.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_left.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_right.png" -) -set_source_files_properties("../shared/images/groupframe_bottom_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_bottom_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_left_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_left_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_right_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_right_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_top_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_top_stretch.png" -) -set_source_files_properties("../shared/images/groupframe_topleft.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topleft.png" -) -set_source_files_properties("../shared/images/groupframe_topright.png" - PROPERTIES QT_RESOURCE_ALIAS "images/groupframe_topright.png" -) -set_source_files_properties("../shared/images/line_dash_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot.png" -) -set_source_files_properties("../shared/images/line_dash_dot_dot.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dash_dot_dot.png" -) -set_source_files_properties("../shared/images/line_dashed.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dashed.png" -) -set_source_files_properties("../shared/images/line_dotted.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_dotted.png" -) -set_source_files_properties("../shared/images/line_solid.png" - PROPERTIES QT_RESOURCE_ALIAS "images/line_solid.png" -) -set_source_files_properties("../shared/images/radiobutton-on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton-on.png" -) -set_source_files_properties("../shared/images/radiobutton_off.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_off.png" -) -set_source_files_properties("../shared/images/radiobutton_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/radiobutton_on.png" -) -set_source_files_properties("../shared/images/slider_bar.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_bar.png" -) -set_source_files_properties("../shared/images/slider_thumb_on.png" - PROPERTIES QT_RESOURCE_ALIAS "images/slider_thumb_on.png" -) -set_source_files_properties("../shared/images/title_cap_left.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_left.png" -) -set_source_files_properties("../shared/images/title_cap_right.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_cap_right.png" -) -set_source_files_properties("../shared/images/title_stretch.png" - PROPERTIES QT_RESOURCE_ALIAS "images/title_stretch.png" +target_link_libraries(pathstroke PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) + +# Resources: set(shared_resource_files - "images/button_normal_cap_left.png" - "images/button_normal_cap_right.png" - "images/button_normal_stretch.png" - "images/button_pressed_cap_left.png" - "images/button_pressed_cap_right.png" - "images/button_pressed_stretch.png" - "images/frame_bottom.png" - "images/frame_bottomleft.png" - "images/frame_bottomright.png" - "images/frame_left.png" - "images/frame_right.png" - "images/frame_top.png" - "images/frame_topleft.png" - "images/frame_topright.png" - "images/groupframe_bottom_left.png" - "images/groupframe_bottom_right.png" - "images/groupframe_bottom_stretch.png" - "images/groupframe_left_stretch.png" - "images/groupframe_right_stretch.png" - "images/groupframe_top_stretch.png" - "images/groupframe_topleft.png" - "images/groupframe_topright.png" - "images/line_dash_dot.png" - "images/line_dash_dot_dot.png" - "images/line_dashed.png" - "images/line_dotted.png" - "images/line_solid.png" - "images/radiobutton-on.png" - "images/radiobutton_off.png" - "images/radiobutton_on.png" - "images/slider_bar.png" - "images/slider_thumb_on.png" - "images/title_cap_left.png" - "images/title_cap_right.png" - "images/title_stretch.png" + "../shared/images/button_normal_cap_left.png" + "../shared/images/button_normal_cap_right.png" + "../shared/images/button_normal_stretch.png" + "../shared/images/button_pressed_cap_left.png" + "../shared/images/button_pressed_cap_right.png" + "../shared/images/button_pressed_stretch.png" + "../shared/images/frame_bottom.png" + "../shared/images/frame_bottomleft.png" + "../shared/images/frame_bottomright.png" + "../shared/images/frame_left.png" + "../shared/images/frame_right.png" + "../shared/images/frame_top.png" + "../shared/images/frame_topleft.png" + "../shared/images/frame_topright.png" + "../shared/images/groupframe_bottom_left.png" + "../shared/images/groupframe_bottom_right.png" + "../shared/images/groupframe_bottom_stretch.png" + "../shared/images/groupframe_left_stretch.png" + "../shared/images/groupframe_right_stretch.png" + "../shared/images/groupframe_top_stretch.png" + "../shared/images/groupframe_topleft.png" + "../shared/images/groupframe_topright.png" + "../shared/images/line_dash_dot.png" + "../shared/images/line_dash_dot_dot.png" + "../shared/images/line_dashed.png" + "../shared/images/line_dotted.png" + "../shared/images/line_solid.png" + "../shared/images/radiobutton-on.png" + "../shared/images/radiobutton_off.png" + "../shared/images/radiobutton_on.png" + "../shared/images/slider_bar.png" + "../shared/images/slider_thumb_on.png" + "../shared/images/title_cap_left.png" + "../shared/images/title_cap_right.png" + "../shared/images/title_stretch.png" ) -qt6_add_resources(pathstroke "shared" +qt_add_resources(pathstroke "shared" PREFIX "/res" BASE @@ -185,30 +76,28 @@ qt6_add_resources(pathstroke "shared" FILES ${shared_resource_files} ) + set(pathstroke_resource_files "pathstroke.cpp" "pathstroke.html" ) -qt6_add_resources(pathstroke "pathstroke" +qt_add_resources(pathstroke "pathstroke" PREFIX "/res/pathstroke" FILES ${pathstroke_resource_files} ) -if(QT_FEATURE_opengl) - target_sources(pathstroke PUBLIC - ../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - ) - - target_link_libraries(pathstroke PUBLIC - Qt::OpenGL - ) -endif() - install(TARGETS pathstroke - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET pathstroke + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/pathstroke/main.cpp b/examples/widgets/painting/pathstroke/main.cpp index 35317480a3..4f991e8a0a 100644 --- a/examples/widgets/painting/pathstroke/main.cpp +++ b/examples/widgets/painting/pathstroke/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "pathstroke.h" @@ -54,11 +7,6 @@ int main(int argc, char **argv) { - Q_INIT_RESOURCE(pathstroke); -#ifdef Q_OS_ANDROID - qputenv("QT_SCALE_FACTOR", "2"); -#endif - QApplication app(argc, argv); bool smallScreen = QApplication::arguments().contains("-small-screen"); diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index 412c2da6a4..cd54a7a8aa 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "pathstroke.h" #include "arthurstyle.h" @@ -224,12 +177,6 @@ void PathStrokeControls::layoutForDesktop() QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(mainGroup); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); -#endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); @@ -253,9 +200,6 @@ void PathStrokeControls::layoutForDesktop() mainGroupLayout->addWidget(animated); mainGroupLayout->addStretch(1); mainGroupLayout->addWidget(showSourceButton); -#if QT_CONFIG(opengl) - mainGroupLayout->addWidget(enableOpenGLButton); -#endif mainGroupLayout->addWidget(whatsThisButton); @@ -268,10 +212,6 @@ void PathStrokeControls::layoutForDesktop() connect(showSourceButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::showSource); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QAbstractButton::clicked, - m_renderer, &ArthurFrame::enableOpenGL); -#endif connect(whatsThisButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::setDescriptionEnabled); connect(m_renderer, &ArthurFrame::descriptionEnabledChanged, @@ -306,13 +246,6 @@ void PathStrokeControls::layoutForSmallScreens() penWidth->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); penWidth->setRange(0, 500); -#if QT_CONFIG(opengl) - QPushButton *enableOpenGLButton = new QPushButton(this); - enableOpenGLButton->setText(tr("Use OpenGL")); - enableOpenGLButton->setCheckable(true); - enableOpenGLButton->setChecked(m_renderer->usesOpenGL()); -#endif - // Layouts: QHBoxLayout *penWidthLayout = new QHBoxLayout; penWidthLayout->addWidget(penWidthLabel, 0, Qt::AlignRight); @@ -321,9 +254,6 @@ void PathStrokeControls::layoutForSmallScreens() QVBoxLayout *leftLayout = new QVBoxLayout; leftLayout->addWidget(m_capGroup); leftLayout->addWidget(m_joinGroup); -#if QT_CONFIG(opengl) - leftLayout->addWidget(enableOpenGLButton); -#endif leftLayout->addLayout(penWidthLayout); QVBoxLayout *rightLayout = new QVBoxLayout; @@ -344,10 +274,6 @@ void PathStrokeControls::layoutForSmallScreens() mainLayout->addWidget(quitBtn, 2, 1, Qt::AlignHCenter | Qt::AlignTop); mainLayout->addWidget(okBtn, 2, 2, Qt::AlignHCenter | Qt::AlignTop); -#if QT_CONFIG(opengl) - connect(enableOpenGLButton, &QAbstractButton::clicked, m_renderer, &ArthurFrame::enableOpenGL); -#endif - connect(penWidth, &QAbstractSlider::valueChanged, m_renderer, &PathStrokeRenderer::setPenWidth); connect(quitBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitQuitSignal); connect(okBtn, &QAbstractButton::clicked, this, &PathStrokeControls::emitOkSignal); @@ -388,7 +314,7 @@ PathStrokeWidget::PathStrokeWidget(bool smallScreen) connect(m_renderer, &PathStrokeRenderer::clicked, this, &PathStrokeWidget::showControls); connect(m_controls, &PathStrokeControls::okPressed, this, &PathStrokeWidget::hideControls); - connect(m_controls, SIGNAL(quitPressed()), QApplication::instance(), SLOT(quit())); + connect(m_controls, &PathStrokeControls::quitPressed, QApplication::instance(), &QApplication::quit); } void PathStrokeWidget::showControls() @@ -622,11 +548,11 @@ bool PathStrokeRenderer::event(QEvent *e) case QEvent::TouchUpdate: { const QTouchEvent *const event = static_cast<const QTouchEvent*>(e); - const QList<QTouchEvent::TouchPoint> points = event->touchPoints(); - for (const QTouchEvent::TouchPoint &touchPoint : points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: + const auto points = event->points(); + for (const auto &point : points) { + const int id = point.id(); + switch (point.state()) { + case QEventPoint::Pressed: { // find the point, move it const auto mappedPoints = m_fingerPointMapping.values(); @@ -638,32 +564,32 @@ bool PathStrokeRenderer::event(QEvent *e) if (activePoints.contains(i)) continue; - qreal d = QLineF(touchPoint.position(), m_points.at(i)).length(); + qreal d = QLineF(point.position(), m_points.at(i)).length(); if ((distance < 0 && d < 12 * m_pointSize) || d < distance) { distance = d; activePoint = i; } } if (activePoint != -1) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); - m_points[activePoint] = touchPoint.position(); + m_fingerPointMapping.insert(point.id(), activePoint); + m_points[activePoint] = point.position(); } break; } - case Qt::TouchPointReleased: + case QEventPoint::Released: { // move the point and release QHash<int,int>::iterator it = m_fingerPointMapping.find(id); - m_points[it.value()] = touchPoint.position(); + m_points[it.value()] = point.position(); m_fingerPointMapping.erase(it); break; } - case Qt::TouchPointMoved: + case QEventPoint::Updated: { // move the point const int pointIdx = m_fingerPointMapping.value(id, -1); if (pointIdx >= 0) - m_points[pointIdx] = touchPoint.position(); + m_points[pointIdx] = point.position(); break; } default: diff --git a/examples/widgets/painting/pathstroke/pathstroke.h b/examples/widgets/painting/pathstroke/pathstroke.h index e7e78b641b..05f678dcc6 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.h +++ b/examples/widgets/painting/pathstroke/pathstroke.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef PATHSTROKE_H #define PATHSTROKE_H diff --git a/examples/widgets/painting/shared/CMakeLists.txt b/examples/widgets/painting/shared/CMakeLists.txt index 4c7049e01d..5eaa3b42e1 100644 --- a/examples/widgets/painting/shared/CMakeLists.txt +++ b/examples/widgets/painting/shared/CMakeLists.txt @@ -1,7 +1,8 @@ -# special case: Entire file! +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -# special case: add_library(painting_shared OBJECT) +add_library(painting_shared::painting_shared ALIAS painting_shared) qt6_wrap_cpp(moc_files arthurwidgets.h hoverpoints.h) # no automoc for OBJECT libs:-/ target_sources(painting_shared PRIVATE arthurstyle.cpp arthurstyle.h @@ -9,16 +10,8 @@ target_sources(painting_shared PRIVATE hoverpoints.cpp hoverpoints.h ${moc_files} ) -target_link_libraries(painting_shared PUBLIC Qt::Widgets) -target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -## Scopes: -##################################################################### +set_target_properties(painting_shared PROPERTIES UNITY_BUILD OFF) -if (TARGET Qt::OpenGL OR QT_FEATURE_opengles2) - target_compile_definitions(painting_shared PRIVATE QT_OPENGL_SUPPORT) - target_link_libraries(painting_shared PRIVATE - Qt::OpenGL - Qt::Widgets - ) -endif() +target_link_libraries(painting_shared PUBLIC Qt6::Widgets) +target_include_directories(painting_shared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp index 31be899357..15087b8e1a 100644 --- a/examples/widgets/painting/shared/arthurstyle.cpp +++ b/examples/widgets/painting/shared/arthurstyle.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "arthurstyle.h" #include "arthurwidgets.h" @@ -441,7 +394,7 @@ int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWid void ArthurStyle::polish(QWidget *widget) { if (widget->layout() && qobject_cast<QGroupBox *>(widget)) { - if (widget->findChildren<QGroupBox *>().size() == 0) { + if (!widget->findChild<QGroupBox *>()) { widget->layout()->setSpacing(0); widget->layout()->setContentsMargins(12, 12, 12, 12); } else { diff --git a/examples/widgets/painting/shared/arthurstyle.h b/examples/widgets/painting/shared/arthurstyle.h index 64c888b636..e665a87192 100644 --- a/examples/widgets/painting/shared/arthurstyle.h +++ b/examples/widgets/painting/shared/arthurstyle.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef ARTHURSTYLE_H #define ARTHURSTYLE_H diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp index bd8a6d7b62..4ff435783b 100644 --- a/examples/widgets/painting/shared/arthurwidgets.cpp +++ b/examples/widgets/painting/shared/arthurwidgets.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "arthurwidgets.h" #include <QApplication> @@ -61,94 +14,28 @@ #include <QBoxLayout> #include <QRegularExpression> #include <QOffscreenSurface> -#include <QOpenGLContext> -#if QT_CONFIG(opengl) -#include <QtOpenGL/QOpenGLPaintDevice> -#include <QtOpenGL/QOpenGLWindow> -#endif extern QPixmap cached(const QString &img); ArthurFrame::ArthurFrame(QWidget *parent) - : QWidget(parent) - , m_prefer_image(false) + : QWidget(parent), + m_tile(QPixmap(128, 128)) { -#if QT_CONFIG(opengl) - m_glWindow = nullptr; - m_glWidget = nullptr; - m_use_opengl = false; -#endif - m_document = nullptr; - m_show_doc = false; - - m_tile = QPixmap(128, 128); m_tile.fill(Qt::white); QPainter pt(&m_tile); QColor color(230, 230, 230); pt.fillRect(0, 0, 64, 64, color); pt.fillRect(64, 64, 64, 64, color); pt.end(); - -// QPalette pal = palette(); -// pal.setBrush(backgroundRole(), m_tile); -// setPalette(pal); } - -#if QT_CONFIG(opengl) -void ArthurFrame::enableOpenGL(bool use_opengl) -{ - if (m_use_opengl == use_opengl) - return; - - m_use_opengl = use_opengl; - - if (!m_glWindow && use_opengl) { - createGlWindow(); - QApplication::postEvent(this, new QResizeEvent(size(), size())); - } - - if (use_opengl) { - m_glWidget->show(); - } else { - if (m_glWidget) - m_glWidget->hide(); - } - - update(); -} - -void ArthurFrame::createGlWindow() -{ - Q_ASSERT(m_use_opengl); - - m_glWindow = new QOpenGLWindow(); - QSurfaceFormat f = QSurfaceFormat::defaultFormat(); - f.setSamples(4); - f.setAlphaBufferSize(8); - f.setStencilBufferSize(8); - m_glWindow->setFormat(f); - m_glWindow->setFlags(Qt::WindowTransparentForInput); - m_glWindow->resize(width(), height()); - m_glWidget = QWidget::createWindowContainer(m_glWindow, this); - // create() must be called after createWindowContainer() otherwise - // an incorrect offsetting of the position will occur. - m_glWindow->create(); -} -#endif - - void ArthurFrame::paintEvent(QPaintEvent *e) { static QImage *static_image = nullptr; QPainter painter; - if (preferImage() -#if QT_CONFIG(opengl) - && !m_use_opengl -#endif - ) { + if (preferImage()) { if (!static_image || static_image->size() != size()) { delete static_image; static_image = new QImage(size(), QImage::Format_RGB32); @@ -163,18 +50,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e) painter.fillRect(0, height() - o, o, o, bg); painter.fillRect(width() - o, height() - o, o, o, bg); } else { -#if QT_CONFIG(opengl) - if (m_use_opengl && m_glWindow->isValid()) { - m_glWindow->makeCurrent(); - - painter.begin(m_glWindow); - painter.fillRect(QRectF(0, 0, m_glWindow->width(), m_glWindow->height()), palette().color(backgroundRole())); - } else { - painter.begin(this); - } -#else painter.begin(this); -#endif } painter.setClipRect(e->rect()); @@ -209,7 +85,7 @@ void ArthurFrame::paintEvent(QPaintEvent *e) painter.restore(); painter.save(); - if (m_show_doc) + if (m_showDoc) paintDescription(&painter); painter.restore(); @@ -218,35 +94,23 @@ void ArthurFrame::paintEvent(QPaintEvent *e) painter.setBrush(Qt::NoBrush); painter.drawPath(clipPath); - if (preferImage() -#if QT_CONFIG(opengl) - && !m_use_opengl -#endif - ) { + if (preferImage()) { painter.end(); painter.begin(this); painter.drawImage(e->rect(), *static_image, e->rect()); } -#if QT_CONFIG(opengl) - if (m_use_opengl) - m_glWindow->update(); -#endif } void ArthurFrame::resizeEvent(QResizeEvent *e) { -#if QT_CONFIG(opengl) - if (m_glWidget) - m_glWidget->setGeometry(0, 0, e->size().width(), e->size().height()); -#endif QWidget::resizeEvent(e); } void ArthurFrame::setDescriptionEnabled(bool enabled) { - if (m_show_doc != enabled) { - m_show_doc = enabled; - emit descriptionEnabledChanged(m_show_doc); + if (m_showDoc != enabled) { + m_showDoc = enabled; + emit descriptionEnabledChanged(m_showDoc); update(); } } @@ -276,9 +140,8 @@ void ArthurFrame::paintDescription(QPainter *painter) int pageWidth = qMax(width() - 100, 100); int pageHeight = qMax(height() - 100, 100); - if (pageWidth != m_document->pageSize().width()) { + if (pageWidth != m_document->pageSize().width()) m_document->setPageSize(QSize(pageWidth, pageHeight)); - } QRect textRect(width() / 2 - pageWidth / 2, height() / 2 - pageHeight / 2, @@ -340,7 +203,7 @@ void ArthurFrame::showSource() if (!f.open(QFile::ReadOnly)) contents = tr("Could not open file: '%1'").arg(m_sourceFileName); else - contents = f.readAll(); + contents = QString::fromUtf8(f.readAll()); } contents.replace(QLatin1Char('&'), QStringLiteral("&")); @@ -381,7 +244,7 @@ void ArthurFrame::showSource() const QString html = QStringLiteral("<html><pre>") + contents + QStringLiteral("</pre></html>"); QTextBrowser *sourceViewer = new QTextBrowser; - sourceViewer->setWindowTitle(tr("Source: %1").arg(m_sourceFileName.midRef(5))); + sourceViewer->setWindowTitle(tr("Source: %1").arg(QStringView{ m_sourceFileName }.mid(5))); sourceViewer->setParent(this, Qt::Dialog); sourceViewer->setAttribute(Qt::WA_DeleteOnClose); sourceViewer->setLineWrapMode(QTextEdit::NoWrap); diff --git a/examples/widgets/painting/shared/arthurwidgets.h b/examples/widgets/painting/shared/arthurwidgets.h index 73e1310c0e..e508e811cb 100644 --- a/examples/widgets/painting/shared/arthurwidgets.h +++ b/examples/widgets/painting/shared/arthurwidgets.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef ARTHURWIDGETS_H #define ARTHURWIDGETS_H @@ -56,7 +9,6 @@ #include <QPushButton> #include <QGroupBox> -QT_FORWARD_DECLARE_CLASS(QOpenGLWindow) QT_FORWARD_DECLARE_CLASS(QTextDocument) QT_FORWARD_DECLARE_CLASS(QTextEdit) QT_FORWARD_DECLARE_CLASS(QVBoxLayout) @@ -69,7 +21,6 @@ public: ArthurFrame(QWidget *parent); virtual void paint(QPainter *) {} - void paintDescription(QPainter *p); void loadDescription(const QString &filename); @@ -77,21 +28,13 @@ public: void loadSourceFile(const QString &fileName); - bool preferImage() const { return m_prefer_image; } -#if QT_CONFIG(opengl) - QOpenGLWindow *glWindow() const { return m_glWindow; } -#endif + bool preferImage() const { return m_preferImage; } public slots: - void setPreferImage(bool pi) { m_prefer_image = pi; } + void setPreferImage(bool pi) { m_preferImage = pi; } void setDescriptionEnabled(bool enabled); void showSource(); -#if QT_CONFIG(opengl) - void enableOpenGL(bool use_opengl); - bool usesOpenGL() { return m_use_opengl; } -#endif - signals: void descriptionEnabledChanged(bool); @@ -99,20 +42,13 @@ protected: void paintEvent(QPaintEvent *) override; void resizeEvent(QResizeEvent *) override; -#if QT_CONFIG(opengl) - virtual void createGlWindow(); - QOpenGLWindow *m_glWindow; - QWidget *m_glWidget; - bool m_use_opengl; -#endif QPixmap m_tile; - bool m_show_doc; - bool m_prefer_image; - QTextDocument *m_document; + bool m_showDoc = false; + bool m_preferImage = false; + QTextDocument *m_document = nullptr; QString m_sourceFileName; - }; #endif diff --git a/examples/widgets/painting/shared/fbopaintdevice.cpp b/examples/widgets/painting/shared/fbopaintdevice.cpp deleted file mode 100644 index 9368293218..0000000000 --- a/examples/widgets/painting/shared/fbopaintdevice.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ - -#include "fbopaintdevice.h" - -#include <QOffscreenSurface> -#include <QOpenGLFunctions> - -QFboPaintDevice::QFboPaintDevice(const QSize &size, bool flipped, bool clearOnInit, - QOpenGLFramebufferObject::Attachment attachment) - : QOpenGLPaintDevice(size) -{ - QOpenGLFramebufferObjectFormat format; - format.setAttachment(attachment); - format.setSamples(4); - m_framebufferObject = new QOpenGLFramebufferObject(size, format); - QOffscreenSurface *surface = new QOffscreenSurface(); - surface->create(); - m_surface = surface; - setPaintFlipped(flipped); - if (clearOnInit) { - m_framebufferObject->bind(); - - context()->functions()->glClearColor(0, 0, 0, 0); - context()->functions()->glClear(GL_COLOR_BUFFER_BIT); - } -} - -QFboPaintDevice::~QFboPaintDevice() -{ - delete m_framebufferObject; - delete m_surface; -} - -void QFboPaintDevice::ensureActiveTarget() -{ - if (QOpenGLContext::currentContext() != context()) - context()->makeCurrent(m_surface); - - m_framebufferObject->bind(); -} - -GLuint QFboPaintDevice::takeTexture() -{ - // We have multisamples so we can't just forward takeTexture(). - QOpenGLFramebufferObject resolvedFbo(m_framebufferObject->size(), m_framebufferObject->attachment()); - QOpenGLFramebufferObject::blitFramebuffer(&resolvedFbo, m_framebufferObject); - return resolvedFbo.takeTexture(); -} - -QImage QFboPaintDevice::toImage() const -{ - QOpenGLContext *currentContext = QOpenGLContext::currentContext(); - QSurface *currentSurface = currentContext ? currentContext->surface() : nullptr; - - context()->makeCurrent(m_surface); - - QImage image = m_framebufferObject->toImage(!paintFlipped()); - - if (currentContext) - currentContext->makeCurrent(currentSurface); - else - context()->doneCurrent(); - - return image; -} diff --git a/examples/widgets/painting/shared/fbopaintdevice.h b/examples/widgets/painting/shared/fbopaintdevice.h deleted file mode 100644 index a42bcc756d..0000000000 --- a/examples/widgets/painting/shared/fbopaintdevice.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ - -#ifndef QFBOPAINTDEVICE_H -#define QFBOPAINTDEVICE_H - -#ifndef QT_NO_OPENGL - -#include <QImage> -#include <QOpenGLFramebufferObject> -#include <QOpenGLPaintDevice> -#include <QSurface> - -class QFboPaintDevice : public QOpenGLPaintDevice { -public: - QFboPaintDevice(const QSize &size, bool flipped = false, bool clearOnInit = true, - QOpenGLFramebufferObject::Attachment = QOpenGLFramebufferObject::CombinedDepthStencil); - ~QFboPaintDevice(); - - // QOpenGLPaintDevice: - void ensureActiveTarget() override; - - bool isValid() const { return m_framebufferObject->isValid(); } - GLuint handle() const { return m_framebufferObject->handle(); } - GLuint takeTexture(); - QImage toImage() const; - - bool bind() { return m_framebufferObject->bind(); } - bool release() { return m_framebufferObject->release(); } - QSize size() const { return m_framebufferObject->size(); } - - QOpenGLFramebufferObject* framebufferObject() { return m_framebufferObject; } - const QOpenGLFramebufferObject* framebufferObject() const { return m_framebufferObject; } - - static bool isSupported() { return QOpenGLFramebufferObject::hasOpenGLFramebufferObjects(); } - -private: - QOpenGLFramebufferObject *m_framebufferObject; - QSurface *m_surface; -}; - -#endif // QT_NO_OPENGL - -#endif // QFBOPAINTDEVICE_H diff --git a/examples/widgets/painting/shared/hoverpoints.cpp b/examples/widgets/painting/shared/hoverpoints.cpp index 9fe947cedc..a917139613 100644 --- a/examples/widgets/painting/shared/hoverpoints.cpp +++ b/examples/widgets/painting/shared/hoverpoints.cpp @@ -1,87 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "arthurwidgets.h" #include "hoverpoints.h" #include <algorithm> -#if QT_CONFIG(opengl) -#include <QtOpenGL/QOpenGLWindow> -#endif - -#define printf - HoverPoints::HoverPoints(QWidget *widget, PointShape shape) - : QObject(widget) + : QObject(widget), + m_widget(widget), + m_shape(shape) { - m_widget = widget; widget->installEventFilter(this); widget->setAttribute(Qt::WA_AcceptTouchEvents); - m_connectionType = CurveConnection; - m_sortType = NoSort; - m_shape = shape; - m_pointPen = QPen(QColor(255, 255, 255, 191), 1); - m_connectionPen = QPen(QColor(255, 255, 255, 127), 2); - m_pointBrush = QBrush(QColor(191, 191, 191, 127)); - m_pointSize = QSize(11, 11); - m_currentIndex = -1; - m_editable = true; - m_enabled = true; - connect(this, &HoverPoints::pointsChanged, m_widget, QOverload<>::of(&QWidget::update)); } - void HoverPoints::setEnabled(bool enabled) { if (m_enabled != enabled) { @@ -90,191 +26,200 @@ void HoverPoints::setEnabled(bool enabled) } } - bool HoverPoints::eventFilter(QObject *object, QEvent *event) { - if (object == m_widget && m_enabled) { - switch (event->type()) { + if (object != m_widget || !m_enabled) + return false; - case QEvent::MouseButtonPress: - { - if (!m_fingerPointMapping.isEmpty()) - return true; - QMouseEvent *me = (QMouseEvent *) event; - - QPointF clickPos = me->position().toPoint(); - int index = -1; - for (int i=0; i<m_points.size(); ++i) { - QPainterPath path; - if (m_shape == CircleShape) - path.addEllipse(pointBoundingRect(i)); - else - path.addRect(pointBoundingRect(i)); - - if (path.contains(clickPos)) { - index = i; - break; - } + switch (event->type()) { + case QEvent::MouseButtonPress: + { + if (!m_fingerPointMapping.isEmpty()) + return true; + auto *me = static_cast<const QMouseEvent *>(event); + QPointF clickPos = me->position().toPoint(); + qsizetype index = -1; + for (qsizetype i = 0; i < m_points.size(); ++i) { + QPainterPath path; + const QRectF rect = pointBoundingRect(m_points.at(i)); + if (m_shape == CircleShape) + path.addEllipse(rect); + else + path.addRect(rect); + + if (path.contains(clickPos)) { + index = i; + break; } + } - if (me->button() == Qt::LeftButton) { - if (index == -1) { - if (!m_editable) - return false; - int pos = 0; - // Insert sort for x or y - if (m_sortType == XSort) { - for (int i=0; i<m_points.size(); ++i) - if (m_points.at(i).x() > clickPos.x()) { - pos = i; - break; - } - } else if (m_sortType == YSort) { - for (int i=0; i<m_points.size(); ++i) - if (m_points.at(i).y() > clickPos.y()) { - pos = i; - break; - } + if (me->button() == Qt::LeftButton) { + if (index == -1) { + if (!m_editable) + return false; + qsizetype pos = 0; + // Insert sort for x or y + switch (m_sortType) { + case XSort: + for (qsizetype i = 0; i < m_points.size(); ++i) { + if (m_points.at(i).x() > clickPos.x()) { + pos = i; + break; + } } - - m_points.insert(pos, clickPos); - m_locks.insert(pos, 0); - m_currentIndex = pos; - firePointChange(); - } else { - m_currentIndex = index; - } - return true; - - } else if (me->button() == Qt::RightButton) { - if (index >= 0 && m_editable) { - if (m_locks[index] == 0) { - m_locks.remove(index); - m_points.remove(index); + break; + case YSort: + for (qsizetype i = 0; i < m_points.size(); ++i) { + if (m_points.at(i).y() > clickPos.y()) { + pos = i; + break; + } } - firePointChange(); - return true; + break; + default: + break; } + + m_points.insert(pos, clickPos); + m_locks.insert(pos, 0); + m_currentIndex = pos; + firePointChange(); + } else { + m_currentIndex = index; } + return true; + } else if (me->button() == Qt::RightButton) { + if (index >= 0 && m_editable) { + if (m_locks[index] == 0) { + m_locks.remove(index); + m_points.remove(index); + } + firePointChange(); + return true; + } } + } + break; + + case QEvent::MouseButtonRelease: + if (!m_fingerPointMapping.isEmpty()) + return true; + m_currentIndex = -1; break; - case QEvent::MouseButtonRelease: - if (!m_fingerPointMapping.isEmpty()) - return true; - m_currentIndex = -1; - break; + case QEvent::MouseMove: + if (!m_fingerPointMapping.isEmpty()) + return true; + if (m_currentIndex >= 0) { + auto *me = static_cast<const QMouseEvent *>(event); + movePoint(m_currentIndex, me->position().toPoint()); + } + break; - case QEvent::MouseMove: - if (!m_fingerPointMapping.isEmpty()) - return true; - if (m_currentIndex >= 0) - movePoint(m_currentIndex, ((QMouseEvent *)event)->position().toPoint()); - break; - case QEvent::TouchBegin: - case QEvent::TouchUpdate: + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + { + auto *touchEvent = static_cast<const QTouchEvent*>(event); + const auto points = touchEvent->points(); + const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); + for (const auto &point : points) { + const int id = point.id(); + switch (point.state()) { + case QEventPoint::Pressed: + case QEventPoint::Stationary: { - const QTouchEvent *const touchEvent = static_cast<const QTouchEvent*>(event); - const QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints(); - const qreal pointSize = qMax(m_pointSize.width(), m_pointSize.height()); - for (const QTouchEvent::TouchPoint &touchPoint : points) { - const int id = touchPoint.id(); - switch (touchPoint.state()) { - case Qt::TouchPointPressed: - { - // find the point, move it - const auto mappedPoints = m_fingerPointMapping.values(); - QSet<int> activePoints = QSet<int>(mappedPoints.begin(), mappedPoints.end()); - int activePoint = -1; - qreal distance = -1; - const int pointsCount = m_points.size(); - const int activePointCount = activePoints.size(); - if (pointsCount == 2 && activePointCount == 1) { // only two points - activePoint = activePoints.contains(0) ? 1 : 0; - } else { - for (int i=0; i<pointsCount; ++i) { - if (activePoints.contains(i)) - continue; - - qreal d = QLineF(touchPoint.position(), m_points.at(i)).length(); - if ((distance < 0 && d < 12 * pointSize) || d < distance) { - distance = d; - activePoint = i; - } - - } - } - if (activePoint != -1) { - m_fingerPointMapping.insert(touchPoint.id(), activePoint); - movePoint(activePoint, touchPoint.position()); - } - } - break; - case Qt::TouchPointReleased: - { - // move the point and release - QHash<int,int>::iterator it = m_fingerPointMapping.find(id); - movePoint(it.value(), touchPoint.position()); - m_fingerPointMapping.erase(it); - } - break; - case Qt::TouchPointMoved: - { - // move the point - const int pointIdx = m_fingerPointMapping.value(id, -1); - if (pointIdx >= 0) // do we track this point? - movePoint(pointIdx, touchPoint.position()); + // find the point, move it + const auto mappedPoints = m_fingerPointMapping.values(); + QSet<qsizetype> activePoints(mappedPoints.begin(), mappedPoints.end()); + qsizetype activePoint = -1; + qreal distance = -1; + const qsizetype pointsCount = m_points.size(); + const qsizetype activePointCount = activePoints.size(); + if (pointsCount == 2 && activePointCount == 1) { // only two points + activePoint = activePoints.contains(0) ? 1 : 0; + } else { + for (qsizetype i = 0; i < pointsCount; ++i) { + if (activePoints.contains(i)) + continue; + + qreal d = QLineF(point.position(), m_points.at(i)).length(); + if ((distance < 0 && d < 12 * pointSize) || d < distance) { + distance = d; + activePoint = i; } - break; - default: - break; + } } - if (m_fingerPointMapping.isEmpty()) { - event->ignore(); - return false; - } else { - return true; + if (activePoint != -1) { + m_fingerPointMapping.insert(id, activePoint); + movePoint(activePoint, point.position()); } } break; - case QEvent::TouchEnd: - if (m_fingerPointMapping.isEmpty()) { - event->ignore(); - return false; + case QEventPoint::Released: + { + // move the point and release + const auto it = m_fingerPointMapping.constFind(id); + if (it != m_fingerPointMapping.constEnd()) { + movePoint(it.value(), point.position()); + m_fingerPointMapping.erase(it); + } } - return true; break; - - case QEvent::Resize: - { - QResizeEvent *e = (QResizeEvent *) event; - if (e->oldSize().width() == 0 || e->oldSize().height() == 0) - break; - qreal stretch_x = e->size().width() / qreal(e->oldSize().width()); - qreal stretch_y = e->size().height() / qreal(e->oldSize().height()); - for (int i=0; i<m_points.size(); ++i) { - QPointF p = m_points[i]; - movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false); + case QEventPoint::Updated: + { + // move the point + const qsizetype pointIdx = m_fingerPointMapping.value(id, -1); + if (pointIdx >= 0) // do we track this point? + movePoint(pointIdx, point.position()); } - - firePointChange(); break; + default: + break; + } } - - case QEvent::Paint: - { - QWidget *that_widget = m_widget; - m_widget = nullptr; - QCoreApplication::sendEvent(object, event); - m_widget = that_widget; - paintPoints(); - return true; + if (m_fingerPointMapping.isEmpty()) { + event->ignore(); + return false; + } + return true; + } + case QEvent::TouchEnd: + if (m_fingerPointMapping.isEmpty()) { + event->ignore(); + return false; } - default: + return true; + + case QEvent::Resize: + { + auto *e = static_cast<const QResizeEvent *>(event); + if (e->oldSize().width() <= 0 || e->oldSize().height() <= 0) break; + qreal stretch_x = e->size().width() / qreal(e->oldSize().width()); + qreal stretch_y = e->size().height() / qreal(e->oldSize().height()); + for (qsizetype i = 0; i < m_points.size(); ++i) { + QPointF p = m_points.at(i); + movePoint(i, QPointF(p.x() * stretch_x, p.y() * stretch_y), false); } + + firePointChange(); + break; + } + + case QEvent::Paint: + { + QWidget *that_widget = m_widget; + m_widget = nullptr; + QCoreApplication::sendEvent(object, event); + m_widget = that_widget; + paintPoints(); + return true; + } + + default: + break; } return false; @@ -284,17 +229,7 @@ bool HoverPoints::eventFilter(QObject *object, QEvent *event) void HoverPoints::paintPoints() { QPainter p; -#if QT_CONFIG(opengl) - ArthurFrame *af = qobject_cast<ArthurFrame *>(m_widget); - if (af && af->usesOpenGL() && af->glWindow()->isValid()) { - af->glWindow()->makeCurrent(); - p.begin(af->glWindow()); - } else { - p.begin(m_widget); - } -#else p.begin(m_widget); -#endif p.setRenderHint(QPainter::Antialiasing); @@ -304,8 +239,8 @@ void HoverPoints::paintPoints() if (m_connectionType == CurveConnection) { QPainterPath path; path.moveTo(m_points.at(0)); - for (int i=1; i<m_points.size(); ++i) { - QPointF p1 = m_points.at(i-1); + for (qsizetype i = 1; i < m_points.size(); ++i) { + QPointF p1 = m_points.at(i - 1); QPointF p2 = m_points.at(i); qreal distance = p2.x() - p1.x(); @@ -322,8 +257,8 @@ void HoverPoints::paintPoints() p.setPen(m_pointPen); p.setBrush(m_pointBrush); - for (int i=0; i<m_points.size(); ++i) { - QRectF bounds = pointBoundingRect(i); + for (const auto &point : std::as_const(m_points)) { + QRectF bounds = pointBoundingRect(point); if (m_shape == CircleShape) p.drawEllipse(bounds); else @@ -354,32 +289,28 @@ void HoverPoints::setPoints(const QPolygonF &points) if (points.size() != m_points.size()) m_fingerPointMapping.clear(); m_points.clear(); - for (int i=0; i<points.size(); ++i) + for (qsizetype i = 0; i < points.size(); ++i) m_points << bound_point(points.at(i), boundingRect(), 0); m_locks.clear(); if (m_points.size() > 0) { m_locks.resize(m_points.size()); - m_locks.fill(0); } } - -void HoverPoints::movePoint(int index, const QPointF &point, bool emitUpdate) +void HoverPoints::movePoint(qsizetype index, const QPointF &point, bool emitUpdate) { m_points[index] = bound_point(point, boundingRect(), m_locks.at(index)); if (emitUpdate) firePointChange(); } - inline static bool x_less_than(const QPointF &p1, const QPointF &p2) { return p1.x() < p2.x(); } - inline static bool y_less_than(const QPointF &p1, const QPointF &p2) { return p1.y() < p2.y(); @@ -387,14 +318,11 @@ inline static bool y_less_than(const QPointF &p1, const QPointF &p2) void HoverPoints::firePointChange() { -// printf("HoverPoints::firePointChange(), current=%d\n", m_currentIndex); - if (m_sortType != NoSort) { QPointF oldCurrent; - if (m_currentIndex != -1) { + if (m_currentIndex != -1) oldCurrent = m_points[m_currentIndex]; - } if (m_sortType == XSort) std::sort(m_points.begin(), m_points.end(), x_less_than); @@ -403,22 +331,14 @@ void HoverPoints::firePointChange() // Compensate for changed order... if (m_currentIndex != -1) { - for (int i=0; i<m_points.size(); ++i) { + for (qsizetype i = 0; i < m_points.size(); ++i) { if (m_points[i] == oldCurrent) { m_currentIndex = i; break; } } } - -// printf(" - firePointChange(), current=%d\n", m_currentIndex); - } -// for (int i=0; i<m_points.size(); ++i) { -// printf(" - point(%2d)=[%.2f, %.2f], lock=%d\n", -// i, m_points.at(i).x(), m_points.at(i).y(), m_locks.at(i)); -// } - emit pointsChanged(m_points); } diff --git a/examples/widgets/painting/shared/hoverpoints.h b/examples/widgets/painting/shared/hoverpoints.h index 3c6f356e1b..cac0dd5892 100644 --- a/examples/widgets/painting/shared/hoverpoints.h +++ b/examples/widgets/painting/shared/hoverpoints.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the demonstration applications 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef HOVERPOINTS_H #define HOVERPOINTS_H @@ -124,35 +77,33 @@ public: void firePointChange(); private: - inline QRectF pointBoundingRect(int i) const; - void movePoint(int i, const QPointF &newPos, bool emitChange = true); + inline QRectF pointBoundingRect(const QPointF &p) const; + void movePoint(qsizetype i, const QPointF &newPos, bool emitChange = true); QWidget *m_widget; QPolygonF m_points; QRectF m_bounds; PointShape m_shape; - SortType m_sortType; - ConnectionType m_connectionType; + SortType m_sortType = NoSort; + ConnectionType m_connectionType = CurveConnection; QList<uint> m_locks; - QSizeF m_pointSize; - int m_currentIndex; - bool m_editable; - bool m_enabled; + QSizeF m_pointSize{11, 11}; + qsizetype m_currentIndex= -1; + bool m_editable = true; + bool m_enabled = true; - QHash<int, int> m_fingerPointMapping; + QHash<int, qsizetype> m_fingerPointMapping; - QPen m_pointPen; - QBrush m_pointBrush; - QPen m_connectionPen; + QPen m_pointPen{QColor(255, 255, 255, 191), 1}; + QBrush m_pointBrush{QColor(191, 191, 191, 127)}; + QPen m_connectionPen{QColor(255, 255, 255, 127), 2}; }; - -inline QRectF HoverPoints::pointBoundingRect(int i) const +inline QRectF HoverPoints::pointBoundingRect(const QPointF &p) const { - QPointF p = m_points.at(i); qreal w = m_pointSize.width(); qreal h = m_pointSize.height(); qreal x = p.x() - w / 2; diff --git a/examples/widgets/painting/shared/shared.pri b/examples/widgets/painting/shared/shared.pri index 7e2b4df8cb..77881b03cc 100644 --- a/examples/widgets/painting/shared/shared.pri +++ b/examples/widgets/painting/shared/shared.pri @@ -1,11 +1,5 @@ INCLUDEPATH += $$PWD -qtConfig(opengl) { - QT += opengl - SOURCES += $$PWD/fbopaintdevice.cpp - HEADERS += $$PWD/fbopaintdevice.h -} - SOURCES += \ $$PWD/arthurstyle.cpp\ $$PWD/arthurwidgets.cpp \ diff --git a/examples/widgets/painting/shared/use_lib.cmake b/examples/widgets/painting/shared/use_lib.cmake new file mode 100644 index 0000000000..84684a3444 --- /dev/null +++ b/examples/widgets/painting/shared/use_lib.cmake @@ -0,0 +1,12 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +# Include this file in your example project to use the library defined in this directory. +# This avoids find_package calls in a directory scope different from the directory scope of the +# consuming target. + +if(NOT TARGET Qt::Widgets) + find_package(Qt6 REQUIRED COMPONENTS Widgets) +endif() + +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}" painting_shared) diff --git a/examples/widgets/painting/transformations/CMakeLists.txt b/examples/widgets/painting/transformations/CMakeLists.txt index b5725967ea..dfc35b2551 100644 --- a/examples/widgets/painting/transformations/CMakeLists.txt +++ b/examples/widgets/painting/transformations/CMakeLists.txt @@ -1,33 +1,39 @@ -# Generated from transformations.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.16) project(transformations LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) +qt_standard_project_setup() -set(INSTALL_EXAMPLEDIR "examples/widgets/painting/transformations") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(transformations +qt_add_executable(transformations main.cpp renderarea.cpp renderarea.h window.cpp window.h ) -target_link_libraries(transformations PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +set_target_properties(transformations PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(transformations PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS transformations - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET transformations + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/painting/transformations/main.cpp b/examples/widgets/painting/transformations/main.cpp index 99725195e5..27409403a5 100644 --- a/examples/widgets/painting/transformations/main.cpp +++ b/examples/widgets/painting/transformations/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/painting/transformations/renderarea.cpp b/examples/widgets/painting/transformations/renderarea.cpp index 1ebdfd5423..f967db6ee6 100644 --- a/examples/widgets/painting/transformations/renderarea.cpp +++ b/examples/widgets/painting/transformations/renderarea.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "renderarea.h" diff --git a/examples/widgets/painting/transformations/renderarea.h b/examples/widgets/painting/transformations/renderarea.h index d4be7cefa4..37286a889a 100644 --- a/examples/widgets/painting/transformations/renderarea.h +++ b/examples/widgets/painting/transformations/renderarea.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef RENDERAREA_H #define RENDERAREA_H diff --git a/examples/widgets/painting/transformations/window.cpp b/examples/widgets/painting/transformations/window.cpp index a07e4dd5d1..fb1512c256 100644 --- a/examples/widgets/painting/transformations/window.cpp +++ b/examples/widgets/painting/transformations/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" diff --git a/examples/widgets/painting/transformations/window.h b/examples/widgets/painting/transformations/window.h index a1129a3609..550817acce 100644 --- a/examples/widgets/painting/transformations/window.h +++ b/examples/widgets/painting/transformations/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H |