summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/tools')
-rw-r--r--examples/widgets/tools/.prev_CMakeLists.txt17
-rw-r--r--examples/widgets/tools/CMakeLists.txt24
-rw-r--r--examples/widgets/tools/completer/CMakeLists.txt51
-rw-r--r--examples/widgets/tools/completer/fsmodel.cpp51
-rw-r--r--examples/widgets/tools/completer/fsmodel.h51
-rw-r--r--examples/widgets/tools/completer/main.cpp53
-rw-r--r--examples/widgets/tools/completer/mainwindow.cpp51
-rw-r--r--examples/widgets/tools/completer/mainwindow.h51
-rw-r--r--examples/widgets/tools/customcompleter/CMakeLists.txt51
-rw-r--r--examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc28
-rw-r--r--examples/widgets/tools/customcompleter/main.cpp53
-rw-r--r--examples/widgets/tools/customcompleter/mainwindow.cpp51
-rw-r--r--examples/widgets/tools/customcompleter/mainwindow.h51
-rw-r--r--examples/widgets/tools/customcompleter/textedit.cpp51
-rw-r--r--examples/widgets/tools/customcompleter/textedit.h51
-rw-r--r--examples/widgets/tools/echoplugin/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/echoplugin/echoplugin.pro5
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt37
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt37
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echointerface.h74
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.cpp137
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.h89
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/echowindow.pro21
-rw-r--r--examples/widgets/tools/echoplugin/echowindow/main.cpp66
-rw-r--r--examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt35
-rw-r--r--examples/widgets/tools/echoplugin/plugin/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.cpp58
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.h70
-rw-r--r--examples/widgets/tools/echoplugin/plugin/echoplugin.json1
-rw-r--r--examples/widgets/tools/echoplugin/plugin/plugin.pro18
-rw-r--r--examples/widgets/tools/i18n/CMakeLists.txt63
-rw-r--r--examples/widgets/tools/i18n/i18n.pro27
-rw-r--r--examples/widgets/tools/i18n/i18n.qrc18
-rw-r--r--examples/widgets/tools/i18n/languagechooser.cpp181
-rw-r--r--examples/widgets/tools/i18n/languagechooser.h96
-rw-r--r--examples/widgets/tools/i18n/main.cpp64
-rw-r--r--examples/widgets/tools/i18n/mainwindow.cpp113
-rw-r--r--examples/widgets/tools/i18n/mainwindow.h86
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ar.qmbin736 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ar.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_cs.qmbin796 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_cs.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_de.qmbin848 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_de.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_el.qmbin804 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_el.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_en.qmbin810 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_en.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_eo.qmbin806 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_eo.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_fr.qmbin844 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_fr.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_it.qmbin808 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_it.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_jp.qmbin722 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_jp.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ko.qmbin690 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ko.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_no.qmbin804 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_no.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ru.qmbin806 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_ru.ts59
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_sv.qmbin814 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_sv.ts57
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_zh.qmbin700 -> 0 bytes
-rw-r--r--examples/widgets/tools/i18n/translations/i18n_zh.ts57
-rw-r--r--examples/widgets/tools/plugandpaint/CMakeLists.txt7
-rw-r--r--examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt70
-rw-r--r--examples/widgets/tools/plugandpaint/app/CMakeLists.txt72
-rw-r--r--examples/widgets/tools/plugandpaint/app/app.pro33
-rw-r--r--examples/widgets/tools/plugandpaint/app/interfaces.h124
-rw-r--r--examples/widgets/tools/plugandpaint/app/main.cpp66
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.cpp329
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.h115
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.cpp199
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.h101
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.cpp165
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.h86
-rw-r--r--examples/widgets/tools/plugandpaint/plugandpaint.pro7
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt4
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt36
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json1
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro17
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp197
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h101
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt36
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt40
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json1
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro17
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp129
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h75
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/plugins.pro3
-rw-r--r--examples/widgets/tools/regularexpression/CMakeLists.txt51
-rw-r--r--examples/widgets/tools/regularexpression/main.cpp51
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.cpp169
-rw-r--r--examples/widgets/tools/regularexpression/regularexpressiondialog.h67
-rw-r--r--examples/widgets/tools/settingseditor/CMakeLists.txt39
-rw-r--r--examples/widgets/tools/settingseditor/inifiles/licensepage.ini46
-rw-r--r--examples/widgets/tools/settingseditor/inifiles/qsa.ini26
-rw-r--r--examples/widgets/tools/settingseditor/locationdialog.cpp240
-rw-r--r--examples/widgets/tools/settingseditor/locationdialog.h96
-rw-r--r--examples/widgets/tools/settingseditor/main.cpp64
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp222
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.h91
-rw-r--r--examples/widgets/tools/settingseditor/settingseditor.pro18
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp278
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.h108
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.cpp424
-rw-r--r--examples/widgets/tools/settingseditor/variantdelegate.h100
-rw-r--r--examples/widgets/tools/styleplugin/.prev_CMakeLists.txt4
-rw-r--r--examples/widgets/tools/styleplugin/CMakeLists.txt19
-rw-r--r--examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt32
-rw-r--r--examples/widgets/tools/styleplugin/plugin/CMakeLists.txt37
-rw-r--r--examples/widgets/tools/styleplugin/plugin/plugin.pro24
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.cpp56
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.h66
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyle.json3
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp68
-rw-r--r--examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h70
-rw-r--r--examples/widgets/tools/styleplugin/styleplugin.pro3
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt36
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/main.cpp68
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp72
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.h64
-rw-r--r--examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro19
-rw-r--r--examples/widgets/tools/tools.pro13
-rw-r--r--examples/widgets/tools/treemodelcompleter/CMakeLists.txt51
-rw-r--r--examples/widgets/tools/treemodelcompleter/main.cpp53
-rw-r--r--examples/widgets/tools/treemodelcompleter/mainwindow.cpp56
-rw-r--r--examples/widgets/tools/treemodelcompleter/mainwindow.h51
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp51
-rw-r--r--examples/widgets/tools/treemodelcompleter/treemodelcompleter.h51
-rw-r--r--examples/widgets/tools/undo/CMakeLists.txt66
-rw-r--r--examples/widgets/tools/undo/commands.cpp177
-rw-r--r--examples/widgets/tools/undo/commands.h123
-rw-r--r--examples/widgets/tools/undo/document.cpp448
-rw-r--r--examples/widgets/tools/undo/document.h133
-rw-r--r--examples/widgets/tools/undo/icons/background.pngbin93 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/blue.pngbin1659 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/circle.pngbin1359 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/exit.pngbin1731 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/fileclose.pngbin1121 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/filenew.pngbin1266 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/fileopen.pngbin1771 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/filesave.pngbin1022 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/green.pngbin1766 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/ok.pngbin979 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/icons/red.pngbin1653 -> 0 bytes
-rw-r--r--examples/widgets/tools/undo/main.cpp68
-rw-r--r--examples/widgets/tools/undo/mainwindow.cpp457
-rw-r--r--examples/widgets/tools/undo/mainwindow.h96
-rw-r--r--examples/widgets/tools/undo/mainwindow.ui322
-rw-r--r--examples/widgets/tools/undo/undo.pro17
-rw-r--r--examples/widgets/tools/undo/undo.qrc20
-rw-r--r--examples/widgets/tools/undoframework/CMakeLists.txt58
-rw-r--r--examples/widgets/tools/undoframework/commands.cpp51
-rw-r--r--examples/widgets/tools/undoframework/commands.h51
-rw-r--r--examples/widgets/tools/undoframework/diagramitem.cpp51
-rw-r--r--examples/widgets/tools/undoframework/diagramitem.h51
-rw-r--r--examples/widgets/tools/undoframework/diagramscene.cpp51
-rw-r--r--examples/widgets/tools/undoframework/diagramscene.h51
-rw-r--r--examples/widgets/tools/undoframework/icons/cross.pngbin0 -> 356 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/rectangle.png (renamed from examples/widgets/tools/undo/icons/rectangle.png)bin690 -> 690 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/redo.png (renamed from examples/widgets/tools/undo/icons/redo.png)bin985 -> 985 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/remove.png (renamed from examples/widgets/tools/undo/icons/remove.png)bin1833 -> 1833 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/triangle.png (renamed from examples/widgets/tools/undo/icons/triangle.png)bin850 -> 850 bytes
-rw-r--r--examples/widgets/tools/undoframework/icons/undo.png (renamed from examples/widgets/tools/undo/icons/undo.png)bin962 -> 962 bytes
-rw-r--r--examples/widgets/tools/undoframework/images/cross.pngbin114 -> 0 bytes
-rw-r--r--examples/widgets/tools/undoframework/main.cpp53
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.cpp142
-rw-r--r--examples/widgets/tools/undoframework/mainwindow.h55
-rw-r--r--examples/widgets/tools/undoframework/undoframework.qrc8
173 files changed, 363 insertions, 10139 deletions
diff --git a/examples/widgets/tools/.prev_CMakeLists.txt b/examples/widgets/tools/.prev_CMakeLists.txt
deleted file mode 100644
index 29e7f8f9e8..0000000000
--- a/examples/widgets/tools/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Generated from tools.pro.
-
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
-if(QT_FEATURE_library)
- add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint)
-endif()
-if(QT_FEATURE_translation)
- add_subdirectory(i18n)
-endif()
diff --git a/examples/widgets/tools/CMakeLists.txt b/examples/widgets/tools/CMakeLists.txt
index 022f4a2b8f..a5ec5c4a3e 100644
--- a/examples/widgets/tools/CMakeLists.txt
+++ b/examples/widgets/tools/CMakeLists.txt
@@ -1,18 +1,8 @@
-# Generated from tools.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-add_subdirectory(completer)
-add_subdirectory(customcompleter)
-if(QT_FEATURE_translation) # special case
- add_subdirectory(i18n)
-endif()
-add_subdirectory(regularexpression)
-add_subdirectory(settingseditor)
-add_subdirectory(styleplugin)
-add_subdirectory(treemodelcompleter)
-add_subdirectory(undo)
-add_subdirectory(undoframework)
-
-if(QT_FEATURE_library) # special case
- add_subdirectory(echoplugin)
- add_subdirectory(plugandpaint) # special case
-endif()
+qt_internal_add_example(completer)
+qt_internal_add_example(customcompleter)
+qt_internal_add_example(regularexpression)
+qt_internal_add_example(treemodelcompleter)
+qt_internal_add_example(undoframework)
diff --git a/examples/widgets/tools/completer/CMakeLists.txt b/examples/widgets/tools/completer/CMakeLists.txt
index 18359e54e3..a4ad8055b9 100644
--- a/examples/widgets/tools/completer/CMakeLists.txt
+++ b/examples/widgets/tools/completer/CMakeLists.txt
@@ -1,35 +1,29 @@
-# Generated from completer.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(completer 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/tools/completer")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(completer
+qt_add_executable(completer
fsmodel.cpp fsmodel.h
main.cpp
mainwindow.cpp mainwindow.h
)
-target_link_libraries(completer PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+set_target_properties(completer PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
)
+target_link_libraries(completer PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set(completer_resource_files
@@ -37,7 +31,7 @@ set(completer_resource_files
"resources/wordlist.txt"
)
-qt6_add_resources(completer "completer"
+qt_add_resources(completer "completer"
PREFIX
"/"
FILES
@@ -45,7 +39,14 @@ qt6_add_resources(completer "completer"
)
install(TARGETS completer
- 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 completer
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/completer/fsmodel.cpp b/examples/widgets/tools/completer/fsmodel.cpp
index caa0e824b8..13357a9889 100644
--- a/examples/widgets/tools/completer/fsmodel.cpp
+++ b/examples/widgets/tools/completer/fsmodel.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 "fsmodel.h"
diff --git a/examples/widgets/tools/completer/fsmodel.h b/examples/widgets/tools/completer/fsmodel.h
index 587e08b192..4157cd33c0 100644
--- a/examples/widgets/tools/completer/fsmodel.h
+++ b/examples/widgets/tools/completer/fsmodel.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 FILESYSTEMMODEL_H
#define FILESYSTEMMODEL_H
diff --git a/examples/widgets/tools/completer/main.cpp b/examples/widgets/tools/completer/main.cpp
index 165be38f0e..060dfe5bd8 100644
--- a/examples/widgets/tools/completer/main.cpp
+++ b/examples/widgets/tools/completer/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>
#include "mainwindow.h"
@@ -54,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(completer);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/completer/mainwindow.cpp b/examples/widgets/tools/completer/mainwindow.cpp
index 8e9c0e0615..3b70d76ef0 100644
--- a/examples/widgets/tools/completer/mainwindow.cpp
+++ b/examples/widgets/tools/completer/mainwindow.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 "mainwindow.h"
#include "fsmodel.h"
diff --git a/examples/widgets/tools/completer/mainwindow.h b/examples/widgets/tools/completer/mainwindow.h
index 6e6238bf32..5cfa490b9f 100644
--- a/examples/widgets/tools/completer/mainwindow.h
+++ b/examples/widgets/tools/completer/mainwindow.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 MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/customcompleter/CMakeLists.txt b/examples/widgets/tools/customcompleter/CMakeLists.txt
index 1e8203b170..8340f2cfdf 100644
--- a/examples/widgets/tools/customcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/customcompleter/CMakeLists.txt
@@ -1,42 +1,36 @@
-# Generated from customcompleter.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(customcompleter 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/tools/customcompleter")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(customcompleter
+qt_add_executable(customcompleter
main.cpp
mainwindow.cpp mainwindow.h
textedit.cpp textedit.h
)
-target_link_libraries(customcompleter PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+set_target_properties(customcompleter PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
)
+target_link_libraries(customcompleter PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set(customcompleter_resource_files
"resources/wordlist.txt"
)
-qt6_add_resources(customcompleter "customcompleter"
+qt_add_resources(customcompleter "customcompleter"
PREFIX
"/"
FILES
@@ -44,7 +38,14 @@ qt6_add_resources(customcompleter "customcompleter"
)
install(TARGETS customcompleter
- 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 customcompleter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc b/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
index 9ca86c966c..0b36549dec 100644
--- a/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
+++ b/examples/widgets/tools/customcompleter/doc/src/customcompleter.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example tools/customcompleter
diff --git a/examples/widgets/tools/customcompleter/main.cpp b/examples/widgets/tools/customcompleter/main.cpp
index 939c6788ba..060dfe5bd8 100644
--- a/examples/widgets/tools/customcompleter/main.cpp
+++ b/examples/widgets/tools/customcompleter/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>
#include "mainwindow.h"
@@ -54,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(customcompleter);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/customcompleter/mainwindow.cpp b/examples/widgets/tools/customcompleter/mainwindow.cpp
index b8072b505c..a466250836 100644
--- a/examples/widgets/tools/customcompleter/mainwindow.cpp
+++ b/examples/widgets/tools/customcompleter/mainwindow.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 "mainwindow.h"
#include "textedit.h"
diff --git a/examples/widgets/tools/customcompleter/mainwindow.h b/examples/widgets/tools/customcompleter/mainwindow.h
index cde553e291..1e2e75bd8b 100644
--- a/examples/widgets/tools/customcompleter/mainwindow.h
+++ b/examples/widgets/tools/customcompleter/mainwindow.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 MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/customcompleter/textedit.cpp b/examples/widgets/tools/customcompleter/textedit.cpp
index 0d536fea3c..86f11ca56e 100644
--- a/examples/widgets/tools/customcompleter/textedit.cpp
+++ b/examples/widgets/tools/customcompleter/textedit.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 "textedit.h"
#include <QCompleter>
diff --git a/examples/widgets/tools/customcompleter/textedit.h b/examples/widgets/tools/customcompleter/textedit.h
index 788cb74ae1..55df217813 100644
--- a/examples/widgets/tools/customcompleter/textedit.h
+++ b/examples/widgets/tools/customcompleter/textedit.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 TEXTEDIT_H
#define TEXTEDIT_H
diff --git a/examples/widgets/tools/echoplugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/CMakeLists.txt
deleted file mode 100644
index b848e08e72..0000000000
--- a/examples/widgets/tools/echoplugin/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from echoplugin.pro.
-
-add_subdirectory(echowindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/echoplugin/echoplugin.pro b/examples/widgets/tools/echoplugin/echoplugin.pro
deleted file mode 100644
index 1e3d625b2f..0000000000
--- a/examples/widgets/tools/echoplugin/echoplugin.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-#! [0]
-TEMPLATE = subdirs
-SUBDIRS = echowindow \
- plugin
-#! [0]
diff --git a/examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt b/examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt
deleted file mode 100644
index a3a3201d7e..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from echowindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin 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/tools/echoplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(echoplugin
- echointerface.h
- echowindow.cpp echowindow.h
- main.cpp
-)
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt b/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
deleted file mode 100644
index f87513a70b..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from echowindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin 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/tools/echoplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(echopluginwindow # special case: renamed target
- echointerface.h
- echowindow.cpp echowindow.h
- main.cpp
-)
-target_link_libraries(echopluginwindow PUBLIC # special case
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echopluginwindow # special case: renamed target
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/echowindow/echointerface.h b/examples/widgets/tools/echoplugin/echowindow/echointerface.h
deleted file mode 100644
index fb07f7fb79..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echointerface.h
+++ /dev/null
@@ -1,74 +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 ECHOINTERFACE_H
-#define ECHOINTERFACE_H
-
-#include <QObject>
-#include <QString>
-
-//! [0]
-class EchoInterface
-{
-public:
- virtual ~EchoInterface() = default;
- virtual QString echo(const QString &message) = 0;
-};
-
-
-QT_BEGIN_NAMESPACE
-
-#define EchoInterface_iid "org.qt-project.Qt.Examples.EchoInterface"
-
-Q_DECLARE_INTERFACE(EchoInterface, EchoInterface_iid)
-QT_END_NAMESPACE
-
-//! [0]
-#endif
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp b/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
deleted file mode 100644
index dce6bdedc3..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.cpp
+++ /dev/null
@@ -1,137 +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 "echowindow.h"
-
-#include <QCoreApplication>
-#include <QDir>
-#include <QLabel>
-#include <QLayout>
-#include <QLineEdit>
-#include <QMessageBox>
-#include <QPluginLoader>
-#include <QPushButton>
-
-//! [0]
-EchoWindow::EchoWindow()
-{
- createGUI();
- setLayout(layout);
- setWindowTitle("Echo Plugin Example");
-
- if (!loadPlugin()) {
- QMessageBox::information(this, "Error", "Could not load the plugin");
- lineEdit->setEnabled(false);
- button->setEnabled(false);
- }
-}
-//! [0]
-
-//! [1]
-void EchoWindow::sendEcho()
-{
- QString text = echoInterface->echo(lineEdit->text());
- label->setText(text);
-}
-//! [1]
-
-//! [2]
-void EchoWindow::createGUI()
-{
- lineEdit = new QLineEdit;
- label = new QLabel;
- label->setFrameStyle(QFrame::Box | QFrame::Plain);
- button = new QPushButton(tr("Send Message"));
-
- connect(lineEdit, &QLineEdit::editingFinished,
- this, &EchoWindow::sendEcho);
- connect(button, &QPushButton::clicked,
- this, &EchoWindow::sendEcho);
-
- layout = new QGridLayout;
- layout->addWidget(new QLabel(tr("Message:")), 0, 0);
- layout->addWidget(lineEdit, 0, 1);
- layout->addWidget(new QLabel(tr("Answer:")), 1, 0);
- layout->addWidget(label, 1, 1);
- layout->addWidget(button, 2, 1, Qt::AlignRight);
- layout->setSizeConstraint(QLayout::SetFixedSize);
-}
-//! [2]
-
-//! [3]
-bool EchoWindow::loadPlugin()
-{
- QDir pluginsDir(QCoreApplication::applicationDirPath());
-#if defined(Q_OS_WIN)
- if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
- pluginsDir.cdUp();
-#elif defined(Q_OS_MAC)
- if (pluginsDir.dirName() == "MacOS") {
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- }
-#endif
- pluginsDir.cd("plugins");
- const QStringList entries = pluginsDir.entryList(QDir::Files);
- for (const QString &fileName : entries) {
- QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
- QObject *plugin = pluginLoader.instance();
- if (plugin) {
- echoInterface = qobject_cast<EchoInterface *>(plugin);
- if (echoInterface)
- return true;
- pluginLoader.unload();
- }
- }
-
- return false;
-}
-//! [3]
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.h b/examples/widgets/tools/echoplugin/echowindow/echowindow.h
deleted file mode 100644
index 4005937c05..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.h
+++ /dev/null
@@ -1,89 +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 ECHODIALOG_H
-#define ECHODIALOG_H
-
-#include <QWidget>
-
-#include "echointerface.h"
-
-QT_BEGIN_NAMESPACE
-class QString;
-class QLineEdit;
-class QLabel;
-class QPushButton;
-class QGridLayout;
-QT_END_NAMESPACE
-
-//! [0]
-class EchoWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- EchoWindow();
-
-private slots:
- void sendEcho();
-
-private:
- void createGUI();
- bool loadPlugin();
-
- EchoInterface *echoInterface;
- QLineEdit *lineEdit;
- QLabel *label;
- QPushButton *button;
- QGridLayout *layout;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/echoplugin/echowindow/echowindow.pro b/examples/widgets/tools/echoplugin/echowindow/echowindow.pro
deleted file mode 100644
index 092258dd30..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/echowindow.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-QT += widgets
-
-HEADERS = echowindow.h \
- echointerface.h
-SOURCES = echowindow.cpp \
- main.cpp
-
-TARGET = echoplugin
-QMAKE_PROJECT_NAME = echopluginwindow
-win32 {
- CONFIG(debug, release|debug):DESTDIR = ../debug/
- CONFIG(release, release|debug):DESTDIR = ../release/
-} else {
- DESTDIR = ../
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/echoplugin
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/echoplugin/echowindow/main.cpp b/examples/widgets/tools/echoplugin/echowindow/main.cpp
deleted file mode 100644
index d3cf45fcde..0000000000
--- a/examples/widgets/tools/echoplugin/echowindow/main.cpp
+++ /dev/null
@@ -1,66 +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 "echowindow.h"
-#include "echointerface.h"
-
-//! [0]
-int main(int argv, char *args[])
-{
- QApplication app(argv, args);
-
- EchoWindow window;
- window.show();
-
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt
deleted file mode 100644
index 9f3a93b3bd..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin 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/tools/echoplugin/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_library(echoplugin MODULE
- echoplugin.cpp echoplugin.h
-)
-target_include_directories(echoplugin PUBLIC
- ../echowindow
-)
-
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt b/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
deleted file mode 100644
index 1ca49a1aca..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(echoplugin 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/tools/echoplugin/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(echoplugin)
-target_sources(echoplugin PRIVATE
- echoplugin.cpp echoplugin.h
-)
-target_include_directories(echoplugin PUBLIC
- ../echowindow
-)
-
-target_link_libraries(echoplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS echoplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp b/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp
deleted file mode 100644
index c9dd93aab8..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.cpp
+++ /dev/null
@@ -1,58 +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 "echoplugin.h"
-
-//! [0]
-QString EchoPlugin::echo(const QString &message)
-{
- return message;
-}
-//! [0]
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.h b/examples/widgets/tools/echoplugin/plugin/echoplugin.h
deleted file mode 100644
index f0f237099c..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.h
+++ /dev/null
@@ -1,70 +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 ECHOPLUGIN_H
-#define ECHOPLUGIN_H
-
-#include <QObject>
-#include <QtPlugin>
-#include "echointerface.h"
-
-//! [0]
-class EchoPlugin : public QObject, EchoInterface
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.EchoInterface" FILE "echoplugin.json")
- Q_INTERFACES(EchoInterface)
-
-public:
- QString echo(const QString &message) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/echoplugin/plugin/echoplugin.json b/examples/widgets/tools/echoplugin/plugin/echoplugin.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/echoplugin.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/echoplugin/plugin/plugin.pro b/examples/widgets/tools/echoplugin/plugin/plugin.pro
deleted file mode 100644
index a4b54b18f6..0000000000
--- a/examples/widgets/tools/echoplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-INCLUDEPATH += ../echowindow
-HEADERS = echoplugin.h
-SOURCES = echoplugin.cpp
-TARGET = $$qtLibraryTarget(echoplugin)
-DESTDIR = ../plugins
-#! [0]
-
-EXAMPLE_FILES = echoplugin.json
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/echoplugin/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/i18n/CMakeLists.txt b/examples/widgets/tools/i18n/CMakeLists.txt
deleted file mode 100644
index e01508229f..0000000000
--- a/examples/widgets/tools/i18n/CMakeLists.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-# Generated from i18n.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(i18n 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/tools/i18n")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(i18n
- languagechooser.cpp languagechooser.h
- main.cpp
- mainwindow.cpp mainwindow.h
-)
-target_link_libraries(i18n PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(i18n_resource_files
- "translations/i18n_ar.qm"
- "translations/i18n_cs.qm"
- "translations/i18n_de.qm"
- "translations/i18n_el.qm"
- "translations/i18n_en.qm"
- "translations/i18n_eo.qm"
- "translations/i18n_fr.qm"
- "translations/i18n_it.qm"
- "translations/i18n_jp.qm"
- "translations/i18n_ko.qm"
- "translations/i18n_no.qm"
- "translations/i18n_ru.qm"
- "translations/i18n_sv.qm"
- "translations/i18n_zh.qm"
-)
-
-qt6_add_resources(i18n "i18n"
- PREFIX
- "/"
- FILES
- ${i18n_resource_files}
-)
-
-install(TARGETS i18n
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/i18n/i18n.pro b/examples/widgets/tools/i18n/i18n.pro
deleted file mode 100644
index a4d5e418ea..0000000000
--- a/examples/widgets/tools/i18n/i18n.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-QT += widgets
-requires(qtConfig(listwidget))
-
-HEADERS = languagechooser.h \
- mainwindow.h
-SOURCES = languagechooser.cpp \
- main.cpp \
- mainwindow.cpp
-RESOURCES += i18n.qrc
-TRANSLATIONS += translations/i18n_ar.ts \
- translations/i18n_cs.ts \
- translations/i18n_de.ts \
- translations/i18n_el.ts \
- translations/i18n_en.ts \
- translations/i18n_eo.ts \
- translations/i18n_fr.ts \
- translations/i18n_it.ts \
- translations/i18n_jp.ts \
- translations/i18n_ko.ts \
- translations/i18n_no.ts \
- translations/i18n_ru.ts \
- translations/i18n_sv.ts \
- translations/i18n_zh.ts
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/i18n
-INSTALLS += target
diff --git a/examples/widgets/tools/i18n/i18n.qrc b/examples/widgets/tools/i18n/i18n.qrc
deleted file mode 100644
index 16a89f140b..0000000000
--- a/examples/widgets/tools/i18n/i18n.qrc
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>translations/i18n_ar.qm</file>
- <file>translations/i18n_cs.qm</file>
- <file>translations/i18n_de.qm</file>
- <file>translations/i18n_el.qm</file>
- <file>translations/i18n_en.qm</file>
- <file>translations/i18n_eo.qm</file>
- <file>translations/i18n_fr.qm</file>
- <file>translations/i18n_it.qm</file>
- <file>translations/i18n_jp.qm</file>
- <file>translations/i18n_ko.qm</file>
- <file>translations/i18n_no.qm</file>
- <file>translations/i18n_ru.qm</file>
- <file>translations/i18n_sv.qm</file>
- <file>translations/i18n_zh.qm</file>
-</qresource>
-</RCC>
diff --git a/examples/widgets/tools/i18n/languagechooser.cpp b/examples/widgets/tools/i18n/languagechooser.cpp
deleted file mode 100644
index 51dfce915f..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.cpp
+++ /dev/null
@@ -1,181 +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 "languagechooser.h"
-#include "mainwindow.h"
-
-#include <QCoreApplication>
-#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QDir>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QPushButton>
-#include <QTranslator>
-
-LanguageChooser::LanguageChooser(const QString &defaultLang, QWidget *parent)
- : QDialog(parent, Qt::WindowStaysOnTopHint)
-{
- groupBox = new QGroupBox("Languages");
-
- QGridLayout *groupBoxLayout = new QGridLayout;
-
- const QStringList qmFiles = findQmFiles();
- for (int i = 0; i < qmFiles.size(); ++i) {
- const QString &qmlFile = qmFiles.at(i);
- QCheckBox *checkBox = new QCheckBox(languageName(qmlFile));
- qmFileForCheckBoxMap.insert(checkBox, qmlFile);
- connect(checkBox, &QCheckBox::toggled,
- this, &LanguageChooser::checkBoxToggled);
- if (languageMatch(defaultLang, qmlFile))
- checkBox->setCheckState(Qt::Checked);
- groupBoxLayout->addWidget(checkBox, i / 2, i % 2);
- }
- groupBox->setLayout(groupBoxLayout);
-
- buttonBox = new QDialogButtonBox;
- showAllButton = buttonBox->addButton("Show All",
- QDialogButtonBox::ActionRole);
- hideAllButton = buttonBox->addButton("Hide All",
- QDialogButtonBox::ActionRole);
-
- connect(showAllButton, &QAbstractButton::clicked, this, &LanguageChooser::showAll);
- connect(hideAllButton, &QAbstractButton::clicked, this, &LanguageChooser::hideAll);
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(groupBox);
- mainLayout->addWidget(buttonBox);
- setLayout(mainLayout);
-
- setWindowTitle("I18N");
-}
-
-bool LanguageChooser::languageMatch(const QString &lang, const QString &qmFile)
-{
- //qmFile: i18n_xx.qm
- const QString prefix = "i18n_";
- const int langTokenLength = 2; /*FIXME: is checking two chars enough?*/
- return qmFile.midRef(qmFile.indexOf(prefix) + prefix.length(), langTokenLength) == lang.leftRef(langTokenLength);
-}
-
-bool LanguageChooser::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::Close) {
- MainWindow *window = qobject_cast<MainWindow *>(object);
- if (window) {
- QCheckBox *checkBox = mainWindowForCheckBoxMap.key(window);
- if (checkBox)
- checkBox->setChecked(false);
- }
- }
- return QDialog::eventFilter(object, event);
-}
-
-void LanguageChooser::closeEvent(QCloseEvent * /* event */)
-{
- QCoreApplication::quit();
-}
-
-void LanguageChooser::checkBoxToggled()
-{
- QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender());
- MainWindow *window = mainWindowForCheckBoxMap.value(checkBox);
- if (!window) {
- QTranslator translator;
- translator.load(qmFileForCheckBoxMap.value(checkBox));
- qApp->installTranslator(&translator);
-
- window = new MainWindow;
- window->setPalette(colorForLanguage(checkBox->text()));
-
- window->installEventFilter(this);
- mainWindowForCheckBoxMap.insert(checkBox, window);
- }
- window->setVisible(checkBox->isChecked());
-}
-
-void LanguageChooser::showAll()
-{
- for (auto it = qmFileForCheckBoxMap.keyBegin(); it != qmFileForCheckBoxMap.keyEnd(); ++it)
- (*it)->setChecked(true);
-}
-
-void LanguageChooser::hideAll()
-{
- for (auto it = qmFileForCheckBoxMap.keyBegin(); it != qmFileForCheckBoxMap.keyEnd(); ++it)
- (*it)->setChecked(false);
-}
-
-QStringList LanguageChooser::findQmFiles()
-{
- QDir dir(":/translations");
- QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files,
- QDir::Name);
- for (QString &fileName : fileNames)
- fileName = dir.filePath(fileName);
- return fileNames;
-}
-
-QString LanguageChooser::languageName(const QString &qmFile)
-{
- QTranslator translator;
- translator.load(qmFile);
-
- return translator.translate("MainWindow", "English");
-}
-
-QColor LanguageChooser::colorForLanguage(const QString &language)
-{
- size_t hashValue = qHash(language);
- int red = 156 + (hashValue & 0x3F);
- int green = 156 + ((hashValue >> 6) & 0x3F);
- int blue = 156 + ((hashValue >> 12) & 0x3F);
- return QColor(red, green, blue);
-}
diff --git a/examples/widgets/tools/i18n/languagechooser.h b/examples/widgets/tools/i18n/languagechooser.h
deleted file mode 100644
index 733cc50fd3..0000000000
--- a/examples/widgets/tools/i18n/languagechooser.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 LANGUAGECHOOSER_H
-#define LANGUAGECHOOSER_H
-
-#include <QDialog>
-#include <QHash>
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QAbstractButton;
-class QCheckBox;
-class QDialogButtonBox;
-class QGroupBox;
-QT_END_NAMESPACE
-class MainWindow;
-
-class LanguageChooser : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit LanguageChooser(const QString &defaultLang = QString(), QWidget *parent = nullptr);
-
-protected:
- bool eventFilter(QObject *object, QEvent *event) override;
- void closeEvent(QCloseEvent *event) override;
-
-private slots:
- void checkBoxToggled();
- void showAll();
- void hideAll();
-
-private:
- static QStringList findQmFiles();
- static QString languageName(const QString &qmFile);
- static QColor colorForLanguage(const QString &language);
- static bool languageMatch(const QString &lang, const QString &qmFile);
-
- QGroupBox *groupBox;
- QDialogButtonBox *buttonBox;
- QAbstractButton *showAllButton;
- QAbstractButton *hideAllButton;
- QHash<QCheckBox *, QString> qmFileForCheckBoxMap;
- QHash<QCheckBox *, MainWindow *> mainWindowForCheckBoxMap;
-};
-
-#endif
diff --git a/examples/widgets/tools/i18n/main.cpp b/examples/widgets/tools/i18n/main.cpp
deleted file mode 100644
index 33db0dbfc2..0000000000
--- a/examples/widgets/tools/i18n/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 <QLocale>
-#include "languagechooser.h"
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Q_INIT_RESOURCE(i18n);
-
- QApplication app(argc, argv);
- LanguageChooser chooser(QLocale::system().name());
- chooser.show();
- return app.exec();
-}
diff --git a/examples/widgets/tools/i18n/mainwindow.cpp b/examples/widgets/tools/i18n/mainwindow.cpp
deleted file mode 100644
index a107a819ca..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.cpp
+++ /dev/null
@@ -1,113 +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 "mainwindow.h"
-
-#include <QAction>
-#include <QCoreApplication>
-#include <QGroupBox>
-#include <QListWidget>
-#include <QMenuBar>
-#include <QRadioButton>
-#include <QStatusBar>
-#include <QVBoxLayout>
-
-static const char * const listEntries[] = {
- QT_TRANSLATE_NOOP("MainWindow", "First"),
- QT_TRANSLATE_NOOP("MainWindow", "Second"),
- QT_TRANSLATE_NOOP("MainWindow", "Third"),
- nullptr
-};
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- centralWidget = new QWidget;
- setCentralWidget(centralWidget);
-
- createGroupBox();
-
- listWidget = new QListWidget;
- for (const char *entry : listEntries)
- listWidget->addItem(tr(entry));
-
- QVBoxLayout *mainLayout = new QVBoxLayout;
- mainLayout->addWidget(groupBox);
- mainLayout->addWidget(listWidget);
- centralWidget->setLayout(mainLayout);
-
- exitAction = new QAction(tr("E&xit"), this);
- connect(exitAction, &QAction::triggered, qApp, QCoreApplication::quit);
-
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->setPalette(QPalette(Qt::red));
- fileMenu->addAction(exitAction);
-
- setWindowTitle(tr("Language: %1").arg(tr("English")));
- statusBar()->showMessage(tr("Internationalization Example"));
-
- if (tr("LTR") == "RTL")
- setLayoutDirection(Qt::RightToLeft);
-}
-
-void MainWindow::createGroupBox()
-{
- groupBox = new QGroupBox(tr("View"));
- perspectiveRadioButton = new QRadioButton(tr("Perspective"));
- isometricRadioButton = new QRadioButton(tr("Isometric"));
- obliqueRadioButton = new QRadioButton(tr("Oblique"));
- perspectiveRadioButton->setChecked(true);
-
- QVBoxLayout *groupBoxLayout = new QVBoxLayout;
- groupBoxLayout->addWidget(perspectiveRadioButton);
- groupBoxLayout->addWidget(isometricRadioButton);
- groupBoxLayout->addWidget(obliqueRadioButton);
- groupBox->setLayout(groupBoxLayout);
-}
diff --git a/examples/widgets/tools/i18n/mainwindow.h b/examples/widgets/tools/i18n/mainwindow.h
deleted file mode 100644
index 105472d60c..0000000000
--- a/examples/widgets/tools/i18n/mainwindow.h
+++ /dev/null
@@ -1,86 +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 <QMainWindow>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QGroupBox;
-class QLabel;
-class QListWidget;
-class QMenu;
-class QRadioButton;
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
-private:
- void createGroupBox();
-
- QWidget *centralWidget;
- QLabel *label;
- QGroupBox *groupBox;
- QListWidget *listWidget;
- QRadioButton *perspectiveRadioButton;
- QRadioButton *isometricRadioButton;
- QRadioButton *obliqueRadioButton;
- QMenu *fileMenu;
- QAction *exitAction;
-};
-
-#endif
diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.qm b/examples/widgets/tools/i18n/translations/i18n_ar.qm
deleted file mode 100644
index a134c468bb..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ar.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.ts b/examples/widgets/tools/i18n/translations/i18n_ar.ts
deleted file mode 100644
index a7ec2c9404..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ar.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>First</source>
- <translation>أول</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>مثال التدويل</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>متماثل</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>اللغة: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>العربية</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>مصمت</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>منظور</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>ثانى</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>ثالث</translation>
- </message>
- <message>
- <source>View</source>
- <translation>مرئى</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>أخرج</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>الملف</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>RTL</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.qm b/examples/widgets/tools/i18n/translations/i18n_cs.qm
deleted file mode 100644
index 5b7ff95b05..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_cs.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.ts b/examples/widgets/tools/i18n/translations/i18n_cs.ts
deleted file mode 100644
index 6c4dee9b2e..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_cs.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Pohled</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Soubor</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Konec</translation>
- </message>
- <message>
- <source>First</source>
- <translation>První</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Třetí</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Jayzk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Český</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Nakloněný</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Druhý</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrický</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivní</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Ukázka lokalizace</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_de.qm b/examples/widgets/tools/i18n/translations/i18n_de.qm
deleted file mode 100644
index 177fc49b8b..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_de.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_de.ts b/examples/widgets/tools/i18n/translations/i18n_de.ts
deleted file mode 100644
index 249a61d020..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_de.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Ansicht</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Datei</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Be&amp;enden</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Erstens</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Drittens</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Deutsch</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Sprache: %1</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Schief</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Zweitens</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrisch</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivisch</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationalisierungsbeispiel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_el.qm b/examples/widgets/tools/i18n/translations/i18n_el.qm
deleted file mode 100644
index 5483291bb0..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_el.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_el.ts b/examples/widgets/tools/i18n/translations/i18n_el.ts
deleted file mode 100644
index d23a0aad3e..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_el.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Αρχείο</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Έ&amp;ξοδος</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Πρώτο</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Παράδειγμα διεθνοποίησης</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Ισομετρική</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Γλώσσα: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Ελληνικά</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Πλάγια</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Προοπτική</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Δεύτερο</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Τρίτο</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Όψη</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_en.qm b/examples/widgets/tools/i18n/translations/i18n_en.qm
deleted file mode 100644
index 9190ac7e6f..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_en.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_en.ts b/examples/widgets/tools/i18n/translations/i18n_en.ts
deleted file mode 100644
index ca38e958c1..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_en.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>E&amp;xit</source>
- <translation>E&amp;xit</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;File</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationalization Example</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Language: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>English</translation>
- </message>
- <message>
- <source>View</source>
- <translation>View</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspective</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometric</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblique</translation>
- </message>
- <message>
- <source>First</source>
- <translation>First</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Second</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Third</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.qm b/examples/widgets/tools/i18n/translations/i18n_eo.qm
deleted file mode 100644
index a8457bef06..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_eo.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.ts b/examples/widgets/tools/i18n/translations/i18n_eo.ts
deleted file mode 100644
index 16a37becd9..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_eo.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Dosiero</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Unue</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Ekzemplo pri internaciigo</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometria</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Lingvo: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Esperanto</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblikva</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektiva</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Due</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Trie</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Aspekto</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Fini</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.qm b/examples/widgets/tools/i18n/translations/i18n_fr.qm
deleted file mode 100644
index 3e8a69b80d..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_fr.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.ts b/examples/widgets/tools/i18n/translations/i18n_fr.ts
deleted file mode 100644
index 0012892ef2..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_fr.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Vue</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Fichier</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Quitter</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Premier</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Troisième</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Langue : %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Français</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Oblique</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Deuxième</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isométrique</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspective</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Exemple d&apos;internationalisation</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_it.qm b/examples/widgets/tools/i18n/translations/i18n_it.qm
deleted file mode 100644
index 3dffd30548..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_it.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_it.ts b/examples/widgets/tools/i18n/translations/i18n_it.ts
deleted file mode 100644
index d516a277b6..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_it.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>First</source>
- <translation>Primo</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Esempio di localizzazione</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrica</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Lingua: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Italiano</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Obliqua</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Prospettica</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Secondo</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Terzo</translation>
- </message>
- <message>
- <source>View</source>
- <translation>Vista</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Esci</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;File</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.qm b/examples/widgets/tools/i18n/translations/i18n_jp.qm
deleted file mode 100644
index 017bc96cfc..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_jp.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.ts b/examples/widgets/tools/i18n/translations/i18n_jp.ts
deleted file mode 100644
index 067b5a8a0b..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_jp.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>ファイル(&amp;F)</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>終了(&amp;X)</translation>
- </message>
- <message>
- <source>First</source>
- <translation>第一行</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>国際化(i18n)の例</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>等角投影法</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>言語: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>日本語</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>斜め投影法</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>遠近法</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>第二行</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>第三行</translation>
- </message>
- <message>
- <source>View</source>
- <translation>表示方式</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.qm b/examples/widgets/tools/i18n/translations/i18n_ko.qm
deleted file mode 100644
index d61b93db39..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ko.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.ts b/examples/widgets/tools/i18n/translations/i18n_ko.ts
deleted file mode 100644
index bfd5924518..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ko.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>&amp;File</source>
- <translation>파일&amp;F</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>종료&amp;X</translation>
- </message>
- <message>
- <source>First</source>
- <translation>첫번째</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>국제화 예제</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>등측도</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>언어 : %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>한국어</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>빗각</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>원근화법</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>두번째</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>세번째</translation>
- </message>
- <message>
- <source>View</source>
- <translation>보기</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_no.qm b/examples/widgets/tools/i18n/translations/i18n_no.qm
deleted file mode 100644
index c84b0d74ba..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_no.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_no.ts b/examples/widgets/tools/i18n/translations/i18n_no.ts
deleted file mode 100644
index 2e06974997..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_no.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Vis</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Fil</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Avslutt</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Første</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Tredje</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Språk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Norsk</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Skjevt</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Andre</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometrisk</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektiv</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internasjonaliseringseksempel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.qm b/examples/widgets/tools/i18n/translations/i18n_ru.qm
deleted file mode 100644
index a76e1b8703..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ru.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.ts b/examples/widgets/tools/i18n/translations/i18n_ru.ts
deleted file mode 100644
index 748cc12fd9..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_ru.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS><TS version="1.1" language="ru">
-<defaultcodec></defaultcodec>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Вид</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>Файл</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>Выход</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Первый</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Третий</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Язык: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Русский</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Курсив</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Второй</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Изометрический</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Перспектива</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Пример интернационализации</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.qm b/examples/widgets/tools/i18n/translations/i18n_sv.qm
deleted file mode 100644
index 7204b308b1..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_sv.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.ts b/examples/widgets/tools/i18n/translations/i18n_sv.ts
deleted file mode 100644
index ac4ab98bd3..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_sv.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>Visa</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>&amp;Arkiv</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>&amp;Avsluta</translation>
- </message>
- <message>
- <source>First</source>
- <translation>Första</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>Tredje</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>Språk: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>Svenska</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>Skevt</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>Andra</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>Isometriskt</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>Perspektivt</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>Internationaliseringsexempel</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.qm b/examples/widgets/tools/i18n/translations/i18n_zh.qm
deleted file mode 100644
index 32053f4633..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_zh.qm
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.ts b/examples/widgets/tools/i18n/translations/i18n_zh.ts
deleted file mode 100644
index 3b715470a8..0000000000
--- a/examples/widgets/tools/i18n/translations/i18n_zh.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-<!DOCTYPE TS><TS>
-<context>
- <name>MainWindow</name>
- <message>
- <source>View</source>
- <translation>视图</translation>
- </message>
- <message>
- <source>&amp;File</source>
- <translation>文件[&amp;F]</translation>
- </message>
- <message>
- <source>E&amp;xit</source>
- <translation>退出[&amp;x]</translation>
- </message>
- <message>
- <source>First</source>
- <translation>第一个</translation>
- </message>
- <message>
- <source>Third</source>
- <translation>第三个</translation>
- </message>
- <message>
- <source>Language: %1</source>
- <translation>语言: %1</translation>
- </message>
- <message>
- <source>English</source>
- <translation>简体中文</translation>
- </message>
- <message>
- <source>Oblique</source>
- <translation>斜投影</translation>
- </message>
- <message>
- <source>Second</source>
- <translation>第二个</translation>
- </message>
- <message>
- <source>Isometric</source>
- <translation>等角投影</translation>
- </message>
- <message>
- <source>Perspective</source>
- <translation>透视投影</translation>
- </message>
- <message>
- <source>Internationalization Example</source>
- <translation>国际化范例</translation>
- </message>
- <message>
- <source>LTR</source>
- <translation>LTR</translation>
- </message>
-</context>
-</TS>
diff --git a/examples/widgets/tools/plugandpaint/CMakeLists.txt b/examples/widgets/tools/plugandpaint/CMakeLists.txt
deleted file mode 100644
index 4e35d0d0c3..0000000000
--- a/examples/widgets/tools/plugandpaint/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Generated from plugandpaint.pro.
-
-if(NOT QT_FEATURE_inputdialog)
- return()
-endif()
-add_subdirectory(plugins)
-add_subdirectory(app)
diff --git a/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt
deleted file mode 100644
index 2ec3418964..0000000000
--- a/examples/widgets/tools/plugandpaint/app/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint 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/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(plugandpaint
- interfaces.h
- main.cpp
- mainwindow.cpp mainwindow.h
- paintarea.cpp paintarea.h
- plugindialog.cpp plugindialog.h
-)
-target_link_libraries(plugandpaint PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-endif()
-
-install(TARGETS plugandpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt b/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
deleted file mode 100644
index 07f6810bd6..0000000000
--- a/examples/widgets/tools/plugandpaint/app/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-# Generated from app.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(plugandpaint 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/tools/plugandpaint")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(plugandpaint
- interfaces.h
- main.cpp
- mainwindow.cpp mainwindow.h
- paintarea.cpp paintarea.h
- plugindialog.cpp plugindialog.h
-)
-target_link_libraries(plugandpaint PUBLIC
- # Remove: L../plugins
- Qt::Core
- Qt::Gui
- Qt::Widgets
- pnp_basictools # special case
-)
-target_link_libraries(plugandpaint PUBLIC pnp_basictools) # special case
-
-if(macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- (
- )
- pnp_basictools$
- )
-endif()
-
-if(NOT macx-xcode)
- target_link_libraries(plugandpaint PUBLIC
- pnp_basictools
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (APPLE))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- _debug
- )
-endif()
-
-if(((NOT (macx-xcode)) AND (( NOT debug_and_release OR build_pass ) AND CONFIG(debug,debug OR release))) AND (WIN32))
- target_link_libraries(plugandpaint PUBLIC
- (LIBS, 0)
- (LIBS, 1)
- d
- )
-endif()
-
-install(TARGETS plugandpaint
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/app/app.pro b/examples/widgets/tools/plugandpaint/app/app.pro
deleted file mode 100644
index 558d359e7d..0000000000
--- a/examples/widgets/tools/plugandpaint/app/app.pro
+++ /dev/null
@@ -1,33 +0,0 @@
-#! [0]
-TARGET = plugandpaint
-DESTDIR = ..
-
-QT += widgets
-
-HEADERS = interfaces.h \
- mainwindow.h \
- paintarea.h \
- plugindialog.h
-SOURCES = main.cpp \
- mainwindow.cpp \
- paintarea.cpp \
- plugindialog.cpp
-
-LIBS = -L../plugins
-
-macx-xcode {
- LIBS += -lpnp_basictools$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})
-} else {
- LIBS += -lpnp_basictools
- if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
- mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
- win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
- }
-}
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/plugandpaint/app/interfaces.h b/examples/widgets/tools/plugandpaint/app/interfaces.h
deleted file mode 100644
index 705e578809..0000000000
--- a/examples/widgets/tools/plugandpaint/app/interfaces.h
+++ /dev/null
@@ -1,124 +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 INTERFACES_H
-#define INTERFACES_H
-
-#include <QtPlugin>
-
-QT_BEGIN_NAMESPACE
-class QImage;
-class QPainter;
-class QWidget;
-class QPainterPath;
-class QPoint;
-class QRect;
-class QString;
-class QStringList;
-QT_END_NAMESPACE
-
-//! [0]
-class BrushInterface
-{
-public:
- virtual ~BrushInterface() = default;
-
- virtual QStringList brushes() const = 0;
- virtual QRect mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos) = 0;
- virtual QRect mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos) = 0;
- virtual QRect mouseRelease(const QString &brush, QPainter &painter,
- const QPoint &pos) = 0;
-};
-//! [0]
-
-//! [1]
-class ShapeInterface
-{
-public:
- virtual ~ShapeInterface() = default;
-
- virtual QStringList shapes() const = 0;
- virtual QPainterPath generateShape(const QString &shape,
- QWidget *parent) = 0;
-};
-//! [1]
-
-//! [2]
-class FilterInterface
-{
-public:
- virtual ~FilterInterface() = default;
-
- virtual QStringList filters() const = 0;
- virtual QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) = 0;
-};
-//! [2]
-
-QT_BEGIN_NAMESPACE
-//! [3] //! [4]
-#define BrushInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface/1.0"
-
-Q_DECLARE_INTERFACE(BrushInterface, BrushInterface_iid)
-//! [3]
-
-#define ShapeInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.ShapeInterface/1.0"
-
-Q_DECLARE_INTERFACE(ShapeInterface, ShapeInterface_iid)
-//! [5]
-#define FilterInterface_iid "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface/1.0"
-
-Q_DECLARE_INTERFACE(FilterInterface, FilterInterface_iid)
-//! [4] //! [5]
-QT_END_NAMESPACE
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/main.cpp b/examples/widgets/tools/plugandpaint/app/main.cpp
deleted file mode 100644
index f50fd86b97..0000000000
--- a/examples/widgets/tools/plugandpaint/app/main.cpp
+++ /dev/null
@@ -1,66 +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$
-**
-****************************************************************************/
-
-//! [0]
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QtPlugin>
-
-Q_IMPORT_PLUGIN(BasicToolsPlugin)
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- MainWindow window;
- window.show();
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
deleted file mode 100644
index ff3b3614af..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
+++ /dev/null
@@ -1,329 +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 "mainwindow.h"
-#include "interfaces.h"
-#include "paintarea.h"
-#include "plugindialog.h"
-
-#include <QAction>
-#include <QActionGroup>
-#include <QApplication>
-#include <QColorDialog>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QMenu>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QPluginLoader>
-#include <QScrollArea>
-#include <QTimer>
-
-MainWindow::MainWindow() : paintArea(new PaintArea)
- , scrollArea(new QScrollArea)
-{
- scrollArea->setBackgroundRole(QPalette::Dark);
- scrollArea->setWidget(paintArea);
- setCentralWidget(scrollArea);
-
- createActions();
- createMenus();
- loadPlugins();
-
- setWindowTitle(tr("Plug & Paint"));
-
- if (!brushActionGroup->actions().isEmpty())
- brushActionGroup->actions().first()->trigger();
-
- QTimer::singleShot(500, this, &MainWindow::aboutPlugins);
-}
-
-void MainWindow::open()
-{
- const QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open File"),
- QDir::currentPath());
- if (!fileName.isEmpty()) {
- if (!paintArea->openImage(fileName)) {
- QMessageBox::information(this, tr("Plug & Paint"),
- tr("Cannot load %1.").arg(fileName));
- return;
- }
- paintArea->adjustSize();
- }
-}
-
-bool MainWindow::saveAs()
-{
- const QString initialPath = QDir::currentPath() + "/untitled.png";
-
- const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- initialPath);
- if (fileName.isEmpty())
- return false;
-
- return paintArea->saveImage(fileName, "png");
-}
-
-void MainWindow::brushColor()
-{
- const QColor newColor = QColorDialog::getColor(paintArea->brushColor());
- if (newColor.isValid())
- paintArea->setBrushColor(newColor);
-}
-
-void MainWindow::brushWidth()
-{
- bool ok;
- const int newWidth = QInputDialog::getInt(this, tr("Plug & Paint"),
- tr("Select brush width:"),
- paintArea->brushWidth(),
- 1, 50, 1, &ok);
- if (ok)
- paintArea->setBrushWidth(newWidth);
-}
-
-//! [0]
-void MainWindow::changeBrush()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iBrush = qobject_cast<BrushInterface *>(action->parent());
- if (!iBrush)
- return;
- const QString brush = action->text();
-
- paintArea->setBrush(iBrush, brush);
-}
-//! [0]
-
-//! [1]
-void MainWindow::insertShape()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iShape = qobject_cast<ShapeInterface *>(action->parent());
- if (!iShape)
- return;
-
- const QPainterPath path = iShape->generateShape(action->text(), this);
- if (!path.isEmpty())
- paintArea->insertShape(path);
-}
-//! [1]
-
-//! [2]
-void MainWindow::applyFilter()
-{
- auto action = qobject_cast<QAction *>(sender());
- if (!action)
- return;
- auto iFilter = qobject_cast<FilterInterface *>(action->parent());
- if (!iFilter)
- return;
-
- const QImage image = iFilter->filterImage(action->text(), paintArea->image(),
- this);
- paintArea->setImage(image);
-}
-//! [2]
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Plug & Paint"),
- tr("The <b>Plug & Paint</b> example demonstrates how to write Qt "
- "applications that can be extended through plugins."));
-}
-
-//! [3]
-void MainWindow::aboutPlugins()
-{
- PluginDialog dialog(pluginsDir.path(), pluginFileNames, this);
- dialog.exec();
-}
-//! [3]
-
-void MainWindow::createActions()
-{
- openAct = new QAction(tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- connect(openAct, &QAction::triggered, this, &MainWindow::open);
-
- saveAsAct = new QAction(tr("&Save As..."), this);
- saveAsAct->setShortcuts(QKeySequence::SaveAs);
- connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
-
- exitAct = new QAction(tr("E&xit"), this);
- exitAct->setShortcuts(QKeySequence::Quit);
- connect(exitAct, &QAction::triggered, this, &MainWindow::close);
-
- brushColorAct = new QAction(tr("&Brush Color..."), this);
- connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor);
-
- brushWidthAct = new QAction(tr("&Brush Width..."), this);
- connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth);
-
- brushActionGroup = new QActionGroup(this);
-
- aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
-
- aboutPluginsAct = new QAction(tr("About &Plugins"), this);
- connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins);
-}
-
-void MainWindow::createMenus()
-{
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- brushMenu = menuBar()->addMenu(tr("&Brush"));
- brushMenu->addAction(brushColorAct);
- brushMenu->addAction(brushWidthAct);
- brushMenu->addSeparator();
-
- shapesMenu = menuBar()->addMenu(tr("&Shapes"));
-
- filterMenu = menuBar()->addMenu(tr("&Filter"));
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
- helpMenu->addAction(aboutPluginsAct);
-}
-
-//! [4]
-void MainWindow::loadPlugins()
-{
- const auto staticInstances = QPluginLoader::staticInstances();
- for (QObject *plugin : staticInstances)
- populateMenus(plugin);
-//! [4] //! [5]
-
- pluginsDir = QDir(QCoreApplication::applicationDirPath());
-
-#if defined(Q_OS_WIN)
- if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
- pluginsDir.cdUp();
-#elif defined(Q_OS_MAC)
- if (pluginsDir.dirName() == "MacOS") {
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- pluginsDir.cdUp();
- }
-#endif
- pluginsDir.cd("plugins");
-//! [5]
-
-//! [6]
- const auto entryList = pluginsDir.entryList(QDir::Files);
- for (const QString &fileName : entryList) {
- QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
- QObject *plugin = loader.instance();
- if (plugin) {
- populateMenus(plugin);
- pluginFileNames += fileName;
-//! [6] //! [7]
- }
-//! [7] //! [8]
- }
-//! [8]
-
-//! [9]
- brushMenu->setEnabled(!brushActionGroup->actions().isEmpty());
- shapesMenu->setEnabled(!shapesMenu->actions().isEmpty());
- filterMenu->setEnabled(!filterMenu->actions().isEmpty());
-}
-//! [9]
-
-//! [10]
-void MainWindow::populateMenus(QObject *plugin)
-{
- auto iBrush = qobject_cast<BrushInterface *>(plugin);
- if (iBrush)
- addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush,
- brushActionGroup);
-
- auto iShape = qobject_cast<ShapeInterface *>(plugin);
- if (iShape)
- addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape);
-
- auto iFilter = qobject_cast<FilterInterface *>(plugin);
- if (iFilter)
- addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter);
-}
-//! [10]
-
-void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
- QMenu *menu, Member member,
- QActionGroup *actionGroup)
-{
- for (const QString &text : texts) {
- auto action = new QAction(text, plugin);
- connect(action, &QAction::triggered, this, member);
- menu->addAction(action);
-
- if (actionGroup) {
- action->setCheckable(true);
- actionGroup->addAction(action);
- }
- }
-}
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.h b/examples/widgets/tools/plugandpaint/app/mainwindow.h
deleted file mode 100644
index 2b54264893..0000000000
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.h
+++ /dev/null
@@ -1,115 +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 <QDir>
-#include <QMainWindow>
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QActionGroup;
-class QMenu;
-class QScrollArea;
-QT_END_NAMESPACE
-class PaintArea;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow();
-
-private slots:
- void open();
- bool saveAs();
- void brushColor();
- void brushWidth();
- void changeBrush();
- void insertShape();
- void applyFilter();
- void about();
- void aboutPlugins();
-
-private:
- typedef void (MainWindow::*Member)();
-
- void createActions();
- void createMenus();
- void loadPlugins();
- void populateMenus(QObject *plugin);
- void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
- Member member, QActionGroup *actionGroup = nullptr);
-
- PaintArea *paintArea = nullptr;
- QScrollArea *scrollArea = nullptr;
- QDir pluginsDir;
- QStringList pluginFileNames;
-
- QMenu *fileMenu = nullptr;
- QMenu *brushMenu = nullptr;
- QMenu *shapesMenu = nullptr;
- QMenu *filterMenu = nullptr;
- QMenu *helpMenu = nullptr;
- QActionGroup *brushActionGroup = nullptr;
- QAction *openAct = nullptr;
- QAction *saveAsAct = nullptr;
- QAction *exitAct = nullptr;
- QAction *brushWidthAct = nullptr;
- QAction *brushColorAct = nullptr;
- QAction *aboutAct = nullptr;
- QAction *aboutQtAct = nullptr;
- QAction *aboutPluginsAct = nullptr;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.cpp b/examples/widgets/tools/plugandpaint/app/paintarea.cpp
deleted file mode 100644
index e3292e3b91..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.cpp
+++ /dev/null
@@ -1,199 +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 "paintarea.h"
-#include "interfaces.h"
-
-#include <QMouseEvent>
-#include <QPainter>
-
-PaintArea::PaintArea(QWidget *parent) : QWidget(parent)
-{
- setAttribute(Qt::WA_StaticContents);
- setAttribute(Qt::WA_OpaquePaintEvent);
-
- theImage.fill(qRgb(255, 255, 255));
-}
-
-bool PaintArea::openImage(const QString &fileName)
-{
- QImage image;
- if (!image.load(fileName))
- return false;
-
- setImage(image);
- return true;
-}
-
-bool PaintArea::saveImage(const QString &fileName, const char *fileFormat)
-{
- return theImage.save(fileName, fileFormat);
-}
-
-void PaintArea::setImage(const QImage &image)
-{
- theImage = image.convertToFormat(QImage::Format_RGB32);
- update();
- updateGeometry();
-}
-
-void PaintArea::insertShape(const QPainterPath &path)
-{
- pendingPath = path;
-#ifndef QT_NO_CURSOR
- setCursor(Qt::CrossCursor);
-#endif
-}
-
-void PaintArea::setBrushColor(const QColor &color)
-{
- this->color = color;
-}
-
-void PaintArea::setBrushWidth(int width)
-{
- thickness = width;
-}
-
-//! [0]
-void PaintArea::setBrush(BrushInterface *brushInterface, const QString &brush)
-{
- this->brushInterface = brushInterface;
- this->brush = brush;
-}
-//! [0]
-
-QSize PaintArea::sizeHint() const
-{
- return theImage.size();
-}
-
-void PaintArea::paintEvent(QPaintEvent * /* event */)
-{
- QPainter painter(this);
- painter.drawImage(QPoint(0, 0), theImage);
-}
-
-void PaintArea::mousePressEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton) {
- if (!pendingPath.isEmpty()) {
- QPainter painter(&theImage);
- setupPainter(painter);
-
- const QRectF boundingRect = pendingPath.boundingRect();
- QLinearGradient gradient(boundingRect.topRight(),
- boundingRect.bottomLeft());
- gradient.setColorAt(0.0, QColor(color.red(), color.green(),
- color.blue(), 63));
- gradient.setColorAt(1.0, QColor(color.red(), color.green(),
- color.blue(), 191));
- painter.setBrush(gradient);
- painter.translate(event->position().toPoint() - boundingRect.center());
- painter.drawPath(pendingPath);
-
- pendingPath = QPainterPath();
-#ifndef QT_NO_CURSOR
- unsetCursor();
-#endif
- update();
- } else {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- const QRect rect = brushInterface->mousePress(brush, painter,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = event->position().toPoint();
- }
- }
-}
-
-//! [1]
-void PaintArea::mouseMoveEvent(QMouseEvent *event)
-{
- if ((event->buttons() & Qt::LeftButton) && lastPos != QPoint(-1, -1)) {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- const QRect rect = brushInterface->mouseMove(brush, painter, lastPos,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = event->position().toPoint();
- }
-}
-//! [1]
-
-void PaintArea::mouseReleaseEvent(QMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton && lastPos != QPoint(-1, -1)) {
- if (brushInterface) {
- QPainter painter(&theImage);
- setupPainter(painter);
- QRect rect = brushInterface->mouseRelease(brush, painter,
- event->position().toPoint());
- update(rect);
- }
-
- lastPos = QPoint(-1, -1);
- }
-}
-
-void PaintArea::setupPainter(QPainter &painter)
-{
- painter.setRenderHint(QPainter::Antialiasing, true);
- painter.setPen(QPen(color, thickness, Qt::SolidLine, Qt::RoundCap,
- Qt::RoundJoin));
-}
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.h b/examples/widgets/tools/plugandpaint/app/paintarea.h
deleted file mode 100644
index 1d1e6006c8..0000000000
--- a/examples/widgets/tools/plugandpaint/app/paintarea.h
+++ /dev/null
@@ -1,101 +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 PAINTAREA_H
-#define PAINTAREA_H
-
-#include <QColor>
-#include <QImage>
-#include <QPainterPath>
-#include <QWidget>
-
-class BrushInterface;
-
-class PaintArea : public QWidget
-{
- Q_OBJECT
-
-public:
- PaintArea(QWidget *parent = nullptr);
-
- bool openImage(const QString &fileName);
- bool saveImage(const QString &fileName, const char *fileFormat);
- void setImage(const QImage &image);
- void insertShape(const QPainterPath &path);
- void setBrushColor(const QColor &color);
- void setBrushWidth(int width);
- void setBrush(BrushInterface *brushInterface, const QString &brush);
-
- QImage image() const { return theImage; }
- QColor brushColor() const { return color; }
- int brushWidth() const { return thickness; }
- QSize sizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
-
-private:
- void setupPainter(QPainter &painter);
-
- QImage theImage = {500, 400, QImage::Format_RGB32};
- QColor color = Qt::blue;
- int thickness = 3;
-
- BrushInterface *brushInterface = nullptr;
- QString brush;
- QPoint lastPos = {-1, -1};
-
- QPainterPath pendingPath;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
deleted file mode 100644
index 204d6ffec4..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
+++ /dev/null
@@ -1,165 +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 "plugindialog.h"
-#include "interfaces.h"
-
-#include <QDir>
-#include <QGridLayout>
-#include <QHeaderView>
-#include <QLabel>
-#include <QPluginLoader>
-#include <QPushButton>
-#include <QStringList>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-
-PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
- QWidget *parent) :
- QDialog(parent),
- label(new QLabel),
- treeWidget(new QTreeWidget),
- okButton(new QPushButton(tr("OK")))
-{
- treeWidget->setAlternatingRowColors(false);
- treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
- treeWidget->setColumnCount(1);
- treeWidget->header()->hide();
-
- okButton->setDefault(true);
-
- connect(okButton, &QAbstractButton::clicked, this, &QWidget::close);
-
- QGridLayout *mainLayout = new QGridLayout;
- mainLayout->setColumnStretch(0, 1);
- mainLayout->setColumnStretch(2, 1);
- mainLayout->addWidget(label, 0, 0, 1, 3);
- mainLayout->addWidget(treeWidget, 1, 0, 1, 3);
- mainLayout->addWidget(okButton, 2, 1);
- setLayout(mainLayout);
-
- interfaceIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- interfaceIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- featureIcon.addPixmap(style()->standardPixmap(QStyle::SP_FileIcon));
-
- setWindowTitle(tr("Plugin Information"));
- findPlugins(path, fileNames);
-}
-
-//! [0]
-void PluginDialog::findPlugins(const QString &path,
- const QStringList &fileNames)
-{
- label->setText(tr("Plug & Paint found the following plugins\n"
- "(looked in %1):")
- .arg(QDir::toNativeSeparators(path)));
-
- const QDir dir(path);
-
- const auto staticInstances = QPluginLoader::staticInstances();
- for (QObject *plugin : staticInstances)
- populateTreeWidget(plugin, tr("%1 (Static Plugin)")
- .arg(plugin->metaObject()->className()));
-
- for (const QString &fileName : fileNames) {
- QPluginLoader loader(dir.absoluteFilePath(fileName));
- QObject *plugin = loader.instance();
- if (plugin)
- populateTreeWidget(plugin, fileName);
- }
-}
-//! [0]
-
-//! [1]
-void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
-{
- auto pluginItem = new QTreeWidgetItem(treeWidget);
- pluginItem->setText(0, text);
- pluginItem->setExpanded(true);
-
- QFont boldFont = pluginItem->font(0);
- boldFont.setBold(true);
- pluginItem->setFont(0, boldFont);
-
- if (plugin) {
- auto iBrush = qobject_cast<BrushInterface *>(plugin);
- if (iBrush)
- addItems(pluginItem, "BrushInterface", iBrush->brushes());
-
- auto iShape = qobject_cast<ShapeInterface *>(plugin);
- if (iShape)
- addItems(pluginItem, "ShapeInterface", iShape->shapes());
-
- auto iFilter = qobject_cast<FilterInterface *>(plugin);
- if (iFilter)
- addItems(pluginItem, "FilterInterface", iFilter->filters());
- }
-}
-//! [1]
-
-void PluginDialog::addItems(QTreeWidgetItem *pluginItem,
- const char *interfaceName,
- const QStringList &features)
-{
- auto interfaceItem = new QTreeWidgetItem(pluginItem);
- interfaceItem->setText(0, interfaceName);
- interfaceItem->setIcon(0, interfaceIcon);
-
- for (QString feature : features) {
- if (feature.endsWith("..."))
- feature.chop(3);
- auto featureItem = new QTreeWidgetItem(interfaceItem);
- featureItem->setText(0, feature);
- featureItem->setIcon(0, featureIcon);
- }
-}
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.h b/examples/widgets/tools/plugandpaint/app/plugindialog.h
deleted file mode 100644
index b18b30e62c..0000000000
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.h
+++ /dev/null
@@ -1,86 +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 PLUGINDIALOG_H
-#define PLUGINDIALOG_H
-
-#include <QDialog>
-#include <QIcon>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QPushButton;
-class QStringList;
-class QTreeWidget;
-class QTreeWidgetItem;
-QT_END_NAMESPACE
-
-class PluginDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- PluginDialog(const QString &path, const QStringList &fileNames,
- QWidget *parent = nullptr);
-
-private:
- void findPlugins(const QString &path, const QStringList &fileNames);
- void populateTreeWidget(QObject *plugin, const QString &text);
- void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName,
- const QStringList &features);
-
- QLabel *label = nullptr;
- QTreeWidget *treeWidget = nullptr;
- QPushButton *okButton = nullptr;
- QIcon interfaceIcon;
- QIcon featureIcon;
-};
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugandpaint.pro b/examples/widgets/tools/plugandpaint/plugandpaint.pro
deleted file mode 100644
index 58c4dbbb6e..0000000000
--- a/examples/widgets/tools/plugandpaint/plugandpaint.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT_FOR_CONFIG += widgets
-requires(qtConfig(inputdialog))
-
-TEMPLATE = subdirs
-SUBDIRS = plugins app
-
-app.depends = plugins
diff --git a/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
deleted file mode 100644
index 1e63da97ca..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from plugins.pro.
-
-add_subdirectory(basictools)
-add_subdirectory(extrafilters)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt
deleted file mode 100644
index 76474c282b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools 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/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt6_add_plugin(pnp_basictools STATIC)
-target_sources(pnp_basictools PRIVATE
- basictoolsplugin.cpp basictoolsplugin.h
-)
-target_include_directories(pnp_basictools PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_basictools PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
deleted file mode 100644
index 8baeb5357d..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from basictools.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_basictools 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/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_basictools STATIC)
-target_sources(pnp_basictools PRIVATE
- basictoolsplugin.cpp basictoolsplugin.h
-)
-target_include_directories(pnp_basictools PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_basictools PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_basictools
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json b/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro b/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro
deleted file mode 100644
index f5ba95252c..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictools.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin static
-QT += widgets
-INCLUDEPATH += ../../app
-HEADERS = basictoolsplugin.h
-SOURCES = basictoolsplugin.cpp
-TARGET = $$qtLibraryTarget(pnp_basictools)
-DESTDIR = ../../plugins
-#! [0]
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-uikit: CONFIG += debug_and_release
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
deleted file mode 100644
index 64f9f7a0d9..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
+++ /dev/null
@@ -1,197 +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 "basictoolsplugin.h"
-
-#include <QInputDialog>
-#include <QPainter>
-#include <QRandomGenerator>
-#include <QtMath>
-
-//! [0]
-QStringList BasicToolsPlugin::brushes() const
-{
- return {tr("Pencil"), tr("Air Brush"), tr("Random Letters")};
-}
-//! [0]
-
-//! [1]
-QRect BasicToolsPlugin::mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos)
-{
- return mouseMove(brush, painter, pos, pos);
-}
-//! [1]
-
-//! [2]
-QRect BasicToolsPlugin::mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos)
-{
- painter.save();
-
- int rad = painter.pen().width() / 2;
- QRect boundingRect = QRect(oldPos, newPos).normalized()
- .adjusted(-rad, -rad, +rad, +rad);
- QColor color = painter.pen().color();
- int thickness = painter.pen().width();
- QColor transparentColor(color.red(), color.green(), color.blue(), 0);
-//! [2] //! [3]
-
- if (brush == tr("Pencil")) {
- painter.drawLine(oldPos, newPos);
- } else if (brush == tr("Air Brush")) {
- int numSteps = 2 + (newPos - oldPos).manhattanLength() / 2;
-
- painter.setBrush(QBrush(color, Qt::Dense6Pattern));
- painter.setPen(Qt::NoPen);
-
- for (int i = 0; i < numSteps; ++i) {
- int x = oldPos.x() + i * (newPos.x() - oldPos.x()) / (numSteps - 1);
- int y = oldPos.y() + i * (newPos.y() - oldPos.y()) / (numSteps - 1);
-
- painter.drawEllipse(x - (thickness / 2), y - (thickness / 2),
- thickness, thickness);
- }
- } else if (brush == tr("Random Letters")) {
- QChar ch(QRandomGenerator::global()->bounded('A', 'Z' + 1));
-
- QFont biggerFont = painter.font();
- biggerFont.setBold(true);
- biggerFont.setPointSize(biggerFont.pointSize() + thickness);
- painter.setFont(biggerFont);
-
- painter.drawText(newPos, QString(ch));
-
- QFontMetrics metrics(painter.font());
- boundingRect = metrics.boundingRect(ch);
- boundingRect.translate(newPos);
- boundingRect.adjust(-10, -10, +10, +10);
- }
- painter.restore();
- return boundingRect;
-}
-//! [3]
-
-//! [4]
-QRect BasicToolsPlugin::mouseRelease(const QString & /* brush */,
- QPainter & /* painter */,
- const QPoint & /* pos */)
-{
- return QRect(0, 0, 0, 0);
-}
-//! [4]
-
-//! [5]
-QStringList BasicToolsPlugin::shapes() const
-{
- return {tr("Circle"), tr("Star"), tr("Text...")};
-}
-//! [5]
-
-//! [6]
-QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
- QWidget *parent)
-{
- QPainterPath path;
-
- if (shape == tr("Circle")) {
- path.addEllipse(0, 0, 50, 50);
- } else if (shape == tr("Star")) {
- path.moveTo(90, 50);
- for (int i = 1; i < 5; ++i) {
- path.lineTo(50 + 40 * std::cos(0.8 * i * M_PI),
- 50 + 40 * std::sin(0.8 * i * M_PI));
- }
- path.closeSubpath();
- } else if (shape == tr("Text...")) {
- QString text = QInputDialog::getText(parent, tr("Text Shape"),
- tr("Enter text:"),
- QLineEdit::Normal, tr("Qt"));
- if (!text.isEmpty()) {
- QFont timesFont("Times", 50);
- timesFont.setStyleStrategy(QFont::ForceOutline);
- path.addText(0, 0, timesFont, text);
- }
- }
-
- return path;
-}
-//! [6]
-
-//! [7]
-QStringList BasicToolsPlugin::filters() const
-{
- return {tr("Invert Pixels"), tr("Swap RGB"), tr("Grayscale")};
-}
-//! [7]
-
-//! [8]
-QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image,
- QWidget * /* parent */)
-{
- QImage result = image.convertToFormat(QImage::Format_RGB32);
-
- if (filter == tr("Invert Pixels")) {
- result.invertPixels();
- } else if (filter == tr("Swap RGB")) {
- result = result.rgbSwapped();
- } else if (filter == tr("Grayscale")) {
- for (int y = 0; y < result.height(); ++y) {
- for (int x = 0; x < result.width(); ++x) {
- QRgb pixel = result.pixel(x, y);
- int gray = qGray(pixel);
- int alpha = qAlpha(pixel);
- result.setPixel(x, y, qRgba(gray, gray, gray, alpha));
- }
- }
- }
- return result;
-}
-//! [8]
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h
deleted file mode 100644
index 1d9d170daa..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.h
+++ /dev/null
@@ -1,101 +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 BASICTOOLSPLUGIN_H
-#define BASICTOOLSPLUGIN_H
-
-//! [0]
-#include <interfaces.h>
-
-#include <QImage>
-#include <QObject>
-#include <QPainterPath>
-#include <QRect>
-#include <QStringList>
-#include <QtPlugin>
-
-//! [1]
-class BasicToolsPlugin : public QObject,
- public BrushInterface,
- public ShapeInterface,
- public FilterInterface
-{
- Q_OBJECT
-//! [4]
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json")
-//! [4]
- Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)
-//! [0]
-
-//! [2]
-public:
-//! [1]
- // BrushInterface
- QStringList brushes() const override;
- QRect mousePress(const QString &brush, QPainter &painter,
- const QPoint &pos) override;
- QRect mouseMove(const QString &brush, QPainter &painter,
- const QPoint &oldPos, const QPoint &newPos) override;
- QRect mouseRelease(const QString &brush, QPainter &painter,
- const QPoint &pos) override;
-
- // ShapeInterface
- QStringList shapes() const override;
- QPainterPath generateShape(const QString &shape, QWidget *parent) override;
-
- // FilterInterface
- QStringList filters() const override;
- QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) override;
-//! [3]
-};
-//! [2] //! [3]
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt
deleted file mode 100644
index 57f37843b8..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters 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/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_extrafilters)
-target_sources(pnp_extrafilters PRIVATE
- extrafiltersplugin.cpp extrafiltersplugin.h
-)
-target_include_directories(pnp_extrafilters PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_extrafilters PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt b/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
deleted file mode 100644
index 1c2d500497..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-# Generated from extrafilters.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pnp_extrafilters 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/tools/plugandpaint/plugins")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(pnp_extrafilters)
-target_sources(pnp_extrafilters PRIVATE
- extrafiltersplugin.cpp extrafiltersplugin.h
-)
-target_include_directories(pnp_extrafilters PUBLIC
- ../../app
-)
-
-target_link_libraries(pnp_extrafilters PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS pnp_extrafilters
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json
deleted file mode 100644
index 0967ef424b..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro
deleted file mode 100644
index e137b04823..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafilters.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-INCLUDEPATH += ../../app
-HEADERS = extrafiltersplugin.h
-SOURCES = extrafiltersplugin.cpp
-TARGET = $$qtLibraryTarget(pnp_extrafilters)
-DESTDIR = ../../plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/plugandpaint/plugins
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-uikit: CONFIG += debug_and_release
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
deleted file mode 100644
index 30c616a830..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
+++ /dev/null
@@ -1,129 +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 "extrafiltersplugin.h"
-
-#include <QInputDialog>
-
-QStringList ExtraFiltersPlugin::filters() const
-{
- return {tr("Flip Horizontally"), tr("Flip Vertically"),
- tr("Smudge..."), tr("Threshold...")};
-}
-
-QImage ExtraFiltersPlugin::filterImage(const QString &filter,
- const QImage &image, QWidget *parent)
-{
- QImage original = image.convertToFormat(QImage::Format_RGB32);
- QImage result = original;
-
- if (filter == tr("Flip Horizontally")) {
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(original.width() - x - 1, y);
- result.setPixel(x, y, pixel);
- }
- }
- } else if (filter == tr("Flip Vertically")) {
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(x, original.height() - y - 1);
- result.setPixel(x, y, pixel);
- }
- }
- } else if (filter == tr("Smudge...")) {
- bool ok;
- int numIters = QInputDialog::getInt(parent, tr("Smudge Filter"),
- tr("Enter number of iterations:"),
- 5, 1, 20, 1, &ok);
- if (ok) {
- for (int i = 0; i < numIters; ++i) {
- for (int y = 1; y < original.height() - 1; ++y) {
- for (int x = 1; x < original.width() - 1; ++x) {
- QRgb p1 = original.pixel(x, y);
- QRgb p2 = original.pixel(x, y + 1);
- QRgb p3 = original.pixel(x, y - 1);
- QRgb p4 = original.pixel(x + 1, y);
- QRgb p5 = original.pixel(x - 1, y);
-
- int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4)
- + qRed(p5)) / 5;
- int green = (qGreen(p1) + qGreen(p2) + qGreen(p3)
- + qGreen(p4) + qGreen(p5)) / 5;
- int blue = (qBlue(p1) + qBlue(p2) + qBlue(p3)
- + qBlue(p4) + qBlue(p5)) / 5;
- int alpha = (qAlpha(p1) + qAlpha(p2) + qAlpha(p3)
- + qAlpha(p4) + qAlpha(p5)) / 5;
-
- result.setPixel(x, y, qRgba(red, green, blue, alpha));
- }
- }
- }
- }
- } else if (filter == tr("Threshold...")) {
- bool ok;
- int threshold = QInputDialog::getInt(parent, tr("Threshold Filter"),
- tr("Enter threshold:"),
- 10, 1, 256, 1, &ok);
- if (ok) {
- int factor = 256 / threshold;
- for (int y = 0; y < original.height(); ++y) {
- for (int x = 0; x < original.width(); ++x) {
- QRgb pixel = original.pixel(x, y);
- result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor,
- qGreen(pixel) / factor * factor,
- qBlue(pixel) / factor * factor,
- qAlpha(pixel)));
- }
- }
- }
- }
- return result;
-}
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h
deleted file mode 100644
index dddde78caa..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.h
+++ /dev/null
@@ -1,75 +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 EXTRAFILTERSPLUGIN_H
-#define EXTRAFILTERSPLUGIN_H
-
-//! [0]
-#include <interfaces.h>
-
-#include <QObject>
-#include <QtPlugin>
-#include <QStringList>
-#include <QImage>
-
-class ExtraFiltersPlugin : public QObject, public FilterInterface
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.FilterInterface" FILE "extrafilters.json")
- Q_INTERFACES(FilterInterface)
-
-public:
- QStringList filters() const override;
- QImage filterImage(const QString &filter, const QImage &image,
- QWidget *parent) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/plugandpaint/plugins/plugins.pro b/examples/widgets/tools/plugandpaint/plugins/plugins.pro
deleted file mode 100644
index e15220c621..0000000000
--- a/examples/widgets/tools/plugandpaint/plugins/plugins.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = basictools \
- extrafilters
diff --git a/examples/widgets/tools/regularexpression/CMakeLists.txt b/examples/widgets/tools/regularexpression/CMakeLists.txt
index da31574e8b..af7701f1cf 100644
--- a/examples/widgets/tools/regularexpression/CMakeLists.txt
+++ b/examples/widgets/tools/regularexpression/CMakeLists.txt
@@ -1,41 +1,35 @@
-# Generated from regularexpression.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(regularexpression 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/tools/regularexpression")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(regularexpression
+qt_add_executable(regularexpression
main.cpp
regularexpressiondialog.cpp regularexpressiondialog.h
)
-target_link_libraries(regularexpression PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+set_target_properties(regularexpression PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
)
+target_link_libraries(regularexpression PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set(regularexpression_resource_files
"images/copy.png"
)
-qt6_add_resources(regularexpression "regularexpression"
+qt_add_resources(regularexpression "regularexpression"
PREFIX
"/"
FILES
@@ -43,7 +37,14 @@ qt6_add_resources(regularexpression "regularexpression"
)
install(TARGETS regularexpression
- 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 regularexpression
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/regularexpression/main.cpp b/examples/widgets/tools/regularexpression/main.cpp
index 4b6b210226..460aa892c0 100644
--- a/examples/widgets/tools/regularexpression/main.cpp
+++ b/examples/widgets/tools/regularexpression/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 "regularexpressiondialog.h"
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
index 51025b7100..6ba781731f 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.cpp
@@ -1,54 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
-** 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 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+// Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "regularexpressiondialog.h"
@@ -66,12 +19,13 @@
#include <QAction>
#include <QClipboard>
#include <QContextMenuEvent>
+#include <QFont>
+#include <QFontDatabase>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QFormLayout>
-#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
@@ -106,6 +60,20 @@ static QString codeToPattern(QString code)
return code;
}
+static QFrame *createHorizontalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ return result;
+}
+
+static QFrame *createVerticalSeparator()
+{
+ auto *result = new QFrame;
+ result->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ return result;
+}
+
class PatternLineEdit : public QLineEdit
{
Q_OBJECT
@@ -239,6 +207,7 @@ void RegularExpressionDialog::setResultUiEnabled(bool enabled)
{
matchDetailsTreeWidget->setEnabled(enabled);
namedGroupsTreeWidget->setEnabled(enabled);
+ replacementTextEdit->setEnabled(enabled);
}
static void setTextColor(QWidget *widget, const QColor &color)
@@ -264,6 +233,7 @@ void RegularExpressionDialog::refresh()
matchDetailsTreeWidget->clear();
namedGroupsTreeWidget->clear();
regexpStatusLabel->setText(QString());
+ replacementTextEdit->clear();
if (pattern.isEmpty()) {
setResultUiEnabled(false);
@@ -271,12 +241,12 @@ void RegularExpressionDialog::refresh()
return;
}
- QRegularExpression rx(pattern);
- if (!rx.isValid()) {
+ regularExpression.setPattern(pattern);
+ if (!regularExpression.isValid()) {
setTextColor(patternLineEdit, Qt::red);
regexpStatusLabel->setText(tr("Invalid: syntax error at position %1 (%2)")
- .arg(rx.patternErrorOffset())
- .arg(rx.errorString()));
+ .arg(regularExpression.patternErrorOffset())
+ .arg(regularExpression.errorString()));
setResultUiEnabled(false);
setUpdatesEnabled(true);
return;
@@ -308,11 +278,13 @@ void RegularExpressionDialog::refresh()
if (useUnicodePropertiesOptionCheckBox->isChecked())
patternOptions |= QRegularExpression::UseUnicodePropertiesOption;
- rx.setPatternOptions(patternOptions);
+ regularExpression.setPatternOptions(patternOptions);
- const int capturingGroupsCount = rx.captureCount() + 1;
+ const int capturingGroupsCount = regularExpression.captureCount() + 1;
- QRegularExpressionMatchIterator iterator = rx.globalMatch(text, offsetSpinBox->value(), matchType, matchOptions);
+ const int offset = offsetSpinBox->value();
+ QRegularExpressionMatchIterator iterator =
+ regularExpression.globalMatch(text, offset, matchType, matchOptions);
int i = 0;
while (iterator.hasNext()) {
@@ -334,7 +306,7 @@ void RegularExpressionDialog::refresh()
regexpStatusLabel->setText(tr("Valid"));
- const QStringList namedCaptureGroups = rx.namedCaptureGroups();
+ const QStringList namedCaptureGroups = regularExpression.namedCaptureGroups();
for (int i = 0; i < namedCaptureGroups.size(); ++i) {
const QString currentNamedCaptureGroup = namedCaptureGroups.at(i);
@@ -343,28 +315,44 @@ void RegularExpressionDialog::refresh()
namedGroupItem->setText(1, currentNamedCaptureGroup.isNull() ? tr("<no name>") : currentNamedCaptureGroup);
}
+ updateReplacement();
setUpdatesEnabled(true);
}
-void RegularExpressionDialog::setupUi()
+void RegularExpressionDialog::updateReplacement()
{
- QWidget *leftHalfContainer = setupLeftUi();
-
- QFrame *verticalSeparator = new QFrame;
- verticalSeparator->setFrameStyle(QFrame::VLine | QFrame::Sunken);
-
- QWidget *rightHalfContainer = setupRightUi();
+ replacementTextEdit->clear();
+ const QString &replacement = replacementLineEdit->text();
+ if (!regularExpression.isValid() || replacement.isEmpty())
+ return;
- QHBoxLayout *mainLayout = new QHBoxLayout;
- mainLayout->addWidget(leftHalfContainer);
- mainLayout->addWidget(verticalSeparator);
- mainLayout->addWidget(rightHalfContainer);
+ QString replaced = subjectTextEdit->toPlainText();
+ replaced.replace(regularExpression, replacement);
+ replacementTextEdit->setPlainText(replaced);
+}
- setLayout(mainLayout);
+void RegularExpressionDialog::setupUi()
+{
+ auto *mainLayout = new QVBoxLayout(this);
+ mainLayout->addWidget(setupTextUi());
+ mainLayout->addWidget(createHorizontalSeparator());
+ auto *horizontalLayout = new QHBoxLayout();
+ mainLayout->addLayout(horizontalLayout);
+ horizontalLayout->addWidget(setupOptionsUi());
+ horizontalLayout->addWidget(createVerticalSeparator());
+ horizontalLayout->addWidget(setupInfoUi());
+
+ auto font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
+ patternLineEdit->setFont(font);
+ rawStringLiteralLineEdit->setFont(font);
+ escapedPatternLineEdit->setFont(font);
+ replacementLineEdit->setFont(font);
+ subjectTextEdit->setFont(font);
+ replacementTextEdit->setFont(font);
}
-QWidget *RegularExpressionDialog::setupLeftUi()
+QWidget *RegularExpressionDialog::setupTextUi()
{
QWidget *container = new QWidget;
@@ -387,6 +375,35 @@ QWidget *RegularExpressionDialog::setupLeftUi()
subjectTextEdit = new QPlainTextEdit;
layout->addRow(tr("&Subject text:"), subjectTextEdit);
+ layout->addRow(createHorizontalSeparator());
+
+ QLabel *replaceLabel = new QLabel(tr("<h3>Replacement"));
+ layout->addRow(replaceLabel);
+
+ replacementLineEdit = new QLineEdit;
+ replacementLineEdit->setClearButtonEnabled(true);
+ connect(replacementLineEdit, &QLineEdit::textChanged, this,
+ &RegularExpressionDialog::updateReplacement);
+ layout->addRow(tr("&Replace by:"), replacementLineEdit);
+ replacementLineEdit->setToolTip(tr("Use \\1, \\2... as placeholders for the captured groups."));
+
+ replacementTextEdit = new QPlainTextEdit;
+ replacementTextEdit->setReadOnly(true);
+ layout->addRow(tr("Result:"), replacementTextEdit);
+
+ return container;
+}
+
+QWidget *RegularExpressionDialog::setupOptionsUi()
+{
+ QWidget *container = new QWidget;
+
+ QFormLayout *layout = new QFormLayout(container);
+ layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+ layout->setContentsMargins(QMargins());
+
+ layout->addRow(new QLabel(tr("<h3>Options</h3>")));
+
caseInsensitiveOptionCheckBox = new QCheckBox(tr("Case insensitive (/i)"));
dotMatchesEverythingOptionCheckBox = new QCheckBox(tr("Dot matches everything (/s)"));
multilineOptionCheckBox = new QCheckBox(tr("Multiline (/m)"));
@@ -431,7 +448,7 @@ QWidget *RegularExpressionDialog::setupLeftUi()
return container;
}
-QWidget *RegularExpressionDialog::setupRightUi()
+QWidget *RegularExpressionDialog::setupInfoUi()
{
QWidget *container = new QWidget;
@@ -447,9 +464,7 @@ QWidget *RegularExpressionDialog::setupRightUi()
matchDetailsTreeWidget->setSizeAdjustPolicy(QTreeWidget::AdjustToContents);
layout->addRow(tr("Match details:"), matchDetailsTreeWidget);
- QFrame *horizontalSeparator = new QFrame;
- horizontalSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
- layout->addRow(horizontalSeparator);
+ layout->addRow(createHorizontalSeparator());
QLabel *regexpInfoLabel = new QLabel(tr("<h3>Regular expression information</h3>"));
layout->addRow(regexpInfoLabel);
diff --git a/examples/widgets/tools/regularexpression/regularexpressiondialog.h b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
index b0db4d884c..6924cc0c7b 100644
--- a/examples/widgets/tools/regularexpression/regularexpressiondialog.h
+++ b/examples/widgets/tools/regularexpression/regularexpressiondialog.h
@@ -1,59 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
-** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
-** 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 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+// Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef REGULAREXPRESSIONDIALOG_H
#define REGULAREXPRESSIONDIALOG_H
#include <QDialog>
+#include <QRegularExpression>
QT_BEGIN_NAMESPACE
class QCheckBox;
@@ -72,18 +26,25 @@ class RegularExpressionDialog : public QDialog
public:
RegularExpressionDialog(QWidget *parent = nullptr);
+private slots:
+ void updateReplacement();
+
private:
void refresh();
void setupUi();
QWidget *setupLeftUi();
- QWidget *setupRightUi();
+ QWidget *setupTextUi();
+ QWidget *setupOptionsUi();
+ QWidget *setupInfoUi();
void setResultUiEnabled(bool enabled);
QLineEdit *patternLineEdit;
QLineEdit *rawStringLiteralLineEdit;
QLineEdit *escapedPatternLineEdit;
+ QLineEdit *replacementLineEdit;
QPlainTextEdit *subjectTextEdit;
+ QPlainTextEdit *replacementTextEdit;
QCheckBox *caseInsensitiveOptionCheckBox;
QCheckBox *dotMatchesEverythingOptionCheckBox;
@@ -104,6 +65,8 @@ private:
QLabel *regexpStatusLabel;
QTreeWidget *namedGroupsTreeWidget;
+
+ QRegularExpression regularExpression;
};
#endif
diff --git a/examples/widgets/tools/settingseditor/CMakeLists.txt b/examples/widgets/tools/settingseditor/CMakeLists.txt
deleted file mode 100644
index 957d0a0fa8..0000000000
--- a/examples/widgets/tools/settingseditor/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-# Generated from settingseditor.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(settingseditor 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/tools/settingseditor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(settingseditor
- locationdialog.cpp locationdialog.h
- main.cpp
- mainwindow.cpp mainwindow.h
- settingstree.cpp settingstree.h
- variantdelegate.cpp variantdelegate.h
-)
-target_link_libraries(settingseditor PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS settingseditor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/settingseditor/inifiles/licensepage.ini b/examples/widgets/tools/settingseditor/inifiles/licensepage.ini
deleted file mode 100644
index 608d1b7885..0000000000
--- a/examples/widgets/tools/settingseditor/inifiles/licensepage.ini
+++ /dev/null
@@ -1,46 +0,0 @@
-[Field%201]
-Bottom=89
-Flags=MULTILINE|VSCROLL|READONLY
-Left=4
-Right=296
-State=No license agreement file found. Please contact support.
-Top=14
-Type=Text
-
-[Field%202]
-Bottom=8
-Left=4
-Right=294
-Text=Press Page Down to see the rest of the agreement.
-Top=0
-Type=Label
-
-[Field%203]
-Bottom=111
-Left=4
-Right=297
-Text=If you accept the terms of the agreement, select the first option below. You must accept the agreement to install this software. Click Next to continue.
-Top=92
-Type=Label
-
-[Field%204]
-Bottom=129
-Flags=GROUP|NOTIFY
-Left=4
-Right=299
-Text=I &accept the terms in the License Agreement
-Top=120
-Type=RadioButton
-
-[Field%205]
-Bottom=140
-Flags=NOTIFY
-Left=4
-Right=300
-State=1
-Text=I &do not accept the terms in the License Agreement
-Top=129
-Type=RadioButton
-
-[Settings]
-NumFields=5
diff --git a/examples/widgets/tools/settingseditor/inifiles/qsa.ini b/examples/widgets/tools/settingseditor/inifiles/qsa.ini
deleted file mode 100644
index 56a2964ee5..0000000000
--- a/examples/widgets/tools/settingseditor/inifiles/qsa.ini
+++ /dev/null
@@ -1,26 +0,0 @@
-[Field%201]
-Bottom=65
-Left=0
-Right=299
-Text=QSA Build Options
-Top=9
-Type=Groupbox
-
-[Field%202]
-Bottom=37
-Left=20
-Right=284
-Text=Don't compile QSA Workbench into QSA.
-Top=27
-Type=Checkbox
-
-[Field%203]
-Bottom=56
-Left=20
-Right=247
-Text=Don't compile QSA Workbench nor QSA Editor into QSA.
-Top=45
-Type=Checkbox
-
-[Settings]
-NumFields=3
diff --git a/examples/widgets/tools/settingseditor/locationdialog.cpp b/examples/widgets/tools/settingseditor/locationdialog.cpp
deleted file mode 100644
index 86119a1afd..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.cpp
+++ /dev/null
@@ -1,240 +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 "locationdialog.h"
-
-#include <QBoxLayout>
-#include <QComboBox>
-#include <QDialogButtonBox>
-#include <QDir>
-#include <QPushButton>
-#include <QGroupBox>
-#include <QHeaderView>
-#include <QLabel>
-#include <QLineEdit>
-#include <QTableWidget>
-#include <QTableWidgetItem>
-
-LocationDialog::LocationDialog(QWidget *parent)
- : QDialog(parent)
-{
- formatComboBox = new QComboBox;
- formatComboBox->addItem(tr("Native"));
- formatComboBox->addItem(tr("INI"));
-
- scopeComboBox = new QComboBox;
- scopeComboBox->addItem(tr("User"));
- scopeComboBox->addItem(tr("System"));
-
- organizationComboBox = new QComboBox;
- organizationComboBox->addItem(tr("QtProject"));
- organizationComboBox->setEditable(true);
-
- applicationComboBox = new QComboBox;
- applicationComboBox->addItem(tr("Any"));
- applicationComboBox->addItem(tr("Qt Creator"));
- applicationComboBox->addItem(tr("Application Example"));
- applicationComboBox->addItem(tr("Assistant"));
- applicationComboBox->addItem(tr("Designer"));
- applicationComboBox->addItem(tr("Linguist"));
- applicationComboBox->setEditable(true);
- applicationComboBox->setCurrentIndex(1);
-
- formatLabel = new QLabel(tr("&Format:"));
- formatLabel->setBuddy(formatComboBox);
-
- scopeLabel = new QLabel(tr("&Scope:"));
- scopeLabel->setBuddy(scopeComboBox);
-
- organizationLabel = new QLabel(tr("&Organization:"));
- organizationLabel->setBuddy(organizationComboBox);
-
- applicationLabel = new QLabel(tr("&Application:"));
- applicationLabel->setBuddy(applicationComboBox);
-
- locationsGroupBox = new QGroupBox(tr("Setting Locations"));
-
- const QStringList labels{tr("Location"), tr("Access")};
-
- locationsTable = new QTableWidget;
- locationsTable->setSelectionMode(QAbstractItemView::SingleSelection);
- locationsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
- locationsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
- locationsTable->setColumnCount(2);
- locationsTable->setHorizontalHeaderLabels(labels);
- locationsTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
- locationsTable->horizontalHeader()->resizeSection(1, 180);
- connect(locationsTable, &QTableWidget::itemActivated, this, &LocationDialog::itemActivated);
-
- buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-
- connect(formatComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(scopeComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(organizationComboBox->lineEdit(),
- &QLineEdit::editingFinished,
- this, &LocationDialog::updateLocationsTable);
- connect(applicationComboBox->lineEdit(),
- &QLineEdit::editingFinished,
- this, &LocationDialog::updateLocationsTable);
- connect(applicationComboBox, &QComboBox::activated,
- this, &LocationDialog::updateLocationsTable);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
-
- QVBoxLayout *locationsLayout = new QVBoxLayout(locationsGroupBox);
- locationsLayout->addWidget(locationsTable);
-
- QGridLayout *mainLayout = new QGridLayout(this);
- mainLayout->addWidget(formatLabel, 0, 0);
- mainLayout->addWidget(formatComboBox, 0, 1);
- mainLayout->addWidget(scopeLabel, 1, 0);
- mainLayout->addWidget(scopeComboBox, 1, 1);
- mainLayout->addWidget(organizationLabel, 2, 0);
- mainLayout->addWidget(organizationComboBox, 2, 1);
- mainLayout->addWidget(applicationLabel, 3, 0);
- mainLayout->addWidget(applicationComboBox, 3, 1);
- mainLayout->addWidget(locationsGroupBox, 4, 0, 1, 2);
- mainLayout->addWidget(buttonBox, 5, 0, 1, 2);
-
- updateLocationsTable();
-
- setWindowTitle(tr("Open Application Settings"));
- resize(650, 400);
-}
-
-QSettings::Format LocationDialog::format() const
-{
- if (formatComboBox->currentIndex() == 0)
- return QSettings::NativeFormat;
- else
- return QSettings::IniFormat;
-}
-
-QSettings::Scope LocationDialog::scope() const
-{
- if (scopeComboBox->currentIndex() == 0)
- return QSettings::UserScope;
- else
- return QSettings::SystemScope;
-}
-
-QString LocationDialog::organization() const
-{
- return organizationComboBox->currentText();
-}
-
-QString LocationDialog::application() const
-{
- if (applicationComboBox->currentText() == tr("Any"))
- return QString();
- else
- return applicationComboBox->currentText();
-}
-
-void LocationDialog::itemActivated(QTableWidgetItem *)
-{
- buttonBox->button(QDialogButtonBox::Ok)->animateClick();
-}
-
-void LocationDialog::updateLocationsTable()
-{
- locationsTable->setUpdatesEnabled(false);
- locationsTable->setRowCount(0);
-
- for (int i = 0; i < 2; ++i) {
- if (i == 0 && scope() == QSettings::SystemScope)
- continue;
-
- QSettings::Scope actualScope = (i == 0) ? QSettings::UserScope
- : QSettings::SystemScope;
- for (int j = 0; j < 2; ++j) {
- if (j == 0 && application().isEmpty())
- continue;
-
- QString actualApplication;
- if (j == 0)
- actualApplication = application();
- QSettings settings(format(), actualScope, organization(),
- actualApplication);
-
- int row = locationsTable->rowCount();
- locationsTable->setRowCount(row + 1);
-
- QTableWidgetItem *item0 = new QTableWidgetItem(QDir::toNativeSeparators(settings.fileName()));
-
- QTableWidgetItem *item1 = new QTableWidgetItem;
- bool disable = (settings.childKeys().isEmpty()
- && settings.childGroups().isEmpty());
-
- if (row == 0) {
- if (settings.isWritable()) {
- item1->setText(tr("Read-write"));
- disable = false;
- } else {
- item1->setText(tr("Read-only"));
- }
- buttonBox->button(QDialogButtonBox::Ok)->setDisabled(disable);
- } else {
- item1->setText(tr("Read-only fallback"));
- }
-
- if (disable) {
- item0->setFlags(item0->flags() & ~Qt::ItemIsEnabled);
- item1->setFlags(item1->flags() & ~Qt::ItemIsEnabled);
- }
-
- locationsTable->setItem(row, 0, item0);
- locationsTable->setItem(row, 1, item1);
- }
- }
- locationsTable->setUpdatesEnabled(true);
-}
diff --git a/examples/widgets/tools/settingseditor/locationdialog.h b/examples/widgets/tools/settingseditor/locationdialog.h
deleted file mode 100644
index cd2efecb0b..0000000000
--- a/examples/widgets/tools/settingseditor/locationdialog.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 LOCATIONDIALOG_H
-#define LOCATIONDIALOG_H
-
-#include <QDialog>
-#include <QSettings>
-
-QT_BEGIN_NAMESPACE
-class QComboBox;
-class QDialogButtonBox;
-class QGroupBox;
-class QLabel;
-class QTableWidget;
-class QTableWidgetItem;
-QT_END_NAMESPACE
-
-class LocationDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- LocationDialog(QWidget *parent = nullptr);
-
- QSettings::Format format() const;
- QSettings::Scope scope() const;
- QString organization() const;
- QString application() const;
-
-private slots:
- void updateLocationsTable();
- void itemActivated(QTableWidgetItem *);
-
-private:
- QLabel *formatLabel;
- QLabel *scopeLabel;
- QLabel *organizationLabel;
- QLabel *applicationLabel;
- QComboBox *formatComboBox;
- QComboBox *scopeComboBox;
- QComboBox *organizationComboBox;
- QComboBox *applicationComboBox;
- QGroupBox *locationsGroupBox;
- QTableWidget *locationsTable;
- QDialogButtonBox *buttonBox;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/main.cpp b/examples/widgets/tools/settingseditor/main.cpp
deleted file mode 100644
index 3186e9dea5..0000000000
--- a/examples/widgets/tools/settingseditor/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[])
-{
- QApplication app(argc, argv);
- QCoreApplication::setApplicationName("Settings Editor");
- QCoreApplication::setApplicationVersion(QT_VERSION_STR);
-
- MainWindow mainWin;
- mainWin.show();
- return app.exec();
-}
diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp
deleted file mode 100644
index 225a396f91..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ /dev/null
@@ -1,222 +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 "locationdialog.h"
-#include "mainwindow.h"
-#include "settingstree.h"
-
-#include <QAction>
-#include <QApplication>
-#include <QFileDialog>
-#include <QInputDialog>
-#include <QLineEdit>
-#include <QMenuBar>
-#include <QMessageBox>
-#include <QScreen>
-#include <QStandardPaths>
-#include <QStatusBar>
-
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
- , settingsTree(new SettingsTree)
-{
- setCentralWidget(settingsTree);
-
- createActions();
-
- autoRefreshAct->setChecked(true);
- fallbacksAct->setChecked(true);
-
- setWindowTitle(QCoreApplication::applicationName());
- const QRect availableGeometry = screen()->availableGeometry();
- adjustSize();
- move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
-}
-
-void MainWindow::openSettings()
-{
- if (!locationDialog)
- locationDialog = new LocationDialog(this);
-
- if (locationDialog->exec() != QDialog::Accepted)
- return;
-
- SettingsPtr settings(new QSettings(locationDialog->format(),
- locationDialog->scope(),
- locationDialog->organization(),
- locationDialog->application()));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(true);
-}
-
-void MainWindow::openIniFile()
-{
- const QString directory = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
- const QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open INI File"),
- directory, tr("INI Files (*.ini *.conf)"));
- if (fileName.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(fileName, QSettings::IniFormat));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::openPropertyList()
-{
- const QString directory = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
- const QString fileName =
- QFileDialog::getOpenFileName(this, tr("Open Property List"),
- directory, tr("Property List Files (*.plist)"));
- if (fileName.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(fileName, QSettings::NativeFormat));
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::openRegistryPath()
-{
- const QString path =
- QInputDialog::getText(this, tr("Open Registry Path"),
- tr("Enter the path in the Windows registry:"),
- QLineEdit::Normal, "HKEY_CURRENT_USER\\");
- if (path.isEmpty())
- return;
-
- SettingsPtr settings(new QSettings(path, QSettings::NativeFormat));
-
- setSettingsObject(settings);
- fallbacksAct->setEnabled(false);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Settings Editor"),
- tr("The <b>Settings Editor</b> example shows how to access "
- "application settings using Qt."));
-}
-
-void MainWindow::createActions()
-{
- QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
-
- QAction *openSettingsAct = fileMenu->addAction(tr("&Open Application Settings..."), this, &MainWindow::openSettings);
- openSettingsAct->setShortcuts(QKeySequence::Open);
-
- QAction *openIniFileAct = fileMenu->addAction(tr("Open I&NI File..."), this, &MainWindow::openIniFile);
- openIniFileAct->setShortcut(tr("Ctrl+N"));
-
-#ifdef Q_OS_MACOS
- QAction *openPropertyListAct = fileMenu->addAction(tr("Open Apple &Property List..."), this, &MainWindow::openPropertyList);
- openPropertyListAct->setShortcut(tr("Ctrl+P"));
-#endif // Q_OS_MACOS
-
-#ifdef Q_OS_WIN
- QAction *openRegistryPathAct = fileMenu->addAction(tr("Open Windows &Registry Path..."), this, &MainWindow::openRegistryPath);
- openRegistryPathAct->setShortcut(tr("Ctrl+G"));
-#endif // Q_OS_WIN
-
- fileMenu->addSeparator();
-
- refreshAct = fileMenu->addAction(tr("&Refresh"), settingsTree, &SettingsTree::refresh);
- refreshAct->setShortcut(tr("Ctrl+R"));
- refreshAct->setEnabled(false);
-
- fileMenu->addSeparator();
-
- QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close);
- exitAct->setShortcuts(QKeySequence::Quit);
-
- QMenu *optionsMenu = menuBar()->addMenu(tr("&Options"));
-
- autoRefreshAct = optionsMenu->addAction(tr("&Auto-Refresh"));
- autoRefreshAct->setShortcut(tr("Ctrl+A"));
- autoRefreshAct->setCheckable(true);
- autoRefreshAct->setEnabled(false);
- connect(autoRefreshAct, &QAction::triggered,
- settingsTree, &SettingsTree::setAutoRefresh);
- connect(autoRefreshAct, &QAction::triggered,
- refreshAct, &QAction::setDisabled);
-
- fallbacksAct = optionsMenu->addAction(tr("&Fallbacks"));
- fallbacksAct->setShortcut(tr("Ctrl+F"));
- fallbacksAct->setCheckable(true);
- fallbacksAct->setEnabled(false);
- connect(fallbacksAct, &QAction::triggered,
- settingsTree, &SettingsTree::setFallbacksEnabled);
-
- QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(tr("&About"), this, &MainWindow::about);
- helpMenu->addAction(tr("About &Qt"), qApp, &QCoreApplication::quit);
-}
-
-void MainWindow::setSettingsObject(const SettingsPtr &settings)
-{
- settings->setFallbacksEnabled(fallbacksAct->isChecked());
- settingsTree->setSettingsObject(settings);
-
- refreshAct->setEnabled(true);
- autoRefreshAct->setEnabled(true);
-
- QString niceName = QDir::cleanPath(settings->fileName());
- int pos = niceName.lastIndexOf(QLatin1Char('/'));
- if (pos != -1)
- niceName.remove(0, pos + 1);
-
- if (!settings->isWritable())
- niceName = tr("%1 (read only)").arg(niceName);
-
- setWindowTitle(tr("%1 - %2").arg(niceName, QCoreApplication::applicationName()));
- statusBar()->showMessage(tr("Opened \"%1\"").arg(QDir::toNativeSeparators(settings->fileName())));
-}
diff --git a/examples/widgets/tools/settingseditor/mainwindow.h b/examples/widgets/tools/settingseditor/mainwindow.h
deleted file mode 100644
index b1115005a9..0000000000
--- a/examples/widgets/tools/settingseditor/mainwindow.h
+++ /dev/null
@@ -1,91 +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 <QMainWindow>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QAction;
-class QSettings;
-QT_END_NAMESPACE
-class LocationDialog;
-class SettingsTree;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- typedef QSharedPointer<QSettings> SettingsPtr;
-
- MainWindow(QWidget *parent = nullptr);
-
-private slots:
- void openSettings();
- void openIniFile();
- void openPropertyList();
- void openRegistryPath();
- void about();
-
-private:
- void createActions();
- void setSettingsObject(const SettingsPtr &settings);
-
- SettingsTree *settingsTree = nullptr;
- LocationDialog *locationDialog = nullptr;
- QAction *refreshAct = nullptr;
- QAction *autoRefreshAct = nullptr;
- QAction *fallbacksAct = nullptr;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/settingseditor.pro b/examples/widgets/tools/settingseditor/settingseditor.pro
deleted file mode 100644
index 4880b7e582..0000000000
--- a/examples/widgets/tools/settingseditor/settingseditor.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-QT += widgets
-requires(qtConfig(tablewidget))
-
-HEADERS = locationdialog.h \
- mainwindow.h \
- settingstree.h \
- variantdelegate.h
-SOURCES = locationdialog.cpp \
- main.cpp \
- mainwindow.cpp \
- settingstree.cpp \
- variantdelegate.cpp
-
-EXAMPLE_FILES = inifiles
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/settingseditor
-INSTALLS += target
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
deleted file mode 100644
index 04af8ce3b9..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ /dev/null
@@ -1,278 +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 "settingstree.h"
-#include "variantdelegate.h"
-
-#include <QApplication>
-#include <QHeaderView>
-#include <QScreen>
-#include <QSettings>
-
-SettingsTree::SettingsTree(QWidget *parent)
- : QTreeWidget(parent),
- m_typeChecker(new TypeChecker)
-{
- setItemDelegate(new VariantDelegate(m_typeChecker, this));
-
- setHeaderLabels({tr("Setting"), tr("Type"), tr("Value")});
- header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
- header()->setSectionResizeMode(2, QHeaderView::Stretch);
-
- refreshTimer.setInterval(2000);
-
- groupIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirClosedIcon),
- QIcon::Normal, QIcon::Off);
- groupIcon.addPixmap(style()->standardPixmap(QStyle::SP_DirOpenIcon),
- QIcon::Normal, QIcon::On);
- keyIcon.addPixmap(style()->standardPixmap(QStyle::SP_FileIcon));
-
- connect(&refreshTimer, &QTimer::timeout, this, &SettingsTree::maybeRefresh);
-}
-
-SettingsTree::~SettingsTree() = default;
-
-void SettingsTree::setSettingsObject(const SettingsPtr &newSettings)
-{
- settings = newSettings;
- clear();
-
- if (settings.isNull()) {
- refreshTimer.stop();
- } else {
- refresh();
- if (autoRefresh)
- refreshTimer.start();
- }
-}
-
-QSize SettingsTree::sizeHint() const
-{
- const QRect availableGeometry = screen()->availableGeometry();
- return QSize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3);
-}
-
-void SettingsTree::setAutoRefresh(bool autoRefresh)
-{
- this->autoRefresh = autoRefresh;
- if (!settings.isNull()) {
- if (autoRefresh) {
- maybeRefresh();
- refreshTimer.start();
- } else {
- refreshTimer.stop();
- }
- }
-}
-
-void SettingsTree::setFallbacksEnabled(bool enabled)
-{
- if (!settings.isNull()) {
- settings->setFallbacksEnabled(enabled);
- refresh();
- }
-}
-
-void SettingsTree::maybeRefresh()
-{
- if (state() != EditingState)
- refresh();
-}
-
-void SettingsTree::refresh()
-{
- if (settings.isNull())
- return;
-
- disconnect(this, &QTreeWidget::itemChanged,
- this, &SettingsTree::updateSetting);
-
- settings->sync();
- updateChildItems(nullptr);
-
- connect(this, &QTreeWidget::itemChanged,
- this, &SettingsTree::updateSetting);
-}
-
-bool SettingsTree::event(QEvent *event)
-{
- if (event->type() == QEvent::WindowActivate) {
- if (isActiveWindow() && autoRefresh)
- maybeRefresh();
- }
- return QTreeWidget::event(event);
-}
-
-void SettingsTree::updateSetting(QTreeWidgetItem *item)
-{
- QString key = item->text(0);
- QTreeWidgetItem *ancestor = item->parent();
- while (ancestor) {
- key.prepend(ancestor->text(0) + QLatin1Char('/'));
- ancestor = ancestor->parent();
- }
-
- settings->setValue(key, item->data(2, Qt::UserRole));
- if (autoRefresh)
- refresh();
-}
-
-void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
-{
- int dividerIndex = 0;
-
- const QStringList childGroups = settings->childGroups();
- for (const QString &group : childGroups) {
- QTreeWidgetItem *child;
- int childIndex = findChild(parent, group, dividerIndex);
- if (childIndex != -1) {
- child = childAt(parent, childIndex);
- child->setText(1, QString());
- child->setText(2, QString());
- child->setData(2, Qt::UserRole, QVariant());
- moveItemForward(parent, childIndex, dividerIndex);
- } else {
- child = createItem(group, parent, dividerIndex);
- }
- child->setIcon(0, groupIcon);
- ++dividerIndex;
-
- settings->beginGroup(group);
- updateChildItems(child);
- settings->endGroup();
- }
-
- const QStringList childKeys = settings->childKeys();
- for (const QString &key : childKeys) {
- QTreeWidgetItem *child;
- int childIndex = findChild(parent, key, 0);
-
- if (childIndex == -1 || childIndex >= dividerIndex) {
- if (childIndex != -1) {
- child = childAt(parent, childIndex);
- for (int i = 0; i < child->childCount(); ++i)
- delete childAt(child, i);
- moveItemForward(parent, childIndex, dividerIndex);
- } else {
- child = createItem(key, parent, dividerIndex);
- }
- child->setIcon(0, keyIcon);
- ++dividerIndex;
- } else {
- child = childAt(parent, childIndex);
- }
-
- QVariant value = settings->value(key);
- if (value.userType() == QMetaType::UnknownType) {
- child->setText(1, "Invalid");
- } else {
- if (value.type() == QVariant::String) {
- const QString stringValue = value.toString();
- if (m_typeChecker->boolExp.match(stringValue).hasMatch()) {
- value.setValue(stringValue.compare("true", Qt::CaseInsensitive) == 0);
- } else if (m_typeChecker->signedIntegerExp.match(stringValue).hasMatch())
- value.setValue(stringValue.toInt());
- }
-
- child->setText(1, value.typeName());
- }
- child->setText(2, VariantDelegate::displayText(value));
- child->setData(2, Qt::UserRole, value);
- }
-
- while (dividerIndex < childCount(parent))
- delete childAt(parent, dividerIndex);
-}
-
-QTreeWidgetItem *SettingsTree::createItem(const QString &text,
- QTreeWidgetItem *parent, int index)
-{
- QTreeWidgetItem *after = nullptr;
- if (index != 0)
- after = childAt(parent, index - 1);
-
- QTreeWidgetItem *item;
- if (parent)
- item = new QTreeWidgetItem(parent, after);
- else
- item = new QTreeWidgetItem(this, after);
-
- item->setText(0, text);
- item->setFlags(item->flags() | Qt::ItemIsEditable);
- return item;
-}
-
-QTreeWidgetItem *SettingsTree::childAt(QTreeWidgetItem *parent, int index) const
-{
- return (parent ? parent->child(index) : topLevelItem(index));
-}
-
-int SettingsTree::childCount(QTreeWidgetItem *parent) const
-{
- return (parent ? parent->childCount() : topLevelItemCount());
-}
-
-int SettingsTree::findChild(QTreeWidgetItem *parent, const QString &text,
- int startIndex) const
-{
- for (int i = startIndex; i < childCount(parent); ++i) {
- if (childAt(parent, i)->text(0) == text)
- return i;
- }
- return -1;
-}
-
-void SettingsTree::moveItemForward(QTreeWidgetItem *parent, int oldIndex,
- int newIndex)
-{
- for (int i = 0; i < oldIndex - newIndex; ++i)
- delete childAt(parent, newIndex);
-}
diff --git a/examples/widgets/tools/settingseditor/settingstree.h b/examples/widgets/tools/settingseditor/settingstree.h
deleted file mode 100644
index 54b1ce6157..0000000000
--- a/examples/widgets/tools/settingseditor/settingstree.h
+++ /dev/null
@@ -1,108 +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 SETTINGSTREE_H
-#define SETTINGSTREE_H
-
-#include <QIcon>
-#include <QTimer>
-#include <QTreeWidget>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-class QSettings;
-QT_END_NAMESPACE
-
-struct TypeChecker;
-
-class SettingsTree : public QTreeWidget
-{
- Q_OBJECT
-
-public:
- using SettingsPtr = QSharedPointer<QSettings>;
- using TypeCheckerPtr = QSharedPointer<TypeChecker>;
-
- SettingsTree(QWidget *parent = nullptr);
- ~SettingsTree();
-
- void setSettingsObject(const SettingsPtr &settings);
- QSize sizeHint() const override;
-
-public slots:
- void setAutoRefresh(bool autoRefresh);
- void setFallbacksEnabled(bool enabled);
- void maybeRefresh();
- void refresh();
-
-protected:
- bool event(QEvent *event) override;
-
-private slots:
- void updateSetting(QTreeWidgetItem *item);
-
-private:
- void updateChildItems(QTreeWidgetItem *parent);
- QTreeWidgetItem *createItem(const QString &text, QTreeWidgetItem *parent,
- int index);
- QTreeWidgetItem *childAt(QTreeWidgetItem *parent, int index) const;
- int childCount(QTreeWidgetItem *parent) const;
- int findChild(QTreeWidgetItem *parent, const QString &text, int startIndex) const;
- void moveItemForward(QTreeWidgetItem *parent, int oldIndex, int newIndex);
-
- SettingsPtr settings;
- TypeCheckerPtr m_typeChecker;
- QTimer refreshTimer;
- QIcon groupIcon;
- QIcon keyIcon;
- bool autoRefresh = false;
-};
-
-#endif
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.cpp b/examples/widgets/tools/settingseditor/variantdelegate.cpp
deleted file mode 100644
index 255f6135be..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.cpp
+++ /dev/null
@@ -1,424 +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 "variantdelegate.h"
-
-#include <QCheckBox>
-#include <QDateTime>
-#include <QLineEdit>
-#include <QSpinBox>
-#include <QRegularExpressionValidator>
-#include <QTextStream>
-
-#include <algorithm>
-
-static bool isPrintableChar(char c)
-{
- return uchar(c) >= 32 && uchar(c) < 128;
-}
-
-static bool isPrintable(const QByteArray &ba)
-{
- return std::all_of(ba.cbegin(), ba.cend(), isPrintableChar);
-}
-
-static QString byteArrayToString(const QByteArray &ba)
-{
- if (isPrintable(ba))
- return QString::fromLatin1(ba);
- QString result;
- for (char c : ba) {
- if (isPrintableChar(c)) {
- if (c == '\\')
- result += QLatin1Char(c);
- result += QLatin1Char(c);
- } else {
- const uint uc = uchar(c);
- result += "\\x";
- if (uc < 16)
- result += '0';
- result += QString::number(uc, 16);
- }
- }
- return result;
-}
-
-TypeChecker::TypeChecker()
-{
- boolExp.setPattern("^(true)|(false)$");
- boolExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
- Q_ASSERT(boolExp.isValid());
-
- byteArrayExp.setPattern(R"RX(^[\x00-\xff]*$)RX");
- charExp.setPattern("^.$");
- Q_ASSERT(charExp.isValid());
- colorExp.setPattern(R"RX(^\(([0-9]*),([0-9]*),([0-9]*),([0-9]*)\)$)RX");
- Q_ASSERT(colorExp.isValid());
- doubleExp.setPattern("");
- pointExp.setPattern(R"RX(^\((-?[0-9]*),(-?[0-9]*)\)$)RX");
- Q_ASSERT(pointExp.isValid());
- rectExp.setPattern(R"RX(^\((-?[0-9]*),(-?[0-9]*),(-?[0-9]*),(-?[0-9]*)\)$)RX");
- Q_ASSERT(rectExp.isValid());
- signedIntegerExp.setPattern("^-?[0-9]*$");
- Q_ASSERT(signedIntegerExp.isValid());
- sizeExp = pointExp;
- unsignedIntegerExp.setPattern("^[0-9]+$");
- Q_ASSERT(unsignedIntegerExp.isValid());
-
- const QString datePattern = "([0-9]{,4})-([0-9]{,2})-([0-9]{,2})";
- dateExp.setPattern('^' + datePattern + '$');
- Q_ASSERT(dateExp.isValid());
- const QString timePattern = "([0-9]{,2}):([0-9]{,2}):([0-9]{,2})";
- timeExp.setPattern('^' + timePattern + '$');
- Q_ASSERT(timeExp.isValid());
- dateTimeExp.setPattern('^' + datePattern + 'T' + timePattern + '$');
- Q_ASSERT(dateTimeExp.isValid());
-}
-
-VariantDelegate::VariantDelegate(const QSharedPointer<TypeChecker> &typeChecker,
- QObject *parent)
- : QStyledItemDelegate(parent),
- m_typeChecker(typeChecker)
-{
-}
-
-void VariantDelegate::paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const
-{
- if (index.column() == 2) {
- QVariant value = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(value.userType())) {
- QStyleOptionViewItem myOption = option;
- myOption.state &= ~QStyle::State_Enabled;
- QStyledItemDelegate::paint(painter, myOption, index);
- return;
- }
- }
-
- QStyledItemDelegate::paint(painter, option, index);
-}
-
-QWidget *VariantDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem & /* option */,
- const QModelIndex &index) const
-{
- if (index.column() != 2)
- return nullptr;
-
- QVariant originalValue = index.model()->data(index, Qt::UserRole);
- if (!isSupportedType(originalValue.userType()))
- return nullptr;
-
- switch (originalValue.userType()) {
- case QMetaType::Bool:
- return new QCheckBox(parent);
- break;
- case QMetaType::Int:
- case QMetaType::LongLong: {
- auto spinBox = new QSpinBox(parent);
- spinBox->setRange(-32767, 32767);
- return spinBox;
- }
- case QMetaType::UInt:
- case QMetaType::ULongLong: {
- auto spinBox = new QSpinBox(parent);
- spinBox->setRange(0, 63335);
- return spinBox;
- }
- default:
- break;
- }
-
- QLineEdit *lineEdit = new QLineEdit(parent);
- lineEdit->setFrame(false);
-
- QRegularExpression regExp;
-
- switch (originalValue.userType()) {
- case QMetaType::Bool:
- regExp = m_typeChecker->boolExp;
- break;
- case QMetaType::QByteArray:
- regExp = m_typeChecker->byteArrayExp;
- break;
- case QMetaType::QChar:
- regExp = m_typeChecker->charExp;
- break;
- case QMetaType::QColor:
- regExp = m_typeChecker->colorExp;
- break;
- case QMetaType::QDate:
- regExp = m_typeChecker->dateExp;
- break;
- case QMetaType::QDateTime:
- regExp = m_typeChecker->dateTimeExp;
- break;
- case QMetaType::Double:
- regExp = m_typeChecker->doubleExp;
- break;
- case QMetaType::Int:
- case QMetaType::LongLong:
- regExp = m_typeChecker->signedIntegerExp;
- break;
- case QMetaType::QPoint:
- regExp = m_typeChecker->pointExp;
- break;
- case QMetaType::QRect:
- regExp = m_typeChecker->rectExp;
- break;
- case QMetaType::QSize:
- regExp = m_typeChecker->sizeExp;
- break;
- case QMetaType::QTime:
- regExp = m_typeChecker->timeExp;
- break;
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- regExp = m_typeChecker->unsignedIntegerExp;
- break;
- default:
- break;
- }
-
- if (regExp.isValid()) {
- QValidator *validator = new QRegularExpressionValidator(regExp, lineEdit);
- lineEdit->setValidator(validator);
- }
-
- return lineEdit;
-}
-
-void VariantDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
-{
- QVariant value = index.model()->data(index, Qt::UserRole);
- if (auto spinBox = qobject_cast<QSpinBox *>(editor)) {
- const auto userType = value.userType();
- if (userType == QMetaType::UInt || userType == QMetaType::ULongLong)
- spinBox->setValue(value.toUInt());
- else
- spinBox->setValue(value.toInt());
- } else if (auto checkBox = qobject_cast<QCheckBox *>(editor)) {
- checkBox->setChecked(value.toBool());
- } else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor)) {
- if (value.userType() == QMetaType::QByteArray
- && !isPrintable(value.toByteArray())) {
- lineEdit->setReadOnly(true);
- }
- lineEdit->setText(displayText(value));
- }
-}
-
-void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
-{
- const QVariant originalValue = index.model()->data(index, Qt::UserRole);
- QVariant value;
-
- if (auto spinBox = qobject_cast<QSpinBox *>(editor)) {
- value.setValue(spinBox->value());
- } else if (auto checkBox = qobject_cast<QCheckBox *>(editor)) {
- value.setValue(checkBox->isChecked());
- } else if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor)) {
- if (!lineEdit->isModified())
- return;
-
- QString text = lineEdit->text();
- const QValidator *validator = lineEdit->validator();
- if (validator) {
- int pos;
- if (validator->validate(text, pos) != QValidator::Acceptable)
- return;
- }
-
- QRegularExpressionMatch match;
-
- switch (originalValue.userType()) {
- case QMetaType::QChar:
- value = text.at(0);
- break;
- case QMetaType::QColor:
- match = m_typeChecker->colorExp.match(text);
- value = QColor(qMin(match.captured(1).toInt(), 255),
- qMin(match.captured(2).toInt(), 255),
- qMin(match.captured(3).toInt(), 255),
- qMin(match.captured(4).toInt(), 255));
- break;
- case QMetaType::QDate:
- {
- QDate date = QDate::fromString(text, Qt::ISODate);
- if (!date.isValid())
- return;
- value = date;
- }
- break;
- case QMetaType::QDateTime:
- {
- QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
- if (!dateTime.isValid())
- return;
- value = dateTime;
- }
- break;
- case QMetaType::QPoint:
- match = m_typeChecker->pointExp.match(text);
- value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
- break;
- case QMetaType::QRect:
- match = m_typeChecker->rectExp.match(text);
- value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
- match.captured(3).toInt(), match.captured(4).toInt());
- break;
- case QMetaType::QSize:
- match = m_typeChecker->sizeExp.match(text);
- value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
- break;
- case QMetaType::QStringList:
- value = text.split(',');
- break;
- case QMetaType::QTime:
- {
- QTime time = QTime::fromString(text, Qt::ISODate);
- if (!time.isValid())
- return;
- value = time;
- }
- break;
- default:
- value = text;
- value.convert(originalValue.userType());
- }
- }
-
- model->setData(index, displayText(value), Qt::DisplayRole);
- model->setData(index, value, Qt::UserRole);
-}
-
-bool VariantDelegate::isSupportedType(int type)
-{
- switch (type) {
- case QMetaType::Bool:
- case QMetaType::QByteArray:
- case QMetaType::QChar:
- case QMetaType::QColor:
- case QMetaType::QDate:
- case QMetaType::QDateTime:
- case QMetaType::Double:
- case QMetaType::Int:
- case QMetaType::LongLong:
- case QMetaType::QPoint:
- case QMetaType::QRect:
- case QMetaType::QSize:
- case QMetaType::QString:
- case QMetaType::QStringList:
- case QMetaType::QTime:
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- return true;
- default:
- return false;
- }
-}
-
-QString VariantDelegate::displayText(const QVariant &value)
-{
- switch (value.userType()) {
- case QMetaType::Bool:
- return value.toBool() ? "✓" : "☐";
- case QMetaType::QByteArray:
- return byteArrayToString(value.toByteArray());
- case QMetaType::QChar:
- case QMetaType::Double:
- case QMetaType::Int:
- case QMetaType::LongLong:
- case QMetaType::QString:
- case QMetaType::UInt:
- case QMetaType::ULongLong:
- return value.toString();
- case QMetaType::QColor:
- {
- QColor color = qvariant_cast<QColor>(value);
- return QString("(%1,%2,%3,%4)")
- .arg(color.red()).arg(color.green())
- .arg(color.blue()).arg(color.alpha());
- }
- case QMetaType::QDate:
- return value.toDate().toString(Qt::ISODate);
- case QMetaType::QDateTime:
- return value.toDateTime().toString(Qt::ISODate);
- case QMetaType::UnknownType:
- return "<Invalid>";
- case QMetaType::QPoint:
- {
- QPoint point = value.toPoint();
- return QString("(%1,%2)").arg(point.x()).arg(point.y());
- }
- case QMetaType::QRect:
- {
- QRect rect = value.toRect();
- return QString("(%1,%2,%3,%4)")
- .arg(rect.x()).arg(rect.y())
- .arg(rect.width()).arg(rect.height());
- }
- case QMetaType::QSize:
- {
- QSize size = value.toSize();
- return QString("(%1,%2)").arg(size.width()).arg(size.height());
- }
- case QMetaType::QStringList:
- return value.toStringList().join(',');
- case QMetaType::QTime:
- return value.toTime().toString(Qt::ISODate);
- default:
- break;
- }
- return QString("<%1>").arg(value.typeName());
-}
diff --git a/examples/widgets/tools/settingseditor/variantdelegate.h b/examples/widgets/tools/settingseditor/variantdelegate.h
deleted file mode 100644
index 9d46aa77a5..0000000000
--- a/examples/widgets/tools/settingseditor/variantdelegate.h
+++ /dev/null
@@ -1,100 +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 VARIANTDELEGATE_H
-#define VARIANTDELEGATE_H
-
-#include <QStyledItemDelegate>
-#include <QRegularExpression>
-#include <QSharedPointer>
-
-struct TypeChecker
-{
- TypeChecker();
-
- QRegularExpression boolExp;
- QRegularExpression byteArrayExp;
- QRegularExpression charExp;
- QRegularExpression colorExp;
- QRegularExpression dateExp;
- QRegularExpression dateTimeExp;
- QRegularExpression doubleExp;
- QRegularExpression pointExp;
- QRegularExpression rectExp;
- QRegularExpression signedIntegerExp;
- QRegularExpression sizeExp;
- QRegularExpression timeExp;
- QRegularExpression unsignedIntegerExp;
-};
-
-class VariantDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-
-public:
- explicit VariantDelegate(const QSharedPointer<TypeChecker> &typeChecker,
- QObject *parent = nullptr);
-
- void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
- const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const override;
- void setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const override;
-
- static bool isSupportedType(int type);
- static QString displayText(const QVariant &value);
-
-private:
- QSharedPointer<TypeChecker> m_typeChecker;
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/.prev_CMakeLists.txt b/examples/widgets/tools/styleplugin/.prev_CMakeLists.txt
deleted file mode 100644
index 630c3703f8..0000000000
--- a/examples/widgets/tools/styleplugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from styleplugin.pro.
-
-add_subdirectory(stylewindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/styleplugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/CMakeLists.txt
deleted file mode 100644
index af10d38700..0000000000
--- a/examples/widgets/tools/styleplugin/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated from styleplugin.pro.
-
-# special case begin
-cmake_minimum_required(VERSION 3.14)
-project(styleplugin LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-set(INSTALL_EXAMPLEDIR "examples")
-
-find_package(Qt6 COMPONENTS Widgets)
-# special case end
-
-add_subdirectory(stylewindow)
-add_subdirectory(plugin)
diff --git a/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt
deleted file mode 100644
index c1be706fde..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simplestyleplugin 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/tools/styleplugin/styles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_library(simplestyleplugin MODULE
- simplestyle.cpp simplestyle.h
- simplestyleplugin.cpp simplestyleplugin.h
-)
-target_link_libraries(simplestyleplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplestyleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt b/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
deleted file mode 100644
index 84266d0068..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from plugin.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(simplestyleplugin 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/tools/styleplugin/styles")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-qt_add_plugin(simplestyleplugin)
-target_sources(simplestyleplugin PRIVATE
- simplestyle.cpp simplestyle.h
- simplestyleplugin.cpp simplestyleplugin.h
-)
-target_link_libraries(simplestyleplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS simplestyleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/plugin/plugin.pro b/examples/widgets/tools/styleplugin/plugin/plugin.pro
deleted file mode 100644
index 35184fc82a..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-#! [0]
-TEMPLATE = lib
-CONFIG += plugin
-QT += widgets
-HEADERS = simplestyle.h \
- simplestyleplugin.h
-SOURCES = simplestyle.cpp \
- simplestyleplugin.cpp
-TARGET = simplestyleplugin
-#! [0]
-win32 {
- CONFIG(debug, release|debug):DESTDIR = ../debug/styles/
- CONFIG(release, release|debug):DESTDIR = ../release/styles/
-} else {
- DESTDIR = ../styles/
-}
-
-EXAMPLE_FILES += simplestyle.json
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/styleplugin/styles
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp b/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp
deleted file mode 100644
index 765c9c2745..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.cpp
+++ /dev/null
@@ -1,56 +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 "simplestyle.h"
-
-void SimpleStyle::polish(QPalette &palette)
-{
- palette.setBrush(QPalette::Button, Qt::red);
-}
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.h b/examples/widgets/tools/styleplugin/plugin/simplestyle.h
deleted file mode 100644
index 4f49de8cbc..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.h
+++ /dev/null
@@ -1,66 +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 SIMPLESTYLE_H
-#define SIMPLESTYLE_H
-
-#include <QProxyStyle>
-
-class SimpleStyle : public QProxyStyle
-{
- Q_OBJECT
-
-public:
- SimpleStyle() = default;
-
- void polish(QPalette &palette) override;
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyle.json b/examples/widgets/tools/styleplugin/plugin/simplestyle.json
deleted file mode 100644
index a708e2aafe..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyle.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "simplestyle" ]
-}
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp
deleted file mode 100644
index cbe7c15cc0..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.cpp
+++ /dev/null
@@ -1,68 +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 "simplestyleplugin.h"
-#include "simplestyle.h"
-
-//! [0]
-QStringList SimpleStylePlugin::keys() const
-{
- return {"SimpleStyle"};
-}
-//! [0]
-
-//! [1]
-QStyle *SimpleStylePlugin::create(const QString &key)
-{
- if (key.toLower() == "simplestyle")
- return new SimpleStyle;
- return nullptr;
-}
-//! [1]
diff --git a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h b/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
deleted file mode 100644
index 3ce37410eb..0000000000
--- a/examples/widgets/tools/styleplugin/plugin/simplestyleplugin.h
+++ /dev/null
@@ -1,70 +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 SIMPLESTYLEPLUGIN_H
-#define SIMPLESTYLEPLUGIN_H
-
-#include <QStylePlugin>
-
-//! [0]
-class SimpleStylePlugin : public QStylePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "simplestyle.json")
-
-public:
- SimpleStylePlugin() = default;
-
- QStringList keys() const;
- QStyle *create(const QString &key) override;
-};
-//! [0]
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/styleplugin.pro b/examples/widgets/tools/styleplugin/styleplugin.pro
deleted file mode 100644
index 4f120637b0..0000000000
--- a/examples/widgets/tools/styleplugin/styleplugin.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = stylewindow \
- plugin
diff --git a/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt b/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt
deleted file mode 100644
index 4f8e652ede..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/CMakeLists.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-# Generated from stylewindow.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(styleplugin 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/tools/styleplugin")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(styleplugin
- main.cpp
- stylewindow.cpp stylewindow.h
-)
-target_link_libraries(styleplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS styleplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/styleplugin/stylewindow/main.cpp b/examples/widgets/tools/styleplugin/stylewindow/main.cpp
deleted file mode 100644
index ff29eb119e..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/main.cpp
+++ /dev/null
@@ -1,68 +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 <QStyleFactory>
-
-#include "stylewindow.h"
-
-//! [0]
-int main(int argv, char *args[])
-{
- QApplication app(argv, args);
- QApplication::setStyle(QStyleFactory::create("simplestyle"));
-
- StyleWindow window;
- window.resize(200, 50);
- window.show();
-
- return app.exec();
-}
-//! [0]
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp
deleted file mode 100644
index 90413ed12e..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.cpp
+++ /dev/null
@@ -1,72 +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 <QGridLayout>
-#include <QGroupBox>
-#include <QPushButton>
-
-#include "stylewindow.h"
-
-StyleWindow::StyleWindow()
-{
- QPushButton *styledButton = new QPushButton(tr("Big Red Button"));
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(styledButton);
-
- QGroupBox *styleBox = new QGroupBox(tr("A simple style button"));
- styleBox->setLayout(layout);
-
- QGridLayout *outerLayout = new QGridLayout;
- outerLayout->addWidget(styleBox, 0, 0);
- setLayout(outerLayout);
-
- setWindowTitle(tr("Style Plugin Example"));
-}
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h
deleted file mode 100644
index 7538f8d1bb..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.h
+++ /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$
-**
-****************************************************************************/
-
-#ifndef STYLEWINDOW_H
-#define STYLEWINDOW_H
-
-#include <QWidget>
-
-class StyleWindow : public QWidget
-{
- Q_OBJECT
-
-public:
- StyleWindow();
-};
-
-#endif
diff --git a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro b/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro
deleted file mode 100644
index cdc1bd2fda..0000000000
--- a/examples/widgets/tools/styleplugin/stylewindow/stylewindow.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-QT += widgets
-
-HEADERS = stylewindow.h
-SOURCES = stylewindow.cpp \
- main.cpp
-
-TARGET = styleplugin
-win32 {
- debug:DESTDIR = ../debug/
- release:DESTDIR = ../release/
-} else {
- DESTDIR = ../
-}
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/styleplugin
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/widgets/tools/tools.pro b/examples/widgets/tools/tools.pro
index d2a02deb6b..a6d483f7e2 100644
--- a/examples/widgets/tools/tools.pro
+++ b/examples/widgets/tools/tools.pro
@@ -2,20 +2,7 @@ TEMPLATE = subdirs
SUBDIRS = \
completer \
customcompleter \
- echoplugin \
- i18n \
- plugandpaint \
regularexpression \
- settingseditor \
- styleplugin \
treemodelcompleter \
- undo \
undoframework
-contains(DEFINES, QT_NO_TRANSLATION): SUBDIRS -= i18n
-
-!qtConfig(library) {
- SUBDIRS -= \
- echoplugin \
- plugandpaint
-}
diff --git a/examples/widgets/tools/treemodelcompleter/CMakeLists.txt b/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
index 02a68df7e8..4f512db3ee 100644
--- a/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
+++ b/examples/widgets/tools/treemodelcompleter/CMakeLists.txt
@@ -1,42 +1,36 @@
-# Generated from treemodelcompleter.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(treemodelcompleter 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/tools/treemodelcompleter")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(treemodelcompleter
+qt_add_executable(treemodelcompleter
main.cpp
mainwindow.cpp mainwindow.h
treemodelcompleter.cpp treemodelcompleter.h
)
-target_link_libraries(treemodelcompleter PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+set_target_properties(treemodelcompleter PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
)
+target_link_libraries(treemodelcompleter PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set(treemodelcompleter_resource_files
"resources/treemodel.txt"
)
-qt6_add_resources(treemodelcompleter "treemodelcompleter"
+qt_add_resources(treemodelcompleter "treemodelcompleter"
PREFIX
"/"
FILES
@@ -44,7 +38,14 @@ qt6_add_resources(treemodelcompleter "treemodelcompleter"
)
install(TARGETS treemodelcompleter
- 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 treemodelcompleter
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/treemodelcompleter/main.cpp b/examples/widgets/tools/treemodelcompleter/main.cpp
index 6d150fe80f..060dfe5bd8 100644
--- a/examples/widgets/tools/treemodelcompleter/main.cpp
+++ b/examples/widgets/tools/treemodelcompleter/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>
#include "mainwindow.h"
@@ -54,8 +7,6 @@
//! [0]
int main(int argc, char *argv[])
{
- Q_INIT_RESOURCE(treemodelcompleter);
-
QApplication app(argc, argv);
MainWindow window;
window.show();
diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp b/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
index 44c5b1312a..cf7c73911d 100644
--- a/examples/widgets/tools/treemodelcompleter/mainwindow.cpp
+++ b/examples/widgets/tools/treemodelcompleter/mainwindow.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 "mainwindow.h"
#include "treemodelcompleter.h"
@@ -206,7 +159,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
QRegularExpression re("^\\s+");
while (!file.atEnd()) {
- const QString line = QString::fromUtf8(file.readLine()).trimmed();
+ const QString line = QString::fromUtf8(file.readLine());
const QString trimmedLine = line.trimmed();
if (trimmedLine.isEmpty())
continue;
@@ -218,7 +171,7 @@ QAbstractItemModel *MainWindow::modelFromFile(const QString &fileName)
level = 0;
} else {
const int capLen = match.capturedLength();
- level = line.startsWith(QLatin1Char('\t')) ? capLen / 4 : capLen;
+ level = capLen / 4;
}
if (level + 1 >= parents.size())
@@ -267,4 +220,3 @@ void MainWindow::updateContentsLabel(const QString &sep)
{
contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep));
}
-
diff --git a/examples/widgets/tools/treemodelcompleter/mainwindow.h b/examples/widgets/tools/treemodelcompleter/mainwindow.h
index 87f492c4ac..5641196241 100644
--- a/examples/widgets/tools/treemodelcompleter/mainwindow.h
+++ b/examples/widgets/tools/treemodelcompleter/mainwindow.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 MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
index 8930c815d5..28a15404f1 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.cpp
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.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 "treemodelcompleter.h"
#include <QStringList>
diff --git a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
index d7d1852cc7..7fb413781b 100644
--- a/examples/widgets/tools/treemodelcompleter/treemodelcompleter.h
+++ b/examples/widgets/tools/treemodelcompleter/treemodelcompleter.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 TREEMODELCOMPLETER_H
#define TREEMODELCOMPLETER_H
diff --git a/examples/widgets/tools/undo/CMakeLists.txt b/examples/widgets/tools/undo/CMakeLists.txt
deleted file mode 100644
index 151825cf33..0000000000
--- a/examples/widgets/tools/undo/CMakeLists.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-# Generated from undo.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(undo 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/tools/undo")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(undo
- commands.cpp commands.h
- document.cpp document.h
- main.cpp
- mainwindow.cpp mainwindow.h mainwindow.ui
-)
-target_link_libraries(undo PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(undo_resource_files
- "icons/background.png"
- "icons/blue.png"
- "icons/circle.png"
- "icons/exit.png"
- "icons/fileclose.png"
- "icons/filenew.png"
- "icons/fileopen.png"
- "icons/filesave.png"
- "icons/green.png"
- "icons/ok.png"
- "icons/rectangle.png"
- "icons/red.png"
- "icons/redo.png"
- "icons/remove.png"
- "icons/triangle.png"
- "icons/undo.png"
-)
-
-qt6_add_resources(undo "undo"
- PREFIX
- "/"
- FILES
- ${undo_resource_files}
-)
-
-install(TARGETS undo
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/tools/undo/commands.cpp b/examples/widgets/tools/undo/commands.cpp
deleted file mode 100644
index 97204f9d2f..0000000000
--- a/examples/widgets/tools/undo/commands.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include "commands.h"
-
-static constexpr int setShapeRectCommandId = 1;
-static constexpr int setShapeColorCommandId = 2;
-
-/******************************************************************************
-** AddShapeCommand
-*/
-
-AddShapeCommand::AddShapeCommand(Document *doc, const Shape &shape, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shape(shape)
-{
-}
-
-void AddShapeCommand::undo()
-{
- m_doc->deleteShape(m_shapeName);
-}
-
-void AddShapeCommand::redo()
-{
- // A shape only gets a name when it is inserted into a document
- m_shapeName = m_doc->addShape(m_shape);
- setText(QObject::tr("Add %1").arg(m_shapeName));
-}
-
-/******************************************************************************
-** RemoveShapeCommand
-*/
-
-RemoveShapeCommand::RemoveShapeCommand(Document *doc, const QString &shapeName,
- QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shape(doc->shape(shapeName))
- , m_shapeName(shapeName)
-{
- setText(QObject::tr("Remove %1").arg(shapeName));
-}
-
-void RemoveShapeCommand::undo()
-{
- m_shapeName = m_doc->addShape(m_shape);
-}
-
-void RemoveShapeCommand::redo()
-{
- m_doc->deleteShape(m_shapeName);
-}
-
-/******************************************************************************
-** SetShapeColorCommand
-*/
-
-SetShapeColorCommand::SetShapeColorCommand(Document *doc, const QString &shapeName,
- const QColor &color, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName)
- , m_oldColor(doc->shape(shapeName).color()), m_newColor(color)
-{
- setText(QObject::tr("Set %1's color").arg(shapeName));
-}
-
-void SetShapeColorCommand::undo()
-{
- m_doc->setShapeColor(m_shapeName, m_oldColor);
-}
-
-void SetShapeColorCommand::redo()
-{
- m_doc->setShapeColor(m_shapeName, m_newColor);
-}
-
-bool SetShapeColorCommand::mergeWith(const QUndoCommand *command)
-{
- if (command->id() != setShapeColorCommandId)
- return false;
-
- const SetShapeColorCommand *other = static_cast<const SetShapeColorCommand*>(command);
- if (m_shapeName != other->m_shapeName)
- return false;
-
- m_newColor = other->m_newColor;
- return true;
-}
-
-int SetShapeColorCommand::id() const
-{
- return setShapeColorCommandId;
-}
-
-/******************************************************************************
-** SetShapeRectCommand
-*/
-
-SetShapeRectCommand::SetShapeRectCommand(Document *doc, const QString &shapeName,
- const QRect &rect, QUndoCommand *parent)
- : QUndoCommand(parent), m_doc(doc), m_shapeName(shapeName)
- , m_oldRect(doc->shape(shapeName).rect()), m_newRect(rect)
-{
- setText(QObject::tr("Change %1's geometry").arg(shapeName));
-}
-
-void SetShapeRectCommand::undo()
-{
- m_doc->setShapeRect(m_shapeName, m_oldRect);
-}
-
-void SetShapeRectCommand::redo()
-{
- m_doc->setShapeRect(m_shapeName, m_newRect);
-}
-
-bool SetShapeRectCommand::mergeWith(const QUndoCommand *command)
-{
- if (command->id() != setShapeRectCommandId)
- return false;
-
- const SetShapeRectCommand *other = static_cast<const SetShapeRectCommand*>(command);
- if (m_shapeName != other->m_shapeName)
- return false;
-
- m_newRect = other->m_newRect;
- return true;
-}
-
-int SetShapeRectCommand::id() const
-{
- return setShapeRectCommandId;
-}
diff --git a/examples/widgets/tools/undo/commands.h b/examples/widgets/tools/undo/commands.h
deleted file mode 100644
index ccb550fdd4..0000000000
--- a/examples/widgets/tools/undo/commands.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#ifndef COMMANDS_H
-#define COMMANDS_H
-
-#include <QUndoCommand>
-#include "document.h"
-
-class AddShapeCommand : public QUndoCommand
-{
-public:
- AddShapeCommand(Document *doc, const Shape &shape,
- QUndoCommand *parent = nullptr);
- void undo() override;
- void redo() override;
-
-private:
- Document *m_doc;
- Shape m_shape;
- QString m_shapeName;
-};
-
-class RemoveShapeCommand : public QUndoCommand
-{
-public:
- RemoveShapeCommand(Document *doc, const QString &shapeName,
- QUndoCommand *parent = nullptr);
- void undo() override;
- void redo() override;
-
-private:
- Document *m_doc;
- Shape m_shape;
- QString m_shapeName;
-};
-
-class SetShapeColorCommand : public QUndoCommand
-{
-public:
- SetShapeColorCommand(Document *doc, const QString &shapeName,
- const QColor &color, QUndoCommand *parent = nullptr);
-
- void undo() override;
- void redo() override;
-
- bool mergeWith(const QUndoCommand *command) override;
- int id() const override;
-
-private:
- Document *m_doc;
- QString m_shapeName;
- QColor m_oldColor;
- QColor m_newColor;
-};
-
-class SetShapeRectCommand : public QUndoCommand
-{
-public:
- SetShapeRectCommand(Document *doc, const QString &shapeName,
- const QRect &rect, QUndoCommand *parent = nullptr);
-
- void undo() override;
- void redo() override;
-
- bool mergeWith(const QUndoCommand *command) override;
- int id() const override;
-
-private:
- Document *m_doc;
- QString m_shapeName;
- QRect m_oldRect;
- QRect m_newRect;
-};
-
-#endif // COMMANDS_H
diff --git a/examples/widgets/tools/undo/document.cpp b/examples/widgets/tools/undo/document.cpp
deleted file mode 100644
index 339a63abae..0000000000
--- a/examples/widgets/tools/undo/document.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include "document.h"
-#include "commands.h"
-
-#include <QPainter>
-#include <QPaintEvent>
-#include <QTextStream>
-#include <QUndoStack>
-
-static constexpr int resizeHandleWidth = 6;
-
-/******************************************************************************
-** Shape
-*/
-
-const QSize Shape::minSize(80, 50);
-
-Shape::Shape(Type type, const QColor &color, const QRect &rect)
- : m_type(type), m_rect(rect), m_color(color)
-{
-}
-
-Shape::Type Shape::type() const
-{
- return m_type;
-}
-
-QRect Shape::rect() const
-{
- return m_rect;
-}
-
-QColor Shape::color() const
-{
- return m_color;
-}
-
-QString Shape::name() const
-{
- return m_name;
-}
-
-QRect Shape::resizeHandle() const
-{
- QPoint br = m_rect.bottomRight();
- return QRect(br - QPoint(resizeHandleWidth, resizeHandleWidth), br);
-}
-
-QString Shape::typeToString(Type type)
-{
- switch (type) {
- case Rectangle:
- return QLatin1String("Rectangle");
- case Circle:
- return QLatin1String("Circle");
- case Triangle:
- return QLatin1String("Triangle");
- }
-
- return QString();
-}
-
-Shape::Type Shape::stringToType(const QString &s, bool *ok)
-{
- if (ok != nullptr)
- *ok = true;
-
- if (s == QLatin1String("Rectangle"))
- return Rectangle;
- if (s == QLatin1String("Circle"))
- return Circle;
- if (s == QLatin1String("Triangle"))
- return Triangle;
-
- if (ok != nullptr)
- *ok = false;
- return Rectangle;
-}
-
-/******************************************************************************
-** Document
-*/
-
-Document::Document(QWidget *parent)
- : QWidget(parent), m_undoStack(new QUndoStack(this))
-{
- setAutoFillBackground(true);
- setBackgroundRole(QPalette::Base);
-
- QPalette pal = palette();
- pal.setBrush(QPalette::Base, QPixmap(":/icons/background.png"));
- pal.setColor(QPalette::HighlightedText, Qt::red);
- setPalette(pal);
-}
-
-QString Document::addShape(const Shape &shape)
-{
- QString name = Shape::typeToString(shape.type());
- name = uniqueName(name);
-
- m_shapeList.append(shape);
- m_shapeList[m_shapeList.count() - 1].m_name = name;
- setCurrentShape(m_shapeList.count() - 1);
-
- return name;
-}
-
-void Document::deleteShape(const QString &shapeName)
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- update(m_shapeList.at(index).rect());
-
- m_shapeList.removeAt(index);
-
- if (index <= m_currentIndex) {
- m_currentIndex = -1;
- if (index == m_shapeList.count())
- --index;
- setCurrentShape(index);
- }
-}
-
-Shape Document::shape(const QString &shapeName) const
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return Shape();
- return m_shapeList.at(index);
-}
-
-void Document::setShapeRect(const QString &shapeName, const QRect &rect)
-{
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- Shape &shape = m_shapeList[index];
-
- update(shape.rect());
- update(rect);
-
- shape.m_rect = rect;
-}
-
-void Document::setShapeColor(const QString &shapeName, const QColor &color)
-{
-
- int index = indexOf(shapeName);
- if (index == -1)
- return;
-
- Shape &shape = m_shapeList[index];
- shape.m_color = color;
-
- update(shape.rect());
-}
-
-QUndoStack *Document::undoStack() const
-{
- return m_undoStack;
-}
-
-bool Document::load(QTextStream &stream)
-{
- m_shapeList.clear();
-
- while (!stream.atEnd()) {
- QString shapeType, shapeName, colorName;
- int left, top, width, height;
- stream >> shapeType >> shapeName >> colorName >> left >> top >> width >> height;
- if (stream.status() != QTextStream::Ok)
- return false;
- bool ok;
- Shape::Type type = Shape::stringToType(shapeType, &ok);
- if (!ok)
- return false;
- QColor color(colorName);
- if (!color.isValid())
- return false;
-
- Shape shape(type);
- shape.m_name = shapeName;
- shape.m_color = color;
- shape.m_rect = QRect(left, top, width, height);
-
- m_shapeList.append(shape);
- }
-
- m_currentIndex = m_shapeList.isEmpty() ? -1 : 0;
-
- return true;
-}
-
-void Document::save(QTextStream &stream)
-{
- for (int i = 0; i < m_shapeList.count(); ++i) {
- const Shape &shape = m_shapeList.at(i);
- QRect r = shape.rect();
- stream << Shape::typeToString(shape.type()) << QLatin1Char(' ')
- << shape.name() << QLatin1Char(' ')
- << shape.color().name() << QLatin1Char(' ')
- << r.left() << QLatin1Char(' ')
- << r.top() << QLatin1Char(' ')
- << r.width() << QLatin1Char(' ')
- << r.height();
- if (i != m_shapeList.count() - 1)
- stream << QLatin1Char('\n');
- }
- m_undoStack->setClean();
-}
-
-QString Document::fileName() const
-{
- return m_fileName;
-}
-
-void Document::setFileName(const QString &fileName)
-{
- m_fileName = fileName;
-}
-
-int Document::indexAt(const QPoint &pos) const
-{
- for (int i = m_shapeList.count() - 1; i >= 0; --i) {
- if (m_shapeList.at(i).rect().contains(pos))
- return i;
- }
- return -1;
-}
-
-void Document::mousePressEvent(QMouseEvent *event)
-{
- event->accept();
- int index = indexAt(event->position().toPoint());;
- if (index != -1) {
- setCurrentShape(index);
-
- const Shape &shape = m_shapeList.at(index);
- m_resizeHandlePressed = shape.resizeHandle().contains(event->position().toPoint());
-
- if (m_resizeHandlePressed)
- m_mousePressOffset = shape.rect().bottomRight() - event->position().toPoint();
- else
- m_mousePressOffset = event->position().toPoint() - shape.rect().topLeft();
- }
- m_mousePressIndex = index;
-}
-
-void Document::mouseReleaseEvent(QMouseEvent *event)
-{
- event->accept();
- m_mousePressIndex = -1;
-}
-
-void Document::mouseMoveEvent(QMouseEvent *event)
-{
- event->accept();
-
- if (m_mousePressIndex == -1)
- return;
-
- const Shape &shape = m_shapeList.at(m_mousePressIndex);
-
- QRect rect;
- if (m_resizeHandlePressed) {
- rect = QRect(shape.rect().topLeft(), event->position().toPoint() + m_mousePressOffset);
- } else {
- rect = shape.rect();
- rect.moveTopLeft(event->position().toPoint() - m_mousePressOffset);
- }
-
- QSize size = rect.size().expandedTo(Shape::minSize);
- rect.setSize(size);
-
- m_undoStack->push(new SetShapeRectCommand(this, shape.name(), rect));
-}
-
-static QGradient gradient(const QColor &color, const QRect &rect)
-{
- QColor c = color;
- c.setAlpha(160);
- QLinearGradient result(rect.topLeft(), rect.bottomRight());
- result.setColorAt(0, c.darker(150));
- result.setColorAt(0.5, c.lighter(200));
- result.setColorAt(1, c.darker(150));
- return result;
-}
-
-static QPolygon triangle(const QRect &rect)
-{
- QPolygon result(3);
- result.setPoint(0, rect.center().x(), rect.top());
- result.setPoint(1, rect.right(), rect.bottom());
- result.setPoint(2, rect.left(), rect.bottom());
- return result;
-}
-
-void Document::paintEvent(QPaintEvent *event)
-{
- QRegion paintRegion = event->region();
- QPainter painter(this);
- QPalette pal = palette();
-
- for (int i = 0; i < m_shapeList.count(); ++i) {
- const Shape &shape = m_shapeList.at(i);
-
- if (!paintRegion.contains(shape.rect()))
- continue;
-
- QPen pen = pal.text().color();
- pen.setWidth(i == m_currentIndex ? 2 : 1);
- painter.setPen(pen);
- painter.setBrush(gradient(shape.color(), shape.rect()));
-
- QRect rect = shape.rect();
- rect.adjust(1, 1, -resizeHandleWidth/2, -resizeHandleWidth/2);
-
- // paint the shape
- switch (shape.type()) {
- case Shape::Rectangle:
- painter.drawRect(rect);
- break;
- case Shape::Circle:
- painter.setRenderHint(QPainter::Antialiasing);
- painter.drawEllipse(rect);
- painter.setRenderHint(QPainter::Antialiasing, false);
- break;
- case Shape::Triangle:
- painter.setRenderHint(QPainter::Antialiasing);
- painter.drawPolygon(triangle(rect));
- painter.setRenderHint(QPainter::Antialiasing, false);
- break;
- }
-
- // paint the resize handle
- painter.setPen(pal.text().color());
- painter.setBrush(Qt::white);
- painter.drawRect(shape.resizeHandle().adjusted(0, 0, -1, -1));
-
- // paint the shape name
- painter.setBrush(pal.text());
- if (shape.type() == Shape::Triangle)
- rect.adjust(0, rect.height()/2, 0, 0);
- painter.drawText(rect, Qt::AlignCenter, shape.name());
- }
-}
-
-void Document::setCurrentShape(int index)
-{
- QString currentName;
-
- if (m_currentIndex != -1)
- update(m_shapeList.at(m_currentIndex).rect());
-
- m_currentIndex = index;
-
- if (m_currentIndex != -1) {
- const Shape &current = m_shapeList.at(m_currentIndex);
- update(current.rect());
- currentName = current.name();
- }
-
- emit currentShapeChanged(currentName);
-}
-
-int Document::indexOf(const QString &shapeName) const
-{
- for (int i = 0; i < m_shapeList.count(); ++i) {
- if (m_shapeList.at(i).name() == shapeName)
- return i;
- }
- return -1;
-}
-
-QString Document::uniqueName(const QString &name) const
-{
- QString unique;
-
- for (int i = 0; ; ++i) {
- unique = name;
- if (i > 0)
- unique += QString::number(i);
- if (indexOf(unique) == -1)
- break;
- }
-
- return unique;
-}
-
-QString Document::currentShapeName() const
-{
- if (m_currentIndex == -1)
- return QString();
- return m_shapeList.at(m_currentIndex).name();
-}
-
diff --git a/examples/widgets/tools/undo/document.h b/examples/widgets/tools/undo/document.h
deleted file mode 100644
index 6e728ca7a9..0000000000
--- a/examples/widgets/tools/undo/document.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#ifndef DOCUMENT_H
-#define DOCUMENT_H
-
-#include <QWidget>
-
-QT_FORWARD_DECLARE_CLASS(QUndoStack)
-QT_FORWARD_DECLARE_CLASS(QTextStream)
-
-class Shape
-{
-public:
- enum Type { Rectangle, Circle, Triangle };
-
- explicit Shape(Type type = Rectangle, const QColor &color = Qt::red, const QRect &rect = QRect());
-
- Type type() const;
- QString name() const;
- QRect rect() const;
- QRect resizeHandle() const;
- QColor color() const;
-
- static QString typeToString(Type type);
- static Type stringToType(const QString &s, bool *ok = nullptr);
-
- static const QSize minSize;
-
-private:
- Type m_type;
- QRect m_rect;
- QColor m_color;
- QString m_name;
-
- friend class Document;
-};
-
-class Document : public QWidget
-{
- Q_OBJECT
-
-public:
- Document(QWidget *parent = nullptr);
-
- QString addShape(const Shape &shape);
- void deleteShape(const QString &shapeName);
- Shape shape(const QString &shapeName) const;
- QString currentShapeName() const;
-
- void setShapeRect(const QString &shapeName, const QRect &rect);
- void setShapeColor(const QString &shapeName, const QColor &color);
-
- bool load(QTextStream &stream);
- void save(QTextStream &stream);
-
- QString fileName() const;
- void setFileName(const QString &fileName);
-
- QUndoStack *undoStack() const;
-
-signals:
- void currentShapeChanged(const QString &shapeName);
-
-protected:
- void paintEvent(QPaintEvent *event) override;
- void mousePressEvent(QMouseEvent *event) override;
- void mouseReleaseEvent(QMouseEvent *event) override;
- void mouseMoveEvent(QMouseEvent *event) override;
-
-private:
- void setCurrentShape(int index);
- int indexOf(const QString &shapeName) const;
- int indexAt(const QPoint &pos) const;
- QString uniqueName(const QString &name) const;
-
- QList<Shape> m_shapeList;
- QPoint m_mousePressOffset;
- QString m_fileName;
- QUndoStack *m_undoStack = nullptr;
- int m_currentIndex = -1;
- int m_mousePressIndex = -1;
- bool m_resizeHandlePressed = false;
-};
-
-#endif // DOCUMENT_H
diff --git a/examples/widgets/tools/undo/icons/background.png b/examples/widgets/tools/undo/icons/background.png
deleted file mode 100644
index 3bc5ed8cf0..0000000000
--- a/examples/widgets/tools/undo/icons/background.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/blue.png b/examples/widgets/tools/undo/icons/blue.png
deleted file mode 100644
index 4e181bb61a..0000000000
--- a/examples/widgets/tools/undo/icons/blue.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/circle.png b/examples/widgets/tools/undo/icons/circle.png
deleted file mode 100644
index ed16c6e144..0000000000
--- a/examples/widgets/tools/undo/icons/circle.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/exit.png b/examples/widgets/tools/undo/icons/exit.png
deleted file mode 100644
index 539cb2ead9..0000000000
--- a/examples/widgets/tools/undo/icons/exit.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/fileclose.png b/examples/widgets/tools/undo/icons/fileclose.png
deleted file mode 100644
index c5483d14ab..0000000000
--- a/examples/widgets/tools/undo/icons/fileclose.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/filenew.png b/examples/widgets/tools/undo/icons/filenew.png
deleted file mode 100644
index 57e57e343b..0000000000
--- a/examples/widgets/tools/undo/icons/filenew.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/fileopen.png b/examples/widgets/tools/undo/icons/fileopen.png
deleted file mode 100644
index 33e0d6394c..0000000000
--- a/examples/widgets/tools/undo/icons/fileopen.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/filesave.png b/examples/widgets/tools/undo/icons/filesave.png
deleted file mode 100644
index 57fd5e2f34..0000000000
--- a/examples/widgets/tools/undo/icons/filesave.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/green.png b/examples/widgets/tools/undo/icons/green.png
deleted file mode 100644
index e2e7cc9e50..0000000000
--- a/examples/widgets/tools/undo/icons/green.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/ok.png b/examples/widgets/tools/undo/icons/ok.png
deleted file mode 100644
index e355ea91bc..0000000000
--- a/examples/widgets/tools/undo/icons/ok.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/red.png b/examples/widgets/tools/undo/icons/red.png
deleted file mode 100644
index 58c3e7253b..0000000000
--- a/examples/widgets/tools/undo/icons/red.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undo/main.cpp b/examples/widgets/tools/undo/main.cpp
deleted file mode 100644
index 1a6dcf8c48..0000000000
--- a/examples/widgets/tools/undo/main.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include "mainwindow.h"
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(undo);
-#ifdef Q_OS_ANDROID
- QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-#endif
-
- QApplication app(argc, argv);
-
- MainWindow win;
- win.resize(800, 600);
- win.show();
-
- return app.exec();
-}
diff --git a/examples/widgets/tools/undo/mainwindow.cpp b/examples/widgets/tools/undo/mainwindow.cpp
deleted file mode 100644
index 5623a09ad2..0000000000
--- a/examples/widgets/tools/undo/mainwindow.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "document.h"
-#include "commands.h"
-
-#include <QUndoGroup>
-#include <QUndoStack>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QRandomGenerator>
-#include <QTextStream>
-#include <QToolButton>
-
-MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
-{
- setupUi(this);
-
- QWidget *w = documentTabs->widget(0);
- documentTabs->removeTab(0);
- delete w;
-
- connect(actionOpen, &QAction::triggered, this, &MainWindow::openDocument);
- connect(actionClose, &QAction::triggered, this, &MainWindow::closeDocument);
- connect(actionNew, &QAction::triggered, this, &MainWindow::newDocument);
- connect(actionSave, &QAction::triggered, this, &MainWindow::saveDocument);
- connect(actionExit, &QAction::triggered, this, &QWidget::close);
- connect(actionRed, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionGreen, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionBlue, &QAction::triggered, this, &MainWindow::setShapeColor);
- connect(actionAddCircle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionAddRectangle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionAddTriangle, &QAction::triggered, this, &MainWindow::addShape);
- connect(actionRemoveShape, &QAction::triggered, this, &MainWindow::removeShape);
- connect(actionAddRobot, &QAction::triggered, this, &MainWindow::addRobot);
- connect(actionAddSnowman, &QAction::triggered, this, &MainWindow::addSnowman);
- connect(actionAbout, &QAction::triggered, this, &MainWindow::about);
- connect(actionAboutQt, &QAction::triggered, this, &MainWindow::aboutQt);
-
- connect(undoLimit, &QSpinBox::valueChanged, this, &MainWindow::updateActions);
- connect(documentTabs, &QTabWidget::currentChanged, this, &MainWindow::updateActions);
-
- actionOpen->setShortcut(QString("Ctrl+O"));
- actionClose->setShortcut(QString("Ctrl+W"));
- actionNew->setShortcut(QString("Ctrl+N"));
- actionSave->setShortcut(QString("Ctrl+S"));
- actionExit->setShortcut(QString("Ctrl+Q"));
- actionRemoveShape->setShortcut(QString("Del"));
- actionRed->setShortcut(QString("Alt+R"));
- actionGreen->setShortcut(QString("Alt+G"));
- actionBlue->setShortcut(QString("Alt+B"));
- actionAddCircle->setShortcut(QString("Alt+C"));
- actionAddRectangle->setShortcut(QString("Alt+L"));
- actionAddTriangle->setShortcut(QString("Alt+T"));
-
- m_undoGroup = new QUndoGroup(this);
- undoView->setGroup(m_undoGroup);
- undoView->setCleanIcon(QIcon(":/icons/ok.png"));
-
- QAction *undoAction = m_undoGroup->createUndoAction(this);
- QAction *redoAction = m_undoGroup->createRedoAction(this);
- undoAction->setIcon(QIcon(":/icons/undo.png"));
- redoAction->setIcon(QIcon(":/icons/redo.png"));
- menuShape->insertAction(menuShape->actions().at(0), undoAction);
- menuShape->insertAction(undoAction, redoAction);
-
- toolBar->addAction(undoAction);
- toolBar->addAction(redoAction);
-
- newDocument();
- updateActions();
-};
-
-void MainWindow::updateActions()
-{
- Document *doc = currentDocument();
- m_undoGroup->setActiveStack(doc == nullptr ? nullptr : doc->undoStack());
- QString shapeName = doc == nullptr ? QString() : doc->currentShapeName();
-
- actionAddRobot->setEnabled(doc != nullptr);
- actionAddSnowman->setEnabled(doc != nullptr);
- actionAddCircle->setEnabled(doc != nullptr);
- actionAddRectangle->setEnabled(doc != nullptr);
- actionAddTriangle->setEnabled(doc != nullptr);
- actionClose->setEnabled(doc != nullptr);
- actionSave->setEnabled(doc != nullptr && !doc->undoStack()->isClean());
- undoLimit->setEnabled(doc != nullptr && doc->undoStack()->count() == 0);
-
- if (shapeName.isEmpty()) {
- actionRed->setEnabled(false);
- actionGreen->setEnabled(false);
- actionBlue->setEnabled(false);
- actionRemoveShape->setEnabled(false);
- } else {
- Shape shape = doc->shape(shapeName);
- actionRed->setEnabled(shape.color() != Qt::red);
- actionGreen->setEnabled(shape.color() != Qt::green);
- actionBlue->setEnabled(shape.color() != Qt::blue);
- actionRemoveShape->setEnabled(true);
- }
-
- if (doc != nullptr) {
- int index = documentTabs->indexOf(doc);
- Q_ASSERT(index != -1);
- static const QIcon unsavedIcon(":/icons/filesave.png");
- documentTabs->setTabIcon(index, doc->undoStack()->isClean() ? QIcon() : unsavedIcon);
-
- if (doc->undoStack()->count() == 0)
- doc->undoStack()->setUndoLimit(undoLimit->value());
- }
-}
-
-void MainWindow::openDocument()
-{
- QString fileName = QFileDialog::getOpenFileName(this);
- if (fileName.isEmpty())
- return;
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- QMessageBox::warning(this,
- tr("File error"),
- tr("Failed to open\n%1").arg(fileName));
- return;
- }
- QTextStream stream(&file);
-
- Document *doc = new Document();
- if (!doc->load(stream)) {
- QMessageBox::warning(this,
- tr("Parse error"),
- tr("Failed to parse\n%1").arg(fileName));
- delete doc;
- return;
- }
-
- doc->setFileName(fileName);
- addDocument(doc);
-}
-
-QString MainWindow::fixedWindowTitle(const Document *doc) const
-{
- QString title = doc->fileName();
-
- if (title.isEmpty())
- title = tr("Unnamed");
- else
- title = QFileInfo(title).fileName();
-
- QString result;
-
- for (int i = 0; ; ++i) {
- result = title;
- if (i > 0)
- result += QString::number(i);
-
- bool unique = true;
- for (int j = 0; j < documentTabs->count(); ++j) {
- const QWidget *widget = documentTabs->widget(j);
- if (widget == doc)
- continue;
- if (result == documentTabs->tabText(j)) {
- unique = false;
- break;
- }
- }
-
- if (unique)
- break;
- }
-
- return result;
-}
-
-void MainWindow::addDocument(Document *doc)
-{
- if (documentTabs->indexOf(doc) != -1)
- return;
- m_undoGroup->addStack(doc->undoStack());
- documentTabs->addTab(doc, fixedWindowTitle(doc));
- connect(doc, &Document::currentShapeChanged, this, &MainWindow::updateActions);
- connect(doc->undoStack(), &QUndoStack::indexChanged, this, &MainWindow::updateActions);
- connect(doc->undoStack(), &QUndoStack::cleanChanged, this, &MainWindow::updateActions);
-
- setCurrentDocument(doc);
-}
-
-void MainWindow::setCurrentDocument(Document *doc)
-{
- documentTabs->setCurrentWidget(doc);
-}
-
-Document *MainWindow::currentDocument() const
-{
- return qobject_cast<Document*>(documentTabs->currentWidget());
-}
-
-void MainWindow::removeDocument(Document *doc)
-{
- int index = documentTabs->indexOf(doc);
- if (index == -1)
- return;
-
- documentTabs->removeTab(index);
- m_undoGroup->removeStack(doc->undoStack());
- disconnect(doc, &Document::currentShapeChanged, this, &MainWindow::updateActions);
- disconnect(doc->undoStack(), &QUndoStack::indexChanged, this, &MainWindow::updateActions);
- disconnect(doc->undoStack(), &QUndoStack::cleanChanged, this, &MainWindow::updateActions);
-
- if (documentTabs->count() == 0) {
- newDocument();
- updateActions();
- }
-}
-
-void MainWindow::saveDocument()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- for (;;) {
- QString fileName = doc->fileName();
-
- if (fileName.isEmpty())
- fileName = QFileDialog::getSaveFileName(this);
- if (fileName.isEmpty())
- break;
-
- QFile file(fileName);
- if (!file.open(QIODevice::WriteOnly)) {
- QMessageBox::warning(this,
- tr("File error"),
- tr("Failed to open\n%1").arg(fileName));
- doc->setFileName(QString());
- } else {
- QTextStream stream(&file);
- doc->save(stream);
- doc->setFileName(fileName);
-
- int index = documentTabs->indexOf(doc);
- Q_ASSERT(index != -1);
- documentTabs->setTabText(index, fixedWindowTitle(doc));
-
- break;
- }
- }
-}
-
-void MainWindow::closeDocument()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- if (!doc->undoStack()->isClean()) {
- int button
- = QMessageBox::warning(this,
- tr("Unsaved changes"),
- tr("Would you like to save this document?"),
- QMessageBox::Yes, QMessageBox::No);
- if (button == QMessageBox::Yes)
- saveDocument();
- }
-
- removeDocument(doc);
- delete doc;
-}
-
-void MainWindow::newDocument()
-{
- addDocument(new Document());
-}
-
-static QColor randomColor()
-{
- int r = QRandomGenerator::global()->bounded(3);
- switch (r) {
- case 0:
- return Qt::red;
- case 1:
- return Qt::green;
- default:
- break;
- }
- return Qt::blue;
-}
-
-static QRect randomRect(const QSize &s)
-{
- QSize min = Shape::minSize;
-
- int left = qRound((s.width() - min.width()) * (QRandomGenerator::global()->bounded(1.0)));
- int top = qRound((s.height() - min.height()) * (QRandomGenerator::global()->bounded(1.0)));
- int width = qRound((s.width() - left - min.width()) * (QRandomGenerator::global()->bounded(1.0))) + min.width();
- int height = qRound((s.height() - top - min.height()) * (QRandomGenerator::global()->bounded(1.0))) + min.height();
-
- return QRect(left, top, width, height);
-}
-
-void MainWindow::addShape()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- Shape::Type type;
-
- if (sender() == actionAddCircle)
- type = Shape::Circle;
- else if (sender() == actionAddRectangle)
- type = Shape::Rectangle;
- else if (sender() == actionAddTriangle)
- type = Shape::Triangle;
- else return;
-
- Shape newShape(type, randomColor(), randomRect(doc->size()));
- doc->undoStack()->push(new AddShapeCommand(doc, newShape));
-}
-
-void MainWindow::removeShape()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- QString shapeName = doc->currentShapeName();
- if (shapeName.isEmpty())
- return;
-
- doc->undoStack()->push(new RemoveShapeCommand(doc, shapeName));
-}
-
-void MainWindow::setShapeColor()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- QString shapeName = doc->currentShapeName();
- if (shapeName.isEmpty())
- return;
-
- QColor color;
-
- if (sender() == actionRed)
- color = Qt::red;
- else if (sender() == actionGreen)
- color = Qt::green;
- else if (sender() == actionBlue)
- color = Qt::blue;
- else
- return;
-
- if (color == doc->shape(shapeName).color())
- return;
-
- doc->undoStack()->push(new SetShapeColorCommand(doc, shapeName, color));
-}
-
-void MainWindow::addSnowman()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- // Create a macro command using beginMacro() and endMacro()
-
- doc->undoStack()->beginMacro(tr("Add snowman"));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(51, 30, 97, 95))));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(27, 123, 150, 133))));
- doc->undoStack()->push(new AddShapeCommand(doc,
- Shape(Shape::Circle, Qt::blue, QRect(11, 253, 188, 146))));
- doc->undoStack()->endMacro();
-}
-
-void MainWindow::addRobot()
-{
- Document *doc = currentDocument();
- if (doc == nullptr)
- return;
-
- // Compose a macro command by explicitly adding children to a parent command
-
- QUndoCommand *parent = new QUndoCommand(tr("Add robot"));
-
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(115, 15, 81, 70)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(82, 89, 148, 188)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(76, 280, 80, 165)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(163, 280, 80, 164)), parent);
- new AddShapeCommand(doc, Shape(Shape::Circle, Qt::blue, QRect(116, 25, 80, 50)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(232, 92, 80, 127)), parent);
- new AddShapeCommand(doc, Shape(Shape::Rectangle, Qt::green, QRect(2, 92, 80, 125)), parent);
-
- doc->undoStack()->push(parent);
-}
-
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About Undo"), tr("The Undo demonstration shows how to use the Qt Undo framework."));
-}
-
-void MainWindow::aboutQt()
-{
- QMessageBox::aboutQt(this, tr("About Qt"));
-}
diff --git a/examples/widgets/tools/undo/mainwindow.h b/examples/widgets/tools/undo/mainwindow.h
deleted file mode 100644
index 87ee3084fb..0000000000
--- a/examples/widgets/tools/undo/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 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 MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include "ui_mainwindow.h"
-
-class Document;
-
-class MainWindow : public QMainWindow, public Ui::MainWindow
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = nullptr);
-
- void addDocument(Document *doc);
- void removeDocument(Document *doc);
- void setCurrentDocument(Document *doc);
- Document *currentDocument() const;
-
-public slots:
- void openDocument();
- void saveDocument();
- void closeDocument();
- void newDocument();
-
- void addShape();
- void removeShape();
- void setShapeColor();
-
- void addSnowman();
- void addRobot();
-
- void about();
- void aboutQt();
-
-private slots:
- void updateActions();
-
-private:
- QUndoGroup *m_undoGroup;
-
- QString fixedWindowTitle(const Document *doc) const;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/widgets/tools/undo/mainwindow.ui b/examples/widgets/tools/undo/mainwindow.ui
deleted file mode 100644
index 91a0b437e5..0000000000
--- a/examples/widgets/tools/undo/mainwindow.ui
+++ /dev/null
@@ -1,322 +0,0 @@
-<ui version="4.0" >
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>567</width>
- <height>600</height>
- </rect>
- </property>
- <property name="iconSize" >
- <size>
- <width>32</width>
- <height>32</height>
- </size>
- </property>
- <widget class="QWidget" name="centralwidget" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>0</number>
- </property>
- <item>
- <widget class="QTabWidget" name="documentTabs" >
- <property name="currentIndex" >
- <number>0</number>
- </property>
- <widget class="QWidget" name="tab" >
- <attribute name="title" >
- <string>Tab 1</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>567</width>
- <height>27</height>
- </rect>
- </property>
- <widget class="QMenu" name="menuFile" >
- <property name="title" >
- <string>File</string>
- </property>
- <addaction name="actionNew" />
- <addaction name="actionOpen" />
- <addaction name="actionSave" />
- <addaction name="actionClose" />
- <addaction name="separator" />
- <addaction name="actionExit" />
- </widget>
- <widget class="QMenu" name="menuShape" >
- <property name="title" >
- <string>Edit</string>
- </property>
- <widget class="QMenu" name="menuMacros" >
- <property name="title" >
- <string>Macros</string>
- </property>
- <addaction name="actionAddRobot" />
- <addaction name="actionAddSnowman" />
- </widget>
- <addaction name="separator" />
- <addaction name="actionAddCircle" />
- <addaction name="actionAddRectangle" />
- <addaction name="actionAddTriangle" />
- <addaction name="actionRemoveShape" />
- <addaction name="separator" />
- <addaction name="actionRed" />
- <addaction name="actionGreen" />
- <addaction name="actionBlue" />
- <addaction name="separator" />
- <addaction name="menuMacros" />
- </widget>
- <widget class="QMenu" name="menuHelp" >
- <property name="title" >
- <string>Help</string>
- </property>
- <addaction name="actionAbout" />
- <addaction name="actionAboutQt" />
- </widget>
- <addaction name="menuFile" />
- <addaction name="menuShape" />
- <addaction name="menuHelp" />
- </widget>
- <widget class="QStatusBar" name="statusbar" />
- <widget class="QToolBar" name="toolBar" >
- <property name="windowTitle" >
- <string>File actions</string>
- </property>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <attribute name="toolBarArea" >
- <enum>TopToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak" >
- <bool>false</bool>
- </attribute>
- <addaction name="actionNew" />
- <addaction name="actionOpen" />
- <addaction name="actionSave" />
- <addaction name="actionClose" />
- <addaction name="separator" />
- </widget>
- <widget class="QToolBar" name="shapeToolBar" >
- <property name="windowTitle" >
- <string>Shape actions</string>
- </property>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <attribute name="toolBarArea" >
- <enum>LeftToolBarArea</enum>
- </attribute>
- <attribute name="toolBarBreak" >
- <bool>false</bool>
- </attribute>
- <addaction name="actionAddRectangle" />
- <addaction name="actionAddCircle" />
- <addaction name="actionAddTriangle" />
- <addaction name="actionRemoveShape" />
- <addaction name="separator" />
- <addaction name="actionRed" />
- <addaction name="actionGreen" />
- <addaction name="actionBlue" />
- </widget>
- <widget class="QDockWidget" name="dockWidget" >
- <property name="windowTitle" >
- <string>Undo Stack</string>
- </property>
- <attribute name="dockWidgetArea" >
- <number>2</number>
- </attribute>
- <widget class="QWidget" name="dockWidgetContents" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>4</number>
- </property>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label" >
- <property name="text" >
- <string>Undo limit</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="undoLimit" />
- </item>
- </layout>
- </item>
- <item>
- <widget class="QUndoView" name="undoView" >
- <property name="alternatingRowColors" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- <action name="actionOpen" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/fileopen.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Open</string>
- </property>
- </action>
- <action name="actionClose" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/fileclose.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Close</string>
- </property>
- </action>
- <action name="actionNew" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/filenew.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;New</string>
- </property>
- </action>
- <action name="actionSave" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/filesave.png</iconset>
- </property>
- <property name="text" >
- <string>&amp;Save</string>
- </property>
- </action>
- <action name="actionExit" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/exit.png</iconset>
- </property>
- <property name="text" >
- <string>E&amp;xit</string>
- </property>
- </action>
- <action name="actionRed" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/red.png</iconset>
- </property>
- <property name="text" >
- <string>Red</string>
- </property>
- </action>
- <action name="actionGreen" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/green.png</iconset>
- </property>
- <property name="text" >
- <string>Green</string>
- </property>
- </action>
- <action name="actionBlue" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/blue.png</iconset>
- </property>
- <property name="text" >
- <string>Blue</string>
- </property>
- </action>
- <action name="actionAddRectangle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/rectangle.png</iconset>
- </property>
- <property name="text" >
- <string>Add Rectangle</string>
- </property>
- </action>
- <action name="actionAddCircle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/circle.png</iconset>
- </property>
- <property name="text" >
- <string>Add Circle</string>
- </property>
- </action>
- <action name="actionRemoveShape" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/remove.png</iconset>
- </property>
- <property name="text" >
- <string>Remove Shape</string>
- </property>
- </action>
- <action name="actionAddRobot" >
- <property name="text" >
- <string>Add robot</string>
- </property>
- </action>
- <action name="actionAddSnowman" >
- <property name="text" >
- <string>Add snowan</string>
- </property>
- </action>
- <action name="actionAddTriangle" >
- <property name="icon" >
- <iconset resource="undo.qrc" >:/icons/triangle.png</iconset>
- </property>
- <property name="text" >
- <string>addTriangle</string>
- </property>
- </action>
- <action name="actionAbout" >
- <property name="text" >
- <string>About</string>
- </property>
- </action>
- <action name="actionAboutQt" >
- <property name="text" >
- <string>About Qt</string>
- </property>
- </action>
- </widget>
- <customwidgets>
- <customwidget>
- <class>QUndoView</class>
- <extends>QListView</extends>
- <header>qundoview.h</header>
- </customwidget>
- </customwidgets>
- <resources>
- <include location="undo.qrc" />
- </resources>
- <connections/>
-</ui>
diff --git a/examples/widgets/tools/undo/undo.pro b/examples/widgets/tools/undo/undo.pro
deleted file mode 100644
index 9b7b577dd3..0000000000
--- a/examples/widgets/tools/undo/undo.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-QT += widgets
-requires(qtConfig(undoview))
-
-SOURCES += main.cpp mainwindow.cpp commands.cpp document.cpp
-HEADERS += mainwindow.h commands.h document.h
-FORMS += mainwindow.ui
-
-build_all:!build_pass {
- CONFIG -= build_all
- CONFIG += release
-}
-
-RESOURCES += undo.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tools/undo
-INSTALLS += target
diff --git a/examples/widgets/tools/undo/undo.qrc b/examples/widgets/tools/undo/undo.qrc
deleted file mode 100644
index 65619b8f1a..0000000000
--- a/examples/widgets/tools/undo/undo.qrc
+++ /dev/null
@@ -1,20 +0,0 @@
-<RCC>
- <qresource prefix="/" >
- <file>icons/background.png</file>
- <file>icons/blue.png</file>
- <file>icons/circle.png</file>
- <file>icons/exit.png</file>
- <file>icons/fileclose.png</file>
- <file>icons/filenew.png</file>
- <file>icons/fileopen.png</file>
- <file>icons/filesave.png</file>
- <file>icons/green.png</file>
- <file>icons/ok.png</file>
- <file>icons/rectangle.png</file>
- <file>icons/red.png</file>
- <file>icons/redo.png</file>
- <file>icons/remove.png</file>
- <file>icons/triangle.png</file>
- <file>icons/undo.png</file>
- </qresource>
-</RCC>
diff --git a/examples/widgets/tools/undoframework/CMakeLists.txt b/examples/widgets/tools/undoframework/CMakeLists.txt
index 59fc1a36a1..27912f04c7 100644
--- a/examples/widgets/tools/undoframework/CMakeLists.txt
+++ b/examples/widgets/tools/undoframework/CMakeLists.txt
@@ -1,44 +1,43 @@
-# Generated from undoframework.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(undoframework 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/tools/undoframework")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(undoframework
+qt_add_executable(undoframework
commands.cpp commands.h
diagramitem.cpp diagramitem.h
diagramscene.cpp diagramscene.h
main.cpp
mainwindow.cpp mainwindow.h
)
-target_link_libraries(undoframework PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
+
+set_target_properties(undoframework PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
)
+target_link_libraries(undoframework PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Widgets
+)
# Resources:
set(undoframework_resource_files
- "images/cross.png"
+ "icons/cross.png"
+ "icons/rectangle.png"
+ "icons/redo.png"
+ "icons/remove.png"
+ "icons/triangle.png"
+ "icons/undo.png"
)
-qt6_add_resources(undoframework "undoframework"
+qt_add_resources(undoframework "undoframework"
PREFIX
"/"
FILES
@@ -46,7 +45,14 @@ qt6_add_resources(undoframework "undoframework"
)
install(TARGETS undoframework
- 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 undoframework
+ OUTPUT_SCRIPT deploy_script
+ NO_UNSUPPORTED_PLATFORM_ERROR
)
+install(SCRIPT ${deploy_script})
diff --git a/examples/widgets/tools/undoframework/commands.cpp b/examples/widgets/tools/undoframework/commands.cpp
index 077d7eccaa..67fb739dc4 100644
--- a/examples/widgets/tools/undoframework/commands.cpp
+++ b/examples/widgets/tools/undoframework/commands.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 "commands.h"
#include "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/commands.h b/examples/widgets/tools/undoframework/commands.h
index 185d36d668..f4048ce198 100644
--- a/examples/widgets/tools/undoframework/commands.h
+++ b/examples/widgets/tools/undoframework/commands.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 COMMANDS_H
#define COMMANDS_H
diff --git a/examples/widgets/tools/undoframework/diagramitem.cpp b/examples/widgets/tools/undoframework/diagramitem.cpp
index 91da6538cf..918de742a5 100644
--- a/examples/widgets/tools/undoframework/diagramitem.cpp
+++ b/examples/widgets/tools/undoframework/diagramitem.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 "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/diagramitem.h b/examples/widgets/tools/undoframework/diagramitem.h
index 13ff614427..95adac928e 100644
--- a/examples/widgets/tools/undoframework/diagramitem.h
+++ b/examples/widgets/tools/undoframework/diagramitem.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 DIAGRAMITEM_H
#define DIAGRAMITEM_H
diff --git a/examples/widgets/tools/undoframework/diagramscene.cpp b/examples/widgets/tools/undoframework/diagramscene.cpp
index 65909ab6cb..8fab7b86bc 100644
--- a/examples/widgets/tools/undoframework/diagramscene.cpp
+++ b/examples/widgets/tools/undoframework/diagramscene.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 "diagramscene.h"
#include "diagramitem.h"
diff --git a/examples/widgets/tools/undoframework/diagramscene.h b/examples/widgets/tools/undoframework/diagramscene.h
index 205d4162bb..fe4c06b11a 100644
--- a/examples/widgets/tools/undoframework/diagramscene.h
+++ b/examples/widgets/tools/undoframework/diagramscene.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 DIAGRAMSCENE_H
#define DIAGRAMSCENE_H
diff --git a/examples/widgets/tools/undoframework/icons/cross.png b/examples/widgets/tools/undoframework/icons/cross.png
new file mode 100644
index 0000000000..3570a242ae
--- /dev/null
+++ b/examples/widgets/tools/undoframework/icons/cross.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/rectangle.png b/examples/widgets/tools/undoframework/icons/rectangle.png
index 3a7d9795fd..3a7d9795fd 100644
--- a/examples/widgets/tools/undo/icons/rectangle.png
+++ b/examples/widgets/tools/undoframework/icons/rectangle.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/redo.png b/examples/widgets/tools/undoframework/icons/redo.png
index 5591517e1c..5591517e1c 100644
--- a/examples/widgets/tools/undo/icons/redo.png
+++ b/examples/widgets/tools/undoframework/icons/redo.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/remove.png b/examples/widgets/tools/undoframework/icons/remove.png
index 7a7b048c0a..7a7b048c0a 100644
--- a/examples/widgets/tools/undo/icons/remove.png
+++ b/examples/widgets/tools/undoframework/icons/remove.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/triangle.png b/examples/widgets/tools/undoframework/icons/triangle.png
index 2969131c31..2969131c31 100644
--- a/examples/widgets/tools/undo/icons/triangle.png
+++ b/examples/widgets/tools/undoframework/icons/triangle.png
Binary files differ
diff --git a/examples/widgets/tools/undo/icons/undo.png b/examples/widgets/tools/undoframework/icons/undo.png
index 8cf63a8ec9..8cf63a8ec9 100644
--- a/examples/widgets/tools/undo/icons/undo.png
+++ b/examples/widgets/tools/undoframework/icons/undo.png
Binary files differ
diff --git a/examples/widgets/tools/undoframework/images/cross.png b/examples/widgets/tools/undoframework/images/cross.png
deleted file mode 100644
index 09e5e8c2ad..0000000000
--- a/examples/widgets/tools/undoframework/images/cross.png
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/tools/undoframework/main.cpp b/examples/widgets/tools/undoframework/main.cpp
index cf090f56eb..8dfa3ffb4b 100644
--- a/examples/widgets/tools/undoframework/main.cpp
+++ b/examples/widgets/tools/undoframework/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>
@@ -55,8 +8,6 @@
//! [0]
int main(int argv, char *args[])
{
- Q_INIT_RESOURCE(undoframework);
-
QApplication app(argv, args);
MainWindow mainWindow;
diff --git a/examples/widgets/tools/undoframework/mainwindow.cpp b/examples/widgets/tools/undoframework/mainwindow.cpp
index 583af11a2b..c2a6c1cff6 100644
--- a/examples/widgets/tools/undoframework/mainwindow.cpp
+++ b/examples/widgets/tools/undoframework/mainwindow.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 "mainwindow.h"
#include "diagramscene.h"
@@ -54,70 +7,75 @@
#include "commands.h"
#include <QAction>
+#include <QDockWidget>
#include <QGraphicsView>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
+#include <QToolBar>
#include <QUndoView>
//! [0]
MainWindow::MainWindow()
{
undoStack = new QUndoStack(this);
+ diagramScene = new DiagramScene();
+
+ const QBrush pixmapBrush(QPixmap(":/icons/cross.png").scaled(30, 30));
+ diagramScene->setBackgroundBrush(pixmapBrush);
+ diagramScene->setSceneRect(QRect(0, 0, 500, 500));
createActions();
createMenus();
+ createToolBars();
createUndoView();
- diagramScene = new DiagramScene();
- QBrush pixmapBrush(QPixmap(":/images/cross.png").scaled(30, 30));
- diagramScene->setBackgroundBrush(pixmapBrush);
- diagramScene->setSceneRect(QRect(0, 0, 500, 500));
-
connect(diagramScene, &DiagramScene::itemMoved,
this, &MainWindow::itemMoved);
+ connect(diagramScene, &DiagramScene::selectionChanged,
+ this, &MainWindow::updateActions);
setWindowTitle("Undo Framework");
QGraphicsView *view = new QGraphicsView(diagramScene);
setCentralWidget(view);
- resize(700, 500);
+ adjustSize();
}
//! [0]
//! [1]
void MainWindow::createUndoView()
{
- undoView = new QUndoView(undoStack);
- undoView->setWindowTitle(tr("Command List"));
- undoView->show();
- undoView->setAttribute(Qt::WA_QuitOnClose, false);
+ QDockWidget *undoDockWidget = new QDockWidget;
+ undoDockWidget->setWindowTitle(tr("Command List"));
+ undoDockWidget->setWidget(new QUndoView(undoStack));
+ addDockWidget(Qt::RightDockWidgetArea, undoDockWidget);
}
//! [1]
//! [2]
void MainWindow::createActions()
{
- deleteAction = new QAction(tr("&Delete Item"), this);
+ deleteAction = new QAction(QIcon(":/icons/remove.png"), tr("&Delete Item"), this);
deleteAction->setShortcut(tr("Del"));
connect(deleteAction, &QAction::triggered, this, &MainWindow::deleteItem);
-//! [2] //! [3]
+//! [2]
-//! [3] //! [4]
- addBoxAction = new QAction(tr("Add &Box"), this);
-//! [4]
+ addBoxAction = new QAction(QIcon(":/icons/rectangle.png"), tr("Add &Box"), this);
addBoxAction->setShortcut(tr("Ctrl+O"));
connect(addBoxAction, &QAction::triggered, this, &MainWindow::addBox);
- addTriangleAction = new QAction(tr("Add &Triangle"), this);
+ addTriangleAction = new QAction(QIcon(":/icons/triangle.png"), tr("Add &Triangle"), this);
addTriangleAction->setShortcut(tr("Ctrl+T"));
connect(addTriangleAction, &QAction::triggered, this, &MainWindow::addTriangle);
//! [5]
undoAction = undoStack->createUndoAction(this, tr("&Undo"));
+ undoAction->setIcon(QIcon(":/icons/undo.png"));
undoAction->setShortcuts(QKeySequence::Undo);
redoAction = undoStack->createRedoAction(this, tr("&Redo"));
+ redoAction->setIcon(QIcon(":/icons/redo.png"));
redoAction->setShortcuts(QKeySequence::Redo);
//! [5]
@@ -130,46 +88,66 @@ void MainWindow::createActions()
aboutShortcuts << tr("Ctrl+A") << tr("Ctrl+B");
aboutAction->setShortcuts(aboutShortcuts);
connect(aboutAction, &QAction::triggered, this, &MainWindow::about);
+
+//! [6]
+ updateActions();
}
+void MainWindow::updateActions()
+{
+ deleteAction->setEnabled(!diagramScene->selectedItems().isEmpty());
+}
//! [6]
+
+//! [7]
void MainWindow::createMenus()
{
-//! [6]
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(exitAction);
-//! [7]
editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(undoAction);
editMenu->addAction(redoAction);
editMenu->addSeparator();
editMenu->addAction(deleteAction);
- connect(editMenu, &QMenu::aboutToShow,
- this, &MainWindow::itemMenuAboutToShow);
- connect(editMenu, &QMenu::aboutToHide,
- this, &MainWindow::itemMenuAboutToHide);
-
//! [7]
+
itemMenu = menuBar()->addMenu(tr("&Item"));
itemMenu->addAction(addBoxAction);
itemMenu->addAction(addTriangleAction);
+//! [8]
helpMenu = menuBar()->addMenu(tr("&About"));
helpMenu->addAction(aboutAction);
-//! [8]
}
+
+void MainWindow::createToolBars()
+{
+ QToolBar *editToolBar = new QToolBar;
+ editToolBar->addAction(undoAction);
+ editToolBar->addAction(redoAction);
+ editToolBar->addSeparator();
+ editToolBar->addAction(deleteAction);
//! [8]
+ QToolBar *itemToolBar = new QToolBar;
+ itemToolBar->addAction(addBoxAction);
+ itemToolBar->addAction(addTriangleAction);
+//! [9]
+ addToolBar(editToolBar);
+ addToolBar(itemToolBar);
+}
//! [9]
+
+//! [11]
void MainWindow::itemMoved(DiagramItem *movedItem,
const QPointF &oldPosition)
{
undoStack->push(new MoveCommand(movedItem, oldPosition));
}
-//! [9]
+//! [11]
-//! [10]
+//! [12]
void MainWindow::deleteItem()
{
if (diagramScene->selectedItems().isEmpty())
@@ -178,20 +156,6 @@ void MainWindow::deleteItem()
QUndoCommand *deleteCommand = new DeleteCommand(diagramScene);
undoStack->push(deleteCommand);
}
-//! [10]
-
-//! [11]
-void MainWindow::itemMenuAboutToHide()
-{
- deleteAction->setEnabled(true);
-}
-//! [11]
-
-//! [12]
-void MainWindow::itemMenuAboutToShow()
-{
- deleteAction->setEnabled(!diagramScene->selectedItems().isEmpty());
-}
//! [12]
//! [13]
diff --git a/examples/widgets/tools/undoframework/mainwindow.h b/examples/widgets/tools/undoframework/mainwindow.h
index c1a56e0770..5ef1dddf75 100644
--- a/examples/widgets/tools/undoframework/mainwindow.h
+++ b/examples/widgets/tools/undoframework/mainwindow.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 MAINWINDOW_H
#define MAINWINDOW_H
@@ -79,12 +32,12 @@ private slots:
void addBox();
void addTriangle();
void about();
- void itemMenuAboutToShow();
- void itemMenuAboutToHide();
+ void updateActions();
private:
void createActions();
void createMenus();
+ void createToolBars();
void createUndoView();
QAction *deleteAction = nullptr;
diff --git a/examples/widgets/tools/undoframework/undoframework.qrc b/examples/widgets/tools/undoframework/undoframework.qrc
index 6321d94d8d..298cc768bd 100644
--- a/examples/widgets/tools/undoframework/undoframework.qrc
+++ b/examples/widgets/tools/undoframework/undoframework.qrc
@@ -1,6 +1,10 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
- <file>images/cross.png</file>
+ <file>icons/cross.png</file>
+ <file>icons/rectangle.png</file>
+ <file>icons/redo.png</file>
+ <file>icons/remove.png</file>
+ <file>icons/triangle.png</file>
+ <file>icons/undo.png</file>
</qresource>
</RCC>
-