summaryrefslogtreecommitdiffstats
path: root/examples/widgets/painting/composition
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/painting/composition')
-rw-r--r--examples/widgets/painting/composition/.prev_CMakeLists.txt220
-rw-r--r--examples/widgets/painting/composition/CMakeLists.txt248
-rw-r--r--examples/widgets/painting/composition/composition.cpp164
-rw-r--r--examples/widgets/painting/composition/composition.h65
-rw-r--r--examples/widgets/painting/composition/main.cpp51
5 files changed, 86 insertions, 662 deletions
diff --git a/examples/widgets/painting/composition/.prev_CMakeLists.txt b/examples/widgets/painting/composition/.prev_CMakeLists.txt
deleted file mode 100644
index a61e5fe2dd..0000000000
--- a/examples/widgets/painting/composition/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,220 +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)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/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 0b359735d2..b88ee42e41 100644
--- a/examples/widgets/painting/composition/CMakeLists.txt
+++ b/examples/widgets/painting/composition/CMakeLists.txt
@@ -1,186 +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()
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/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
@@ -188,6 +76,7 @@ qt6_add_resources(composition "shared"
FILES
${shared_resource_files}
)
+
set(composition_resource_files
"composition.cpp"
"composition.html"
@@ -195,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"