diff options
Diffstat (limited to 'examples/widgets/painting/deform')
-rw-r--r-- | examples/widgets/painting/deform/.prev_CMakeLists.txt | 117 | ||||
-rw-r--r-- | examples/widgets/painting/deform/CMakeLists.txt | 75 | ||||
-rw-r--r-- | examples/widgets/painting/deform/main.cpp | 53 | ||||
-rw-r--r-- | examples/widgets/painting/deform/pathdeform.cpp | 127 | ||||
-rw-r--r-- | examples/widgets/painting/deform/pathdeform.h | 51 |
5 files changed, 37 insertions, 386 deletions
diff --git a/examples/widgets/painting/deform/.prev_CMakeLists.txt b/examples/widgets/painting/deform/.prev_CMakeLists.txt deleted file mode 100644 index c99df00a5a..0000000000 --- a/examples/widgets/painting/deform/.prev_CMakeLists.txt +++ /dev/null @@ -1,117 +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) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/deform") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_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 -) -set_target_properties(deform PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_include_directories(deform PUBLIC - ../shared -) - -target_link_libraries(deform PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(shared_resource_files - "../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" - 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 6ab43cc371..1038df03ad 100644 --- a/examples/widgets/painting/deform/CMakeLists.txt +++ b/examples/widgets/painting/deform/CMakeLists.txt @@ -1,56 +1,34 @@ -# 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) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/painting/deform") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(deform - # 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 pathdeform.cpp pathdeform.h ) + set_target_properties(deform PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_include_directories(deform PUBLIC - ../shared -) -# special case begin if(NOT TARGET painting_shared::painting_shared) include(../shared/use_lib.cmake) endif() -# special case end -target_link_libraries(deform PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets - painting_shared::painting_shared # special case +target_link_libraries(deform PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets + painting_shared::painting_shared ) - # Resources: set(shared_resource_files "../shared/images/button_normal_cap_left.png" @@ -90,7 +68,7 @@ set(shared_resource_files "../shared/images/title_stretch.png" ) -qt6_add_resources(deform "shared" +qt_add_resources(deform "shared" PREFIX "/res" BASE @@ -98,33 +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} ) -# 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 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 |