diff options
Diffstat (limited to 'examples/widgets/painting/affine')
-rw-r--r-- | examples/widgets/painting/affine/.prev_CMakeLists.txt | 223 | ||||
-rw-r--r-- | examples/widgets/painting/affine/CMakeLists.txt | 256 | ||||
-rw-r--r-- | examples/widgets/painting/affine/main.cpp | 55 | ||||
-rw-r--r-- | examples/widgets/painting/affine/xform.cpp | 156 | ||||
-rw-r--r-- | examples/widgets/painting/affine/xform.h | 67 |
5 files changed, 121 insertions, 636 deletions
diff --git a/examples/widgets/painting/affine/.prev_CMakeLists.txt b/examples/widgets/painting/affine/.prev_CMakeLists.txt deleted file mode 100644 index d367ef75bd..0000000000 --- a/examples/widgets/painting/affine/.prev_CMakeLists.txt +++ /dev/null @@ -1,223 +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) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/affine") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_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 -) -set_target_properties(affine PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -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 c3323693b8..dd39086620 100644 --- a/examples/widgets/painting/affine/CMakeLists.txt +++ b/examples/widgets/painting/affine/CMakeLists.txt @@ -1,201 +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) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/affine") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(affine - # special case begin - # remove files from ../shared - #../shared/arthurstyle.cpp ../shared/arthurstyle.h - #../shared/arthurwidgets.cpp ../shared/arthurwidgets.h - #../shared/hoverpoints.cpp ../shared/hoverpoints.h - # special case end main.cpp xform.cpp xform.h ) + set_target_properties(affine PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_include_directories(affine PUBLIC - ../shared -) -# special case begin if(NOT TARGET painting_shared::painting_shared) - add_subdirectory(../shared painting_shared) + include(../shared/use_lib.cmake) endif() -# special case end -target_link_libraries(affine PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared::painting_shared # special case +target_link_libraries(affine PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) - # 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" + "../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" +) + +qt_add_resources(affine "shared" PREFIX "/res" BASE @@ -203,34 +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} ) -# special case begin -# remove files from ../shared -#if(QT_FEATURE_opengl) - #target_sources(affine PUBLIC - #../shared/fbopaintdevice.cpp ../shared/fbopaintdevice.h - #) - - #target_link_libraries(affine PUBLIC - #Qt::OpenGL - #) -#endif() -# special case end - 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; |