diff options
Diffstat (limited to 'examples/widgets/widgets')
236 files changed, 1272 insertions, 14696 deletions
diff --git a/examples/widgets/widgets/CMakeLists.txt b/examples/widgets/widgets/CMakeLists.txt index 8daf6a69ae..feb3067727 100644 --- a/examples/widgets/widgets/CMakeLists.txt +++ b/examples/widgets/widgets/CMakeLists.txt @@ -1,27 +1,14 @@ -# Generated from widgets.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -add_subdirectory(analogclock) -add_subdirectory(calculator) -add_subdirectory(calendarwidget) -add_subdirectory(charactermap) -add_subdirectory(codeeditor) -add_subdirectory(digitalclock) -add_subdirectory(elidedlabel) -add_subdirectory(groupbox) -add_subdirectory(icons) -add_subdirectory(imageviewer) -add_subdirectory(lineedits) -add_subdirectory(movie) -add_subdirectory(mousebuttons) -add_subdirectory(scribble) -add_subdirectory(shapedclock) -add_subdirectory(sliders) -add_subdirectory(spinboxes) -add_subdirectory(styles) -add_subdirectory(stylesheet) -add_subdirectory(tablet) -add_subdirectory(tetrix) -add_subdirectory(tooltips) -add_subdirectory(validators) -add_subdirectory(wiggly) -add_subdirectory(windowflags) +qt_internal_add_example(analogclock) +qt_internal_add_example(calculator) +qt_internal_add_example(calendarwidget) +qt_internal_add_example(lineedits) +qt_internal_add_example(scribble) +qt_internal_add_example(shapedclock) +qt_internal_add_example(shortcuteditor) +qt_internal_add_example(sliders) +qt_internal_add_example(spinboxes) +qt_internal_add_example(tablet) +qt_internal_add_example(windowflags) diff --git a/examples/widgets/widgets/analogclock/CMakeLists.txt b/examples/widgets/widgets/analogclock/CMakeLists.txt index 50dc07919c..82b9ef3928 100644 --- a/examples/widgets/widgets/analogclock/CMakeLists.txt +++ b/examples/widgets/widgets/analogclock/CMakeLists.txt @@ -1,40 +1,38 @@ -# Generated from analogclock.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(analogclock LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/analogclock") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(analogclock analogclock.cpp analogclock.h main.cpp ) + set_target_properties(analogclock PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(analogclock PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(analogclock PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS analogclock - 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 analogclock + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/analogclock/analogclock.cpp b/examples/widgets/widgets/analogclock/analogclock.cpp index 06e298659d..feb7f4e8b5 100644 --- a/examples/widgets/widgets/analogclock/analogclock.cpp +++ b/examples/widgets/widgets/analogclock/analogclock.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 "analogclock.h" @@ -78,22 +31,31 @@ AnalogClock::AnalogClock(QWidget *parent) void AnalogClock::paintEvent(QPaintEvent *) //! [8] //! [10] { - static const QPoint hourHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -40) + static const QPoint hourHand[4] = { + QPoint(5, 14), + QPoint(-5, 14), + QPoint(-4, -71), + QPoint(4, -71) }; - static const QPoint minuteHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -70) + static const QPoint minuteHand[4] = { + QPoint(4, 14), + QPoint(-4, 14), + QPoint(-3, -89), + QPoint(3, -89) }; - QColor hourColor(127, 0, 127); - QColor minuteColor(0, 127, 127, 191); + static const QPoint secondsHand[4] = { + QPoint(1, 14), + QPoint(-1, 14), + QPoint(-1, -89), + QPoint(1, -89) + }; + + const QColor hourColor(palette().color(QPalette::Text)); + const QColor minuteColor(palette().color(QPalette::Text)); + const QColor secondsColor(palette().color(QPalette::Accent)); int side = qMin(width(), height()); - QTime time = QTime::currentTime(); //! [10] //! [11] @@ -102,45 +64,58 @@ void AnalogClock::paintEvent(QPaintEvent *) painter.setRenderHint(QPainter::Antialiasing); //! [12] //! [13] painter.translate(width() / 2, height() / 2); -//! [13] //! [14] painter.scale(side / 200.0, side / 200.0); -//! [9] //! [14] +//! [9] //! [13] + +//! [14] + QTime time = QTime::currentTime(); +//! [14] //! [15] painter.setPen(Qt::NoPen); //! [15] //! [16] painter.setBrush(hourColor); //! [16] +//! [18] -//! [17] //! [18] +//! [17] painter.save(); //! [17] //! [19] painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); - painter.drawConvexPolygon(hourHand, 3); + painter.drawConvexPolygon(hourHand, 4); painter.restore(); //! [18] //! [19] //! [20] - painter.setPen(hourColor); -//! [20] //! [21] - for (int i = 0; i < 12; ++i) { - painter.drawLine(88, 0, 96, 0); + painter.drawRect(73, -3, 16, 6); painter.rotate(30.0); } +//! [20] + //! [21] + painter.setBrush(minuteColor); //! [22] - painter.setPen(Qt::NoPen); -//! [22] //! [23] - painter.setBrush(minuteColor); + painter.save(); + painter.rotate(6.0 * time.minute()); + painter.drawConvexPolygon(minuteHand, 4); + painter.restore(); +//! [21] //! [22] + + +//! [23] + painter.setBrush(secondsColor); +//! [23] //! [24] painter.save(); - painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); - painter.drawConvexPolygon(minuteHand, 3); + painter.rotate(6.0 * time.second()); + painter.drawConvexPolygon(secondsHand, 4); + painter.drawEllipse(-3, -3, 6, 6); + painter.drawEllipse(-5, -68, 10, 10); painter.restore(); -//! [23] //! [24] +//! [24] //! [25] painter.setPen(minuteColor); @@ -148,10 +123,10 @@ void AnalogClock::paintEvent(QPaintEvent *) //! [27] for (int j = 0; j < 60; ++j) { - if ((j % 5) != 0) - painter.drawLine(92, 0, 96, 0); + painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } //! [27] + } //! [26] diff --git a/examples/widgets/widgets/analogclock/analogclock.h b/examples/widgets/widgets/analogclock/analogclock.h index e2486a915f..a268773782 100644 --- a/examples/widgets/widgets/analogclock/analogclock.h +++ b/examples/widgets/widgets/analogclock/analogclock.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 ANALOGCLOCK_H #define ANALOGCLOCK_H diff --git a/examples/widgets/widgets/analogclock/main.cpp b/examples/widgets/widgets/analogclock/main.cpp index 98de67b08a..0bba7b9ab4 100644 --- a/examples/widgets/widgets/analogclock/main.cpp +++ b/examples/widgets/widgets/analogclock/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/calculator/CMakeLists.txt b/examples/widgets/widgets/calculator/CMakeLists.txt index 5f961e350d..abf12d5663 100644 --- a/examples/widgets/widgets/calculator/CMakeLists.txt +++ b/examples/widgets/widgets/calculator/CMakeLists.txt @@ -1,41 +1,39 @@ -# Generated from calculator.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(calculator LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calculator") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(calculator button.cpp button.h calculator.cpp calculator.h main.cpp ) + set_target_properties(calculator PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(calculator PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(calculator PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS calculator - 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 calculator + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/calculator/button.cpp b/examples/widgets/widgets/calculator/button.cpp index cc370a563c..b1d37d99a5 100644 --- a/examples/widgets/widgets/calculator/button.cpp +++ b/examples/widgets/widgets/calculator/button.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 "button.h" diff --git a/examples/widgets/widgets/calculator/button.h b/examples/widgets/widgets/calculator/button.h index 7c6f26867f..04a9f1e3dd 100644 --- a/examples/widgets/widgets/calculator/button.h +++ b/examples/widgets/widgets/calculator/button.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 BUTTON_H #define BUTTON_H diff --git a/examples/widgets/widgets/calculator/calculator.cpp b/examples/widgets/widgets/calculator/calculator.cpp index 2c3669b7a8..073b10f985 100644 --- a/examples/widgets/widgets/calculator/calculator.cpp +++ b/examples/widgets/widgets/calculator/calculator.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 "calculator.h" #include "button.h" @@ -76,29 +29,29 @@ Calculator::Calculator(QWidget *parent) //! [4] for (int i = 0; i < NumDigitButtons; ++i) - digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); + digitButtons[i] = createButton(QString::number(i), &Calculator::digitClicked); - Button *pointButton = createButton(tr("."), SLOT(pointClicked())); - Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); + Button *pointButton = createButton(tr("."), &Calculator::pointClicked); + Button *changeSignButton = createButton(tr("\302\261"), &Calculator::changeSignClicked); - Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); - Button *clearButton = createButton(tr("Clear"), SLOT(clear())); - Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); + Button *backspaceButton = createButton(tr("Backspace"), &Calculator::backspaceClicked); + Button *clearButton = createButton(tr("Clear"), &Calculator::clear); + Button *clearAllButton = createButton(tr("Clear All"), &Calculator::clearAll); - Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); - Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); - Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); - Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); + Button *clearMemoryButton = createButton(tr("MC"), &Calculator::clearMemory); + Button *readMemoryButton = createButton(tr("MR"), &Calculator::readMemory); + Button *setMemoryButton = createButton(tr("MS"), &Calculator::setMemory); + Button *addToMemoryButton = createButton(tr("M+"), &Calculator::addToMemory); - Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); - Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); - Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); - Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); + Button *divisionButton = createButton(tr("\303\267"), &Calculator::multiplicativeOperatorClicked); + Button *timesButton = createButton(tr("\303\227"), &Calculator::multiplicativeOperatorClicked); + Button *minusButton = createButton(tr("-"), &Calculator::additiveOperatorClicked); + Button *plusButton = createButton(tr("+"), &Calculator::additiveOperatorClicked); - Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); - Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); - Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); - Button *equalButton = createButton(tr("="), SLOT(equalClicked())); + Button *squareRootButton = createButton(tr("Sqrt"), &Calculator::unaryOperatorClicked); + Button *powerButton = createButton(tr("x\302\262"), &Calculator::unaryOperatorClicked); + Button *reciprocalButton = createButton(tr("1/x"), &Calculator::unaryOperatorClicked); + Button *equalButton = createButton(tr("="), &Calculator::equalClicked); //! [4] //! [5] @@ -371,10 +324,11 @@ void Calculator::addToMemory() } //! [32] //! [34] -Button *Calculator::createButton(const QString &text, const char *member) +template<typename PointerToMemberFunction> +Button *Calculator::createButton(const QString &text, const PointerToMemberFunction &member) { Button *button = new Button(text); - connect(button, SIGNAL(clicked()), this, member); + connect(button, &Button::clicked, this, member); return button; } //! [34] diff --git a/examples/widgets/widgets/calculator/calculator.h b/examples/widgets/widgets/calculator/calculator.h index 937de185e7..42e9ac5335 100644 --- a/examples/widgets/widgets/calculator/calculator.h +++ b/examples/widgets/widgets/calculator/calculator.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 CALCULATOR_H #define CALCULATOR_H @@ -86,7 +39,8 @@ private slots: //! [1] private: //! [1] //! [2] - Button *createButton(const QString &text, const char *member); + template<typename PointerToMemberFunction> + Button *createButton(const QString &text, const PointerToMemberFunction &member); void abortOperation(); bool calculate(double rightOperand, const QString &pendingOperator); //! [2] diff --git a/examples/widgets/widgets/calculator/main.cpp b/examples/widgets/widgets/calculator/main.cpp index a034bb262e..38da9255a7 100644 --- a/examples/widgets/widgets/calculator/main.cpp +++ b/examples/widgets/widgets/calculator/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/calendarwidget/CMakeLists.txt b/examples/widgets/widgets/calendarwidget/CMakeLists.txt index 74c342ab73..9e8f7681ca 100644 --- a/examples/widgets/widgets/calendarwidget/CMakeLists.txt +++ b/examples/widgets/widgets/calendarwidget/CMakeLists.txt @@ -1,40 +1,38 @@ -# Generated from calendarwidget.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(calendarwidget LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/calendarwidget") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(calendarwidget main.cpp window.cpp window.h ) + set_target_properties(calendarwidget PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(calendarwidget PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(calendarwidget PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS calendarwidget - 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 calendarwidget + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/calendarwidget/main.cpp b/examples/widgets/widgets/calendarwidget/main.cpp index 2582e83841..b2be8181cf 100644 --- a/examples/widgets/widgets/calendarwidget/main.cpp +++ b/examples/widgets/widgets/calendarwidget/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index 23010a6e1a..a26d28d242 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" @@ -237,6 +190,9 @@ void Window::createPreviewGroupBox() } //! [9] +// TODO: use loc.name() as label (but has underscore in place of slash) +// TODO: use locale() == loc instead of only comparing language and territory +// Needs someone familiar with this example to work out ramifications //! [10] void Window::createGeneralOptionsGroupBox() { @@ -247,16 +203,16 @@ void Window::createGeneralOptionsGroupBox() int index = 0; for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { QLocale::Language lang = static_cast<QLocale::Language>(_lang); - QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang); - for (int i = 0; i < countries.count(); ++i) { - QLocale::Country country = countries.at(i); + const auto locales = + QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyTerritory); + for (auto loc : locales) { QString label = QLocale::languageToString(lang); + auto territory = loc.territory(); label += QLatin1Char('/'); - label += QLocale::countryToString(country); - QLocale locale(lang, country); - if (this->locale().language() == lang && this->locale().country() == country) + label += QLocale::territoryToString(territory); + if (locale().language() == lang && locale().territory() == territory) curLocaleIndex = index; - localeCombo->addItem(label, locale); + localeCombo->addItem(label, loc); ++index; } } diff --git a/examples/widgets/widgets/calendarwidget/window.h b/examples/widgets/widgets/calendarwidget/window.h index 1b673b8ce0..3e9785ec8a 100644 --- a/examples/widgets/widgets/calendarwidget/window.h +++ b/examples/widgets/widgets/calendarwidget/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/widgets/charactermap/CMakeLists.txt b/examples/widgets/widgets/charactermap/CMakeLists.txt deleted file mode 100644 index 07791589c1..0000000000 --- a/examples/widgets/widgets/charactermap/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Generated from charactermap.pro. - -cmake_minimum_required(VERSION 3.14) -project(charactermap 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/widgets/charactermap") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(charactermap - characterwidget.cpp characterwidget.h - main.cpp - mainwindow.cpp mainwindow.h -) -set_target_properties(charactermap PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(charactermap PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS charactermap - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/charactermap/charactermap.pro b/examples/widgets/widgets/charactermap/charactermap.pro deleted file mode 100644 index 373aabca73..0000000000 --- a/examples/widgets/widgets/charactermap/charactermap.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) - -HEADERS = characterwidget.h \ - mainwindow.h -SOURCES = characterwidget.cpp \ - mainwindow.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/charactermap -INSTALLS += target diff --git a/examples/widgets/widgets/charactermap/characterwidget.cpp b/examples/widgets/widgets/charactermap/characterwidget.cpp deleted file mode 100644 index a9d5a06164..0000000000 --- a/examples/widgets/widgets/charactermap/characterwidget.cpp +++ /dev/null @@ -1,192 +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 "characterwidget.h" - -#include <QFontDatabase> -#include <QMouseEvent> -#include <QPainter> -#include <QToolTip> - -//! [0] -CharacterWidget::CharacterWidget(QWidget *parent) - : QWidget(parent) -{ - calculateSquareSize(); - setMouseTracking(true); -} -//! [0] - -//! [1] -void CharacterWidget::updateFont(const QFont &font) -{ - displayFont.setFamily(font.family()); - calculateSquareSize(); - adjustSize(); - update(); -} -//! [1] - -//! [2] -void CharacterWidget::updateSize(const QString &fontSize) -{ - displayFont.setPointSize(fontSize.toInt()); - calculateSquareSize(); - adjustSize(); - update(); -} -//! [2] - -void CharacterWidget::updateStyle(const QString &fontStyle) -{ - const QFont::StyleStrategy oldStrategy = displayFont.styleStrategy(); - displayFont = QFontDatabase::font(displayFont.family(), fontStyle, displayFont.pointSize()); - displayFont.setStyleStrategy(oldStrategy); - calculateSquareSize(); - adjustSize(); - update(); -} - -void CharacterWidget::updateFontMerging(bool enable) -{ - if (enable) - displayFont.setStyleStrategy(QFont::PreferDefault); - else - displayFont.setStyleStrategy(QFont::NoFontMerging); - adjustSize(); - update(); -} - -void CharacterWidget::calculateSquareSize() -{ - squareSize = qMax(16, 4 + QFontMetrics(displayFont, this).height()); -} - -//! [3] -QSize CharacterWidget::sizeHint() const -{ - return QSize(columns*squareSize, (65536 / columns) * squareSize); -} -//! [3] - -//! [4] -void CharacterWidget::mouseMoveEvent(QMouseEvent *event) -{ - QPoint widgetPosition = mapFromGlobal(event->globalPosition().toPoint()); - uint key = (widgetPosition.y() / squareSize) * columns + widgetPosition.x() / squareSize; - - QString text = QString::fromLatin1("<p>Character: <span style=\"font-size: 24pt; font-family: %1\">").arg(displayFont.family()) - + QChar(key) - + QString::fromLatin1("</span><p>Value: 0x") - + QString::number(key, 16); - QToolTip::showText(event->globalPosition().toPoint(), text, this); -} -//! [4] - -//! [5] -void CharacterWidget::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - lastKey = (event->position().toPoint().y() / squareSize) * columns + event->position().toPoint().x() / squareSize; - if (QChar(lastKey).category() != QChar::Other_NotAssigned) - emit characterSelected(QString(QChar(lastKey))); - update(); - } - else - QWidget::mousePressEvent(event); -} -//! [5] - -//! [6] -void CharacterWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.fillRect(event->rect(), QBrush(Qt::white)); - painter.setFont(displayFont); -//! [6] - -//! [7] - QRect redrawRect = event->rect(); - int beginRow = redrawRect.top() / squareSize; - int endRow = redrawRect.bottom() / squareSize; - int beginColumn = redrawRect.left() / squareSize; - int endColumn = redrawRect.right() / squareSize; -//! [7] - -//! [8] - painter.setPen(QPen(Qt::gray)); - for (int row = beginRow; row <= endRow; ++row) { - for (int column = beginColumn; column <= endColumn; ++column) { - painter.drawRect(column * squareSize, row * squareSize, squareSize, squareSize); - } -//! [8] //! [9] - } -//! [9] - -//! [10] - QFontMetrics fontMetrics(displayFont); - painter.setPen(QPen(Qt::black)); - for (int row = beginRow; row <= endRow; ++row) { - for (int column = beginColumn; column <= endColumn; ++column) { - int key = row * columns + column; - painter.setClipRect(column * squareSize, row * squareSize, squareSize, squareSize); - - if (key == lastKey) - painter.fillRect(column * squareSize + 1, row * squareSize + 1, - squareSize, squareSize, QBrush(Qt::red)); - - painter.drawText(column * squareSize + (squareSize / 2) - - fontMetrics.horizontalAdvance(QChar(key)) / 2, - row * squareSize + 4 + fontMetrics.ascent(), - QString(QChar(key))); - } - } -} -//! [10] diff --git a/examples/widgets/widgets/charactermap/characterwidget.h b/examples/widgets/widgets/charactermap/characterwidget.h deleted file mode 100644 index 67ac8a30bf..0000000000 --- a/examples/widgets/widgets/charactermap/characterwidget.h +++ /dev/null @@ -1,97 +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 CHARACTERWIDGET_H -#define CHARACTERWIDGET_H - -#include <QFont> -#include <QSize> -#include <QString> -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QMouseEvent; -class QPaintEvent; -QT_END_NAMESPACE - -//! [0] -class CharacterWidget : public QWidget -{ - Q_OBJECT - -public: - CharacterWidget(QWidget *parent = nullptr); - QSize sizeHint() const override; - -public slots: - void updateFont(const QFont &font); - void updateSize(const QString &fontSize); - void updateStyle(const QString &fontStyle); - void updateFontMerging(bool enable); - -signals: - void characterSelected(const QString &character); - -protected: - void mouseMoveEvent(QMouseEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void paintEvent(QPaintEvent *event) override; - -private: - void calculateSquareSize(); - - QFont displayFont; - int columns = 16; - int lastKey = -1; - int squareSize = 0; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/charactermap/main.cpp b/examples/widgets/widgets/charactermap/main.cpp deleted file mode 100644 index 1bf46b226f..0000000000 --- a/examples/widgets/widgets/charactermap/main.cpp +++ /dev/null @@ -1,61 +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); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp deleted file mode 100644 index cfe0be96ca..0000000000 --- a/examples/widgets/widgets/charactermap/mainwindow.cpp +++ /dev/null @@ -1,311 +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 "characterwidget.h" - -#include <QApplication> -#include <QBoxLayout> -#include <QCheckBox> -#include <QClipboard> -#include <QDialog> -#include <QDialogButtonBox> -#include <QFontComboBox> -#include <QLabel> -#include <QLineEdit> -#include <QMenuBar> -#include <QPlainTextEdit> -#include <QPushButton> -#include <QScreen> -#include <QScrollArea> -#include <QStatusBar> -#include <QTextStream> - -//! [0] -Q_DECLARE_METATYPE(QFontComboBox::FontFilter) - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - QMenu *fileMenu = menuBar()->addMenu(tr("File")); - fileMenu->addAction(tr("Quit"), this, &QWidget::close); - QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(tr("Show Font Info"), this, &MainWindow::showInfo); - helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); - - QWidget *centralWidget = new QWidget; - - QLabel *filterLabel = new QLabel(tr("Filter:")); - filterCombo = new QComboBox; - filterCombo->addItem(tr("All"), QVariant::fromValue(QFontComboBox::AllFonts)); - filterCombo->addItem(tr("Scalable"), QVariant::fromValue(QFontComboBox::ScalableFonts)); - filterCombo->addItem(tr("Monospaced"), QVariant::fromValue(QFontComboBox::MonospacedFonts)); - filterCombo->addItem(tr("Proportional"), QVariant::fromValue(QFontComboBox::ProportionalFonts)); - filterCombo->setCurrentIndex(0); - connect(filterCombo, &QComboBox::currentIndexChanged, - this, &MainWindow::filterChanged); - - QLabel *fontLabel = new QLabel(tr("Font:")); - fontCombo = new QFontComboBox; - QLabel *sizeLabel = new QLabel(tr("Size:")); - sizeCombo = new QComboBox; - QLabel *styleLabel = new QLabel(tr("Style:")); - styleCombo = new QComboBox; - QLabel *fontMergingLabel = new QLabel(tr("Automatic Font Merging:")); - fontMerging = new QCheckBox; - fontMerging->setChecked(true); - - scrollArea = new QScrollArea; - characterWidget = new CharacterWidget; - scrollArea->setWidget(characterWidget); -//! [0] - -//! [1] - findStyles(fontCombo->currentFont()); -//! [1] - findSizes(fontCombo->currentFont()); - -//! [2] - lineEdit = new QLineEdit; - lineEdit->setClearButtonEnabled(true); -#ifndef QT_NO_CLIPBOARD - QPushButton *clipboardButton = new QPushButton(tr("&To clipboard")); -//! [2] - -#endif - -//! [4] - connect(fontCombo, &QFontComboBox::currentFontChanged, - this, &MainWindow::findStyles); - connect(fontCombo, &QFontComboBox::currentFontChanged, - this, &MainWindow::findSizes); - connect(fontCombo, &QFontComboBox::currentFontChanged, - characterWidget, &CharacterWidget::updateFont); - connect(sizeCombo, &QComboBox::currentTextChanged, - characterWidget, &CharacterWidget::updateSize); - connect(styleCombo, &QComboBox::currentTextChanged, - characterWidget, &CharacterWidget::updateStyle); -//! [4] //! [5] - connect(characterWidget, &CharacterWidget::characterSelected, - this, &MainWindow::insertCharacter); - -#ifndef QT_NO_CLIPBOARD - connect(clipboardButton, &QAbstractButton::clicked, this, &MainWindow::updateClipboard); -#endif -//! [5] - connect(fontMerging, &QAbstractButton::toggled, characterWidget, &CharacterWidget::updateFontMerging); - -//! [6] - QHBoxLayout *controlsLayout = new QHBoxLayout; - controlsLayout->addWidget(filterLabel); - controlsLayout->addWidget(filterCombo, 1); - controlsLayout->addWidget(fontLabel); - controlsLayout->addWidget(fontCombo, 1); - controlsLayout->addWidget(sizeLabel); - controlsLayout->addWidget(sizeCombo, 1); - controlsLayout->addWidget(styleLabel); - controlsLayout->addWidget(styleCombo, 1); - controlsLayout->addWidget(fontMergingLabel); - controlsLayout->addWidget(fontMerging, 1); - controlsLayout->addStretch(1); - - QHBoxLayout *lineLayout = new QHBoxLayout; - lineLayout->addWidget(lineEdit, 1); - lineLayout->addSpacing(12); -#ifndef QT_NO_CLIPBOARD - lineLayout->addWidget(clipboardButton); -#endif - - QVBoxLayout *centralLayout = new QVBoxLayout; - centralLayout->addLayout(controlsLayout); - centralLayout->addWidget(scrollArea, 1); - centralLayout->addSpacing(4); - centralLayout->addLayout(lineLayout); - centralWidget->setLayout(centralLayout); - - setCentralWidget(centralWidget); - setWindowTitle(tr("Character Map")); -} -//! [6] - -//! [7] -void MainWindow::findStyles(const QFont &font) -{ - QString currentItem = styleCombo->currentText(); - styleCombo->clear(); -//! [7] - -//! [8] - const QStringList styles = QFontDatabase::styles(font.family()); - for (const QString &style : styles) - styleCombo->addItem(style); - - int styleIndex = styleCombo->findText(currentItem); - - if (styleIndex == -1) - styleCombo->setCurrentIndex(0); - else - styleCombo->setCurrentIndex(styleIndex); -} -//! [8] - -void MainWindow::filterChanged(int f) -{ - const QFontComboBox::FontFilter filter = - qvariant_cast<QFontComboBox::FontFilter>(filterCombo->itemData(f)); - fontCombo->setFontFilters(filter); - statusBar()->showMessage(tr("%n font(s) found", nullptr, fontCombo->count())); -} - -void MainWindow::findSizes(const QFont &font) -{ - QString currentSize = sizeCombo->currentText(); - - { - const QSignalBlocker blocker(sizeCombo); - // sizeCombo signals are now blocked until end of scope - sizeCombo->clear(); - - if (QFontDatabase::isSmoothlyScalable(font.family(), QFontDatabase::styleString(font))) { - const QList<int> sizes = QFontDatabase::standardSizes(); - for (const int size : sizes) { - sizeCombo->addItem(QVariant(size).toString()); - sizeCombo->setEditable(true); - } - - } else { - const QList<int> sizes = QFontDatabase::smoothSizes(font.family(), QFontDatabase::styleString(font)); - for (const int size : sizes ) { - sizeCombo->addItem(QVariant(size).toString()); - sizeCombo->setEditable(false); - } - } - } - - int sizeIndex = sizeCombo->findText(currentSize); - - if(sizeIndex == -1) - sizeCombo->setCurrentIndex(qMax(0, sizeCombo->count() / 3)); - else - sizeCombo->setCurrentIndex(sizeIndex); -} - -//! [9] -void MainWindow::insertCharacter(const QString &character) -{ - lineEdit->insert(character); -} -//! [9] - -//! [10] -#ifndef QT_NO_CLIPBOARD -void MainWindow::updateClipboard() -{ -//! [11] - QGuiApplication::clipboard()->setText(lineEdit->text(), QClipboard::Clipboard); -//! [11] - QGuiApplication::clipboard()->setText(lineEdit->text(), QClipboard::Selection); -} -#endif - -class FontInfoDialog : public QDialog -{ -public: - explicit FontInfoDialog(QWidget *parent = nullptr); - -private: - QString text() const; -}; - -FontInfoDialog::FontInfoDialog(QWidget *parent) : QDialog(parent) -{ - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - QPlainTextEdit *textEdit = new QPlainTextEdit(text(), this); - textEdit->setReadOnly(true); - textEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); - mainLayout->addWidget(textEdit); - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this); - connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - mainLayout->addWidget(buttonBox); -} - -QString FontInfoDialog::text() const -{ - QString text; - QTextStream str(&text); - const QFont defaultFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont); - const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - const QFont titleFont = QFontDatabase::systemFont(QFontDatabase::TitleFont); - const QFont smallestReadableFont = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont); - - str << "Qt " << QT_VERSION_STR << " on " << QGuiApplication::platformName() - << ", " << logicalDpiX() << "DPI"; - if (!qFuzzyCompare(devicePixelRatio(), qreal(1))) - str << ", device pixel ratio: " << devicePixelRatio(); - str << "\n\nDefault font : " << defaultFont.family() << ", " << defaultFont.pointSizeF() << "pt\n" - << "Fixed font : " << fixedFont.family() << ", " << fixedFont.pointSizeF() << "pt\n" - << "Title font : " << titleFont.family() << ", " << titleFont.pointSizeF() << "pt\n" - << "Smallest font: " << smallestReadableFont.family() << ", " << smallestReadableFont.pointSizeF() << "pt\n"; - - return text; -} - -void MainWindow::showInfo() -{ - const QRect screenGeometry = screen()->geometry(); - FontInfoDialog *dialog = new FontInfoDialog(this); - dialog->setWindowTitle(tr("Fonts")); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->resize(screenGeometry.width() / 4, screenGeometry.height() / 4); - dialog->show(); -} - -//! [10] diff --git a/examples/widgets/widgets/charactermap/mainwindow.h b/examples/widgets/widgets/charactermap/mainwindow.h deleted file mode 100644 index 79fe9f9cc8..0000000000 --- a/examples/widgets/widgets/charactermap/mainwindow.h +++ /dev/null @@ -1,97 +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 <QString> - -QT_BEGIN_NAMESPACE -class QClipboard; -class QComboBox; -class QFontComboBox; -class QLineEdit; -class QScrollArea; -class QCheckBox; -QT_END_NAMESPACE -class CharacterWidget; - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - -public slots: - void filterChanged(int); - void findStyles(const QFont &font); - void findSizes(const QFont &font); - void insertCharacter(const QString &character); -#ifndef QT_NO_CLIPBOARD - void updateClipboard(); -#endif - void showInfo(); - -private: - CharacterWidget *characterWidget; - QComboBox *filterCombo; - QComboBox *styleCombo; - QComboBox *sizeCombo; - QFontComboBox *fontCombo; - QLineEdit *lineEdit; - QScrollArea *scrollArea; - QCheckBox *fontMerging; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/codeeditor/CMakeLists.txt b/examples/widgets/widgets/codeeditor/CMakeLists.txt deleted file mode 100644 index 58665eca3c..0000000000 --- a/examples/widgets/widgets/codeeditor/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from codeeditor.pro. - -cmake_minimum_required(VERSION 3.14) -project(codeeditor 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/widgets/codeeditor") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(codeeditor - codeeditor.cpp codeeditor.h - main.cpp -) -set_target_properties(codeeditor PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(codeeditor PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS codeeditor - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/codeeditor/codeeditor.cpp b/examples/widgets/widgets/codeeditor/codeeditor.cpp deleted file mode 100644 index e93a0251e5..0000000000 --- a/examples/widgets/widgets/codeeditor/codeeditor.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 "codeeditor.h" - -#include <QPainter> -#include <QTextBlock> - -//![constructor] - -CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) -{ - lineNumberArea = new LineNumberArea(this); - - connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth); - connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea); - connect(this, &CodeEditor::cursorPositionChanged, this, &CodeEditor::highlightCurrentLine); - - updateLineNumberAreaWidth(0); - highlightCurrentLine(); -} - -//![constructor] - -//![extraAreaWidth] - -int CodeEditor::lineNumberAreaWidth() -{ - int digits = 1; - int max = qMax(1, blockCount()); - while (max >= 10) { - max /= 10; - ++digits; - } - - int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; - - return space; -} - -//![extraAreaWidth] - -//![slotUpdateExtraAreaWidth] - -void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) -{ - setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); -} - -//![slotUpdateExtraAreaWidth] - -//![slotUpdateRequest] - -void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) -{ - if (dy) - lineNumberArea->scroll(0, dy); - else - lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); - - if (rect.contains(viewport()->rect())) - updateLineNumberAreaWidth(0); -} - -//![slotUpdateRequest] - -//![resizeEvent] - -void CodeEditor::resizeEvent(QResizeEvent *e) -{ - QPlainTextEdit::resizeEvent(e); - - QRect cr = contentsRect(); - lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); -} - -//![resizeEvent] - -//![cursorPositionChanged] - -void CodeEditor::highlightCurrentLine() -{ - QList<QTextEdit::ExtraSelection> extraSelections; - - if (!isReadOnly()) { - QTextEdit::ExtraSelection selection; - - QColor lineColor = QColor(Qt::yellow).lighter(160); - - selection.format.setBackground(lineColor); - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - selection.cursor = textCursor(); - selection.cursor.clearSelection(); - extraSelections.append(selection); - } - - setExtraSelections(extraSelections); -} - -//![cursorPositionChanged] - -//![extraAreaPaintEvent_0] - -void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) -{ - QPainter painter(lineNumberArea); - painter.fillRect(event->rect(), Qt::lightGray); - -//![extraAreaPaintEvent_0] - -//![extraAreaPaintEvent_1] - QTextBlock block = firstVisibleBlock(); - int blockNumber = block.blockNumber(); - int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top()); - int bottom = top + qRound(blockBoundingRect(block).height()); -//![extraAreaPaintEvent_1] - -//![extraAreaPaintEvent_2] - while (block.isValid() && top <= event->rect().bottom()) { - if (block.isVisible() && bottom >= event->rect().top()) { - QString number = QString::number(blockNumber + 1); - painter.setPen(Qt::black); - painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), - Qt::AlignRight, number); - } - - block = block.next(); - top = bottom; - bottom = top + qRound(blockBoundingRect(block).height()); - ++blockNumber; - } -} -//![extraAreaPaintEvent_2] - diff --git a/examples/widgets/widgets/codeeditor/codeeditor.h b/examples/widgets/widgets/codeeditor/codeeditor.h deleted file mode 100644 index 283a4e0bdf..0000000000 --- a/examples/widgets/widgets/codeeditor/codeeditor.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 CODEEDITOR_H -#define CODEEDITOR_H - -#include <QPlainTextEdit> - -QT_BEGIN_NAMESPACE -class QPaintEvent; -class QResizeEvent; -class QSize; -class QWidget; -QT_END_NAMESPACE - -class LineNumberArea; - -//![codeeditordefinition] - -class CodeEditor : public QPlainTextEdit -{ - Q_OBJECT - -public: - CodeEditor(QWidget *parent = nullptr); - - void lineNumberAreaPaintEvent(QPaintEvent *event); - int lineNumberAreaWidth(); - -protected: - void resizeEvent(QResizeEvent *event) override; - -private slots: - void updateLineNumberAreaWidth(int newBlockCount); - void highlightCurrentLine(); - void updateLineNumberArea(const QRect &rect, int dy); - -private: - QWidget *lineNumberArea; -}; - -//![codeeditordefinition] -//![extraarea] - -class LineNumberArea : public QWidget -{ -public: - LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor) - {} - - QSize sizeHint() const override - { - return QSize(codeEditor->lineNumberAreaWidth(), 0); - } - -protected: - void paintEvent(QPaintEvent *event) override - { - codeEditor->lineNumberAreaPaintEvent(event); - } - -private: - CodeEditor *codeEditor; -}; - -//![extraarea] - -#endif diff --git a/examples/widgets/widgets/codeeditor/codeeditor.pro b/examples/widgets/widgets/codeeditor/codeeditor.pro deleted file mode 100644 index 5618160d17..0000000000 --- a/examples/widgets/widgets/codeeditor/codeeditor.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT += widgets - -HEADERS = codeeditor.h -SOURCES = main.cpp \ - codeeditor.cpp -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/codeeditor -INSTALLS += target diff --git a/examples/widgets/widgets/codeeditor/main.cpp b/examples/widgets/widgets/codeeditor/main.cpp deleted file mode 100644 index 72d186553a..0000000000 --- a/examples/widgets/widgets/codeeditor/main.cpp +++ /dev/null @@ -1,65 +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 "codeeditor.h" - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - CodeEditor editor; - editor.setWindowTitle(QObject::tr("Code Editor Example")); - editor.show(); - - return app.exec(); -} - diff --git a/examples/widgets/widgets/digitalclock/CMakeLists.txt b/examples/widgets/widgets/digitalclock/CMakeLists.txt deleted file mode 100644 index 5cff6b456f..0000000000 --- a/examples/widgets/widgets/digitalclock/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from digitalclock.pro. - -cmake_minimum_required(VERSION 3.14) -project(digitalclock 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/widgets/digitalclock") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(digitalclock - digitalclock.cpp digitalclock.h - main.cpp -) -set_target_properties(digitalclock PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(digitalclock PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS digitalclock - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/digitalclock/digitalclock.cpp b/examples/widgets/widgets/digitalclock/digitalclock.cpp deleted file mode 100644 index 2b130ecda6..0000000000 --- a/examples/widgets/widgets/digitalclock/digitalclock.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "digitalclock.h" - -#include <QTime> -#include <QTimer> - -//! [0] -DigitalClock::DigitalClock(QWidget *parent) - : QLCDNumber(parent) -{ - setSegmentStyle(Filled); - - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, &DigitalClock::showTime); - timer->start(1000); - - showTime(); - - setWindowTitle(tr("Digital Clock")); - resize(150, 60); -} -//! [0] - -//! [1] -void DigitalClock::showTime() -//! [1] //! [2] -{ - QTime time = QTime::currentTime(); - QString text = time.toString("hh:mm"); - if ((time.second() % 2) == 0) - text[2] = ' '; - display(text); -} -//! [2] diff --git a/examples/widgets/widgets/digitalclock/digitalclock.h b/examples/widgets/widgets/digitalclock/digitalclock.h deleted file mode 100644 index 31c12f39ab..0000000000 --- a/examples/widgets/widgets/digitalclock/digitalclock.h +++ /dev/null @@ -1,69 +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 DIGITALCLOCK_H -#define DIGITALCLOCK_H - -#include <QLCDNumber> - -//! [0] -class DigitalClock : public QLCDNumber -{ - Q_OBJECT - -public: - DigitalClock(QWidget *parent = nullptr); - -private slots: - void showTime(); -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/digitalclock/digitalclock.pro b/examples/widgets/widgets/digitalclock/digitalclock.pro deleted file mode 100644 index 4e4bc0f557..0000000000 --- a/examples/widgets/widgets/digitalclock/digitalclock.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -HEADERS = digitalclock.h -SOURCES = digitalclock.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/digitalclock -INSTALLS += target diff --git a/examples/widgets/widgets/digitalclock/main.cpp b/examples/widgets/widgets/digitalclock/main.cpp deleted file mode 100644 index 9440a81c91..0000000000 --- a/examples/widgets/widgets/digitalclock/main.cpp +++ /dev/null @@ -1,61 +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 "digitalclock.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - DigitalClock clock; - clock.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/elidedlabel/CMakeLists.txt b/examples/widgets/widgets/elidedlabel/CMakeLists.txt deleted file mode 100644 index 338a6cfefe..0000000000 --- a/examples/widgets/widgets/elidedlabel/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Generated from elidedlabel.pro. - -cmake_minimum_required(VERSION 3.14) -project(elidedlabel 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/widgets/elidedlabel") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(elidedlabel - elidedlabel.cpp elidedlabel.h - main.cpp - testwidget.cpp testwidget.h -) -set_target_properties(elidedlabel PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(elidedlabel PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS elidedlabel - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.cpp b/examples/widgets/widgets/elidedlabel/elidedlabel.cpp deleted file mode 100644 index e80f7a9894..0000000000 --- a/examples/widgets/widgets/elidedlabel/elidedlabel.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 "elidedlabel.h" - -#include <QPainter> -#include <QSizePolicy> -#include <QTextLayout> - -//! [0] -ElidedLabel::ElidedLabel(const QString &text, QWidget *parent) - : QFrame(parent) - , elided(false) - , content(text) -{ - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); -} -//! [0] - -//! [1] -void ElidedLabel::setText(const QString &newText) -{ - content = newText; - update(); -} -//! [1] - -//! [2] -void ElidedLabel::paintEvent(QPaintEvent *event) -{ - QFrame::paintEvent(event); - - QPainter painter(this); - QFontMetrics fontMetrics = painter.fontMetrics(); - - bool didElide = false; - int lineSpacing = fontMetrics.lineSpacing(); - int y = 0; - - QTextLayout textLayout(content, painter.font()); - textLayout.beginLayout(); - forever { - QTextLine line = textLayout.createLine(); - - if (!line.isValid()) - break; - - line.setLineWidth(width()); - int nextLineY = y + lineSpacing; - - if (height() >= nextLineY + lineSpacing) { - line.draw(&painter, QPoint(0, y)); - y = nextLineY; - //! [2] - //! [3] - } else { - QString lastLine = content.mid(line.textStart()); - QString elidedLastLine = fontMetrics.elidedText(lastLine, Qt::ElideRight, width()); - painter.drawText(QPoint(0, y + fontMetrics.ascent()), elidedLastLine); - line = textLayout.createLine(); - didElide = line.isValid(); - break; - } - } - textLayout.endLayout(); - //! [3] - - //! [4] - if (didElide != elided) { - elided = didElide; - emit elisionChanged(didElide); - } -} -//! [4] diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.h b/examples/widgets/widgets/elidedlabel/elidedlabel.h deleted file mode 100644 index 0c8d96834e..0000000000 --- a/examples/widgets/widgets/elidedlabel/elidedlabel.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 ELIDEDLABEL_H -#define ELIDEDLABEL_H - -#include <QFrame> -#include <QString> - -//! [0] -class ElidedLabel : public QFrame -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText) - Q_PROPERTY(bool isElided READ isElided) - -public: - explicit ElidedLabel(const QString &text, QWidget *parent = nullptr); - - void setText(const QString &text); - const QString & text() const { return content; } - bool isElided() const { return elided; } - -protected: - void paintEvent(QPaintEvent *event) override; - -signals: - void elisionChanged(bool elided); - -private: - bool elided; - QString content; -}; -//! [0] - -#endif // TEXTWRAPPINGWIDGET_H diff --git a/examples/widgets/widgets/elidedlabel/elidedlabel.pro b/examples/widgets/widgets/elidedlabel/elidedlabel.pro deleted file mode 100644 index 34040c92af..0000000000 --- a/examples/widgets/widgets/elidedlabel/elidedlabel.pro +++ /dev/null @@ -1,20 +0,0 @@ -# Nokia Qt Examples: elided label example - -QT += core gui widgets -requires(qtConfig(combobox)) - -TARGET = elidedlabel -TEMPLATE = app - -SOURCES += \ - main.cpp\ - testwidget.cpp \ - elidedlabel.cpp - -HEADERS += \ - testwidget.h \ - elidedlabel.h - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/elidedlabel -INSTALLS += target diff --git a/examples/widgets/widgets/elidedlabel/main.cpp b/examples/widgets/widgets/elidedlabel/main.cpp deleted file mode 100644 index 1c620c1d41..0000000000 --- a/examples/widgets/widgets/elidedlabel/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 "testwidget.h" - -#include <QApplication> - -//! [0] -int main( int argc, char *argv[] ) -{ - QApplication application( argc, argv ); - TestWidget w; - w.showFullScreen(); - return application.exec(); -} -//! [0] diff --git a/examples/widgets/widgets/elidedlabel/testwidget.cpp b/examples/widgets/widgets/elidedlabel/testwidget.cpp deleted file mode 100644 index 6e7930a359..0000000000 --- a/examples/widgets/widgets/elidedlabel/testwidget.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 "testwidget.h" -#include "elidedlabel.h" - -#include <QGridLayout> -#include <QLabel> -#include <QPushButton> - -//! [0] -TestWidget::TestWidget(QWidget *parent) - : QWidget(parent) -{ - const QString romeo = tr( - "But soft, what light through yonder window breaks? / " - "It is the east, and Juliet is the sun. / " - "Arise, fair sun, and kill the envious moon, / " - "Who is already sick and pale with grief / " - "That thou, her maid, art far more fair than she." - ); - - const QString macbeth = tr( - "To-morrow, and to-morrow, and to-morrow, / " - "Creeps in this petty pace from day to day, / " - "To the last syllable of recorded time; / " - "And all our yesterdays have lighted fools / " - "The way to dusty death. Out, out, brief candle! / " - "Life's but a walking shadow, a poor player, / " - "That struts and frets his hour upon the stage, / " - "And then is heard no more. It is a tale / " - "Told by an idiot, full of sound and fury, / " - "Signifying nothing." - ); - - const QString harry = tr("Feeling lucky, punk?"); - - textSamples << romeo << macbeth << harry; - //! [0] - - //! [1] - sampleIndex = 0; - elidedText = new ElidedLabel(textSamples[sampleIndex], this); - elidedText->setFrameStyle(QFrame::Box); - //! [1] - - //! [2] - QPushButton *switchButton = new QPushButton(tr("Switch text")); - connect(switchButton, &QPushButton::clicked, this, &TestWidget::switchText); - - QPushButton *exitButton = new QPushButton(tr("Exit")); - connect(exitButton, &QPushButton::clicked, this, &TestWidget::close); - - QLabel *label = new QLabel(tr("Elided")); - label->setVisible(elidedText->isElided()); - connect(elidedText, &ElidedLabel::elisionChanged, label, &QLabel::setVisible); - //! [2] - - //! [3] - widthSlider = new QSlider(Qt::Horizontal); - widthSlider->setMinimum(0); - connect(widthSlider, &QSlider::valueChanged, this, &TestWidget::onWidthChanged); - - heightSlider = new QSlider(Qt::Vertical); - heightSlider->setInvertedAppearance(true); - heightSlider->setMinimum(0); - connect(heightSlider, &QSlider::valueChanged, this, &TestWidget::onHeightChanged); - //! [3] - - //! [4] - QGridLayout *layout = new QGridLayout; - layout->addWidget(label, 0, 1, Qt::AlignCenter); - layout->addWidget(switchButton, 0, 2); - layout->addWidget(exitButton, 0, 3); - layout->addWidget(widthSlider, 1, 1, 1, 3); - layout->addWidget(heightSlider, 2, 0); - layout->addWidget(elidedText, 2, 1, 1, 3, Qt::AlignTop | Qt::AlignLeft); - - setLayout(layout); - //! [4] -} - -//! [6] -void TestWidget::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - - int maxWidth = widthSlider->width(); - widthSlider->setMaximum(maxWidth); - widthSlider->setValue(maxWidth / 2); - - int maxHeight = heightSlider->height(); - heightSlider->setMaximum(maxHeight); - heightSlider->setValue(maxHeight / 2); - - elidedText->setFixedSize(widthSlider->value(), heightSlider->value()); -} -//! [6] - -//! [7] -void TestWidget::switchText() -{ - sampleIndex = (sampleIndex + 1) % textSamples.size(); - elidedText->setText(textSamples.at(sampleIndex)); -} -//! [7] - -//! [8] -void TestWidget::onWidthChanged(int width) -{ - elidedText->setFixedWidth(width); -} - -void TestWidget::onHeightChanged(int height) -{ - elidedText->setFixedHeight(height); -} -//! [8] - diff --git a/examples/widgets/widgets/elidedlabel/testwidget.h b/examples/widgets/widgets/elidedlabel/testwidget.h deleted file mode 100644 index bcb2f33044..0000000000 --- a/examples/widgets/widgets/elidedlabel/testwidget.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 TESTWIDGET_H -#define TESTWIDGET_H - -#include <QSlider> -#include <QStringList> -#include <QWidget> - -class ElidedLabel; - -//! [0] -class TestWidget : public QWidget -{ - Q_OBJECT - -public: - TestWidget(QWidget *parent = nullptr); - -protected: - void resizeEvent(QResizeEvent *event) override; - -private slots: - void switchText(); - void onWidthChanged(int width); - void onHeightChanged(int height); - -private: - int sampleIndex; - QStringList textSamples; - ElidedLabel *elidedText; - QSlider *heightSlider; - QSlider *widthSlider; -}; -//! [0] - -#endif // TESTWIDGET_H diff --git a/examples/widgets/widgets/groupbox/CMakeLists.txt b/examples/widgets/widgets/groupbox/CMakeLists.txt deleted file mode 100644 index 74f2fe037f..0000000000 --- a/examples/widgets/widgets/groupbox/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from groupbox.pro. - -cmake_minimum_required(VERSION 3.14) -project(groupbox 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/widgets/groupbox") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(groupbox - main.cpp - window.cpp window.h -) -set_target_properties(groupbox PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(groupbox PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS groupbox - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/groupbox/groupbox.pro b/examples/widgets/widgets/groupbox/groupbox.pro deleted file mode 100644 index 5fb6a14835..0000000000 --- a/examples/widgets/widgets/groupbox/groupbox.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -HEADERS = window.h -SOURCES = window.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/groupbox -INSTALLS += target diff --git a/examples/widgets/widgets/groupbox/main.cpp b/examples/widgets/widgets/groupbox/main.cpp deleted file mode 100644 index 99725195e5..0000000000 --- a/examples/widgets/widgets/groupbox/main.cpp +++ /dev/null @@ -1,61 +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 "window.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Window window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/groupbox/window.cpp b/examples/widgets/widgets/groupbox/window.cpp deleted file mode 100644 index 95c4f216fe..0000000000 --- a/examples/widgets/widgets/groupbox/window.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "window.h" - -#include <QCheckBox> -#include <QGridLayout> -#include <QGroupBox> -#include <QMenu> -#include <QPushButton> -#include <QRadioButton> - -//! [0] -Window::Window(QWidget *parent) - : QWidget(parent) -{ - QGridLayout *grid = new QGridLayout; - grid->addWidget(createFirstExclusiveGroup(), 0, 0); - grid->addWidget(createSecondExclusiveGroup(), 1, 0); - grid->addWidget(createNonExclusiveGroup(), 0, 1); - grid->addWidget(createPushButtonGroup(), 1, 1); - setLayout(grid); - - setWindowTitle(tr("Group Boxes")); - resize(480, 320); -} -//! [0] - -//! [1] -QGroupBox *Window::createFirstExclusiveGroup() -{ -//! [2] - QGroupBox *groupBox = new QGroupBox(tr("Exclusive Radio Buttons")); - - QRadioButton *radio1 = new QRadioButton(tr("&Radio button 1")); - QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2")); - QRadioButton *radio3 = new QRadioButton(tr("Ra&dio button 3")); - - radio1->setChecked(true); -//! [1] //! [3] - - QVBoxLayout *vbox = new QVBoxLayout; - vbox->addWidget(radio1); - vbox->addWidget(radio2); - vbox->addWidget(radio3); - vbox->addStretch(1); - groupBox->setLayout(vbox); -//! [2] - - return groupBox; -} -//! [3] - -//! [4] -QGroupBox *Window::createSecondExclusiveGroup() -{ - QGroupBox *groupBox = new QGroupBox(tr("E&xclusive Radio Buttons")); - groupBox->setCheckable(true); - groupBox->setChecked(false); -//! [4] - -//! [5] - QRadioButton *radio1 = new QRadioButton(tr("Rad&io button 1")); - QRadioButton *radio2 = new QRadioButton(tr("Radi&o button 2")); - QRadioButton *radio3 = new QRadioButton(tr("Radio &button 3")); - radio1->setChecked(true); - QCheckBox *checkBox = new QCheckBox(tr("Ind&ependent checkbox")); - checkBox->setChecked(true); -//! [5] - -//! [6] - QVBoxLayout *vbox = new QVBoxLayout; - vbox->addWidget(radio1); - vbox->addWidget(radio2); - vbox->addWidget(radio3); - vbox->addWidget(checkBox); - vbox->addStretch(1); - groupBox->setLayout(vbox); - - return groupBox; -} -//! [6] - -//! [7] -QGroupBox *Window::createNonExclusiveGroup() -{ - QGroupBox *groupBox = new QGroupBox(tr("Non-Exclusive Checkboxes")); - groupBox->setFlat(true); -//! [7] - -//! [8] - QCheckBox *checkBox1 = new QCheckBox(tr("&Checkbox 1")); - QCheckBox *checkBox2 = new QCheckBox(tr("C&heckbox 2")); - checkBox2->setChecked(true); - QCheckBox *tristateBox = new QCheckBox(tr("Tri-&state button")); - tristateBox->setTristate(true); -//! [8] - tristateBox->setCheckState(Qt::PartiallyChecked); - -//! [9] - QVBoxLayout *vbox = new QVBoxLayout; - vbox->addWidget(checkBox1); - vbox->addWidget(checkBox2); - vbox->addWidget(tristateBox); - vbox->addStretch(1); - groupBox->setLayout(vbox); - - return groupBox; -} -//! [9] - -//! [10] -QGroupBox *Window::createPushButtonGroup() -{ - QGroupBox *groupBox = new QGroupBox(tr("&Push Buttons")); - groupBox->setCheckable(true); - groupBox->setChecked(true); -//! [10] - -//! [11] - QPushButton *pushButton = new QPushButton(tr("&Normal Button")); - QPushButton *toggleButton = new QPushButton(tr("&Toggle Button")); - toggleButton->setCheckable(true); - toggleButton->setChecked(true); - QPushButton *flatButton = new QPushButton(tr("&Flat Button")); - flatButton->setFlat(true); -//! [11] - -//! [12] - QPushButton *popupButton = new QPushButton(tr("Pop&up Button")); - QMenu *menu = new QMenu(this); - menu->addAction(tr("&First Item")); - menu->addAction(tr("&Second Item")); - menu->addAction(tr("&Third Item")); - menu->addAction(tr("F&ourth Item")); - popupButton->setMenu(menu); -//! [12] - - QAction *newAction = menu->addAction(tr("Submenu")); - QMenu *subMenu = new QMenu(tr("Popup Submenu")); - subMenu->addAction(tr("Item 1")); - subMenu->addAction(tr("Item 2")); - subMenu->addAction(tr("Item 3")); - newAction->setMenu(subMenu); - -//! [13] - QVBoxLayout *vbox = new QVBoxLayout; - vbox->addWidget(pushButton); - vbox->addWidget(toggleButton); - vbox->addWidget(flatButton); - vbox->addWidget(popupButton); - vbox->addStretch(1); - groupBox->setLayout(vbox); - - return groupBox; -} -//! [13] diff --git a/examples/widgets/widgets/groupbox/window.h b/examples/widgets/widgets/groupbox/window.h deleted file mode 100644 index 1f041fd003..0000000000 --- a/examples/widgets/widgets/groupbox/window.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QGroupBox; -QT_END_NAMESPACE - -//! [0] -class Window : public QWidget -{ - Q_OBJECT - -public: - Window(QWidget *parent = nullptr); - -private: - QGroupBox *createFirstExclusiveGroup(); - QGroupBox *createSecondExclusiveGroup(); - QGroupBox *createNonExclusiveGroup(); - QGroupBox *createPushButtonGroup(); -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/icons/.prev_CMakeLists.txt b/examples/widgets/widgets/icons/.prev_CMakeLists.txt deleted file mode 100644 index ff25b3eaef..0000000000 --- a/examples/widgets/widgets/icons/.prev_CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Generated from icons.pro. - -cmake_minimum_required(VERSION 3.14) -project(icons 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/widgets/icons") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(icons - iconpreviewarea.cpp iconpreviewarea.h - iconsizespinbox.cpp iconsizespinbox.h - imagedelegate.cpp imagedelegate.h - main.cpp - mainwindow.cpp mainwindow.h -) -set_target_properties(icons PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_compile_definitions(icons PUBLIC - SRCDIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/\\\" -) - -target_link_libraries(icons PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS icons - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/icons/CMakeLists.txt b/examples/widgets/widgets/icons/CMakeLists.txt deleted file mode 100644 index e14272e777..0000000000 --- a/examples/widgets/widgets/icons/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Generated from icons.pro. - -cmake_minimum_required(VERSION 3.14) -project(icons 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/widgets/icons") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(icons - iconpreviewarea.cpp iconpreviewarea.h - iconsizespinbox.cpp iconsizespinbox.h - imagedelegate.cpp imagedelegate.h - main.cpp - mainwindow.cpp mainwindow.h -) -set_target_properties(icons PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_compile_definitions(icons PUBLIC - SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}" # special case -) - -target_link_libraries(icons PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS icons - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/icons/iconpreviewarea.cpp b/examples/widgets/widgets/icons/iconpreviewarea.cpp deleted file mode 100644 index d0ee50fbb1..0000000000 --- a/examples/widgets/widgets/icons/iconpreviewarea.cpp +++ /dev/null @@ -1,179 +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 "iconpreviewarea.h" - -#include <QGridLayout> -#include <QLabel> - -//! [0] -IconPreviewArea::IconPreviewArea(QWidget *parent) - : QWidget(parent) -{ - QGridLayout *mainLayout = new QGridLayout(this); - - for (int row = 0; row < NumStates; ++row) { - stateLabels[row] = createHeaderLabel(IconPreviewArea::iconStateNames().at(row)); - mainLayout->addWidget(stateLabels[row], row + 1, 0); - } - Q_ASSERT(NumStates == 2); - - for (int column = 0; column < NumModes; ++column) { - modeLabels[column] = createHeaderLabel(IconPreviewArea::iconModeNames().at(column)); - mainLayout->addWidget(modeLabels[column], 0, column + 1); - } - Q_ASSERT(NumModes == 4); - - for (int column = 0; column < NumModes; ++column) { - for (int row = 0; row < NumStates; ++row) { - pixmapLabels[column][row] = createPixmapLabel(); - mainLayout->addWidget(pixmapLabels[column][row], row + 1, column + 1); - } - } -} -//! [0] - -//! [42] -QList<QIcon::Mode> IconPreviewArea::iconModes() -{ - static const QList<QIcon::Mode> result = { QIcon::Normal, QIcon::Active, QIcon::Disabled, - QIcon::Selected }; - return result; -} - -QList<QIcon::State> IconPreviewArea::iconStates() -{ - static const QList<QIcon::State> result = { QIcon::Off, QIcon::On }; - return result; -} - -QStringList IconPreviewArea::iconModeNames() -{ - static const QStringList result = {tr("Normal"), tr("Active"), tr("Disabled"), tr("Selected")}; - return result; -} - -QStringList IconPreviewArea::iconStateNames() -{ - static const QStringList result = {tr("Off"), tr("On")}; - return result; -} -//! [42] - -//! [1] -void IconPreviewArea::setIcon(const QIcon &icon) -{ - this->icon = icon; - updatePixmapLabels(); -} -//! [1] - -//! [2] -void IconPreviewArea::setSize(const QSize &size) -{ - if (size != this->size) { - this->size = size; - updatePixmapLabels(); - } -} -//! [2] - -//! [3] -QLabel *IconPreviewArea::createHeaderLabel(const QString &text) -{ - QLabel *label = new QLabel(tr("<b>%1</b>").arg(text)); - label->setAlignment(Qt::AlignCenter); - return label; -} -//! [3] - -//! [4] -QLabel *IconPreviewArea::createPixmapLabel() -{ - QLabel *label = new QLabel; - label->setEnabled(false); - label->setAlignment(Qt::AlignCenter); - label->setFrameShape(QFrame::Box); - label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - label->setBackgroundRole(QPalette::Base); - label->setAutoFillBackground(true); - label->setMinimumSize(132, 132); - return label; -} -//! [4] - -//! [5] -void IconPreviewArea::updatePixmapLabels() -{ - QWindow *window = nullptr; - if (const QWidget *nativeParent = nativeParentWidget()) - window = nativeParent->windowHandle(); - for (int column = 0; column < NumModes; ++column) { - for (int row = 0; row < NumStates; ++row) { - const QPixmap pixmap = - icon.pixmap(window, size, IconPreviewArea::iconModes().at(column), - IconPreviewArea::iconStates().at(row)); - QLabel *pixmapLabel = pixmapLabels[column][row]; - pixmapLabel->setPixmap(pixmap); - pixmapLabel->setEnabled(!pixmap.isNull()); - QString toolTip; - if (!pixmap.isNull()) { - const QSize actualSize = icon.actualSize(size); - toolTip = - tr("Size: %1x%2\nActual size: %3x%4\nDevice pixel ratio: %5") - .arg(size.width()).arg(size.height()) - .arg(actualSize.width()).arg(actualSize.height()) - .arg(pixmap.devicePixelRatio()); - } - pixmapLabel->setToolTip(toolTip); - } - } -} -//! [5] diff --git a/examples/widgets/widgets/icons/iconpreviewarea.h b/examples/widgets/widgets/icons/iconpreviewarea.h deleted file mode 100644 index 5387cb9f6d..0000000000 --- a/examples/widgets/widgets/icons/iconpreviewarea.h +++ /dev/null @@ -1,94 +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 ICONPREVIEWAREA_H -#define ICONPREVIEWAREA_H - -#include <QIcon> -#include <QWidget> -#include <QStringList> -#include <QList> - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE - -//! [0] -class IconPreviewArea : public QWidget -{ - Q_OBJECT - -public: - explicit IconPreviewArea(QWidget *parent = nullptr); - - void setIcon(const QIcon &icon); - void setSize(const QSize &size); - - static QList<QIcon::Mode> iconModes(); - static QList<QIcon::State> iconStates(); - static QStringList iconModeNames(); - static QStringList iconStateNames(); - -private: - QLabel *createHeaderLabel(const QString &text); - QLabel *createPixmapLabel(); - void updatePixmapLabels(); - - enum { NumModes = 4, NumStates = 2 }; - - QIcon icon; - QSize size; - QLabel *stateLabels[NumStates]; - QLabel *modeLabels[NumModes]; - QLabel *pixmapLabels[NumModes][NumStates]; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/icons/icons.pro b/examples/widgets/widgets/icons/icons.pro deleted file mode 100644 index 243ce6b092..0000000000 --- a/examples/widgets/widgets/icons/icons.pro +++ /dev/null @@ -1,20 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) - -HEADERS = iconpreviewarea.h \ - iconsizespinbox.h \ - imagedelegate.h \ - mainwindow.h -SOURCES = iconpreviewarea.cpp \ - iconsizespinbox.cpp \ - imagedelegate.cpp \ - main.cpp \ - mainwindow.cpp - -DEFINES += SRCDIR=\\\"$$PWD/\\\" - -EXAMPLE_FILES = images/* - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/icons -INSTALLS += target diff --git a/examples/widgets/widgets/icons/iconsizespinbox.cpp b/examples/widgets/widgets/icons/iconsizespinbox.cpp deleted file mode 100644 index 8e6c654686..0000000000 --- a/examples/widgets/widgets/icons/iconsizespinbox.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "iconsizespinbox.h" - -#include <QRegularExpression> - -//! [0] -IconSizeSpinBox::IconSizeSpinBox(QWidget *parent) - : QSpinBox(parent) -{ -} -//! [0] - -//! [1] -int IconSizeSpinBox::valueFromText(const QString &text) const -{ - static const QRegularExpression regExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?")); - Q_ASSERT(regExp.isValid()); - - const QRegularExpressionMatch match = regExp.match(text); - if (match.isValid()) - return match.captured(1).toInt(); - return 0; -} -//! [1] - -//! [2] -QString IconSizeSpinBox::textFromValue(int value) const -{ - return tr("%1 x %1").arg(value); -} -//! [2] diff --git a/examples/widgets/widgets/icons/iconsizespinbox.h b/examples/widgets/widgets/icons/iconsizespinbox.h deleted file mode 100644 index 87415ac5d6..0000000000 --- a/examples/widgets/widgets/icons/iconsizespinbox.h +++ /dev/null @@ -1,69 +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 ICONSIZESPINBOX_H -#define ICONSIZESPINBOX_H - -#include <QSpinBox> - -//! [0] -class IconSizeSpinBox : public QSpinBox -{ - Q_OBJECT - -public: - explicit IconSizeSpinBox(QWidget *parent = nullptr); - - int valueFromText(const QString &text) const override; - QString textFromValue(int value) const override; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/icons/imagedelegate.cpp b/examples/widgets/widgets/icons/imagedelegate.cpp deleted file mode 100644 index 9f1e19c9eb..0000000000 --- a/examples/widgets/widgets/icons/imagedelegate.cpp +++ /dev/null @@ -1,111 +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 "imagedelegate.h" -#include "iconpreviewarea.h" - -#include <QComboBox> - -//! [0] -ImageDelegate::ImageDelegate(QObject *parent) - : QStyledItemDelegate(parent) -{} -//! [0] - -//! [1] -QWidget *ImageDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem & /* option */, - const QModelIndex &index) const -{ - QComboBox *comboBox = new QComboBox(parent); - if (index.column() == 1) - comboBox->addItems(IconPreviewArea::iconModeNames()); - else if (index.column() == 2) - comboBox->addItems(IconPreviewArea::iconStateNames()); - - connect(comboBox, &QComboBox::activated, - this, &ImageDelegate::emitCommitData); - - return comboBox; -} -//! [1] - -//! [2] -void ImageDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - QComboBox *comboBox = qobject_cast<QComboBox *>(editor); - if (!comboBox) - return; - - int pos = comboBox->findText(index.model()->data(index).toString(), - Qt::MatchExactly); - comboBox->setCurrentIndex(pos); -} -//! [2] - -//! [3] -void ImageDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - QComboBox *comboBox = qobject_cast<QComboBox *>(editor); - if (!comboBox) - return; - - model->setData(index, comboBox->currentText()); -} -//! [3] - -//! [4] -void ImageDelegate::emitCommitData() -{ - emit commitData(qobject_cast<QWidget *>(sender())); -} -//! [4] diff --git a/examples/widgets/widgets/icons/imagedelegate.h b/examples/widgets/widgets/icons/imagedelegate.h deleted file mode 100644 index 9d65304e2c..0000000000 --- a/examples/widgets/widgets/icons/imagedelegate.h +++ /dev/null @@ -1,78 +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 IMAGEDELEGATE_H -#define IMAGEDELEGATE_H - -#include <QStyledItemDelegate> - -//! [0] -class ImageDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - explicit ImageDelegate(QObject *parent = nullptr); -//! [0] - -//! [1] - 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; - -//! [1] //! [2] -private slots: - void emitCommitData(); -//! [2] -}; - -#endif diff --git a/examples/widgets/widgets/icons/images/designer.png b/examples/widgets/widgets/icons/images/designer.png Binary files differdeleted file mode 100644 index 9f8578b49e..0000000000 --- a/examples/widgets/widgets/icons/images/designer.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/find_disabled.png b/examples/widgets/widgets/icons/images/find_disabled.png Binary files differdeleted file mode 100644 index e85e33fe05..0000000000 --- a/examples/widgets/widgets/icons/images/find_disabled.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/find_normal.png b/examples/widgets/widgets/icons/images/find_normal.png Binary files differdeleted file mode 100644 index 728c27f905..0000000000 --- a/examples/widgets/widgets/icons/images/find_normal.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_off_128x128.png b/examples/widgets/widgets/icons/images/monkey_off_128x128.png Binary files differdeleted file mode 100644 index f878267287..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_off_128x128.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_off_16x16.png b/examples/widgets/widgets/icons/images/monkey_off_16x16.png Binary files differdeleted file mode 100644 index 0ac57d7d4f..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_off_16x16.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_off_32x32.png b/examples/widgets/widgets/icons/images/monkey_off_32x32.png Binary files differdeleted file mode 100644 index 1f7fab694c..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_off_32x32.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_off_64x64.png b/examples/widgets/widgets/icons/images/monkey_off_64x64.png Binary files differdeleted file mode 100644 index 47d8f6de35..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_off_64x64.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_on_128x128.png b/examples/widgets/widgets/icons/images/monkey_on_128x128.png Binary files differdeleted file mode 100644 index 8e1c7468bf..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_on_128x128.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_on_16x16.png b/examples/widgets/widgets/icons/images/monkey_on_16x16.png Binary files differdeleted file mode 100644 index 082e8527f1..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_on_16x16.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_on_32x32.png b/examples/widgets/widgets/icons/images/monkey_on_32x32.png Binary files differdeleted file mode 100644 index bf9acc6cae..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_on_32x32.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/monkey_on_64x64.png b/examples/widgets/widgets/icons/images/monkey_on_64x64.png Binary files differdeleted file mode 100644 index 990f604d98..0000000000 --- a/examples/widgets/widgets/icons/images/monkey_on_64x64.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/qt_extended_16x16.png b/examples/widgets/widgets/icons/images/qt_extended_16x16.png Binary files differdeleted file mode 100644 index 30bcb45ed2..0000000000 --- a/examples/widgets/widgets/icons/images/qt_extended_16x16.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/qt_extended_32x32.png b/examples/widgets/widgets/icons/images/qt_extended_32x32.png Binary files differdeleted file mode 100644 index d609c1e1e5..0000000000 --- a/examples/widgets/widgets/icons/images/qt_extended_32x32.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/images/qt_extended_48x48.png b/examples/widgets/widgets/icons/images/qt_extended_48x48.png Binary files differdeleted file mode 100644 index 0e524fed5f..0000000000 --- a/examples/widgets/widgets/icons/images/qt_extended_48x48.png +++ /dev/null diff --git a/examples/widgets/widgets/icons/main.cpp b/examples/widgets/widgets/icons/main.cpp deleted file mode 100644 index aff2d2013e..0000000000 --- a/examples/widgets/widgets/icons/main.cpp +++ /dev/null @@ -1,81 +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 <QCommandLineParser> -#include <QScreen> - -#include "mainwindow.h" - -//! [45] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - QCoreApplication::setApplicationName(MainWindow::tr("Icons")); - QCoreApplication::setApplicationVersion(QT_VERSION_STR); - QCommandLineParser commandLineParser; - commandLineParser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); - commandLineParser.addHelpOption(); - commandLineParser.addVersionOption(); - commandLineParser.addPositionalArgument(MainWindow::tr("[file]"), MainWindow::tr("Icon file(s) to open.")); - commandLineParser.process(QCoreApplication::arguments()); - - MainWindow mainWin; - if (!commandLineParser.positionalArguments().isEmpty()) - mainWin.loadImages(commandLineParser.positionalArguments()); - - const QRect availableGeometry = mainWin.screen()->availableGeometry(); - mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3); - mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2); - - mainWin.show(); - return app.exec(); -} -//! [45] diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp deleted file mode 100644 index 7280ba9a42..0000000000 --- a/examples/widgets/widgets/icons/mainwindow.cpp +++ /dev/null @@ -1,525 +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 "iconpreviewarea.h" -#include "iconsizespinbox.h" -#include "imagedelegate.h" - -#include <QActionGroup> -#include <QApplication> -#include <QButtonGroup> -#include <QCheckBox> -#include <QFileDialog> -#include <QHeaderView> -#include <QFormLayout> -#include <QGridLayout> -#include <QGroupBox> -#include <QImageReader> -#include <QLabel> -#include <QMenuBar> -#include <QMessageBox> -#include <QRadioButton> -#include <QScreen> -#include <QStandardPaths> -#include <QStyleFactory> -#include <QTableWidget> -#include <QWindow> - -//! [40] -enum { OtherSize = QStyle::PM_CustomBase }; -//! [40] - -//! [0] -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - QWidget *centralWidget = new QWidget(this); - setCentralWidget(centralWidget); - - createActions(); - - QGridLayout *mainLayout = new QGridLayout(centralWidget); - - QGroupBox *previewGroupBox = new QGroupBox(tr("Preview")); - previewArea = new IconPreviewArea(previewGroupBox); - QVBoxLayout *previewLayout = new QVBoxLayout(previewGroupBox); - previewLayout->addWidget(previewArea); - - mainLayout->addWidget(previewGroupBox, 0, 0, 1, 2); - mainLayout->addWidget(createImagesGroupBox(), 1, 0); - QVBoxLayout *vBox = new QVBoxLayout; - vBox->addWidget(createIconSizeGroupBox()); - vBox->addWidget(createHighDpiIconSizeGroupBox()); - vBox->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); - mainLayout->addLayout(vBox, 1, 1); - createContextMenu(); - - setWindowTitle(tr("Icons")); - checkCurrentStyle(); - sizeButtonGroup->button(OtherSize)->click(); -} -//! [0] - -//! [44] -void MainWindow::show() -{ - QMainWindow::show(); - connect(windowHandle(), &QWindow::screenChanged, this, &MainWindow::screenChanged); - screenChanged(); -} -//! [44] - -//! [1] -void MainWindow::about() -{ - QMessageBox::about(this, tr("About Icons"), - tr("The <b>Icons</b> example illustrates how Qt renders an icon in " - "different modes (active, normal, disabled, and selected) and " - "states (on and off) based on a set of images.")); -} -//! [1] - -//! [2] -void MainWindow::changeStyle(bool checked) -{ - if (!checked) - return; - - const QAction *action = qobject_cast<QAction *>(sender()); -//! [2] //! [3] - QStyle *style = QStyleFactory::create(action->data().toString()); -//! [3] //! [4] - Q_ASSERT(style); - QApplication::setStyle(style); - - const QList<QAbstractButton*> buttons = sizeButtonGroup->buttons(); - for (QAbstractButton *button : buttons) { - const QStyle::PixelMetric metric = static_cast<QStyle::PixelMetric>(sizeButtonGroup->id(button)); - const int value = style->pixelMetric(metric); - switch (metric) { - case QStyle::PM_SmallIconSize: - button->setText(tr("Small (%1 x %1)").arg(value)); - break; - case QStyle::PM_LargeIconSize: - button->setText(tr("Large (%1 x %1)").arg(value)); - break; - case QStyle::PM_ToolBarIconSize: - button->setText(tr("Toolbars (%1 x %1)").arg(value)); - break; - case QStyle::PM_ListViewIconSize: - button->setText(tr("List views (%1 x %1)").arg(value)); - break; - case QStyle::PM_IconViewIconSize: - button->setText(tr("Icon views (%1 x %1)").arg(value)); - break; - case QStyle::PM_TabBarIconSize: - button->setText(tr("Tab bars (%1 x %1)").arg(value)); - break; - default: - break; - } - } - - triggerChangeSize(); -} -//! [4] - -//! [5] -void MainWindow::changeSize(QAbstractButton *button, bool checked) -{ - if (!checked) - return; - - const int index = sizeButtonGroup->id(button); - const bool other = index == int(OtherSize); - const int extent = other - ? otherSpinBox->value() - : QApplication::style()->pixelMetric(static_cast<QStyle::PixelMetric>(index)); - - previewArea->setSize(QSize(extent, extent)); - otherSpinBox->setEnabled(other); -} - -void MainWindow::triggerChangeSize() -{ - changeSize(sizeButtonGroup->checkedButton(), true); -} -//! [5] - -//! [6] -void MainWindow::changeIcon() -{ - QIcon icon; - - for (int row = 0; row < imagesTable->rowCount(); ++row) { - const QTableWidgetItem *fileItem = imagesTable->item(row, 0); - const QTableWidgetItem *modeItem = imagesTable->item(row, 1); - const QTableWidgetItem *stateItem = imagesTable->item(row, 2); - - if (fileItem->checkState() == Qt::Checked) { - const int modeIndex = IconPreviewArea::iconModeNames().indexOf(modeItem->text()); - Q_ASSERT(modeIndex >= 0); - const int stateIndex = IconPreviewArea::iconStateNames().indexOf(stateItem->text()); - Q_ASSERT(stateIndex >= 0); - const QIcon::Mode mode = IconPreviewArea::iconModes().at(modeIndex); - const QIcon::State state = IconPreviewArea::iconStates().at(stateIndex); -//! [6] - -//! [8] - const QString fileName = fileItem->data(Qt::UserRole).toString(); - QImage image(fileName); - if (!image.isNull()) - icon.addPixmap(QPixmap::fromImage(image), mode, state); -//! [8] - } - } -//! [11] - previewArea->setIcon(icon); -//! [11] -} - -void MainWindow::addSampleImages() -{ - addImages(QLatin1String(SRCDIR) + QLatin1String("/images")); -} - -void MainWindow::addOtherImages() -{ - static bool firstInvocation = true; - QString directory; - if (firstInvocation) { - firstInvocation = false; - directory = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).value(0, QString()); - } - addImages(directory); -} - -//! [12] -void MainWindow::addImages(const QString &directory) -{ - QFileDialog fileDialog(this, tr("Open Images"), directory); - QStringList mimeTypeFilters; - const QList<QByteArray> mimeTypes = QImageReader::supportedMimeTypes(); - for (const QByteArray &mimeTypeName : mimeTypes) - mimeTypeFilters.append(mimeTypeName); - mimeTypeFilters.sort(); - fileDialog.setMimeTypeFilters(mimeTypeFilters); - fileDialog.selectMimeTypeFilter(QLatin1String("image/png")); - fileDialog.setAcceptMode(QFileDialog::AcceptOpen); - fileDialog.setFileMode(QFileDialog::ExistingFiles); - if (!nativeFileDialogAct->isChecked()) - fileDialog.setOption(QFileDialog::DontUseNativeDialog); - if (fileDialog.exec() == QDialog::Accepted) - loadImages(fileDialog.selectedFiles()); -//! [12] -} - -void MainWindow::loadImages(const QStringList &fileNames) -{ - for (const QString &fileName : fileNames) { - const int row = imagesTable->rowCount(); - imagesTable->setRowCount(row + 1); -//! [13] - const QFileInfo fileInfo(fileName); - const QString imageName = fileInfo.baseName(); - const QString fileName2x = fileInfo.absolutePath() - + QLatin1Char('/') + imageName + QLatin1String("@2x.") + fileInfo.suffix(); - const QFileInfo fileInfo2x(fileName2x); - const QImage image(fileName); - const QString toolTip = - tr("Directory: %1\nFile: %2\nFile@2x: %3\nSize: %4x%5") - .arg(QDir::toNativeSeparators(fileInfo.absolutePath()), fileInfo.fileName()) - .arg(fileInfo2x.exists() ? fileInfo2x.fileName() : tr("<None>")) - .arg(image.width()).arg(image.height()); - QTableWidgetItem *fileItem = new QTableWidgetItem(imageName); - fileItem->setData(Qt::UserRole, fileName); - fileItem->setIcon(QPixmap::fromImage(image)); - fileItem->setFlags((fileItem->flags() | Qt::ItemIsUserCheckable) & ~Qt::ItemIsEditable); - fileItem->setToolTip(toolTip); -//! [13] - -//! [15] - QIcon::Mode mode = QIcon::Normal; - QIcon::State state = QIcon::Off; - if (guessModeStateAct->isChecked()) { - if (imageName.contains(QLatin1String("_act"), Qt::CaseInsensitive)) - mode = QIcon::Active; - else if (imageName.contains(QLatin1String("_dis"), Qt::CaseInsensitive)) - mode = QIcon::Disabled; - else if (imageName.contains(QLatin1String("_sel"), Qt::CaseInsensitive)) - mode = QIcon::Selected; - - if (imageName.contains(QLatin1String("_on"), Qt::CaseInsensitive)) - state = QIcon::On; -//! [15] - } - -//! [18] - imagesTable->setItem(row, 0, fileItem); - QTableWidgetItem *modeItem = - new QTableWidgetItem(IconPreviewArea::iconModeNames().at(IconPreviewArea::iconModes().indexOf(mode))); - modeItem->setToolTip(toolTip); - imagesTable->setItem(row, 1, modeItem); - QTableWidgetItem *stateItem = - new QTableWidgetItem(IconPreviewArea::iconStateNames().at(IconPreviewArea::iconStates().indexOf(state))); - stateItem->setToolTip(toolTip); - imagesTable->setItem(row, 2, stateItem); - imagesTable->openPersistentEditor(modeItem); - imagesTable->openPersistentEditor(stateItem); - - fileItem->setCheckState(Qt::Checked); -//! [18] - } -} - -//! [20] -void MainWindow::removeAllImages() -{ - imagesTable->setRowCount(0); - changeIcon(); -} -//! [20] - -//! [21] -QWidget *MainWindow::createImagesGroupBox() -{ - QGroupBox *imagesGroupBox = new QGroupBox(tr("Images")); - - imagesTable = new QTableWidget; - imagesTable->setSelectionMode(QAbstractItemView::NoSelection); - imagesTable->setItemDelegate(new ImageDelegate(this)); -//! [21] - -//! [22] - const QStringList labels({tr("Image"), tr("Mode"), tr("State")}); - - imagesTable->horizontalHeader()->setDefaultSectionSize(90); - imagesTable->setColumnCount(3); - imagesTable->setHorizontalHeaderLabels(labels); - imagesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); - imagesTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed); - imagesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed); - imagesTable->verticalHeader()->hide(); -//! [22] - -//! [24] - connect(imagesTable, &QTableWidget::itemChanged, - this, &MainWindow::changeIcon); - - QVBoxLayout *layout = new QVBoxLayout(imagesGroupBox); - layout->addWidget(imagesTable); - return imagesGroupBox; -//! [24] -} - -//! [26] -QWidget *MainWindow::createIconSizeGroupBox() -{ - QGroupBox *iconSizeGroupBox = new QGroupBox(tr("Icon Size")); - - sizeButtonGroup = new QButtonGroup(this); - sizeButtonGroup->setExclusive(true); - - connect(sizeButtonGroup, &QButtonGroup::buttonToggled, - this, &MainWindow::changeSize); - - QRadioButton *smallRadioButton = new QRadioButton; - sizeButtonGroup->addButton(smallRadioButton, QStyle::PM_SmallIconSize); - QRadioButton *largeRadioButton = new QRadioButton; - sizeButtonGroup->addButton(largeRadioButton, QStyle::PM_LargeIconSize); - QRadioButton *toolBarRadioButton = new QRadioButton; - sizeButtonGroup->addButton(toolBarRadioButton, QStyle::PM_ToolBarIconSize); - QRadioButton *listViewRadioButton = new QRadioButton; - sizeButtonGroup->addButton(listViewRadioButton, QStyle::PM_ListViewIconSize); - QRadioButton *iconViewRadioButton = new QRadioButton; - sizeButtonGroup->addButton(iconViewRadioButton, QStyle::PM_IconViewIconSize); - QRadioButton *tabBarRadioButton = new QRadioButton; - sizeButtonGroup->addButton(tabBarRadioButton, QStyle::PM_TabBarIconSize); - QRadioButton *otherRadioButton = new QRadioButton(tr("Other:")); - sizeButtonGroup->addButton(otherRadioButton, OtherSize); - otherSpinBox = new IconSizeSpinBox; - otherSpinBox->setRange(8, 256); - const QString spinBoxToolTip = - tr("Enter a custom size within %1..%2") - .arg(otherSpinBox->minimum()).arg(otherSpinBox->maximum()); - otherSpinBox->setValue(64); - otherSpinBox->setToolTip(spinBoxToolTip); - otherRadioButton->setToolTip(spinBoxToolTip); -//! [26] - -//! [27] - connect(otherSpinBox, &QSpinBox::valueChanged, - this, &MainWindow::triggerChangeSize); - - QHBoxLayout *otherSizeLayout = new QHBoxLayout; - otherSizeLayout->addWidget(otherRadioButton); - otherSizeLayout->addWidget(otherSpinBox); - otherSizeLayout->addStretch(); - - QGridLayout *layout = new QGridLayout(iconSizeGroupBox); - layout->addWidget(smallRadioButton, 0, 0); - layout->addWidget(largeRadioButton, 1, 0); - layout->addWidget(toolBarRadioButton, 2, 0); - layout->addWidget(listViewRadioButton, 0, 1); - layout->addWidget(iconViewRadioButton, 1, 1); - layout->addWidget(tabBarRadioButton, 2, 1); - layout->addLayout(otherSizeLayout, 3, 0, 1, 2); - layout->setRowStretch(4, 1); - return iconSizeGroupBox; -//! [27] -} - -void MainWindow::screenChanged() -{ - devicePixelRatioLabel->setText(QString::number(devicePixelRatio())); - if (const QWindow *window = windowHandle()) { - const QScreen *screen = window->screen(); - const QString screenDescription = - tr("\"%1\" (%2x%3)").arg(screen->name()) - .arg(screen->geometry().width()).arg(screen->geometry().height()); - screenNameLabel->setText(screenDescription); - } - changeIcon(); -} - -QWidget *MainWindow::createHighDpiIconSizeGroupBox() -{ - QGroupBox *highDpiGroupBox = new QGroupBox(tr("High DPI Scaling")); - QFormLayout *layout = new QFormLayout(highDpiGroupBox); - devicePixelRatioLabel = new QLabel(highDpiGroupBox); - screenNameLabel = new QLabel(highDpiGroupBox); - layout->addRow(tr("Screen:"), screenNameLabel); - layout->addRow(tr("Device pixel ratio:"), devicePixelRatioLabel); - return highDpiGroupBox; -} - -//! [28] -void MainWindow::createActions() -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - - addSampleImagesAct = new QAction(tr("Add &Sample Images..."), this); - addSampleImagesAct->setShortcut(tr("Ctrl+A")); - connect(addSampleImagesAct, &QAction::triggered, this, &MainWindow::addSampleImages); - fileMenu->addAction(addSampleImagesAct); - - addOtherImagesAct = new QAction(tr("&Add Images..."), this); - addOtherImagesAct->setShortcut(QKeySequence::Open); - connect(addOtherImagesAct, &QAction::triggered, this, &MainWindow::addOtherImages); - fileMenu->addAction(addOtherImagesAct); - - removeAllImagesAct = new QAction(tr("&Remove All Images"), this); - removeAllImagesAct->setShortcut(tr("Ctrl+R")); - connect(removeAllImagesAct, &QAction::triggered, - this, &MainWindow::removeAllImages); - fileMenu->addAction(removeAllImagesAct); - - fileMenu->addSeparator(); - - QAction *exitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close); - exitAct->setShortcuts(QKeySequence::Quit); - - QMenu *viewMenu = menuBar()->addMenu(tr("&View")); - - styleActionGroup = new QActionGroup(this); - const QStringList styleKeys = QStyleFactory::keys(); - for (const QString &styleName : styleKeys) { - QAction *action = new QAction(tr("%1 Style").arg(styleName), styleActionGroup); - action->setData(styleName); - action->setCheckable(true); - connect(action, &QAction::triggered, this, &MainWindow::changeStyle); - viewMenu->addAction(action); - } - - QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings")); - - guessModeStateAct = new QAction(tr("&Guess Image Mode/State"), this); - guessModeStateAct->setCheckable(true); - guessModeStateAct->setChecked(true); - settingsMenu->addAction(guessModeStateAct); - - nativeFileDialogAct = new QAction(tr("&Use Native File Dialog"), this); - nativeFileDialogAct->setCheckable(true); - nativeFileDialogAct->setChecked(true); - settingsMenu->addAction(nativeFileDialogAct); - - QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(tr("&About"), this, &MainWindow::about); - helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt); -} -//! [28] - -//! [30] -void MainWindow::createContextMenu() -{ - imagesTable->setContextMenuPolicy(Qt::ActionsContextMenu); - imagesTable->addAction(addSampleImagesAct); - imagesTable->addAction(addOtherImagesAct); - imagesTable->addAction(removeAllImagesAct); -} -//! [30] - -//! [31] -void MainWindow::checkCurrentStyle() -{ - const QList<QAction *> actions = styleActionGroup->actions(); - for (QAction *action : actions) { - const QString styleName = action->data().toString(); - const std::unique_ptr<QStyle> candidate{QStyleFactory::create(styleName)}; - Q_ASSERT(candidate); - if (candidate->metaObject()->className() - == QApplication::style()->metaObject()->className()) { - action->trigger(); - return; - } - } -} -//! [31] diff --git a/examples/widgets/widgets/icons/mainwindow.h b/examples/widgets/widgets/icons/mainwindow.h deleted file mode 100644 index cd77dae8e8..0000000000 --- a/examples/widgets/widgets/icons/mainwindow.h +++ /dev/null @@ -1,121 +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 <QIcon> -#include <QList> -#include <QMainWindow> -#include <QPixmap> - -QT_BEGIN_NAMESPACE -class QAction; -class QActionGroup; -class QLabel; -class QButtonGroup; -class QTableWidget; -class QAbstractButton; -QT_END_NAMESPACE -class IconPreviewArea; -class IconSizeSpinBox; - -//! [0] -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - - void loadImages(const QStringList &fileNames); - - void show(); - -private slots: - void about(); - void changeStyle(bool checked); - void changeSize(QAbstractButton *button, bool); - void triggerChangeSize(); - void changeIcon(); - void addSampleImages(); - void addOtherImages(); - void removeAllImages(); - void screenChanged(); - -private: - QWidget *createImagesGroupBox(); - QWidget *createIconSizeGroupBox(); - QWidget *createHighDpiIconSizeGroupBox(); - void createActions(); - void createContextMenu(); - void checkCurrentStyle(); - void addImages(const QString &directory); - - IconPreviewArea *previewArea; - - QTableWidget *imagesTable; - - QButtonGroup *sizeButtonGroup; - IconSizeSpinBox *otherSpinBox; - - QLabel *devicePixelRatioLabel; - QLabel *screenNameLabel; - - QAction *addOtherImagesAct; - QAction *addSampleImagesAct; - QAction *removeAllImagesAct; - QAction *guessModeStateAct; - QAction *nativeFileDialogAct; - QActionGroup *styleActionGroup; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt b/examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt deleted file mode 100644 index 9603f8dcbd..0000000000 --- a/examples/widgets/widgets/imageviewer/.prev_CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# Generated from imageviewer.pro. - -cmake_minimum_required(VERSION 3.14) -project(imageviewer 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/widgets/imageviewer") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(imageviewer - imageviewer.cpp imageviewer.h - main.cpp -) -set_target_properties(imageviewer PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(imageviewer PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -if(TARGET Qt::PrintSupport) - target_link_libraries(imageviewer PUBLIC - Qt::PrintSupport - ) -endif() - -install(TARGETS imageviewer - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/imageviewer/CMakeLists.txt b/examples/widgets/widgets/imageviewer/CMakeLists.txt deleted file mode 100644 index a52bc5fb34..0000000000 --- a/examples/widgets/widgets/imageviewer/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Generated from imageviewer.pro. - -cmake_minimum_required(VERSION 3.14) -project(imageviewer 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/widgets/imageviewer") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS PrintSupport) # special case - -qt_add_executable(imageviewer - imageviewer.cpp imageviewer.h - main.cpp -) -set_target_properties(imageviewer PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(imageviewer PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) -# special case begin -if (TARGET Qt::PrintSupport) - target_link_libraries(imageviewer PUBLIC Qt::PrintSupport) -endif() -# special case end - -if(TARGET Qt::PrintSupport) - target_link_libraries(imageviewer PUBLIC - Qt::PrintSupport - ) -endif() - -install(TARGETS imageviewer - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp deleted file mode 100644 index 7de0c7c45b..0000000000 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ /dev/null @@ -1,406 +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 "imageviewer.h" - -#include <QApplication> -#include <QClipboard> -#include <QColorSpace> -#include <QDir> -#include <QFileDialog> -#include <QImageReader> -#include <QImageWriter> -#include <QLabel> -#include <QMenuBar> -#include <QMessageBox> -#include <QMimeData> -#include <QPainter> -#include <QScreen> -#include <QScrollArea> -#include <QScrollBar> -#include <QStandardPaths> -#include <QStatusBar> - -#if defined(QT_PRINTSUPPORT_LIB) -# include <QtPrintSupport/qtprintsupportglobal.h> - -# if QT_CONFIG(printdialog) -# include <QPrintDialog> -# endif -#endif - -//! [0] -ImageViewer::ImageViewer(QWidget *parent) - : QMainWindow(parent), imageLabel(new QLabel) - , scrollArea(new QScrollArea) -{ - imageLabel->setBackgroundRole(QPalette::Base); - imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - imageLabel->setScaledContents(true); - - scrollArea->setBackgroundRole(QPalette::Dark); - scrollArea->setWidget(imageLabel); - scrollArea->setVisible(false); - setCentralWidget(scrollArea); - - createActions(); - - resize(QGuiApplication::primaryScreen()->availableSize() * 3 / 5); -} - -//! [0] -//! [2] - -bool ImageViewer::loadFile(const QString &fileName) -{ - QImageReader reader(fileName); - reader.setAutoTransform(true); - const QImage newImage = reader.read(); - if (newImage.isNull()) { - QMessageBox::information(this, QGuiApplication::applicationDisplayName(), - tr("Cannot load %1: %2") - .arg(QDir::toNativeSeparators(fileName), reader.errorString())); - return false; - } -//! [2] - - setImage(newImage); - - setWindowFilePath(fileName); - - const QString message = tr("Opened \"%1\", %2x%3, Depth: %4") - .arg(QDir::toNativeSeparators(fileName)).arg(image.width()).arg(image.height()).arg(image.depth()); - statusBar()->showMessage(message); - return true; -} - -void ImageViewer::setImage(const QImage &newImage) -{ - image = newImage; - if (image.colorSpace().isValid()) - image.convertToColorSpace(QColorSpace::SRgb); - imageLabel->setPixmap(QPixmap::fromImage(image)); -//! [4] - scaleFactor = 1.0; - - scrollArea->setVisible(true); - printAct->setEnabled(true); - fitToWindowAct->setEnabled(true); - updateActions(); - - if (!fitToWindowAct->isChecked()) - imageLabel->adjustSize(); -} - -//! [4] - -bool ImageViewer::saveFile(const QString &fileName) -{ - QImageWriter writer(fileName); - - if (!writer.write(image)) { - QMessageBox::information(this, QGuiApplication::applicationDisplayName(), - tr("Cannot write %1: %2") - .arg(QDir::toNativeSeparators(fileName)), writer.errorString()); - return false; - } - const QString message = tr("Wrote \"%1\"").arg(QDir::toNativeSeparators(fileName)); - statusBar()->showMessage(message); - return true; -} - -//! [1] - -static void initializeImageFileDialog(QFileDialog &dialog, QFileDialog::AcceptMode acceptMode) -{ - static bool firstDialog = true; - - if (firstDialog) { - firstDialog = false; - const QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); - dialog.setDirectory(picturesLocations.isEmpty() ? QDir::currentPath() : picturesLocations.last()); - } - - QStringList mimeTypeFilters; - const QByteArrayList supportedMimeTypes = acceptMode == QFileDialog::AcceptOpen - ? QImageReader::supportedMimeTypes() : QImageWriter::supportedMimeTypes(); - for (const QByteArray &mimeTypeName : supportedMimeTypes) - mimeTypeFilters.append(mimeTypeName); - mimeTypeFilters.sort(); - dialog.setMimeTypeFilters(mimeTypeFilters); - dialog.selectMimeTypeFilter("image/jpeg"); - if (acceptMode == QFileDialog::AcceptSave) - dialog.setDefaultSuffix("jpg"); -} - -void ImageViewer::open() -{ - QFileDialog dialog(this, tr("Open File")); - initializeImageFileDialog(dialog, QFileDialog::AcceptOpen); - - while (dialog.exec() == QDialog::Accepted && !loadFile(dialog.selectedFiles().first())) {} -} -//! [1] - -void ImageViewer::saveAs() -{ - QFileDialog dialog(this, tr("Save File As")); - initializeImageFileDialog(dialog, QFileDialog::AcceptSave); - - while (dialog.exec() == QDialog::Accepted && !saveFile(dialog.selectedFiles().first())) {} -} - -//! [5] -void ImageViewer::print() -//! [5] //! [6] -{ - Q_ASSERT(!imageLabel->pixmap(Qt::ReturnByValue).isNull()); -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) -//! [6] //! [7] - QPrintDialog dialog(&printer, this); -//! [7] //! [8] - if (dialog.exec()) { - QPainter painter(&printer); - QPixmap pixmap = imageLabel->pixmap(Qt::ReturnByValue); - QRect rect = painter.viewport(); - QSize size = pixmap.size(); - size.scale(rect.size(), Qt::KeepAspectRatio); - painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); - painter.setWindow(pixmap.rect()); - painter.drawPixmap(0, 0, pixmap); - } -#endif -} -//! [8] - -void ImageViewer::copy() -{ -#ifndef QT_NO_CLIPBOARD - QGuiApplication::clipboard()->setImage(image); -#endif // !QT_NO_CLIPBOARD -} - -#ifndef QT_NO_CLIPBOARD -static QImage clipboardImage() -{ - if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData()) { - if (mimeData->hasImage()) { - const QImage image = qvariant_cast<QImage>(mimeData->imageData()); - if (!image.isNull()) - return image; - } - } - return QImage(); -} -#endif // !QT_NO_CLIPBOARD - -void ImageViewer::paste() -{ -#ifndef QT_NO_CLIPBOARD - const QImage newImage = clipboardImage(); - if (newImage.isNull()) { - statusBar()->showMessage(tr("No image in clipboard")); - } else { - setImage(newImage); - setWindowFilePath(QString()); - const QString message = tr("Obtained image from clipboard, %1x%2, Depth: %3") - .arg(newImage.width()).arg(newImage.height()).arg(newImage.depth()); - statusBar()->showMessage(message); - } -#endif // !QT_NO_CLIPBOARD -} - -//! [9] -void ImageViewer::zoomIn() -//! [9] //! [10] -{ - scaleImage(1.25); -} - -void ImageViewer::zoomOut() -{ - scaleImage(0.8); -} - -//! [10] //! [11] -void ImageViewer::normalSize() -//! [11] //! [12] -{ - imageLabel->adjustSize(); - scaleFactor = 1.0; -} -//! [12] - -//! [13] -void ImageViewer::fitToWindow() -//! [13] //! [14] -{ - bool fitToWindow = fitToWindowAct->isChecked(); - scrollArea->setWidgetResizable(fitToWindow); - if (!fitToWindow) - normalSize(); - updateActions(); -} -//! [14] - - -//! [15] -void ImageViewer::about() -//! [15] //! [16] -{ - QMessageBox::about(this, tr("About Image Viewer"), - tr("<p>The <b>Image Viewer</b> example shows how to combine QLabel " - "and QScrollArea to display an image. QLabel is typically used " - "for displaying a text, but it can also display an image. " - "QScrollArea provides a scrolling view around another widget. " - "If the child widget exceeds the size of the frame, QScrollArea " - "automatically provides scroll bars. </p><p>The example " - "demonstrates how QLabel's ability to scale its contents " - "(QLabel::scaledContents), and QScrollArea's ability to " - "automatically resize its contents " - "(QScrollArea::widgetResizable), can be used to implement " - "zooming and scaling features. </p><p>In addition the example " - "shows how to use QPainter to print an image.</p>")); -} -//! [16] - -//! [17] -void ImageViewer::createActions() -//! [17] //! [18] -{ - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - - QAction *openAct = fileMenu->addAction(tr("&Open..."), this, &ImageViewer::open); - openAct->setShortcut(QKeySequence::Open); - - saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &ImageViewer::saveAs); - saveAsAct->setEnabled(false); - - printAct = fileMenu->addAction(tr("&Print..."), this, &ImageViewer::print); - printAct->setShortcut(QKeySequence::Print); - printAct->setEnabled(false); - - fileMenu->addSeparator(); - - QAction *exitAct = fileMenu->addAction(tr("E&xit"), this, &QWidget::close); - exitAct->setShortcut(tr("Ctrl+Q")); - - QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); - - copyAct = editMenu->addAction(tr("&Copy"), this, &ImageViewer::copy); - copyAct->setShortcut(QKeySequence::Copy); - copyAct->setEnabled(false); - - QAction *pasteAct = editMenu->addAction(tr("&Paste"), this, &ImageViewer::paste); - pasteAct->setShortcut(QKeySequence::Paste); - - QMenu *viewMenu = menuBar()->addMenu(tr("&View")); - - zoomInAct = viewMenu->addAction(tr("Zoom &In (25%)"), this, &ImageViewer::zoomIn); - zoomInAct->setShortcut(QKeySequence::ZoomIn); - zoomInAct->setEnabled(false); - - zoomOutAct = viewMenu->addAction(tr("Zoom &Out (25%)"), this, &ImageViewer::zoomOut); - zoomOutAct->setShortcut(QKeySequence::ZoomOut); - zoomOutAct->setEnabled(false); - - normalSizeAct = viewMenu->addAction(tr("&Normal Size"), this, &ImageViewer::normalSize); - normalSizeAct->setShortcut(tr("Ctrl+S")); - normalSizeAct->setEnabled(false); - - viewMenu->addSeparator(); - - fitToWindowAct = viewMenu->addAction(tr("&Fit to Window"), this, &ImageViewer::fitToWindow); - fitToWindowAct->setEnabled(false); - fitToWindowAct->setCheckable(true); - fitToWindowAct->setShortcut(tr("Ctrl+F")); - - QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); - - helpMenu->addAction(tr("&About"), this, &ImageViewer::about); - helpMenu->addAction(tr("About &Qt"), &QApplication::aboutQt); -} -//! [18] - -//! [21] -void ImageViewer::updateActions() -//! [21] //! [22] -{ - saveAsAct->setEnabled(!image.isNull()); - copyAct->setEnabled(!image.isNull()); - zoomInAct->setEnabled(!fitToWindowAct->isChecked()); - zoomOutAct->setEnabled(!fitToWindowAct->isChecked()); - normalSizeAct->setEnabled(!fitToWindowAct->isChecked()); -} -//! [22] - -//! [23] -void ImageViewer::scaleImage(double factor) -//! [23] //! [24] -{ - scaleFactor *= factor; - imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size()); - - adjustScrollBar(scrollArea->horizontalScrollBar(), factor); - adjustScrollBar(scrollArea->verticalScrollBar(), factor); - - zoomInAct->setEnabled(scaleFactor < 3.0); - zoomOutAct->setEnabled(scaleFactor > 0.333); -} -//! [24] - -//! [25] -void ImageViewer::adjustScrollBar(QScrollBar *scrollBar, double factor) -//! [25] //! [26] -{ - scrollBar->setValue(int(factor * scrollBar->value() - + ((factor - 1) * scrollBar->pageStep()/2))); -} -//! [26] diff --git a/examples/widgets/widgets/imageviewer/imageviewer.h b/examples/widgets/widgets/imageviewer/imageviewer.h deleted file mode 100644 index 9c8388d470..0000000000 --- a/examples/widgets/widgets/imageviewer/imageviewer.h +++ /dev/null @@ -1,121 +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 IMAGEVIEWER_H -#define IMAGEVIEWER_H - -#include <QMainWindow> -#include <QImage> -#if defined(QT_PRINTSUPPORT_LIB) -# include <QtPrintSupport/qtprintsupportglobal.h> - -# if QT_CONFIG(printer) -# include <QPrinter> -# endif -#endif - -QT_BEGIN_NAMESPACE -class QAction; -class QLabel; -class QMenu; -class QScrollArea; -class QScrollBar; -QT_END_NAMESPACE - -//! [0] -class ImageViewer : public QMainWindow -{ - Q_OBJECT - -public: - ImageViewer(QWidget *parent = nullptr); - bool loadFile(const QString &); - -private slots: - void open(); - void saveAs(); - void print(); - void copy(); - void paste(); - void zoomIn(); - void zoomOut(); - void normalSize(); - void fitToWindow(); - void about(); - -private: - void createActions(); - void createMenus(); - void updateActions(); - bool saveFile(const QString &fileName); - void setImage(const QImage &newImage); - void scaleImage(double factor); - void adjustScrollBar(QScrollBar *scrollBar, double factor); - - QImage image; - QLabel *imageLabel; - QScrollArea *scrollArea; - double scaleFactor = 1; - -#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) - QPrinter printer; -#endif - - QAction *saveAsAct; - QAction *printAct; - QAction *copyAct; - QAction *zoomInAct; - QAction *zoomOutAct; - QAction *normalSizeAct; - QAction *fitToWindowAct; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/imageviewer/imageviewer.pro b/examples/widgets/widgets/imageviewer/imageviewer.pro deleted file mode 100644 index d3db63ec20..0000000000 --- a/examples/widgets/widgets/imageviewer/imageviewer.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += widgets -requires(qtConfig(filedialog)) -qtHaveModule(printsupport): QT += printsupport - -HEADERS = imageviewer.h -SOURCES = imageviewer.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/imageviewer -INSTALLS += target diff --git a/examples/widgets/widgets/imageviewer/main.cpp b/examples/widgets/widgets/imageviewer/main.cpp deleted file mode 100644 index 035c769693..0000000000 --- a/examples/widgets/widgets/imageviewer/main.cpp +++ /dev/null @@ -1,71 +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 <QCommandLineParser> - -#include "imageviewer.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - QGuiApplication::setApplicationDisplayName(ImageViewer::tr("Image Viewer")); - QCommandLineParser commandLineParser; - commandLineParser.addHelpOption(); - commandLineParser.addPositionalArgument(ImageViewer::tr("[file]"), ImageViewer::tr("Image file to open.")); - commandLineParser.process(QCoreApplication::arguments()); - ImageViewer imageViewer; - if (!commandLineParser.positionalArguments().isEmpty() - && !imageViewer.loadFile(commandLineParser.positionalArguments().front())) { - return -1; - } - imageViewer.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/lineedits/CMakeLists.txt b/examples/widgets/widgets/lineedits/CMakeLists.txt index 9e219e1038..9cfaa784c8 100644 --- a/examples/widgets/widgets/lineedits/CMakeLists.txt +++ b/examples/widgets/widgets/lineedits/CMakeLists.txt @@ -1,40 +1,38 @@ -# Generated from lineedits.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(lineedits LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/lineedits") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(lineedits main.cpp window.cpp window.h ) + set_target_properties(lineedits PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(lineedits PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(lineedits PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS lineedits - 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 lineedits + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/lineedits/main.cpp b/examples/widgets/widgets/lineedits/main.cpp index 99725195e5..27409403a5 100644 --- a/examples/widgets/widgets/lineedits/main.cpp +++ b/examples/widgets/widgets/lineedits/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp index 765f867deb..c8a47a1594 100644 --- a/examples/widgets/widgets/lineedits/window.cpp +++ b/examples/widgets/widgets/lineedits/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" diff --git a/examples/widgets/widgets/lineedits/window.h b/examples/widgets/widgets/lineedits/window.h index a31634f3a3..13fdcf64fa 100644 --- a/examples/widgets/widgets/lineedits/window.h +++ b/examples/widgets/widgets/lineedits/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/widgets/mousebuttons/CMakeLists.txt b/examples/widgets/widgets/mousebuttons/CMakeLists.txt deleted file mode 100644 index 6a8a365d33..0000000000 --- a/examples/widgets/widgets/mousebuttons/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from mousebuttons.pro. - -cmake_minimum_required(VERSION 3.14) -project(mousebuttons 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/widgets/mousebuttons") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(mousebuttons - buttontester.cpp buttontester.h - main.cpp -) -set_target_properties(mousebuttons PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(mousebuttons PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS mousebuttons - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/mousebuttons/buttontester.cpp b/examples/widgets/widgets/mousebuttons/buttontester.cpp deleted file mode 100644 index 88dbbeda45..0000000000 --- a/examples/widgets/widgets/mousebuttons/buttontester.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com> -** 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 "buttontester.h" - -#include <QDebug> - -void ButtonTester::mousePressEvent(QMouseEvent *e) -{ - int j = ButtonTester::buttonByNumber (e->button()); - QString result = "Mouse Press: raw button=" + QString::number(j) - + " Qt=" + enumNameFromValue(e->button()); - QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons()); - result += "\n heldbuttons " + buttonsString; - qDebug() << result; - this->setText(result); - this->repaint(); -} - -void ButtonTester::mouseReleaseEvent(QMouseEvent *e) -{ - int j = ButtonTester::buttonByNumber (e->button()); - QString result = "Mouse Release: raw button=" + QString::number(j) - + " Qt=" + enumNameFromValue(e->button()); - QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons()); - result += "\n heldbuttons " + buttonsString; - qDebug() << result; - this->setText(result); - this->repaint(); - -} - -void ButtonTester::mouseDoubleClickEvent(QMouseEvent *e) -{ - int j = ButtonTester::buttonByNumber (e->button()); - QString result = "Mouse DoubleClick: raw button=" + QString::number(j) - + " Qt=" + enumNameFromValue(e->button()); - QString buttonsString = ButtonTester::enumNamesFromMouseButtons(e->buttons()); - result += "\n heldbuttons" + buttonsString; - qDebug() << result; - this->setText(result); -} - -#if QT_CONFIG(wheelevent) -void ButtonTester::wheelEvent (QWheelEvent *e) -{ - QString result; - const bool vertical = qAbs(e->angleDelta().y()) >= qAbs(e->angleDelta().x()); - const int delta = vertical ? e->angleDelta().y() : e->angleDelta().x(); - if (delta > 0) { - if (vertical) { - result = "Mouse Wheel Event: UP"; - } else { - result = "Mouse Wheel Event: LEFT"; - } - } else if (delta < 0) { - if (vertical) { - result = "Mouse Wheel Event: DOWN"; - } else { - result = "Mouse Wheel Event: RIGHT"; - } - } - qDebug() << result; - this->setText(result); -} -#endif - -int ButtonTester::buttonByNumber(const Qt::MouseButton button) -{ - if (button == Qt::NoButton) return 0; - if (button == Qt::LeftButton) return 1; - if (button == Qt::RightButton) return 2; - if (button == Qt::MiddleButton) return 3; - -/* Please note that Qt Button #4 corresponds to button #8 on all - * platforms which EMULATE wheel events by creating button events - * (Button #4 = Scroll Up; Button #5 = Scroll Down; Button #6 = Scroll - * Left; and Button #7 = Scroll Right.) This includes X11, with both - * Xlib and XCB. So, the "raw button" for "Qt::BackButton" is - * usually described as "Button #8". - - * If your platform supports "smooth scrolling", then, for the cases of - * Qt::BackButton and higher, this program will show "raw button" with a - * value which is too large. Subtract 4 to get the correct button ID for - * your platform. - */ - - if (button == Qt::BackButton) return 8; - if (button == Qt::ForwardButton) return 9; - if (button == Qt::TaskButton) return 10; - if (button == Qt::ExtraButton4) return 11; - if (button == Qt::ExtraButton5) return 12; - if (button == Qt::ExtraButton6) return 13; - if (button == Qt::ExtraButton7) return 14; - if (button == Qt::ExtraButton8) return 15; - if (button == Qt::ExtraButton9) return 16; - if (button == Qt::ExtraButton10) return 17; - if (button == Qt::ExtraButton11) return 18; - if (button == Qt::ExtraButton12) return 19; - if (button == Qt::ExtraButton13) return 20; - if (button == Qt::ExtraButton14) return 21; - if (button == Qt::ExtraButton15) return 22; - if (button == Qt::ExtraButton16) return 23; - if (button == Qt::ExtraButton17) return 24; - if (button == Qt::ExtraButton18) return 25; - if (button == Qt::ExtraButton19) return 26; - if (button == Qt::ExtraButton20) return 27; - if (button == Qt::ExtraButton21) return 28; - if (button == Qt::ExtraButton22) return 29; - if (button == Qt::ExtraButton23) return 30; - if (button == Qt::ExtraButton24) return 31; - qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value"); - return 0; -} - -QString ButtonTester::enumNameFromValue(const Qt::MouseButton button) -{ - if (button == Qt::NoButton) return "NoButton"; - if (button == Qt::LeftButton) return "LeftButton"; - if (button == Qt::RightButton) return "RightButton"; - if (button == Qt::MiddleButton) return "MiddleButton"; - if (button == Qt::BackButton) return "BackButton"; - if (button == Qt::ForwardButton) return "ForwardButton"; - if (button == Qt::TaskButton) return "TaskButton"; - if (button == Qt::ExtraButton4) return "ExtraButton4"; - if (button == Qt::ExtraButton5) return "ExtraButton5"; - if (button == Qt::ExtraButton6) return "ExtraButton6"; - if (button == Qt::ExtraButton7) return "ExtraButton7"; - if (button == Qt::ExtraButton8) return "ExtraButton8"; - if (button == Qt::ExtraButton9) return "ExtraButton9"; - if (button == Qt::ExtraButton10) return "ExtraButton10"; - if (button == Qt::ExtraButton11) return "ExtraButton11"; - if (button == Qt::ExtraButton12) return "ExtraButton12"; - if (button == Qt::ExtraButton13) return "ExtraButton13"; - if (button == Qt::ExtraButton14) return "ExtraButton14"; - if (button == Qt::ExtraButton15) return "ExtraButton15"; - if (button == Qt::ExtraButton16) return "ExtraButton16"; - if (button == Qt::ExtraButton17) return "ExtraButton17"; - if (button == Qt::ExtraButton18) return "ExtraButton18"; - if (button == Qt::ExtraButton19) return "ExtraButton19"; - if (button == Qt::ExtraButton20) return "ExtraButton20"; - if (button == Qt::ExtraButton21) return "ExtraButton21"; - if (button == Qt::ExtraButton22) return "ExtraButton22"; - if (button == Qt::ExtraButton23) return "ExtraButton23"; - if (button == Qt::ExtraButton24) return "ExtraButton24"; - qDebug("QMouseShortcutEntry::addShortcut contained Invalid Qt::MouseButton value"); - return "NoButton"; -} - -QString ButtonTester::enumNamesFromMouseButtons(const Qt::MouseButtons buttons) -{ - QString returnText = ""; - if (buttons == Qt::NoButton) return "NoButton"; - if (buttons & Qt::LeftButton) returnText += "LeftButton "; - if (buttons & Qt::RightButton) returnText += "RightButton "; - if (buttons & Qt::MiddleButton) returnText += "MiddleButton "; - if (buttons & Qt::BackButton) returnText += "BackButton "; - if (buttons & Qt::ForwardButton) returnText += "ForwardButton "; - if (buttons & Qt::TaskButton) returnText += "TaskButton "; - if (buttons & Qt::ExtraButton4) returnText += "ExtraButton4 "; - if (buttons & Qt::ExtraButton5) returnText += "ExtraButton5 "; - if (buttons & Qt::ExtraButton6) returnText += "ExtraButton6 "; - if (buttons & Qt::ExtraButton7) returnText += "ExtraButton7 "; - if (buttons & Qt::ExtraButton8) returnText += "ExtraButton8 "; - if (buttons & Qt::ExtraButton9) returnText += "ExtraButton9 "; - if (buttons & Qt::ExtraButton10) returnText += "ExtraButton10 "; - if (buttons & Qt::ExtraButton11) returnText += "ExtraButton11 "; - if (buttons & Qt::ExtraButton12) returnText += "ExtraButton12 "; - if (buttons & Qt::ExtraButton13) returnText += "ExtraButton13 "; - if (buttons & Qt::ExtraButton14) returnText += "ExtraButton14 "; - if (buttons & Qt::ExtraButton15) returnText += "ExtraButton15 "; - if (buttons & Qt::ExtraButton16) returnText += "ExtraButton16 "; - if (buttons & Qt::ExtraButton17) returnText += "ExtraButton17 "; - if (buttons & Qt::ExtraButton18) returnText += "ExtraButton18 "; - if (buttons & Qt::ExtraButton19) returnText += "ExtraButton19 "; - if (buttons & Qt::ExtraButton20) returnText += "ExtraButton20 "; - if (buttons & Qt::ExtraButton21) returnText += "ExtraButton21 "; - if (buttons & Qt::ExtraButton22) returnText += "ExtraButton22 "; - if (buttons & Qt::ExtraButton23) returnText += "ExtraButton23 "; - if (buttons & Qt::ExtraButton24) returnText += "ExtraButton24 "; - return returnText; -} - diff --git a/examples/widgets/widgets/mousebuttons/buttontester.h b/examples/widgets/widgets/mousebuttons/buttontester.h deleted file mode 100644 index 231733bd44..0000000000 --- a/examples/widgets/widgets/mousebuttons/buttontester.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com> -** 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 BUTTONTESTER_H -#define BUTTONTESTER_H - -#include <QTextEdit> -#include <QString> -#include <QMouseEvent> -#include <QWheelEvent> - -class ButtonTester : public QTextEdit -{ - Q_OBJECT -public: - using QTextEdit::QTextEdit; -protected: - void mousePressEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; -#if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *event) override; -#endif - int buttonByNumber(const Qt::MouseButton button); - QString enumNameFromValue(const Qt::MouseButton button); - QString enumNamesFromMouseButtons(const Qt::MouseButtons buttons); -}; - -#endif // BUTTONTESTER_H diff --git a/examples/widgets/widgets/mousebuttons/main.cpp b/examples/widgets/widgets/mousebuttons/main.cpp deleted file mode 100644 index e35a442181..0000000000 --- a/examples/widgets/widgets/mousebuttons/main.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Rick Stockton <rickstockton@reno-computerhelp.com> -** 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 "buttontester.h" - -#include <QApplication> -#include <QPushButton> -#include <QVBoxLayout> - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - ButtonTester *testArea = new ButtonTester; - testArea->setMinimumSize(500, 350); - -// For this test, Qt::RightButton behaves like any other button. - testArea->setContextMenuPolicy(Qt::NoContextMenu); - testArea->setTextInteractionFlags(Qt::TextSelectableByMouse); - testArea->setText("To test your mouse with Qt, press buttons in this area.\nYou may also scroll or tilt your mouse wheel."); - QPushButton *quitButton = new QPushButton("Quit"); - - QObject::connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(testArea); - layout->addWidget(quitButton); - - QWidget window; - window.setLayout(layout); - window.setWindowTitle("Mouse Button Tester"); - window.show(); - - return app.exec(); -} diff --git a/examples/widgets/widgets/mousebuttons/mousebuttons.pro b/examples/widgets/widgets/mousebuttons/mousebuttons.pro deleted file mode 100644 index e1f4b9527d..0000000000 --- a/examples/widgets/widgets/mousebuttons/mousebuttons.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app - -TARGET = mousebuttons -TEMPLATE = app - -SOURCES += \ - main.cpp\ - buttontester.cpp \ - -HEADERS += \ - buttontester.h \ - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/mousebuttons -INSTALLS += target -QT += core widgets diff --git a/examples/widgets/widgets/movie/CMakeLists.txt b/examples/widgets/widgets/movie/CMakeLists.txt deleted file mode 100644 index a990a98f48..0000000000 --- a/examples/widgets/widgets/movie/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Generated from movie.pro. - -cmake_minimum_required(VERSION 3.14) -project(movie 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/widgets/movie") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(movie - main.cpp - movieplayer.cpp movieplayer.h -) -set_target_properties(movie PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(movie PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS movie - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/movie/animation.gif b/examples/widgets/widgets/movie/animation.gif Binary files differdeleted file mode 100644 index f674369efc..0000000000 --- a/examples/widgets/widgets/movie/animation.gif +++ /dev/null diff --git a/examples/widgets/widgets/movie/main.cpp b/examples/widgets/widgets/movie/main.cpp deleted file mode 100644 index 7e5a07a394..0000000000 --- a/examples/widgets/widgets/movie/main.cpp +++ /dev/null @@ -1,62 +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 "movieplayer.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MoviePlayer player; - player.show(); - player.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/movie/movie.pro b/examples/widgets/widgets/movie/movie.pro deleted file mode 100644 index f9f89109e4..0000000000 --- a/examples/widgets/widgets/movie/movie.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets -requires(qtConfig(filedialog)) - -HEADERS = movieplayer.h -SOURCES = main.cpp \ - movieplayer.cpp - -EXAMPLE_FILES = animation.gif - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/movie -INSTALLS += target diff --git a/examples/widgets/widgets/movie/movieplayer.cpp b/examples/widgets/widgets/movie/movieplayer.cpp deleted file mode 100644 index 76849268ab..0000000000 --- a/examples/widgets/widgets/movie/movieplayer.cpp +++ /dev/null @@ -1,227 +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 "movieplayer.h" - -#include <QCheckBox> -#include <QFileDialog> -#include <QLabel> -#include <QMovie> -#include <QSlider> -#include <QSpinBox> -#include <QStyle> -#include <QToolButton> -#include <QVBoxLayout> - -MoviePlayer::MoviePlayer(QWidget *parent) - : QWidget(parent) -{ - movie = new QMovie(this); - movie->setCacheMode(QMovie::CacheAll); - - movieLabel = new QLabel(tr("No movie loaded")); - movieLabel->setAlignment(Qt::AlignCenter); - movieLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - movieLabel->setBackgroundRole(QPalette::Dark); - movieLabel->setAutoFillBackground(true); - - currentMovieDirectory = "movies"; - - createControls(); - createButtons(); - - connect(movie, &QMovie::frameChanged, this, &MoviePlayer::updateFrameSlider); - connect(movie, &QMovie::stateChanged, this, &MoviePlayer::updateButtons); - connect(fitCheckBox, &QCheckBox::clicked, this, &MoviePlayer::fitToWindow); - connect(frameSlider, &QSlider::valueChanged, this, &MoviePlayer::goToFrame); - connect(speedSpinBox, &QSpinBox::valueChanged, - movie, &QMovie::setSpeed); - - mainLayout = new QVBoxLayout; - mainLayout->addWidget(movieLabel); - mainLayout->addLayout(controlsLayout); - mainLayout->addLayout(buttonsLayout); - setLayout(mainLayout); - - updateFrameSlider(); - updateButtons(); - - setWindowTitle(tr("Movie Player")); - resize(400, 400); -} - -void MoviePlayer::open() -{ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open a Movie"), - currentMovieDirectory); - if (!fileName.isEmpty()) - openFile(fileName); -} - -void MoviePlayer::openFile(const QString &fileName) -{ - currentMovieDirectory = QFileInfo(fileName).path(); - - movie->stop(); - movieLabel->setMovie(movie); - movie->setFileName(fileName); - movie->start(); - - updateFrameSlider(); - updateButtons(); -} - -void MoviePlayer::goToFrame(int frame) -{ - movie->jumpToFrame(frame); -} - -void MoviePlayer::fitToWindow() -{ - movieLabel->setScaledContents(fitCheckBox->isChecked()); -} - -void MoviePlayer::updateFrameSlider() -{ - bool hasFrames = (movie->currentFrameNumber() >= 0); - - if (hasFrames) { - if (movie->frameCount() > 0) { - frameSlider->setMaximum(movie->frameCount() - 1); - } else { - if (movie->currentFrameNumber() > frameSlider->maximum()) - frameSlider->setMaximum(movie->currentFrameNumber()); - } - frameSlider->setValue(movie->currentFrameNumber()); - } else { - frameSlider->setMaximum(0); - } - frameLabel->setEnabled(hasFrames); - frameSlider->setEnabled(hasFrames); -} - -void MoviePlayer::updateButtons() -{ - playButton->setEnabled(movie->isValid() && movie->frameCount() != 1 - && movie->state() == QMovie::NotRunning); - pauseButton->setEnabled(movie->state() != QMovie::NotRunning); - pauseButton->setChecked(movie->state() == QMovie::Paused); - stopButton->setEnabled(movie->state() != QMovie::NotRunning); -} - -void MoviePlayer::createControls() -{ - fitCheckBox = new QCheckBox(tr("Fit to Window")); - - frameLabel = new QLabel(tr("Current frame:")); - - frameSlider = new QSlider(Qt::Horizontal); - frameSlider->setTickPosition(QSlider::TicksBelow); - frameSlider->setTickInterval(10); - - speedLabel = new QLabel(tr("Speed:")); - - speedSpinBox = new QSpinBox; - speedSpinBox->setRange(1, 9999); - speedSpinBox->setValue(100); - speedSpinBox->setSuffix(tr("%")); - - controlsLayout = new QGridLayout; - controlsLayout->addWidget(fitCheckBox, 0, 0, 1, 2); - controlsLayout->addWidget(frameLabel, 1, 0); - controlsLayout->addWidget(frameSlider, 1, 1, 1, 2); - controlsLayout->addWidget(speedLabel, 2, 0); - controlsLayout->addWidget(speedSpinBox, 2, 1); -} - -void MoviePlayer::createButtons() -{ - QSize iconSize(36, 36); - - openButton = new QToolButton; - openButton->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); - openButton->setIconSize(iconSize); - openButton->setToolTip(tr("Open File")); - connect(openButton, &QToolButton::clicked, this, &MoviePlayer::open); - - playButton = new QToolButton; - playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); - playButton->setIconSize(iconSize); - playButton->setToolTip(tr("Play")); - connect(playButton, &QToolButton::clicked, movie, &QMovie::start); - - pauseButton = new QToolButton; - pauseButton->setCheckable(true); - pauseButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); - pauseButton->setIconSize(iconSize); - pauseButton->setToolTip(tr("Pause")); - connect(pauseButton, &QToolButton::clicked, movie, &QMovie::setPaused); - - stopButton = new QToolButton; - stopButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop)); - stopButton->setIconSize(iconSize); - stopButton->setToolTip(tr("Stop")); - connect(stopButton, &QToolButton::clicked, movie, &QMovie::stop); - - quitButton = new QToolButton; - quitButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); - quitButton->setIconSize(iconSize); - quitButton->setToolTip(tr("Quit")); - connect(quitButton, &QToolButton::clicked, this, &MoviePlayer::close); - - buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(); - buttonsLayout->addWidget(openButton); - buttonsLayout->addWidget(playButton); - buttonsLayout->addWidget(pauseButton); - buttonsLayout->addWidget(stopButton); - buttonsLayout->addWidget(quitButton); - buttonsLayout->addStretch(); -} diff --git a/examples/widgets/widgets/movie/movieplayer.h b/examples/widgets/widgets/movie/movieplayer.h deleted file mode 100644 index 7d143bd37c..0000000000 --- a/examples/widgets/widgets/movie/movieplayer.h +++ /dev/null @@ -1,106 +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 MOVIEPLAYER_H -#define MOVIEPLAYER_H - -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QGridLayout; -class QHBoxLayout; -class QLabel; -class QMovie; -class QSlider; -class QSpinBox; -class QToolButton; -class QVBoxLayout; -QT_END_NAMESPACE - -class MoviePlayer : public QWidget -{ - Q_OBJECT - -public: - MoviePlayer(QWidget *parent = nullptr); - void openFile(const QString &fileName); - -private slots: - void open(); - void goToFrame(int frame); - void fitToWindow(); - void updateButtons(); - void updateFrameSlider(); - -private: - void createControls(); - void createButtons(); - - QString currentMovieDirectory; - QLabel *movieLabel; - QMovie *movie; - QToolButton *openButton; - QToolButton *playButton; - QToolButton *pauseButton; - QToolButton *stopButton; - QToolButton *quitButton; - QCheckBox *fitCheckBox; - QSlider *frameSlider; - QSpinBox *speedSpinBox; - QLabel *frameLabel; - QLabel *speedLabel; - - QGridLayout *controlsLayout; - QHBoxLayout *buttonsLayout; - QVBoxLayout *mainLayout; -}; - -#endif diff --git a/examples/widgets/widgets/scribble/.prev_CMakeLists.txt b/examples/widgets/widgets/scribble/.prev_CMakeLists.txt deleted file mode 100644 index 2ce40dc8cb..0000000000 --- a/examples/widgets/widgets/scribble/.prev_CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Generated from scribble.pro. - -cmake_minimum_required(VERSION 3.14) -project(scribble 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/widgets/scribble") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(scribble - main.cpp - mainwindow.cpp mainwindow.h - scribblearea.cpp scribblearea.h -) -set_target_properties(scribble PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(scribble PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -if(TARGET Qt::PrintSupport) - target_link_libraries(scribble PUBLIC - Qt::PrintSupport - ) -endif() - -install(TARGETS scribble - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/scribble/CMakeLists.txt b/examples/widgets/widgets/scribble/CMakeLists.txt index dc7f0f56bb..ec78b1ece8 100644 --- a/examples/widgets/widgets/scribble/CMakeLists.txt +++ b/examples/widgets/widgets/scribble/CMakeLists.txt @@ -1,53 +1,46 @@ -# Generated from scribble.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(scribble 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/widgets/scribble") +find_package(Qt6 + REQUIRED COMPONENTS Core Gui Widgets + OPTIONAL_COMPONENTS PrintSupport +) -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS PrintSupport) # special case +qt_standard_project_setup() qt_add_executable(scribble main.cpp mainwindow.cpp mainwindow.h scribblearea.cpp scribblearea.h ) + set_target_properties(scribble PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(scribble PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(scribble PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) -# special case begin -if (TARGET Qt::PrintSupport) - target_link_libraries(scribble PUBLIC Qt::PrintSupport) -endif() -# special case end -if(TARGET Qt::PrintSupport) - target_link_libraries(scribble PUBLIC - Qt::PrintSupport - ) +if (TARGET Qt6::PrintSupport) + target_link_libraries(scribble PRIVATE Qt6::PrintSupport) endif() install(TARGETS scribble - 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 scribble + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/scribble/main.cpp b/examples/widgets/widgets/scribble/main.cpp index 1bf46b226f..7d7cf3e573 100644 --- a/examples/widgets/widgets/scribble/main.cpp +++ b/examples/widgets/widgets/scribble/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/scribble/mainwindow.cpp b/examples/widgets/widgets/scribble/mainwindow.cpp index c9a34796ac..0a0a658265 100644 --- a/examples/widgets/widgets/scribble/mainwindow.cpp +++ b/examples/widgets/widgets/scribble/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 "scribblearea.h" @@ -200,7 +153,7 @@ void MainWindow::createMenus() //! [15] //! [16] { saveAsMenu = new QMenu(tr("&Save As"), this); - for (QAction *action : qAsConst(saveAsActs)) + for (QAction *action : std::as_const(saveAsActs)) saveAsMenu->addAction(action); fileMenu = new QMenu(tr("&File"), this); diff --git a/examples/widgets/widgets/scribble/mainwindow.h b/examples/widgets/widgets/scribble/mainwindow.h index e57ff065ac..354fdc67a1 100644 --- a/examples/widgets/widgets/scribble/mainwindow.h +++ b/examples/widgets/widgets/scribble/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/widgets/scribble/scribblearea.cpp b/examples/widgets/widgets/scribble/scribblearea.cpp index 2ac293d55a..65021532ef 100644 --- a/examples/widgets/widgets/scribble/scribblearea.cpp +++ b/examples/widgets/widgets/scribble/scribblearea.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 "scribblearea.h" diff --git a/examples/widgets/widgets/scribble/scribblearea.h b/examples/widgets/widgets/scribble/scribblearea.h index ed3c8a2a15..2cea93334f 100644 --- a/examples/widgets/widgets/scribble/scribblearea.h +++ b/examples/widgets/widgets/scribble/scribblearea.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 SCRIBBLEAREA_H #define SCRIBBLEAREA_H diff --git a/examples/widgets/widgets/shapedclock/CMakeLists.txt b/examples/widgets/widgets/shapedclock/CMakeLists.txt index de91c6410c..dd8dc217ef 100644 --- a/examples/widgets/widgets/shapedclock/CMakeLists.txt +++ b/examples/widgets/widgets/shapedclock/CMakeLists.txt @@ -1,40 +1,38 @@ -# Generated from shapedclock.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(shapedclock LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/shapedclock") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(shapedclock main.cpp shapedclock.cpp shapedclock.h ) + set_target_properties(shapedclock PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(shapedclock PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(shapedclock PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS shapedclock - 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 shapedclock + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/shapedclock/main.cpp b/examples/widgets/widgets/shapedclock/main.cpp index 3437597b7a..599e4cc625 100644 --- a/examples/widgets/widgets/shapedclock/main.cpp +++ b/examples/widgets/widgets/shapedclock/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/shapedclock/shapedclock.cpp b/examples/widgets/widgets/shapedclock/shapedclock.cpp index 343ad7c43c..106b3454a6 100644 --- a/examples/widgets/widgets/shapedclock/shapedclock.cpp +++ b/examples/widgets/widgets/shapedclock/shapedclock.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 "shapedclock.h" @@ -101,23 +54,30 @@ void ShapedClock::mouseMoveEvent(QMouseEvent *event) //! [3] void ShapedClock::paintEvent(QPaintEvent *) { - static const QPoint hourHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -40) + static const QPoint hourHand[4] = { + QPoint(5, 14), + QPoint(-5, 14), + QPoint(-4, -71), + QPoint(4, -71) }; - static const QPoint minuteHand[3] = { - QPoint(7, 8), - QPoint(-7, 8), - QPoint(0, -70) + static const QPoint minuteHand[4] = { + QPoint(4, 14), + QPoint(-4, 14), + QPoint(-3, -89), + QPoint(3, -89) + }; + static const QPoint secondsHand[4] = { + QPoint(1, 14), + QPoint(-1, 14), + QPoint(-1, -89), + QPoint(1, -89) }; - QColor hourColor(127, 0, 127); - QColor minuteColor(0, 127, 127, 191); + const QColor hourColor(palette().color(QPalette::Text)); + const QColor minuteColor(palette().color(QPalette::Text)); + const QColor secondsColor(palette().color(QPalette::Accent)); int side = qMin(width(), height()); - QTime time = QTime::currentTime(); - QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); @@ -125,54 +85,52 @@ void ShapedClock::paintEvent(QPaintEvent *) painter.setPen(Qt::NoPen); painter.setBrush(palette().window()); + painter.setOpacity(0.9); painter.drawEllipse(QPoint(0, 0), 98, 98); + painter.setOpacity(1.0); + QTime time = QTime::currentTime(); painter.setPen(Qt::NoPen); painter.setBrush(hourColor); painter.save(); painter.rotate(30.0 * ((time.hour() + time.minute() / 60.0))); - painter.drawConvexPolygon(hourHand, 3); + painter.drawConvexPolygon(hourHand, 4); painter.restore(); - painter.setPen(hourColor); - for (int i = 0; i < 12; ++i) { - painter.drawLine(88, 0, 96, 0); + painter.drawRect(73, -3, 16, 6); painter.rotate(30.0); } - painter.setPen(Qt::NoPen); painter.setBrush(minuteColor); painter.save(); - painter.rotate(6.0 * (time.minute() + time.second() / 60.0)); - painter.drawConvexPolygon(minuteHand, 3); + painter.rotate(6.0 * time.minute()); + painter.drawConvexPolygon(minuteHand, 4); + painter.restore(); + + painter.setBrush(secondsColor); + + painter.save(); + painter.rotate(6.0 * time.second()); + painter.drawConvexPolygon(secondsHand, 4); + painter.drawEllipse(-3, -3, 6, 6); + painter.drawEllipse(-5, -68, 10, 10); painter.restore(); painter.setPen(minuteColor); for (int j = 0; j < 60; ++j) { - if ((j % 5) != 0) - painter.drawLine(92, 0, 96, 0); + painter.drawLine(92, 0, 96, 0); painter.rotate(6.0); } } //! [3] //! [4] -void ShapedClock::resizeEvent(QResizeEvent * /* event */) -{ - int side = qMin(width(), height()); - QRegion maskedRegion(width() / 2 - side / 2, height() / 2 - side / 2, side, - side, QRegion::Ellipse); - setMask(maskedRegion); -} -//! [4] - -//! [5] QSize ShapedClock::sizeHint() const { return QSize(200, 200); } -//! [5] +//! [4] diff --git a/examples/widgets/widgets/shapedclock/shapedclock.h b/examples/widgets/widgets/shapedclock/shapedclock.h index a854d956b3..3dec93cc74 100644 --- a/examples/widgets/widgets/shapedclock/shapedclock.h +++ b/examples/widgets/widgets/shapedclock/shapedclock.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 SHAPEDCLOCK_H #define SHAPEDCLOCK_H @@ -66,7 +19,6 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void paintEvent(QPaintEvent *event) override; - void resizeEvent(QResizeEvent *event) override; private: QPoint dragPosition; diff --git a/examples/widgets/widgets/shortcuteditor/CMakeLists.txt b/examples/widgets/widgets/shortcuteditor/CMakeLists.txt new file mode 100644 index 0000000000..d10248fbd7 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +cmake_minimum_required(VERSION 3.16) +project(shortcuteditor LANGUAGES CXX) + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) + +qt_standard_project_setup() + +qt_add_executable(shortcuteditor + actionmanager.cpp actionmanager.h + application.cpp application.h + main.cpp + mainwindow.cpp mainwindow.h + shortcuteditordelegate.cpp shortcuteditordelegate.h + shortcuteditormodel.cpp shortcuteditormodel.h + shortcuteditorwidget.cpp shortcuteditorwidget.h +) + +set_target_properties(shortcuteditor PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(shortcuteditor PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) + +install(TARGETS shortcuteditor + BUNDLE DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +qt_generate_deploy_app_script( + TARGET shortcuteditor + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR +) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/shortcuteditor/actionmanager.cpp b/examples/widgets/widgets/shortcuteditor/actionmanager.cpp new file mode 100644 index 0000000000..cfe5f42674 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/actionmanager.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "actionmanager.h" + +#include <QAction> +#include <QApplication> +#include <QString> +#include <QVariant> + +static const char *kDefaultShortcutPropertyName = "defaultShortcuts"; +static const char *kIdPropertyName = "id"; +static const char *kAuthorName = "qt"; + +struct ActionIdentifier { + QString author; + QString context; + QString category; + QString name; +}; + +QList<QAction *> ActionManager::registeredActions() const +{ + return m_actions; +} + +void ActionManager::registerAction(QAction *action) +{ + action->setProperty(kDefaultShortcutPropertyName, QVariant::fromValue(action->shortcut())); + m_actions.append(action); +} + +void ActionManager::registerAction(QAction *action, const QString &context, const QString &category) +{ + action->setProperty(kIdPropertyName, QVariant::fromValue(ActionIdentifier{ + kAuthorName, context, category, action->text() + })); + registerAction(action); +} + +QAction *ActionManager::registerAction(const QString &name, const QString &shortcut, const QString &context, const QString &category) +{ + QAction *action = new QAction(name, qApp); + action->setShortcut(QKeySequence(shortcut)); + registerAction(action, context, category); + return action; +} + +QString ActionManager::contextForAction(QAction *action) +{ + return action->property(kIdPropertyName).value<ActionIdentifier>().context; +} + +QString ActionManager::categoryForAction(QAction *action) +{ + return action->property(kIdPropertyName).value<ActionIdentifier>().category; +} diff --git a/examples/widgets/widgets/shortcuteditor/actionmanager.h b/examples/widgets/widgets/shortcuteditor/actionmanager.h new file mode 100644 index 0000000000..da20cd8840 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/actionmanager.h @@ -0,0 +1,33 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef ACTIONMANAGER_H +#define ACTIONMANAGER_H + +#include <QList> +#include <QString> + +QT_BEGIN_NAMESPACE +class QAction; +QT_END_NAMESPACE + +class ActionManager +{ +public: + ActionManager() = default; + ~ActionManager() = default; + + QList<QAction*> registeredActions() const; + + void registerAction(QAction *action); + void registerAction(QAction *action, const QString &context, const QString &category); + QAction *registerAction(const QString &name, const QString &shortcut, const QString &context, const QString &category); + + QString contextForAction(QAction *action); + QString categoryForAction(QAction *action); + +private: + QList<QAction *> m_actions; +}; + +#endif diff --git a/examples/widgets/widgets/shortcuteditor/application.cpp b/examples/widgets/widgets/shortcuteditor/application.cpp new file mode 100644 index 0000000000..4ac76682d0 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/application.cpp @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "application.h" + +Application::Application(int &argc, char **argv) + : QApplication(argc, argv) +{ + m_actionManager = std::make_unique<ActionManager>(); +} + +ActionManager *Application::actionManager() const +{ + return m_actionManager.get(); +} diff --git a/examples/widgets/widgets/shortcuteditor/application.h b/examples/widgets/widgets/shortcuteditor/application.h new file mode 100644 index 0000000000..38808c3ad2 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/application.h @@ -0,0 +1,27 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef APPLICATION_H +#define APPLICATION_H + +#include "actionmanager.h" + +#include <QApplication> + +#include <memory> + +class Application : public QApplication +{ + Q_OBJECT + +public: + Application(int &argc, char **argv); + ~Application() override = default; + + ActionManager *actionManager() const; + +private: + std::unique_ptr<ActionManager> m_actionManager; +}; + +#endif diff --git a/examples/widgets/widgets/shortcuteditor/main.cpp b/examples/widgets/widgets/shortcuteditor/main.cpp new file mode 100644 index 0000000000..029f7a351a --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/main.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "application.h" +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + Application app(argc, argv); + MainWindow window; + window.show(); + return app.exec(); +} diff --git a/examples/widgets/widgets/shortcuteditor/mainwindow.cpp b/examples/widgets/widgets/shortcuteditor/mainwindow.cpp new file mode 100644 index 0000000000..587dbbc5b5 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/mainwindow.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "mainwindow.h" + +#include "actionmanager.h" +#include "application.h" +#include "shortcuteditorwidget.h" + +#include <QAction> +#include <QHBoxLayout> +#include <QPushButton> +#include <QVBoxLayout> + +MainWindow::MainWindow() +{ + QPushButton *topPushButton = new QPushButton("Left"); + QPushButton *bottomPushButton = new QPushButton("Right"); + for (auto nameShortcut : std::vector<std::vector<const char *>>{{"red", "r", "shift+r"}, {"green", "g", "shift+g"}, {"blue", "b", "shift+b"}}) { + Application *application = static_cast<Application *>(QCoreApplication::instance()); + ActionManager *actionManager = application->actionManager(); + QAction *action = actionManager->registerAction(nameShortcut[0], nameShortcut[1], "top", "color"); + topPushButton->addAction(action); + connect(action, &QAction::triggered, this, [topPushButton, nameShortcut]() { + topPushButton->setText(nameShortcut[0]); + }); + + action = actionManager->registerAction(nameShortcut[0], nameShortcut[2], "bottom", "color"); + bottomPushButton->addAction(action); + connect(action, &QAction::triggered, this, [bottomPushButton, nameShortcut]() { + bottomPushButton->setText(nameShortcut[0]); + }); + } + + QVBoxLayout *vBoxLayout = new QVBoxLayout; + vBoxLayout->addWidget(topPushButton); + vBoxLayout->addWidget(bottomPushButton); + + QHBoxLayout *hBoxLayout = new QHBoxLayout; + hBoxLayout->addWidget(new ShortcutEditorWidget); + hBoxLayout->addLayout(vBoxLayout); + + QWidget *centralWidget = new QWidget; + centralWidget->setLayout(hBoxLayout); + setCentralWidget(centralWidget); +} diff --git a/examples/widgets/widgets/shortcuteditor/mainwindow.h b/examples/widgets/widgets/shortcuteditor/mainwindow.h new file mode 100644 index 0000000000..702b3f2d87 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/mainwindow.h @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +class QPushButton; +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(); + ~MainWindow() override = default; +}; + +#endif diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp new file mode 100644 index 0000000000..a8b32bc06a --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "shortcuteditordelegate.h" + +#include <QAbstractItemModel> +#include <QKeySequenceEdit> + +//! [0] +ShortcutEditorDelegate::ShortcutEditorDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} +//! [0] + +//! [1] +QWidget *ShortcutEditorDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &/*option*/, + const QModelIndex &/*index*/) const +{ + QKeySequenceEdit *editor = new QKeySequenceEdit(parent); + connect(editor, &QKeySequenceEdit::editingFinished, this, &ShortcutEditorDelegate::commitAndCloseEditor); + return editor; +} +//! [1] + +//! [2] +void ShortcutEditorDelegate::commitAndCloseEditor() +{ + QKeySequenceEdit *editor = static_cast<QKeySequenceEdit *>(sender()); + Q_EMIT commitData(editor); + Q_EMIT closeEditor(editor); +} +//! [2] + +//! [3] +void ShortcutEditorDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + if (!editor || !index.isValid()) + return; + + QString value = index.model()->data(index, Qt::EditRole).toString(); + + QKeySequenceEdit *keySequenceEdit = static_cast<QKeySequenceEdit *>(editor); + keySequenceEdit->setKeySequence(value); +} +//! [3] + +//! [4] +void ShortcutEditorDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + if (!editor || !model || !index.isValid()) + return; + + const QKeySequenceEdit *keySequenceEdit = static_cast<QKeySequenceEdit *>(editor); + const QKeySequence keySequence = keySequenceEdit->keySequence(); + QString keySequenceString = keySequence.toString(QKeySequence::NativeText); + model->setData(index, keySequenceString); +} +//! [4] + +//! [5] +void ShortcutEditorDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, + const QModelIndex &/*index*/) const +{ + editor->setGeometry(option.rect); +} +//! [5] diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h new file mode 100644 index 0000000000..2818438db3 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h @@ -0,0 +1,34 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef SHORTCUTEDITORDELEGATE_H +#define SHORTCUTEDITORDELEGATE_H + +#include <QStyledItemDelegate> + +//! [0] +class ShortcutEditorDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + explicit ShortcutEditorDelegate(QObject *parent = nullptr); + ~ShortcutEditorDelegate() override = default; + +protected: + 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; + + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + +private: + void commitAndCloseEditor(); +}; +//! [0] + +#endif diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp new file mode 100644 index 0000000000..612f1fb726 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.cpp @@ -0,0 +1,273 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "shortcuteditormodel.h" + +#include "actionmanager.h" +#include "application.h" + +#include <QAction> +#include <QModelIndex> + +// List of actions for all categories +using CategoryActionsMap = QMap<QString, QList<QAction *>>; + +// List of categories for all contexts +using ActionsMap = QMap<QString, CategoryActionsMap>; + + +ShortcutEditorModel::ShortcutEditorModelItem::ShortcutEditorModelItem(const QList<QVariant> &data, ShortcutEditorModelItem *parent) + : m_itemData(data) + , m_parentItem(parent) +{ +} + +ShortcutEditorModel::ShortcutEditorModelItem::~ShortcutEditorModelItem() +{ + qDeleteAll(m_childItems); +} + +void ShortcutEditorModel::ShortcutEditorModelItem::appendChild(ShortcutEditorModelItem *item) +{ + m_childItems.push_back(item); +} + +ShortcutEditorModel::ShortcutEditorModelItem *ShortcutEditorModel::ShortcutEditorModelItem::child(int row) const +{ + if (row < 0 || row >= m_childItems.size()) + return nullptr; + + return m_childItems.at(row); +} + +int ShortcutEditorModel::ShortcutEditorModelItem::childCount() const +{ + return m_childItems.count(); +} + +int ShortcutEditorModel::ShortcutEditorModelItem::columnCount() const +{ + return m_itemData.count(); +} + +QVariant ShortcutEditorModel::ShortcutEditorModelItem::data(int column) const +{ + if (column < 0 || column >= m_itemData.size()) + return QVariant(); + + QVariant columnVariant = m_itemData.at(column); + if (column != static_cast<int>(Column::Shortcut) || columnVariant.canConvert<QString>()) + return columnVariant; + + QAction *action = static_cast<QAction *>(columnVariant.value<void *>()); + if (!action) + return QVariant(); + + QKeySequence keySequence = action->shortcut(); + QString keySequenceString = keySequence.toString(QKeySequence::NativeText); + return keySequenceString; +} + +ShortcutEditorModel::ShortcutEditorModelItem *ShortcutEditorModel::ShortcutEditorModelItem::parentItem() const +{ + return m_parentItem; +} + +int ShortcutEditorModel::ShortcutEditorModelItem::row() const +{ + if (m_parentItem) + return m_parentItem->m_childItems.indexOf(const_cast<ShortcutEditorModelItem*>(this)); + + return 0; +} + +QAction *ShortcutEditorModel::ShortcutEditorModelItem::action() const +{ + QVariant actionVariant = m_itemData.at(static_cast<int>(Column::Shortcut)); + return static_cast<QAction*>(actionVariant.value<void *>()); +} + + +//! [0] +ShortcutEditorModel::ShortcutEditorModel(QObject *parent) + : QAbstractItemModel(parent) +{ + m_rootItem = new ShortcutEditorModelItem({tr("Name"), tr("Shortcut")}); +} +//! [0] + +//! [1] +ShortcutEditorModel::~ShortcutEditorModel() +{ + delete m_rootItem; +} +//! [1] + +//! [2] +void ShortcutEditorModel::setActions() +{ + beginResetModel(); + setupModelData(m_rootItem); + endResetModel(); +} +//! [2] + +//! [3] +QModelIndex ShortcutEditorModel::index(int row, int column, const QModelIndex &parent) const +{ + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + ShortcutEditorModelItem *parentItem; + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast<ShortcutEditorModelItem*>(parent.internalPointer()); + + ShortcutEditorModelItem *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + + return QModelIndex(); +} +//! [3] + +//! [4] +QModelIndex ShortcutEditorModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + ShortcutEditorModelItem *childItem = static_cast<ShortcutEditorModelItem*>(index.internalPointer()); + ShortcutEditorModelItem *parentItem = childItem->parentItem(); + + if (parentItem == m_rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); +} +//! [4] + +//! [5] +int ShortcutEditorModel::rowCount(const QModelIndex &parent) const +{ + ShortcutEditorModelItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = m_rootItem; + else + parentItem = static_cast<ShortcutEditorModelItem*>(parent.internalPointer()); + + return parentItem->childCount(); +} +//! [5] + +//! [6] +int ShortcutEditorModel::columnCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return static_cast<ShortcutEditorModelItem*>(parent.internalPointer())->columnCount(); + + return m_rootItem->columnCount(); +} +//! [6] + +//! [7] +QVariant ShortcutEditorModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole && role != Qt::EditRole) + return QVariant(); + + ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem*>(index.internalPointer()); + return item->data(index.column()); +} +//! [7] + +//! [8] +Qt::ItemFlags ShortcutEditorModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + + Qt::ItemFlags modelFlags = QAbstractItemModel::flags(index); + if (index.column() == static_cast<int>(Column::Shortcut)) + modelFlags |= Qt::ItemIsEditable; + + return modelFlags; +} +//! [8] + +//! [9] +QVariant ShortcutEditorModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + return m_rootItem->data(section); + } + + return QVariant(); +} +//! [9] + +//! [10] +void ShortcutEditorModel::setupModelData(ShortcutEditorModelItem *parent) +{ + ActionsMap actionsMap; + Application *application = static_cast<Application *>(QCoreApplication::instance()); + ActionManager *actionManager = application->actionManager(); + const QList<QAction *> registeredActions = actionManager->registeredActions(); + for (QAction *action : registeredActions) { + QString context = actionManager->contextForAction(action); + QString category = actionManager->categoryForAction(action); + actionsMap[context][category].append(action); + } + + QAction *nullAction = nullptr; + const QString contextIdPrefix = "root"; + // Go through each context, one context - many categories each iteration + for (const auto &contextLevel : actionsMap.keys()) { + ShortcutEditorModelItem *contextLevelItem = new ShortcutEditorModelItem({contextLevel, QVariant::fromValue(nullAction)}, parent); + parent->appendChild(contextLevelItem); + + // Go through each category, one category - many actions each iteration + for (const auto &categoryLevel : actionsMap[contextLevel].keys()) { + ShortcutEditorModelItem *categoryLevelItem = new ShortcutEditorModelItem({categoryLevel, QVariant::fromValue(nullAction)}, contextLevelItem); + contextLevelItem->appendChild(categoryLevelItem); + for (QAction *action : actionsMap[contextLevel][categoryLevel]) { + QString name = action->text(); + if (name.isEmpty() || !action) + continue; + + ShortcutEditorModelItem *actionLevelItem = new ShortcutEditorModelItem({name, QVariant::fromValue(reinterpret_cast<void *>(action))}, categoryLevelItem); + categoryLevelItem->appendChild(actionLevelItem); + } + } + } +} +//! [10] + +//! [11] +bool ShortcutEditorModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (role == Qt::EditRole && index.column() == static_cast<int>(Column::Shortcut)) { + QString keySequenceString = value.toString(); + ShortcutEditorModelItem *item = static_cast<ShortcutEditorModelItem *>(index.internalPointer()); + QAction *itemAction = item->action(); + if (itemAction) { + if (keySequenceString == itemAction->shortcut().toString(QKeySequence::NativeText)) + return true; + itemAction->setShortcut(keySequenceString); + } + Q_EMIT dataChanged(index, index); + + if (keySequenceString.isEmpty()) + return true; + } + + return QAbstractItemModel::setData(index, value, role); +} +//! [11] diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h new file mode 100644 index 0000000000..c687bb4129 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditormodel.h @@ -0,0 +1,71 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef SHORTCUTEDITORMODEL_H +#define SHORTCUTEDITORMODEL_H + +#include <QAbstractItemModel> +#include <QList> +#include <QVariant> + +QT_BEGIN_NAMESPACE +class QAction; +QT_END_NAMESPACE + +enum class Column : uint8_t { + Name, + Shortcut +}; + +//! [0] +class ShortcutEditorModel : public QAbstractItemModel +{ + Q_OBJECT + + class ShortcutEditorModelItem + { + public: + explicit ShortcutEditorModelItem(const QList<QVariant> &data, + ShortcutEditorModelItem *parentItem = nullptr); + ~ShortcutEditorModelItem(); + + void appendChild(ShortcutEditorModelItem *child); + + ShortcutEditorModelItem *child(int row) const; + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + int row() const; + ShortcutEditorModelItem *parentItem() const; + QAction *action() const; + + private: + QList<ShortcutEditorModelItem *> m_childItems; + QList<QVariant> m_itemData; + ShortcutEditorModelItem *m_parentItem; + }; + +public: + explicit ShortcutEditorModel(QObject *parent = nullptr); + ~ShortcutEditorModel() override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + int rowCount(const QModelIndex &index = QModelIndex()) const override; + int columnCount(const QModelIndex &index = QModelIndex()) const override; + + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + + void setActions(); + +private: + void setupModelData(ShortcutEditorModelItem *parent); + + ShortcutEditorModelItem *m_rootItem; +}; +//! [0] + +#endif diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp new file mode 100644 index 0000000000..3e8a027f38 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "shortcuteditorwidget.h" + +#include "shortcuteditordelegate.h" +#include "shortcuteditormodel.h" + +#include <QHeaderView> +#include <QTreeView> +#include <QVBoxLayout> + +//! [0] +ShortcutEditorWidget::ShortcutEditorWidget(QWidget *parent) + : QWidget(parent) +{ + m_model = new ShortcutEditorModel(this); + m_delegate = new ShortcutEditorDelegate(this); + m_view = new QTreeView(this); + m_view->setModel(m_model); + m_view->setItemDelegateForColumn(static_cast<int>(Column::Shortcut), m_delegate); + m_view->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + m_view->setAllColumnsShowFocus(true); + m_view->header()->resizeSection(0, 250); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_view); + setLayout(layout); + + m_model->setActions(); +} +//! [0] diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h new file mode 100644 index 0000000000..44735e65e2 --- /dev/null +++ b/examples/widgets/widgets/shortcuteditor/shortcuteditorwidget.h @@ -0,0 +1,32 @@ +// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef SHORTCUTEDITORWIDGET_H +#define SHORTCUTEDITORWIDGET_H + +#include <QWidget> + +class ShortcutEditorDelegate; +class ShortcutEditorModel; + +QT_BEGIN_NAMESPACE +class QTreeView; +QT_END_NAMESPACE + +//! [0] +class ShortcutEditorWidget : public QWidget +{ + Q_OBJECT + +public: + explicit ShortcutEditorWidget(QWidget *parent = nullptr); + ~ShortcutEditorWidget() override = default; + +private: + ShortcutEditorDelegate *m_delegate; + ShortcutEditorModel *m_model; + QTreeView *m_view; +}; +//! [0] + +#endif diff --git a/examples/widgets/widgets/sliders/CMakeLists.txt b/examples/widgets/widgets/sliders/CMakeLists.txt index 07dd0c0326..c4c9d11e03 100644 --- a/examples/widgets/widgets/sliders/CMakeLists.txt +++ b/examples/widgets/widgets/sliders/CMakeLists.txt @@ -1,41 +1,39 @@ -# Generated from sliders.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(sliders LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/sliders") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(sliders main.cpp slidersgroup.cpp slidersgroup.h window.cpp window.h ) + set_target_properties(sliders PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(sliders PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(sliders PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS sliders - 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 sliders + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/sliders/main.cpp b/examples/widgets/widgets/sliders/main.cpp index 99725195e5..27409403a5 100644 --- a/examples/widgets/widgets/sliders/main.cpp +++ b/examples/widgets/widgets/sliders/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/sliders/slidersgroup.cpp b/examples/widgets/widgets/sliders/slidersgroup.cpp index 912c9798ce..87841c43f9 100644 --- a/examples/widgets/widgets/sliders/slidersgroup.cpp +++ b/examples/widgets/widgets/sliders/slidersgroup.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 "slidersgroup.h" @@ -56,39 +9,28 @@ #include <QSlider> //! [0] -SlidersGroup::SlidersGroup(Qt::Orientation orientation, const QString &title, - QWidget *parent) +SlidersGroup::SlidersGroup(const QString &title, QWidget *parent) : QGroupBox(title, parent) { - slider = new QSlider(orientation); + slider = new QSlider; slider->setFocusPolicy(Qt::StrongFocus); slider->setTickPosition(QSlider::TicksBothSides); slider->setTickInterval(10); slider->setSingleStep(1); - scrollBar = new QScrollBar(orientation); + scrollBar = new QScrollBar; scrollBar->setFocusPolicy(Qt::StrongFocus); dial = new QDial; dial->setFocusPolicy(Qt::StrongFocus); +//! [0] //! [1] connect(slider, &QSlider::valueChanged, scrollBar, &QScrollBar::setValue); connect(scrollBar, &QScrollBar::valueChanged, dial, &QDial::setValue); connect(dial, &QDial::valueChanged, slider, &QSlider::setValue); -//! [0] //! [1] connect(dial, &QDial::valueChanged, this, &SlidersGroup::valueChanged); -//! [1] //! [2] - -//! [2] //! [3] - QBoxLayout::Direction direction; -//! [3] //! [4] - - if (orientation == Qt::Horizontal) - direction = QBoxLayout::TopToBottom; - else - direction = QBoxLayout::LeftToRight; - - QBoxLayout *slidersLayout = new QBoxLayout(direction); +//! [1] //! [4] + slidersLayout = new QBoxLayout(QBoxLayout::LeftToRight); slidersLayout->addWidget(slider); slidersLayout->addWidget(scrollBar); slidersLayout->addWidget(dial); @@ -143,3 +85,14 @@ void SlidersGroup::invertKeyBindings(bool invert) dial->setInvertedControls(invert); } //! [14] + +//! [15] +void SlidersGroup::setOrientation(Qt::Orientation orientation) +{ + slidersLayout->setDirection(orientation == Qt::Horizontal + ? QBoxLayout::TopToBottom + : QBoxLayout::LeftToRight); + scrollBar->setOrientation(orientation); + slider->setOrientation(orientation); +} +//! [15] diff --git a/examples/widgets/widgets/sliders/slidersgroup.h b/examples/widgets/widgets/sliders/slidersgroup.h index 7be8a3b4f8..7e7d887018 100644 --- a/examples/widgets/widgets/sliders/slidersgroup.h +++ b/examples/widgets/widgets/sliders/slidersgroup.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 SLIDERSGROUP_H #define SLIDERSGROUP_H @@ -57,6 +10,7 @@ QT_BEGIN_NAMESPACE class QDial; class QScrollBar; class QSlider; +class QBoxLayout; QT_END_NAMESPACE //! [0] @@ -65,8 +19,7 @@ class SlidersGroup : public QGroupBox Q_OBJECT public: - SlidersGroup(Qt::Orientation orientation, const QString &title, - QWidget *parent = nullptr); + SlidersGroup(const QString &title, QWidget *parent = nullptr); signals: void valueChanged(int value); @@ -77,11 +30,13 @@ public slots: void setMaximum(int value); void invertAppearance(bool invert); void invertKeyBindings(bool invert); + void setOrientation(Qt::Orientation orientation); private: QSlider *slider; QScrollBar *scrollBar; QDial *dial; + QBoxLayout *slidersLayout; }; //! [0] diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp index 916f206379..c62c3b83f5 100644 --- a/examples/widgets/widgets/sliders/window.cpp +++ b/examples/widgets/widgets/sliders/window.cpp @@ -1,59 +1,10 @@ -/**************************************************************************** -** -** 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 "slidersgroup.h" #include "window.h" - #include <QCheckBox> #include <QComboBox> -#include <QHBoxLayout> #include <QLabel> #include <QSpinBox> #include <QStackedWidget> @@ -62,28 +13,15 @@ Window::Window(QWidget *parent) : QWidget(parent) { - horizontalSliders = new SlidersGroup(Qt::Horizontal, tr("Horizontal")); - verticalSliders = new SlidersGroup(Qt::Vertical, tr("Vertical")); - - stackedWidget = new QStackedWidget; - stackedWidget->addWidget(horizontalSliders); - stackedWidget->addWidget(verticalSliders); + slidersGroup = new SlidersGroup(tr("Sliders")); createControls(tr("Controls")); //! [0] //! [1] - connect(horizontalSliders, &SlidersGroup::valueChanged, -//! [1] //! [2] - verticalSliders, &SlidersGroup::setValue); - connect(verticalSliders, &SlidersGroup::valueChanged, - valueSpinBox, &QSpinBox::setValue); - connect(valueSpinBox, &QSpinBox::valueChanged, - horizontalSliders, &SlidersGroup::setValue); - - QHBoxLayout *layout = new QHBoxLayout; + layout = new QBoxLayout(QBoxLayout::LeftToRight); layout->addWidget(controlsGroup); - layout->addWidget(stackedWidget); + layout->addWidget(slidersGroup); setLayout(layout); minimumSpinBox->setValue(0); @@ -92,11 +30,11 @@ Window::Window(QWidget *parent) setWindowTitle(tr("Sliders")); } -//! [2] +//! [1] -//! [3] +//! [2] void Window::createControls(const QString &title) -//! [3] //! [4] +//! [2] //! [3] { controlsGroup = new QGroupBox(title); @@ -107,9 +45,9 @@ void Window::createControls(const QString &title) invertedAppearance = new QCheckBox(tr("Inverted appearance")); invertedKeyBindings = new QCheckBox(tr("Inverted key bindings")); -//! [4] //! [5] +//! [3] //! [4] minimumSpinBox = new QSpinBox; -//! [5] //! [6] +//! [4] //! [5] minimumSpinBox->setRange(-100, 100); minimumSpinBox->setSingleStep(1); @@ -121,30 +59,19 @@ void Window::createControls(const QString &title) valueSpinBox->setRange(-100, 100); valueSpinBox->setSingleStep(1); - orientationCombo = new QComboBox; - orientationCombo->addItem(tr("Horizontal slider-like widgets")); - orientationCombo->addItem(tr("Vertical slider-like widgets")); - -//! [6] //! [7] - connect(orientationCombo, &QComboBox::activated, -//! [7] //! [8] - stackedWidget, &QStackedWidget::setCurrentIndex); - connect(minimumSpinBox, &QSpinBox::valueChanged, - horizontalSliders, &SlidersGroup::setMinimum); +//! [5] //! [6] + connect(slidersGroup, &SlidersGroup::valueChanged, + valueSpinBox, &QSpinBox::setValue); + connect(valueSpinBox, &QSpinBox::valueChanged, + slidersGroup, &SlidersGroup::setValue); connect(minimumSpinBox, &QSpinBox::valueChanged, - verticalSliders, &SlidersGroup::setMinimum); - connect(maximumSpinBox, &QSpinBox::valueChanged, - horizontalSliders, &SlidersGroup::setMaximum); + slidersGroup, &SlidersGroup::setMinimum); connect(maximumSpinBox, &QSpinBox::valueChanged, - verticalSliders, &SlidersGroup::setMaximum); - connect(invertedAppearance, &QCheckBox::toggled, - horizontalSliders, &SlidersGroup::invertAppearance); + slidersGroup, &SlidersGroup::setMaximum); connect(invertedAppearance, &QCheckBox::toggled, - verticalSliders, &SlidersGroup::invertAppearance); + slidersGroup, &SlidersGroup::invertAppearance); connect(invertedKeyBindings, &QCheckBox::toggled, - horizontalSliders, &SlidersGroup::invertKeyBindings); - connect(invertedKeyBindings, &QCheckBox::toggled, - verticalSliders, &SlidersGroup::invertKeyBindings); + slidersGroup, &SlidersGroup::invertKeyBindings); QGridLayout *controlsLayout = new QGridLayout; controlsLayout->addWidget(minimumLabel, 0, 0); @@ -155,7 +82,26 @@ void Window::createControls(const QString &title) controlsLayout->addWidget(valueSpinBox, 2, 1); controlsLayout->addWidget(invertedAppearance, 0, 2); controlsLayout->addWidget(invertedKeyBindings, 1, 2); - controlsLayout->addWidget(orientationCombo, 3, 0, 1, 3); controlsGroup->setLayout(controlsLayout); + +} +//! [6] + + +//! [7] +void Window::resizeEvent(QResizeEvent *) +{ + if (width() == 0 || height() == 0) + return; + + const double aspectRatio = double(width()) / double(height()); + + if (aspectRatio < 1.0) { + layout->setDirection(QBoxLayout::TopToBottom); + slidersGroup->setOrientation(Qt::Horizontal); + } else if (aspectRatio > 1.0) { + layout->setDirection(QBoxLayout::LeftToRight); + slidersGroup->setOrientation(Qt::Vertical); + } } -//! [8] +//! [7] diff --git a/examples/widgets/widgets/sliders/window.h b/examples/widgets/widgets/sliders/window.h index 4894781ac2..8d7338f27c 100644 --- a/examples/widgets/widgets/sliders/window.h +++ b/examples/widgets/widgets/sliders/window.h @@ -1,57 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H #include <QWidget> +#include <QGridLayout> QT_BEGIN_NAMESPACE class QCheckBox; @@ -73,10 +27,9 @@ public: private: void createControls(const QString &title); + void resizeEvent(QResizeEvent *e); - SlidersGroup *horizontalSliders; - SlidersGroup *verticalSliders; - QStackedWidget *stackedWidget; + SlidersGroup *slidersGroup; QGroupBox *controlsGroup; QLabel *minimumLabel; @@ -87,7 +40,7 @@ private: QSpinBox *minimumSpinBox; QSpinBox *maximumSpinBox; QSpinBox *valueSpinBox; - QComboBox *orientationCombo; + QBoxLayout *layout; }; //! [0] diff --git a/examples/widgets/widgets/spinboxes/CMakeLists.txt b/examples/widgets/widgets/spinboxes/CMakeLists.txt index ade330faf2..83e54166bb 100644 --- a/examples/widgets/widgets/spinboxes/CMakeLists.txt +++ b/examples/widgets/widgets/spinboxes/CMakeLists.txt @@ -1,40 +1,38 @@ -# Generated from spinboxes.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(spinboxes LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/spinboxes") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(spinboxes main.cpp window.cpp window.h ) + set_target_properties(spinboxes PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(spinboxes PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(spinboxes PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS spinboxes - 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 spinboxes + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/spinboxes/main.cpp b/examples/widgets/widgets/spinboxes/main.cpp index 99725195e5..27409403a5 100644 --- a/examples/widgets/widgets/spinboxes/main.cpp +++ b/examples/widgets/widgets/spinboxes/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/spinboxes/window.cpp b/examples/widgets/widgets/spinboxes/window.cpp index 6aeb5a8f69..8e67074c1c 100644 --- a/examples/widgets/widgets/spinboxes/window.cpp +++ b/examples/widgets/widgets/spinboxes/window.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include "window.h" diff --git a/examples/widgets/widgets/spinboxes/window.h b/examples/widgets/widgets/spinboxes/window.h index 138773a5aa..421ab58c83 100644 --- a/examples/widgets/widgets/spinboxes/window.h +++ b/examples/widgets/widgets/spinboxes/window.h @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef WINDOW_H #define WINDOW_H diff --git a/examples/widgets/widgets/styles/CMakeLists.txt b/examples/widgets/widgets/styles/CMakeLists.txt deleted file mode 100644 index c847af915c..0000000000 --- a/examples/widgets/widgets/styles/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Generated from styles.pro. - -cmake_minimum_required(VERSION 3.14) -project(styles 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/widgets/styles") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(styles - main.cpp - norwegianwoodstyle.cpp norwegianwoodstyle.h - widgetgallery.cpp widgetgallery.h -) -set_target_properties(styles PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(styles PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(styles_resource_files - "images/woodbackground.png" - "images/woodbutton.png" -) - -qt6_add_resources(styles "styles" - PREFIX - "/" - FILES - ${styles_resource_files} -) - -install(TARGETS styles - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/styles/images/woodbackground.png b/examples/widgets/widgets/styles/images/woodbackground.png Binary files differdeleted file mode 100644 index 8be3366bb4..0000000000 --- a/examples/widgets/widgets/styles/images/woodbackground.png +++ /dev/null diff --git a/examples/widgets/widgets/styles/images/woodbutton.png b/examples/widgets/widgets/styles/images/woodbutton.png Binary files differdeleted file mode 100644 index adb59ef633..0000000000 --- a/examples/widgets/widgets/styles/images/woodbutton.png +++ /dev/null diff --git a/examples/widgets/widgets/styles/main.cpp b/examples/widgets/widgets/styles/main.cpp deleted file mode 100644 index 471589d3ad..0000000000 --- a/examples/widgets/widgets/styles/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 "norwegianwoodstyle.h" -#include "widgetgallery.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(styles); - - QApplication::setStyle(new NorwegianWoodStyle); - - QApplication app(argc, argv); - WidgetGallery gallery; - gallery.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp deleted file mode 100644 index 34a63e0eea..0000000000 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp +++ /dev/null @@ -1,357 +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 "norwegianwoodstyle.h" - -#include <QComboBox> -#include <QPainter> -#include <QPainterPath> -#include <QPushButton> -#include <QStyleFactory> - -NorwegianWoodStyle::NorwegianWoodStyle() : - QProxyStyle(QStyleFactory::create("windows")) -{ - setObjectName("NorwegianWood"); -} - -//! [0] -QPalette NorwegianWoodStyle::standardPalette() const -{ - if (!m_standardPalette.isBrushSet(QPalette::Disabled, QPalette::Mid)) { - QColor brown(212, 140, 95); - QColor beige(236, 182, 120); - QColor slightlyOpaqueBlack(0, 0, 0, 63); - - QImage backgroundImage(":/images/woodbackground.png"); - QImage buttonImage(":/images/woodbutton.png"); - QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32); - - QPainter painter; - painter.begin(&midImage); - painter.setPen(Qt::NoPen); - painter.fillRect(midImage.rect(), slightlyOpaqueBlack); - painter.end(); - //! [0] - - //! [1] - QPalette palette(brown); - - palette.setBrush(QPalette::BrightText, Qt::white); - palette.setBrush(QPalette::Base, beige); - palette.setBrush(QPalette::Highlight, Qt::darkGreen); - setTexture(palette, QPalette::Button, buttonImage); - setTexture(palette, QPalette::Mid, midImage); - setTexture(palette, QPalette::Window, backgroundImage); - - QBrush brush = palette.window(); - brush.setColor(brush.color().darker()); - - palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush); - palette.setBrush(QPalette::Disabled, QPalette::Text, brush); - palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); - palette.setBrush(QPalette::Disabled, QPalette::Base, brush); - palette.setBrush(QPalette::Disabled, QPalette::Button, brush); - palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); - - m_standardPalette = palette; - } - - return m_standardPalette; -} -//! [1] - -//! [3] -void NorwegianWoodStyle::polish(QWidget *widget) -//! [3] //! [4] -{ - if (qobject_cast<QPushButton *>(widget) - || qobject_cast<QComboBox *>(widget)) - widget->setAttribute(Qt::WA_Hover, true); -} -//! [4] - -//! [5] -void NorwegianWoodStyle::unpolish(QWidget *widget) -//! [5] //! [6] -{ - if (qobject_cast<QPushButton *>(widget) - || qobject_cast<QComboBox *>(widget)) - widget->setAttribute(Qt::WA_Hover, false); -} -//! [6] - -//! [7] -int NorwegianWoodStyle::pixelMetric(PixelMetric metric, -//! [7] //! [8] - const QStyleOption *option, - const QWidget *widget) const -{ - switch (metric) { - case PM_ComboBoxFrameWidth: - return 8; - case PM_ScrollBarExtent: - return QProxyStyle::pixelMetric(metric, option, widget) + 4; - default: - return QProxyStyle::pixelMetric(metric, option, widget); - } -} -//! [8] - -//! [9] -int NorwegianWoodStyle::styleHint(StyleHint hint, const QStyleOption *option, -//! [9] //! [10] - const QWidget *widget, - QStyleHintReturn *returnData) const -{ - switch (hint) { - case SH_DitherDisabledText: - return int(false); - case SH_EtchDisabledText: - return int(true); - default: - return QProxyStyle::styleHint(hint, option, widget, returnData); - } -} -//! [10] - -//! [11] -void NorwegianWoodStyle::drawPrimitive(PrimitiveElement element, -//! [11] //! [12] - const QStyleOption *option, - QPainter *painter, - const QWidget *widget) const -{ - switch (element) { - case PE_PanelButtonCommand: - { - int delta = (option->state & State_MouseOver) ? 64 : 0; - QColor slightlyOpaqueBlack(0, 0, 0, 63); - QColor semiTransparentWhite(255, 255, 255, 127 + delta); - QColor semiTransparentBlack(0, 0, 0, 127 - delta); - - int x, y, width, height; - option->rect.getRect(&x, &y, &width, &height); -//! [12] - -//! [13] - QPainterPath roundRect = roundRectPath(option->rect); -//! [13] //! [14] - int radius = qMin(width, height) / 2; -//! [14] - -//! [15] - QBrush brush; -//! [15] //! [16] - bool darker; - - const QStyleOptionButton *buttonOption = - qstyleoption_cast<const QStyleOptionButton *>(option); - if (buttonOption - && (buttonOption->features & QStyleOptionButton::Flat)) { - brush = option->palette.window(); - darker = (option->state & (State_Sunken | State_On)); - } else { - if (option->state & (State_Sunken | State_On)) { - brush = option->palette.mid(); - darker = !(option->state & State_Sunken); - } else { - brush = option->palette.button(); - darker = false; -//! [16] //! [17] - } -//! [17] //! [18] - } -//! [18] - -//! [19] - painter->save(); -//! [19] //! [20] - painter->setRenderHint(QPainter::Antialiasing, true); -//! [20] //! [21] - painter->fillPath(roundRect, brush); -//! [21] //! [22] - if (darker) -//! [22] //! [23] - painter->fillPath(roundRect, slightlyOpaqueBlack); -//! [23] - -//! [24] - int penWidth; -//! [24] //! [25] - if (radius < 10) - penWidth = 3; - else if (radius < 20) - penWidth = 5; - else - penWidth = 7; - - QPen topPen(semiTransparentWhite, penWidth); - QPen bottomPen(semiTransparentBlack, penWidth); - - if (option->state & (State_Sunken | State_On)) - qSwap(topPen, bottomPen); -//! [25] - -//! [26] - int x1 = x; - int x2 = x + radius; - int x3 = x + width - radius; - int x4 = x + width; - - if (option->direction == Qt::RightToLeft) { - qSwap(x1, x4); - qSwap(x2, x3); - } - - QPolygon topHalf; - topHalf << QPoint(x1, y) - << QPoint(x4, y) - << QPoint(x3, y + radius) - << QPoint(x2, y + height - radius) - << QPoint(x1, y + height); - - painter->setClipPath(roundRect); - painter->setClipRegion(topHalf, Qt::IntersectClip); - painter->setPen(topPen); - painter->drawPath(roundRect); -//! [26] //! [32] - - QPolygon bottomHalf = topHalf; - bottomHalf[0] = QPoint(x4, y + height); - - painter->setClipPath(roundRect); - painter->setClipRegion(bottomHalf, Qt::IntersectClip); - painter->setPen(bottomPen); - painter->drawPath(roundRect); - - painter->setPen(option->palette.windowText().color()); - painter->setClipping(false); - painter->drawPath(roundRect); - - painter->restore(); - } - break; -//! [32] //! [33] - default: -//! [33] //! [34] - QProxyStyle::drawPrimitive(element, option, painter, widget); - } -} -//! [34] - -//! [35] -void NorwegianWoodStyle::drawControl(ControlElement element, -//! [35] //! [36] - const QStyleOption *option, - QPainter *painter, - const QWidget *widget) const -{ - switch (element) { - case CE_PushButtonLabel: - { - QStyleOptionButton myButtonOption; - const QStyleOptionButton *buttonOption = - qstyleoption_cast<const QStyleOptionButton *>(option); - if (buttonOption) { - myButtonOption = *buttonOption; - if (myButtonOption.palette.currentColorGroup() - != QPalette::Disabled) { - if (myButtonOption.state & (State_Sunken | State_On)) { - myButtonOption.palette.setBrush(QPalette::ButtonText, - myButtonOption.palette.brightText()); - } - } - } - QProxyStyle::drawControl(element, &myButtonOption, painter, widget); - } - break; - default: - QProxyStyle::drawControl(element, option, painter, widget); - } -} -//! [36] - -//! [37] -void NorwegianWoodStyle::setTexture(QPalette &palette, QPalette::ColorRole role, -//! [37] //! [38] - const QImage &image) -{ - for (int i = 0; i < QPalette::NColorGroups; ++i) { - QBrush brush(image); - brush.setColor(palette.brush(QPalette::ColorGroup(i), role).color()); - palette.setBrush(QPalette::ColorGroup(i), role, brush); - } -} -//! [38] - -//! [39] -QPainterPath NorwegianWoodStyle::roundRectPath(const QRect &rect) -//! [39] //! [40] -{ - int radius = qMin(rect.width(), rect.height()) / 2; - int diam = 2 * radius; - - int x1, y1, x2, y2; - rect.getCoords(&x1, &y1, &x2, &y2); - - QPainterPath path; - path.moveTo(x2, y1 + radius); - path.arcTo(QRect(x2 - diam, y1, diam, diam), 0.0, +90.0); - path.lineTo(x1 + radius, y1); - path.arcTo(QRect(x1, y1, diam, diam), 90.0, +90.0); - path.lineTo(x1, y2 - radius); - path.arcTo(QRect(x1, y2 - diam, diam, diam), 180.0, +90.0); - path.lineTo(x1 + radius, y2); - path.arcTo(QRect(x2 - diam, y2 - diam, diam, diam), 270.0, +90.0); - path.closeSubpath(); - return path; -} -//! [40] diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.h b/examples/widgets/widgets/styles/norwegianwoodstyle.h deleted file mode 100644 index 62ca502d05..0000000000 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.h +++ /dev/null @@ -1,90 +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 NORWEGIANWOODSTYLE_H -#define NORWEGIANWOODSTYLE_H - -#include <QProxyStyle> -#include <QPalette> - -QT_BEGIN_NAMESPACE -class QPainterPath; -QT_END_NAMESPACE - -//! [0] -class NorwegianWoodStyle : public QProxyStyle -{ - Q_OBJECT - -public: - NorwegianWoodStyle(); - - QPalette standardPalette() const override; - - void polish(QWidget *widget) override; - void unpolish(QWidget *widget) override; - int pixelMetric(PixelMetric metric, const QStyleOption *option, - const QWidget *widget) const override; - int styleHint(StyleHint hint, const QStyleOption *option, - const QWidget *widget, QStyleHintReturn *returnData) const override; - void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const override; - void drawControl(ControlElement control, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const override; - -private: - static void setTexture(QPalette &palette, QPalette::ColorRole role, - const QImage &image); - static QPainterPath roundRectPath(const QRect &rect); - mutable QPalette m_standardPalette; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/styles/styles.pro b/examples/widgets/widgets/styles/styles.pro deleted file mode 100644 index 87dee7e04c..0000000000 --- a/examples/widgets/widgets/styles/styles.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) - -HEADERS = norwegianwoodstyle.h \ - widgetgallery.h -SOURCES = main.cpp \ - norwegianwoodstyle.cpp \ - widgetgallery.cpp -RESOURCES = styles.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/styles -INSTALLS += target diff --git a/examples/widgets/widgets/styles/styles.qrc b/examples/widgets/widgets/styles/styles.qrc deleted file mode 100644 index 4fdad8d914..0000000000 --- a/examples/widgets/widgets/styles/styles.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/woodbutton.png</file> - <file>images/woodbackground.png</file> -</qresource> -</RCC> diff --git a/examples/widgets/widgets/styles/widgetgallery.cpp b/examples/widgets/widgets/styles/widgetgallery.cpp deleted file mode 100644 index bf8e93feb4..0000000000 --- a/examples/widgets/widgets/styles/widgetgallery.cpp +++ /dev/null @@ -1,324 +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 "widgetgallery.h" -#include "norwegianwoodstyle.h" - -#include <QApplication> -#include <QCheckBox> -#include <QComboBox> -#include <QDateTimeEdit> -#include <QDial> -#include <QGridLayout> -#include <QGroupBox> -#include <QLabel> -#include <QLineEdit> -#include <QProgressBar> -#include <QPushButton> -#include <QRadioButton> -#include <QScrollBar> -#include <QSpinBox> -#include <QStyle> -#include <QStyleFactory> -#include <QTableWidget> -#include <QTextEdit> -#include <QTimer> - -//! [0] -WidgetGallery::WidgetGallery(QWidget *parent) - : QDialog(parent) -{ - styleComboBox = new QComboBox; - const QString defaultStyleName = QApplication::style()->objectName(); - QStringList styleNames = QStyleFactory::keys(); - styleNames.append("NorwegianWood"); - for (int i = 1, size = styleNames.size(); i < size; ++i) { - if (defaultStyleName.compare(styleNames.at(i), Qt::CaseInsensitive) == 0) { - styleNames.swapItemsAt(0, i); - break; - } - } - styleComboBox->addItems(styleNames); - - styleLabel = new QLabel(tr("&Style:")); - styleLabel->setBuddy(styleComboBox); - - useStylePaletteCheckBox = new QCheckBox(tr("&Use style's standard palette")); - useStylePaletteCheckBox->setChecked(true); - - disableWidgetsCheckBox = new QCheckBox(tr("&Disable widgets")); - - createTopLeftGroupBox(); - createTopRightGroupBox(); - createBottomLeftTabWidget(); - createBottomRightGroupBox(); - createProgressBar(); -//! [0] - -//! [1] - connect(styleComboBox, &QComboBox::textActivated, -//! [1] //! [2] - this, &WidgetGallery::changeStyle); - connect(useStylePaletteCheckBox, &QCheckBox::toggled, - this, &WidgetGallery::changePalette); - connect(disableWidgetsCheckBox, &QCheckBox::toggled, - topLeftGroupBox, &QGroupBox::setDisabled); - connect(disableWidgetsCheckBox, &QCheckBox::toggled, - topRightGroupBox, &QGroupBox::setDisabled); - connect(disableWidgetsCheckBox, &QCheckBox::toggled, - bottomLeftTabWidget, &QGroupBox::setDisabled); - connect(disableWidgetsCheckBox, &QCheckBox::toggled, - bottomRightGroupBox, &QGroupBox::setDisabled); -//! [2] - -//! [3] - QHBoxLayout *topLayout = new QHBoxLayout; -//! [3] //! [4] - topLayout->addWidget(styleLabel); - topLayout->addWidget(styleComboBox); - topLayout->addStretch(1); - topLayout->addWidget(useStylePaletteCheckBox); - topLayout->addWidget(disableWidgetsCheckBox); - - QGridLayout *mainLayout = new QGridLayout; - mainLayout->addLayout(topLayout, 0, 0, 1, 2); - mainLayout->addWidget(topLeftGroupBox, 1, 0); - mainLayout->addWidget(topRightGroupBox, 1, 1); - mainLayout->addWidget(bottomLeftTabWidget, 2, 0); - mainLayout->addWidget(bottomRightGroupBox, 2, 1); - mainLayout->addWidget(progressBar, 3, 0, 1, 2); - mainLayout->setRowStretch(1, 1); - mainLayout->setRowStretch(2, 1); - mainLayout->setColumnStretch(0, 1); - mainLayout->setColumnStretch(1, 1); - setLayout(mainLayout); - - setWindowTitle(tr("Styles")); - styleChanged(); -} -//! [4] - -//! [5] -void WidgetGallery::changeStyle(const QString &styleName) -//! [5] //! [6] -{ - if (styleName == "NorwegianWood") - QApplication::setStyle(new NorwegianWoodStyle); - else - QApplication::setStyle(QStyleFactory::create(styleName)); -} -//! [6] - -//! [7] -void WidgetGallery::changePalette() -//! [7] //! [8] -{ - QApplication::setPalette(useStylePaletteCheckBox->isChecked() ? - QApplication::style()->standardPalette() : QPalette()); -} -//! [8] - -void WidgetGallery::changeEvent(QEvent *event) -{ - if (event->type() == QEvent::StyleChange) - styleChanged(); -} - -void WidgetGallery::styleChanged() -{ - auto styleName = QApplication::style()->objectName(); - for (int i = 0; i < styleComboBox->count(); ++i) { - if (QString::compare(styleComboBox->itemText(i), styleName, Qt::CaseInsensitive) == 0) { - styleComboBox->setCurrentIndex(i); - break; - } - } - - changePalette(); -} - -//! [9] -void WidgetGallery::advanceProgressBar() -//! [9] //! [10] -{ - int curVal = progressBar->value(); - int maxVal = progressBar->maximum(); - progressBar->setValue(curVal + (maxVal - curVal) / 100); -} -//! [10] - -//! [11] -void WidgetGallery::createTopLeftGroupBox() -//! [11] //! [12] -{ - topLeftGroupBox = new QGroupBox(tr("Group 1")); - - radioButton1 = new QRadioButton(tr("Radio button 1")); - radioButton2 = new QRadioButton(tr("Radio button 2")); - radioButton3 = new QRadioButton(tr("Radio button 3")); - radioButton1->setChecked(true); - - checkBox = new QCheckBox(tr("Tri-state check box")); - checkBox->setTristate(true); - checkBox->setCheckState(Qt::PartiallyChecked); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(radioButton1); - layout->addWidget(radioButton2); - layout->addWidget(radioButton3); - layout->addWidget(checkBox); - layout->addStretch(1); - topLeftGroupBox->setLayout(layout); -} -//! [12] - -void WidgetGallery::createTopRightGroupBox() -{ - topRightGroupBox = new QGroupBox(tr("Group 2")); - - defaultPushButton = new QPushButton(tr("Default Push Button")); - defaultPushButton->setDefault(true); - - togglePushButton = new QPushButton(tr("Toggle Push Button")); - togglePushButton->setCheckable(true); - togglePushButton->setChecked(true); - - flatPushButton = new QPushButton(tr("Flat Push Button")); - flatPushButton->setFlat(true); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(defaultPushButton); - layout->addWidget(togglePushButton); - layout->addWidget(flatPushButton); - layout->addStretch(1); - topRightGroupBox->setLayout(layout); -} - -void WidgetGallery::createBottomLeftTabWidget() -{ - bottomLeftTabWidget = new QTabWidget; - bottomLeftTabWidget->setSizePolicy(QSizePolicy::Preferred, - QSizePolicy::Ignored); - - QWidget *tab1 = new QWidget; - tableWidget = new QTableWidget(10, 10); - - QHBoxLayout *tab1hbox = new QHBoxLayout; - tab1hbox->setContentsMargins(5,5, 5, 5); - tab1hbox->addWidget(tableWidget); - tab1->setLayout(tab1hbox); - - QWidget *tab2 = new QWidget; - textEdit = new QTextEdit; - - textEdit->setPlainText(tr("Twinkle, twinkle, little star,\n" - "How I wonder what you are.\n" - "Up above the world so high,\n" - "Like a diamond in the sky.\n" - "Twinkle, twinkle, little star,\n" - "How I wonder what you are!\n")); - - QHBoxLayout *tab2hbox = new QHBoxLayout; - tab2hbox->setContentsMargins(5, 5, 5, 5); - tab2hbox->addWidget(textEdit); - tab2->setLayout(tab2hbox); - - bottomLeftTabWidget->addTab(tab1, tr("&Table")); - bottomLeftTabWidget->addTab(tab2, tr("Text &Edit")); -} - -void WidgetGallery::createBottomRightGroupBox() -{ - bottomRightGroupBox = new QGroupBox(tr("Group 3")); - bottomRightGroupBox->setCheckable(true); - bottomRightGroupBox->setChecked(true); - - lineEdit = new QLineEdit("s3cRe7"); - lineEdit->setEchoMode(QLineEdit::Password); - - spinBox = new QSpinBox(bottomRightGroupBox); - spinBox->setValue(50); - - dateTimeEdit = new QDateTimeEdit(bottomRightGroupBox); - dateTimeEdit->setDateTime(QDateTime::currentDateTime()); - - slider = new QSlider(Qt::Horizontal, bottomRightGroupBox); - slider->setValue(40); - - scrollBar = new QScrollBar(Qt::Horizontal, bottomRightGroupBox); - scrollBar->setValue(60); - - dial = new QDial(bottomRightGroupBox); - dial->setValue(30); - dial->setNotchesVisible(true); - - QGridLayout *layout = new QGridLayout; - layout->addWidget(lineEdit, 0, 0, 1, 2); - layout->addWidget(spinBox, 1, 0, 1, 2); - layout->addWidget(dateTimeEdit, 2, 0, 1, 2); - layout->addWidget(slider, 3, 0); - layout->addWidget(scrollBar, 4, 0); - layout->addWidget(dial, 3, 1, 2, 1); - layout->setRowStretch(5, 1); - bottomRightGroupBox->setLayout(layout); -} - -//! [13] -void WidgetGallery::createProgressBar() -{ - progressBar = new QProgressBar; - progressBar->setRange(0, 10000); - progressBar->setValue(0); - - QTimer *timer = new QTimer(this); - connect(timer, &QTimer::timeout, this, &WidgetGallery::advanceProgressBar); - timer->start(1000); -} -//! [13] diff --git a/examples/widgets/widgets/styles/widgetgallery.h b/examples/widgets/widgets/styles/widgetgallery.h deleted file mode 100644 index 8c4c880536..0000000000 --- a/examples/widgets/widgets/styles/widgetgallery.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 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 WIDGETGALLERY_H -#define WIDGETGALLERY_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -class QDateTimeEdit; -class QDial; -class QGroupBox; -class QLabel; -class QLineEdit; -class QProgressBar; -class QPushButton; -class QRadioButton; -class QScrollBar; -class QSlider; -class QSpinBox; -class QTabWidget; -class QTableWidget; -class QTextEdit; -QT_END_NAMESPACE - -//! [0] -class WidgetGallery : public QDialog -{ - Q_OBJECT - -public: - WidgetGallery(QWidget *parent = nullptr); - -protected: - void changeEvent(QEvent *) override; - -private slots: - void changeStyle(const QString &styleName); - void styleChanged(); - void changePalette(); - void advanceProgressBar(); - -private: - void createTopLeftGroupBox(); - void createTopRightGroupBox(); - void createBottomLeftTabWidget(); - void createBottomRightGroupBox(); - void createProgressBar(); - - QLabel *styleLabel; - QComboBox *styleComboBox; - QCheckBox *useStylePaletteCheckBox; - QCheckBox *disableWidgetsCheckBox; -//! [0] - - QGroupBox *topLeftGroupBox; - QRadioButton *radioButton1; - QRadioButton *radioButton2; - QRadioButton *radioButton3; - QCheckBox *checkBox; - - QGroupBox *topRightGroupBox; - QPushButton *defaultPushButton; - QPushButton *togglePushButton; - QPushButton *flatPushButton; - - QTabWidget *bottomLeftTabWidget; - QTableWidget *tableWidget; - QTextEdit *textEdit; - - QGroupBox *bottomRightGroupBox; - QLineEdit *lineEdit; - QSpinBox *spinBox; - QDateTimeEdit *dateTimeEdit; - QSlider *slider; - QScrollBar *scrollBar; - QDial *dial; - - QProgressBar *progressBar; -//! [1] -}; -//! [1] - -#endif diff --git a/examples/widgets/widgets/stylesheet/CMakeLists.txt b/examples/widgets/widgets/stylesheet/CMakeLists.txt deleted file mode 100644 index ccfb15f68c..0000000000 --- a/examples/widgets/widgets/stylesheet/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -# Generated from stylesheet.pro. - -cmake_minimum_required(VERSION 3.14) -project(stylesheet 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/widgets/stylesheet") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(stylesheet - main.cpp - mainwindow.cpp mainwindow.h mainwindow.ui - stylesheeteditor.cpp stylesheeteditor.h stylesheeteditor.ui -) -set_target_properties(stylesheet PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(stylesheet PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(stylesheet_resource_files - "images/checkbox_checked.png" - "images/checkbox_checked_hover.png" - "images/checkbox_checked_pressed.png" - "images/checkbox_unchecked.png" - "images/checkbox_unchecked_hover.png" - "images/checkbox_unchecked_pressed.png" - "images/down_arrow.png" - "images/down_arrow_disabled.png" - "images/frame.png" - "images/pagefold.png" - "images/pushbutton.png" - "images/pushbutton_hover.png" - "images/pushbutton_pressed.png" - "images/radiobutton_checked.png" - "images/radiobutton_checked_hover.png" - "images/radiobutton_checked_pressed.png" - "images/radiobutton_unchecked.png" - "images/radiobutton_unchecked_hover.png" - "images/radiobutton_unchecked_pressed.png" - "images/sizegrip.png" - "images/spindown.png" - "images/spindown_hover.png" - "images/spindown_off.png" - "images/spindown_pressed.png" - "images/spinup.png" - "images/spinup_hover.png" - "images/spinup_off.png" - "images/spinup_pressed.png" - "images/up_arrow.png" - "images/up_arrow_disabled.png" - "layouts/default.ui" - "layouts/pagefold.ui" - "qss/coffee.qss" - "qss/default.qss" - "qss/pagefold.qss" -) - -qt6_add_resources(stylesheet "stylesheet" - PREFIX - "/" - FILES - ${stylesheet_resource_files} -) - -install(TARGETS stylesheet - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked.png Binary files differdeleted file mode 100644 index cbf06f6513..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_checked.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png Binary files differdeleted file mode 100644 index fb4d4d3fdb..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_checked_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png b/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png Binary files differdeleted file mode 100644 index 852fcc0306..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_checked_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png Binary files differdeleted file mode 100644 index 5f5465582a..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png Binary files differdeleted file mode 100644 index 687364497e..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png b/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png Binary files differdeleted file mode 100644 index 6a768c44de..0000000000 --- a/examples/widgets/widgets/stylesheet/images/checkbox_unchecked_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/down_arrow.png b/examples/widgets/widgets/stylesheet/images/down_arrow.png Binary files differdeleted file mode 100644 index 85004aeaf6..0000000000 --- a/examples/widgets/widgets/stylesheet/images/down_arrow.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png b/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png Binary files differdeleted file mode 100644 index d9eefed4c8..0000000000 --- a/examples/widgets/widgets/stylesheet/images/down_arrow_disabled.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/frame.png b/examples/widgets/widgets/stylesheet/images/frame.png Binary files differdeleted file mode 100644 index 05a600502e..0000000000 --- a/examples/widgets/widgets/stylesheet/images/frame.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/pagefold.png b/examples/widgets/widgets/stylesheet/images/pagefold.png Binary files differdeleted file mode 100644 index 69be8f2a38..0000000000 --- a/examples/widgets/widgets/stylesheet/images/pagefold.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton.png b/examples/widgets/widgets/stylesheet/images/pushbutton.png Binary files differdeleted file mode 100644 index c7529ba02d..0000000000 --- a/examples/widgets/widgets/stylesheet/images/pushbutton.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png b/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png Binary files differdeleted file mode 100644 index af0ef9d561..0000000000 --- a/examples/widgets/widgets/stylesheet/images/pushbutton_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png b/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png Binary files differdeleted file mode 100644 index f7381f752a..0000000000 --- a/examples/widgets/widgets/stylesheet/images/pushbutton_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png Binary files differdeleted file mode 100644 index 8ab9157578..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png Binary files differdeleted file mode 100644 index d68cb009a7..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png b/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png Binary files differdeleted file mode 100644 index e3cd5a59e4..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_checked_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png Binary files differdeleted file mode 100644 index 321a9a1558..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png Binary files differdeleted file mode 100644 index 666a3b0bdd..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png b/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png Binary files differdeleted file mode 100644 index c4b0567aa9..0000000000 --- a/examples/widgets/widgets/stylesheet/images/radiobutton_unchecked_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/sizegrip.png b/examples/widgets/widgets/stylesheet/images/sizegrip.png Binary files differdeleted file mode 100644 index 350583aaac..0000000000 --- a/examples/widgets/widgets/stylesheet/images/sizegrip.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spindown.png b/examples/widgets/widgets/stylesheet/images/spindown.png Binary files differdeleted file mode 100644 index 7ff3c64926..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spindown.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spindown_hover.png b/examples/widgets/widgets/stylesheet/images/spindown_hover.png Binary files differdeleted file mode 100644 index 1486c4dfe4..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spindown_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spindown_off.png b/examples/widgets/widgets/stylesheet/images/spindown_off.png Binary files differdeleted file mode 100644 index a90ab3f038..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spindown_off.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spindown_pressed.png b/examples/widgets/widgets/stylesheet/images/spindown_pressed.png Binary files differdeleted file mode 100644 index f6271cbde2..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spindown_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spinup.png b/examples/widgets/widgets/stylesheet/images/spinup.png Binary files differdeleted file mode 100644 index 1069dd00df..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spinup.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spinup_hover.png b/examples/widgets/widgets/stylesheet/images/spinup_hover.png Binary files differdeleted file mode 100644 index 884c8d77c5..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spinup_hover.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spinup_off.png b/examples/widgets/widgets/stylesheet/images/spinup_off.png Binary files differdeleted file mode 100644 index 02dad1fb29..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spinup_off.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/spinup_pressed.png b/examples/widgets/widgets/stylesheet/images/spinup_pressed.png Binary files differdeleted file mode 100644 index b1843e2a1f..0000000000 --- a/examples/widgets/widgets/stylesheet/images/spinup_pressed.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/up_arrow.png b/examples/widgets/widgets/stylesheet/images/up_arrow.png Binary files differdeleted file mode 100644 index e7f7ddb3a6..0000000000 --- a/examples/widgets/widgets/stylesheet/images/up_arrow.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png b/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png Binary files differdeleted file mode 100644 index 4d2c27770f..0000000000 --- a/examples/widgets/widgets/stylesheet/images/up_arrow_disabled.png +++ /dev/null diff --git a/examples/widgets/widgets/stylesheet/layouts/default.ui b/examples/widgets/widgets/stylesheet/layouts/default.ui deleted file mode 100644 index 431a40956e..0000000000 --- a/examples/widgets/widgets/stylesheet/layouts/default.ui +++ /dev/null @@ -1,329 +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>388</width> - <height>413</height> - </rect> - </property> - <property name="windowTitle" > - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="nameLabel" > - <property name="text" > - <string>&Name:</string> - </property> - <property name="buddy" > - <cstring>nameCombo</cstring> - </property> - </widget> - </item> - <item row="0" column="1" colspan="3" > - <widget class="QComboBox" name="nameCombo" > - <property name="toolTip" > - <string>Specify your name</string> - </property> - <property name="editable" > - <bool>true</bool> - </property> - <property name="currentIndex" > - <number>-1</number> - </property> - <item> - <property name="text" > - <string>Girish</string> - </property> - </item> - <item> - <property name="text" > - <string>Jasmin</string> - </property> - </item> - <item> - <property name="text" > - <string>Simon</string> - </property> - </item> - <item> - <property name="text" > - <string>Zack</string> - </property> - </item> - </widget> - </item> - <item row="1" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="2" > - <widget class="QRadioButton" name="femaleRadioButton" > - <property name="toolTip" > - <string>Check this if you are female</string> - </property> - <property name="text" > - <string>&Female</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="4" > - <widget class="QCheckBox" name="agreeCheckBox" > - <property name="toolTip" > - <string>Please read the license before checking this</string> - </property> - <property name="text" > - <string>I &accept the terms and conditions</string> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QRadioButton" name="maleRadioButton" > - <property name="toolTip" > - <string>Check this if you are male</string> - </property> - <property name="text" > - <string>&Male</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="genderLabel" > - <property name="text" > - <string>Gender:</string> - </property> - </widget> - </item> - <item row="2" column="1" colspan="3" > - <widget class="QSpinBox" name="ageSpinBox" > - <property name="toolTip" > - <string>Specify your age</string> - </property> - <property name="statusTip" > - <string>Specify your age here</string> - </property> - <property name="minimum" > - <number>12</number> - </property> - <property name="value" > - <number>22</number> - </property> - </widget> - </item> - <item row="7" column="2" colspan="2" > - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="ageLabel" > - <property name="text" > - <string>&Age:</string> - </property> - <property name="buddy" > - <cstring>ageSpinBox</cstring> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="passwordLabel" > - <property name="text" > - <string>&Password:</string> - </property> - <property name="buddy" > - <cstring>passwordEdit</cstring> - </property> - </widget> - </item> - <item row="3" column="1" colspan="3" > - <widget class="QLineEdit" name="passwordEdit" > - <property name="toolTip" > - <string>Specify your password</string> - </property> - <property name="statusTip" > - <string>Specify your password here</string> - </property> - <property name="text" > - <string>Password</string> - </property> - <property name="echoMode" > - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="5" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Profession</string> - </property> - <property name="buddy" > - <cstring>professionList</cstring> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QLabel" name="countryLabel" > - <property name="text" > - <string>&Country</string> - </property> - <property name="buddy" > - <cstring>professionList</cstring> - </property> - </widget> - </item> - <item row="5" column="1" colspan="3" > - <widget class="QListWidget" name="professionList" > - <property name="toolTip" > - <string>Select your profession</string> - </property> - <property name="statusTip" > - <string>Select your profession</string> - </property> - <property name="whatsThis" > - <string>Select your profession</string> - </property> - <property name="currentRow" > - <number>1</number> - </property> - <item> - <property name="text" > - <string>Developer</string> - </property> - </item> - <item> - <property name="text" > - <string>Student</string> - </property> - </item> - <item> - <property name="text" > - <string>Fisherman</string> - </property> - </item> - </widget> - </item> - <item row="4" column="1" colspan="3" > - <widget class="QComboBox" name="countryCombo" > - <property name="toolTip" > - <string>Specify your country</string> - </property> - <property name="statusTip" > - <string>Specify your country here</string> - </property> - <property name="currentIndex" > - <number>2</number> - </property> - <item> - <property name="text" > - <string>Germany</string> - </property> - </item> - <item> - <property name="text" > - <string>India</string> - </property> - </item> - <item> - <property name="text" > - <string>Norway</string> - </property> - </item> - <item> - <property name="text" > - <string>United States Of America</string> - </property> - </item> - <item> - <property name="text" > - <string>United Kingdom</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>388</width> - <height>21</height> - </rect> - </property> - <widget class="QMenu" name="menu_File" > - <property name="title" > - <string>&File</string> - </property> - <addaction name="editStyleAction" /> - <addaction name="separator" /> - <addaction name="exitAction" /> - </widget> - <widget class="QMenu" name="menu_Help" > - <property name="title" > - <string>&Help</string> - </property> - <addaction name="aboutAction" /> - <addaction name="separator" /> - <addaction name="aboutQtAction" /> - </widget> - <addaction name="menu_File" /> - <addaction name="menu_Help" /> - </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="exitAction" > - <property name="text" > - <string>&Exit</string> - </property> - </action> - <action name="aboutQtAction" > - <property name="text" > - <string>About Qt</string> - </property> - </action> - <action name="editStyleAction" > - <property name="text" > - <string>Edit &Style</string> - </property> - </action> - <action name="aboutAction" > - <property name="text" > - <string>About</string> - </property> - </action> - </widget> - <tabstops> - <tabstop>maleRadioButton</tabstop> - <tabstop>femaleRadioButton</tabstop> - <tabstop>ageSpinBox</tabstop> - <tabstop>passwordEdit</tabstop> - <tabstop>professionList</tabstop> - <tabstop>agreeCheckBox</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/examples/widgets/widgets/stylesheet/layouts/pagefold.ui b/examples/widgets/widgets/stylesheet/layouts/pagefold.ui deleted file mode 100644 index 7ae313c331..0000000000 --- a/examples/widgets/widgets/stylesheet/layouts/pagefold.ui +++ /dev/null @@ -1,349 +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>392</width> - <height>412</height> - </rect> - </property> - <property name="windowTitle" > - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QFrame" name="mainFrame" > - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" colspan="3" > - <widget class="QComboBox" name="nameCombo" > - <property name="toolTip" > - <string>Specify your name</string> - </property> - <property name="editable" > - <bool>true</bool> - </property> - <property name="currentIndex" > - <number>-1</number> - </property> - <item> - <property name="text" > - <string>Girish</string> - </property> - </item> - <item> - <property name="text" > - <string>Jasmin</string> - </property> - </item> - <item> - <property name="text" > - <string>Simon</string> - </property> - </item> - <item> - <property name="text" > - <string>Zack</string> - </property> - </item> - </widget> - </item> - <item row="1" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="2" > - <widget class="QRadioButton" name="femaleRadioButton" > - <property name="styleSheet" > - <string>Check this if you are female</string> - </property> - <property name="text" > - <string>&Female</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="genderLabel" > - <property name="text" > - <string>Gender:</string> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="ageLabel" > - <property name="text" > - <string>&Age:</string> - </property> - <property name="buddy" > - <cstring>ageSpinBox</cstring> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QRadioButton" name="maleRadioButton" > - <property name="toolTip" > - <string>Check this if you are male</string> - </property> - <property name="text" > - <string>&Male</string> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="nameLabel" > - <property name="text" > - <string>&Name:</string> - </property> - <property name="buddy" > - <cstring>nameCombo</cstring> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="passwordLabel" > - <property name="text" > - <string>&Password:</string> - </property> - <property name="buddy" > - <cstring>passwordEdit</cstring> - </property> - </widget> - </item> - <item row="2" column="1" colspan="3" > - <widget class="QSpinBox" name="ageSpinBox" > - <property name="toolTip" > - <string>Specify your age</string> - </property> - <property name="statusTip" > - <string>Specify your age</string> - </property> - <property name="minimum" > - <number>12</number> - </property> - <property name="value" > - <number>22</number> - </property> - </widget> - </item> - <item row="7" column="2" colspan="2" > - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="6" column="0" colspan="4" > - <widget class="QCheckBox" name="agreeCheckBox" > - <property name="toolTip" > - <string>Please read the LICENSE file before checking</string> - </property> - <property name="text" > - <string>I &accept the terms and &conditions</string> - </property> - </widget> - </item> - <item row="3" column="1" colspan="3" > - <widget class="QLineEdit" name="passwordEdit" > - <property name="toolTip" > - <string>Specify your password</string> - </property> - <property name="statusTip" > - <string>Specify your password</string> - </property> - <property name="text" > - <string>Password</string> - </property> - <property name="echoMode" > - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="5" column="1" colspan="3" > - <widget class="QListWidget" name="professionList" > - <property name="toolTip" > - <string>Select your profession</string> - </property> - <property name="statusTip" > - <string>Specify your name here</string> - </property> - <property name="whatsThis" > - <string>Specify your name here</string> - </property> - <property name="currentRow" > - <number>0</number> - </property> - <item> - <property name="text" > - <string>Developer</string> - </property> - </item> - <item> - <property name="text" > - <string>Student</string> - </property> - </item> - <item> - <property name="text" > - <string>Fisherman</string> - </property> - </item> - </widget> - </item> - <item row="5" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Profession:</string> - </property> - <property name="buddy" > - <cstring>professionList</cstring> - </property> - </widget> - </item> - <item row="4" column="1" colspan="3" > - <widget class="QComboBox" name="countryCombo" > - <property name="toolTip" > - <string>Specify country of origin</string> - </property> - <property name="statusTip" > - <string>Specify country of origin</string> - </property> - <property name="currentIndex" > - <number>6</number> - </property> - <item> - <property name="text" > - <string>Egypt</string> - </property> - </item> - <item> - <property name="text" > - <string>France</string> - </property> - </item> - <item> - <property name="text" > - <string>Germany</string> - </property> - </item> - <item> - <property name="text" > - <string>India</string> - </property> - </item> - <item> - <property name="text" > - <string>Italy</string> - </property> - </item> - <item> - <property name="text" > - <string>Korea</string> - </property> - </item> - <item> - <property name="text" > - <string>Norway</string> - </property> - </item> - </widget> - </item> - <item row="4" column="0" > - <widget class="QLabel" name="countryLabel" > - <property name="text" > - <string>Pro&fession</string> - </property> - <property name="buddy" > - <cstring>professionList</cstring> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>392</width> - <height>25</height> - </rect> - </property> - <widget class="QMenu" name="menu_File" > - <property name="title" > - <string>&File</string> - </property> - <addaction name="editStyleAction" /> - <addaction name="separator" /> - <addaction name="exitAction" /> - </widget> - <widget class="QMenu" name="menu_Help" > - <property name="title" > - <string>&Help</string> - </property> - <addaction name="aboutAction" /> - <addaction name="separator" /> - <addaction name="aboutQtAction" /> - </widget> - <addaction name="menu_File" /> - <addaction name="menu_Help" /> - </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="exitAction" > - <property name="text" > - <string>&Exit</string> - </property> - </action> - <action name="aboutQtAction" > - <property name="text" > - <string>About Qt</string> - </property> - </action> - <action name="editStyleAction" > - <property name="text" > - <string>Edit &Style</string> - </property> - </action> - <action name="aboutAction" > - <property name="text" > - <string>About</string> - </property> - </action> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/widgets/widgets/stylesheet/main.cpp b/examples/widgets/widgets/stylesheet/main.cpp deleted file mode 100644 index 3b1168398a..0000000000 --- a/examples/widgets/widgets/stylesheet/main.cpp +++ /dev/null @@ -1,63 +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[]) -{ - Q_INIT_RESOURCE(stylesheet); - - QApplication app(argc, argv); - MainWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/stylesheet/mainwindow.cpp b/examples/widgets/widgets/stylesheet/mainwindow.cpp deleted file mode 100644 index a8bd20e964..0000000000 --- a/examples/widgets/widgets/stylesheet/mainwindow.cpp +++ /dev/null @@ -1,85 +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 "stylesheeteditor.h" - -#include <QMessageBox> - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - ui.nameLabel->setProperty("class", "mandatory QLabel"); - - styleSheetEditor = new StyleSheetEditor(this); - - statusBar()->addWidget(new QLabel(tr("Ready"))); - - connect(ui.exitAction, &QAction::triggered, qApp, &QApplication::quit); - connect(ui.aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt); -} - -void MainWindow::on_editStyleAction_triggered() -{ - styleSheetEditor->show(); - styleSheetEditor->activateWindow(); -} - -void MainWindow::on_aboutAction_triggered() -{ - QMessageBox::about(this, tr("About Style sheet"), - tr("The <b>Style Sheet</b> example shows how widgets can be styled " - "using <a href=\"http://doc.qt.io/qt-5/stylesheet.html\">Qt " - "Style Sheets</a>. Click <b>File|Edit Style Sheet</b> to pop up the " - "style editor, and either choose an existing style sheet or design " - "your own.")); -} diff --git a/examples/widgets/widgets/stylesheet/mainwindow.h b/examples/widgets/widgets/stylesheet/mainwindow.h deleted file mode 100644 index ba979a3881..0000000000 --- a/examples/widgets/widgets/stylesheet/mainwindow.h +++ /dev/null @@ -1,76 +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 "ui_mainwindow.h" - -class StyleSheetEditor; - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - -private slots: - void on_editStyleAction_triggered(); - void on_aboutAction_triggered(); - -private: - StyleSheetEditor *styleSheetEditor; - Ui::MainWindow ui; -}; - -#endif diff --git a/examples/widgets/widgets/stylesheet/mainwindow.ui b/examples/widgets/widgets/stylesheet/mainwindow.ui deleted file mode 100644 index cc29257afb..0000000000 --- a/examples/widgets/widgets/stylesheet/mainwindow.ui +++ /dev/null @@ -1,356 +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>400</width> - <height>413</height> - </rect> - </property> - <property name="windowTitle" > - <string>Style Sheet</string> - </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QFrame" name="mainFrame" > - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="6" column="0" colspan="5" > - <widget class="QCheckBox" name="agreeCheckBox" > - <property name="toolTip" > - <string>Please read the LICENSE file before checking</string> - </property> - <property name="text" > - <string>I accept the terms and &conditions</string> - </property> - </widget> - </item> - <item row="5" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Profession:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set> - </property> - <property name="buddy" > - <cstring>professionList</cstring> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="nameLabel" > - <property name="text" > - <string>&Name:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="buddy" > - <cstring>nameCombo</cstring> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QRadioButton" name="maleRadioButton" > - <property name="toolTip" > - <string>Check this if you are male</string> - </property> - <property name="text" > - <string>&Male</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <widget class="QLabel" name="passwordLabel" > - <property name="text" > - <string>&Password:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="buddy" > - <cstring>passwordEdit</cstring> - </property> - </widget> - </item> - <item row="4" column="1" colspan="4" > - <widget class="QComboBox" name="countryCombo" > - <property name="toolTip" > - <string>Specify country of origin</string> - </property> - <property name="statusTip" > - <string>Specify country of origin</string> - </property> - <property name="currentIndex" > - <number>6</number> - </property> - <item> - <property name="text" > - <string>Egypt</string> - </property> - </item> - <item> - <property name="text" > - <string>France</string> - </property> - </item> - <item> - <property name="text" > - <string>Germany</string> - </property> - </item> - <item> - <property name="text" > - <string>India</string> - </property> - </item> - <item> - <property name="text" > - <string>Italy</string> - </property> - </item> - <item> - <property name="text" > - <string>Norway</string> - </property> - </item> - <item> - <property name="text" > - <string>Pakistan</string> - </property> - </item> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="ageLabel" > - <property name="text" > - <string>&Age:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="buddy" > - <cstring>ageSpinBox</cstring> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QLabel" name="countryLabel" > - <property name="text" > - <string>Country:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - <property name="buddy" > - <cstring>countryCombo</cstring> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="genderLabel" > - <property name="text" > - <string>Gender:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="1" colspan="4" > - <widget class="QLineEdit" name="passwordEdit" > - <property name="toolTip" > - <string>Specify your password</string> - </property> - <property name="statusTip" > - <string>Specify your password</string> - </property> - <property name="text" > - <string>Password</string> - </property> - <property name="echoMode" > - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="1" column="2" colspan="2" > - <widget class="QRadioButton" name="femaleRadioButton" > - <property name="toolTip"> - <string>Check this if you are female</string> - </property> - <property name="text" > - <string>&Female</string> - </property> - </widget> - </item> - <item row="2" column="1" colspan="2" > - <widget class="QSpinBox" name="ageSpinBox" > - <property name="toolTip" > - <string>Specify your age</string> - </property> - <property name="statusTip" > - <string>Specify your age</string> - </property> - <property name="minimum" > - <number>12</number> - </property> - <property name="value" > - <number>22</number> - </property> - </widget> - </item> - <item row="0" column="1" colspan="4" > - <widget class="QComboBox" name="nameCombo" > - <property name="toolTip" > - <string>Specify your name</string> - </property> - <property name="editable" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="4" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="3" colspan="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>61</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="7" column="3" colspan="2" > - <widget class="QDialogButtonBox" name="buttonBox" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons" > - <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - <item row="5" column="1" colspan="4" > - <widget class="QListWidget" name="professionList" > - <property name="toolTip" > - <string>Select your profession</string> - </property> - <property name="statusTip" > - <string>Specify your name here</string> - </property> - <property name="whatsThis" > - <string>Specify your name here</string> - </property> - <property name="currentRow" > - <number>0</number> - </property> - <item> - <property name="text" > - <string>Developer</string> - </property> - </item> - <item> - <property name="text" > - <string>Student</string> - </property> - </item> - <item> - <property name="text" > - <string>Fisherman</string> - </property> - </item> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>29</height> - </rect> - </property> - <widget class="QMenu" name="menu_File" > - <property name="title" > - <string>&File</string> - </property> - <addaction name="editStyleAction" /> - <addaction name="separator" /> - <addaction name="exitAction" /> - </widget> - <widget class="QMenu" name="menu_Help" > - <property name="title" > - <string>&Help</string> - </property> - <addaction name="aboutAction" /> - <addaction name="aboutQtAction" /> - </widget> - <addaction name="menu_File" /> - <addaction name="menu_Help" /> - </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="exitAction" > - <property name="text" > - <string>&Exit</string> - </property> - </action> - <action name="aboutQtAction" > - <property name="text" > - <string>About Qt</string> - </property> - </action> - <action name="editStyleAction" > - <property name="text" > - <string>Edit &Style...</string> - </property> - </action> - <action name="aboutAction" > - <property name="text" > - <string>About</string> - </property> - </action> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/widgets/widgets/stylesheet/qss/coffee.qss b/examples/widgets/widgets/stylesheet/qss/coffee.qss deleted file mode 100644 index 4571d42d7e..0000000000 --- a/examples/widgets/widgets/stylesheet/qss/coffee.qss +++ /dev/null @@ -1,112 +0,0 @@ -.QWidget { - background-color: beige; -} - -/* Nice Windows-XP-style password character. */ -QLineEdit[echoMode="2"] { - lineedit-password-character: 9679; -} - -/* We provide a min-width and min-height for push buttons - so that they look elegant regardless of the width of the text. */ -QPushButton { - background-color: palegoldenrod; - border-width: 2px; - border-color: darkkhaki; - border-style: solid; - border-radius: 5; - padding: 3px; - min-width: 9ex; - min-height: 2.5ex; -} - -QPushButton:hover { - background-color: khaki; -} - -/* Increase the padding, so the text is shifted when the button is - pressed. */ -QPushButton:pressed { - padding-left: 5px; - padding-top: 5px; - background-color: #d0d67c; -} - -QLabel, QAbstractButton { - font: bold; -} - -/* Mark mandatory fields with a brownish color. */ -.mandatory { - color: brown; -} - -/* Bold text on status bar looks awful. */ -QStatusBar QLabel { - font: normal; -} - -QStatusBar::item { - border-width: 1; - border-color: darkkhaki; - border-style: solid; - border-radius: 2; -} - -QComboBox, QLineEdit, QSpinBox, QTextEdit, QListView { - background-color: cornsilk; - selection-color: #0a214c; - selection-background-color: #C19A6B; -} - -QListView { - show-decoration-selected: 1; -} - -QListView::item:hover { - background-color: wheat; -} - -/* We reserve 1 pixel space in padding. When we get the focus, - we kill the padding and enlarge the border. This makes the items - glow. */ -QLineEdit, QFrame { - border-width: 2px; - padding: 1px; - border-style: solid; - border-color: darkkhaki; - border-radius: 5px; -} - -/* As mentioned above, eliminate the padding and increase the border. */ -QLineEdit:focus, QFrame:focus { - border-width: 3px; - padding: 0px; -} - -/* A QLabel is a QFrame ... */ -QLabel { - border: none; - padding: 0; - background: none; -} - -/* A QToolTip is a QLabel ... */ -QToolTip { - border: 2px solid darkkhaki; - padding: 5px; - border-radius: 3px; - opacity: 200; -} - -/* Nice to have the background color change when hovered. */ -QRadioButton:hover, QCheckBox:hover { - background-color: wheat; -} - -/* Force the dialog's buttons to follow the Windows guidelines. */ -QDialogButtonBox { - button-layout: 0; -} - - diff --git a/examples/widgets/widgets/stylesheet/qss/default.qss b/examples/widgets/widgets/stylesheet/qss/default.qss deleted file mode 100644 index 84eb5e0bc2..0000000000 --- a/examples/widgets/widgets/stylesheet/qss/default.qss +++ /dev/null @@ -1 +0,0 @@ -/* empty stylesheet */ diff --git a/examples/widgets/widgets/stylesheet/qss/pagefold.qss b/examples/widgets/widgets/stylesheet/qss/pagefold.qss deleted file mode 100644 index 3701fc713c..0000000000 --- a/examples/widgets/widgets/stylesheet/qss/pagefold.qss +++ /dev/null @@ -1,299 +0,0 @@ -/* Customize any plain widget that is a child of a QMainWindow. */ -QMainWindow > .QWidget { - background-color: gainsboro; - background-image: url(:/images/pagefold.png); - background-position: top right; - background-repeat: no-repeat -} - -/* Provide a padding for the layout inside the frame. The frame - exists only to provide a padding for the top-right image, so we - explicitly disable the border. */ -#mainFrame { - padding-right: 30px; - border-style: none; - border-image: none; /* since we set a border-image below */ -} - -/* mainFrame won't have this border-image since we have - explicitly set it to 'none' using a more specific selector. */ -QFrame, QLineEdit, QComboBox[editable="true"], QSpinBox { - border-image: url(:/images/frame.png) 4; - border-width: 3; -} - -QLabel { - border: none; - border-image: none; - padding: 0; - background: none; -} - -/* Make text in message boxes selectable. */ -QMessageBox { - /* LinksAccessibleByMouse | TextSelectableByMouse */ - messagebox-text-interaction-flags: 5; -} - -/* Set the selection colors for all widgets. */ -QWidget { - selection-color: black; - selection-background-color: Silver; - color: black; -} - -/* Make the entire row selected in item views. */ -QAbstractItemView { - show-decoration-selected: 1; -} - -/* Nice WindowsXP-style password character for password line edits. */ -QLineEdit[echoMode="2"] { - lineedit-password-character: 9679; -} - -/* Customize tooltips. */ -QToolTip { - background-color: rgb(200,200,255); - border-color: darkslategray; - border-width: 1px; - border-style: solid; - padding: 3px; - font: bold; - border-radius: 3px; - opacity: 200; -} - -/* Customize radio buttons. */ - -QRadioButton { - spacing: 5px; -} - -QRadioButton::indicator { - width: 13px; - height: 13px; -} - -QRadioButton::indicator::unchecked { - image: url(:/images/radiobutton_unchecked.png); -} - -QRadioButton::indicator:unchecked:hover { - image: url(:/images/radiobutton_unchecked_hover.png); -} - -QRadioButton::indicator:unchecked:pressed { - image: url(:/images/radiobutton_unchecked_pressed.png); -} - -QRadioButton::indicator::checked { - image: url(:/images/radiobutton_checked.png); -} - -QRadioButton::indicator:checked:hover { - image: url(:/images/radiobutton_checked_hover.png); -} - -QRadioButton::indicator:checked:pressed { - image: url(:/images/radiobutton_checked_pressed.png); -} - -/* Customize arrows. */ - -*::down-arrow, *::menu-indicator { - image: url(:/images/down_arrow.png); - width: 7px; - height: 7px; -} - -*::down-arrow:disabled, *::down-arrow:off { - image: url(:/images/down_arrow_disabled.png); -} - -*::up-arrow { - image: url(:/images/up_arrow.png); - width: 7px; - height: 7px; -} - -*::up-arrow:disabled, *::up-arrow:off { - image: url(:/images/up_arrow_disabled.png); -} - -/* Customize push buttons and comboboxes. Our read-only combobox - is very similar to a push button, so they share the same border image. */ - -QPushButton { - min-width: 4em; -} - -QPushButton, QComboBox[editable="false"], -QComboBox[editable="true"]::drop-down { - border-image: url(:/images/pushbutton.png) 5; - border-width: 5; -} - -QPushButton:hover, QComboBox[editable="false"]:hover, -QComboBox[editable="true"]::drop-down:hover, QMenuBar::item:hover { - border-image: url(:/images/pushbutton_hover.png) 5; - border-width: 5; -} - -QPushButton:pressed, QComboBox[editable="false"]:on, -QComboBox[editable="true"]::drop-down:on, QMenuBar::item:on { - border-image: url(:/images/pushbutton_pressed.png) 5; - border-width: 5; -} - -/* Customize read-only comboboxes. */ - -QComboBox[editable="false"] { - padding-left: 3px; - padding-right: 20px; /* space for the arrow */ -} - -QComboBox[editable="false"]::drop-down { - subcontrol-origin: padding; - subcontrol-position: top right; - width: 15px; - border-left-style: solid; - border-left-color: darkgray; - border-left-width: 1px; -} - -QComboBox[editable="false"]::down-arrow { - subcontrol-origin: content; - subcontrol-position: center; - position: relative; - left: 1px; /* 1 pixel dropdown border */ -} - -/* The combobox arrow is on when the popup is open. */ -QComboBox[editable="false"]::down-arrow:on { - position: relative; - top: 1px; - left: 2px; -} - -/* Customize editable comboboxes. */ - -QComboBox[editable="true"] { - padding-right: 16px; -} - -QComboBox[editable="true"]::drop-down { - subcontrol-origin: border; - subcontrol-position: top right; - width: 13px; - position: absolute; - top: 2px; - bottom: 2px; - right: 2px; -} - -QComboBox[editable="true"]::drop-down, -QComboBox[editable="true"]::drop-down:hover, -QComboBox[editable="true"]::drop-down:on { - border-width: 0px; - border-left-width: 3px; /* we need only left and center part */ -} - -/* Shift the arrow when it's open. */ -QComboBox[editable="true"]::down-arrow:on { - position: relative; - top: 1px; - left: 1px; -} - -/* Customize check boxes. */ -QCheckBox { - spacing: 5px; -} - -QCheckBox::indicator { - width: 13px; - height: 13px; -} - -QCheckBox::indicator:unchecked { - image: url(:/images/checkbox_unchecked.png); -} - -QCheckBox::indicator:unchecked:hover { - image: url(:/images/checkbox_unchecked_hover.png); -} - -QCheckBox::indicator:unchecked:pressed { - image: url(:/images/checkbox_unchecked_pressed.png); -} - -QCheckBox::indicator:checked { - image: url(:/images/checkbox_checked.png); -} - -QCheckBox::indicator:checked:hover { - image: url(:/images/checkbox_checked_hover.png); -} - -QCheckBox::indicator:checked:pressed { - image: url(:/images/checkbox_checked_pressed.png); -} - -/* Customize the size grip. */ -QSizeGrip { - image: url(:/images/sizegrip.png); - width: 16px; - height: 16px; -} - -/* Customize the menu bar. */ -QMenuBar { - border-image: none; - border-style: none; - border-width: 1px; - border-bottom-style: solid; - border-bottom-color: darkslategray; - padding: 2px; -} - -/* Customize spin boxes. */ - -QSpinBox { - padding-right: 15px; -} - -QSpinBox::up-button { - subcontrol-origin: border; - subcontrol-position: top right; - - width: 16px; /* 16 + 2*1px border-width = 15px padding + 3px parent border */ - border-image: url(:/images/spinup.png) 1; - border-width: 1px; -} - -QSpinBox::up-button:hover { - border-image: url(:/images/spinup_hover.png) 1; -} - -QSpinBox::up-button:pressed { - border-image: url(:/images/spinup_pressed.png) 1; -} - -QSpinBox::down-button { - subcontrol-origin: border; - subcontrol-position: bottom right; - - width: 16px; - border-image: url(:/images/spindown.png) 1; - border-width: 1px; - border-top-width: 0; -} - -QSpinBox::down-button:hover { - border-image: url(:/images/spindown_hover.png) 1; -} - -QSpinBox::down-button:pressed { - border-image: url(:/images/spindown_pressed.png) 1; -} diff --git a/examples/widgets/widgets/stylesheet/stylesheet.pro b/examples/widgets/widgets/stylesheet/stylesheet.pro deleted file mode 100644 index 0fe3187f63..0000000000 --- a/examples/widgets/widgets/stylesheet/stylesheet.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) - -HEADERS = mainwindow.h \ - stylesheeteditor.h -FORMS = mainwindow.ui \ - stylesheeteditor.ui -RESOURCES = stylesheet.qrc -SOURCES = main.cpp \ - mainwindow.cpp \ - stylesheeteditor.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/stylesheet -INSTALLS += target diff --git a/examples/widgets/widgets/stylesheet/stylesheet.qrc b/examples/widgets/widgets/stylesheet/stylesheet.qrc deleted file mode 100644 index e1e61a920a..0000000000 --- a/examples/widgets/widgets/stylesheet/stylesheet.qrc +++ /dev/null @@ -1,39 +0,0 @@ -<RCC> -<qresource prefix="/"> - <file>layouts/default.ui</file> - <file>layouts/pagefold.ui</file> - <file>qss/coffee.qss</file> - <file>qss/default.qss</file> - <file>qss/pagefold.qss</file> - <file>images/pagefold.png</file> - <file>images/frame.png</file> - <file>images/radiobutton_unchecked.png</file> - <file>images/radiobutton_unchecked_pressed.png</file> - <file>images/radiobutton_unchecked_hover.png</file> - <file>images/radiobutton_checked.png</file> - <file>images/radiobutton_checked_pressed.png</file> - <file>images/radiobutton_checked_hover.png</file> - <file>images/pushbutton.png</file> - <file>images/pushbutton_hover.png</file> - <file>images/pushbutton_pressed.png</file> - <file>images/checkbox_unchecked.png</file> - <file>images/checkbox_unchecked_pressed.png</file> - <file>images/checkbox_unchecked_hover.png</file> - <file>images/checkbox_checked.png</file> - <file>images/checkbox_checked_pressed.png</file> - <file>images/checkbox_checked_hover.png</file> - <file>images/down_arrow.png</file> - <file>images/down_arrow_disabled.png</file> - <file>images/up_arrow.png</file> - <file>images/up_arrow_disabled.png</file> - <file>images/sizegrip.png</file> - <file>images/spinup.png</file> - <file>images/spinup_off.png</file> - <file>images/spinup_hover.png</file> - <file>images/spinup_pressed.png</file> - <file>images/spindown.png</file> - <file>images/spindown_off.png</file> - <file>images/spindown_hover.png</file> - <file>images/spindown_pressed.png</file> -</qresource> -</RCC> diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp deleted file mode 100644 index f885964a31..0000000000 --- a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp +++ /dev/null @@ -1,111 +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 "stylesheeteditor.h" - -#include <QFile> -#include <QRegularExpression> -#include <QStyleFactory> - -StyleSheetEditor::StyleSheetEditor(QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - - connect(ui.styleCombo, &QComboBox::textActivated, this, &StyleSheetEditor::setStyleName); - connect(ui.styleSheetCombo, &QComboBox::textActivated, this, &StyleSheetEditor::setStyleSheetName); - connect(ui.styleTextEdit, &QTextEdit::textChanged, this, &StyleSheetEditor::setModified); - connect(ui.applyButton, &QAbstractButton::clicked, this, &StyleSheetEditor::apply); - - QRegularExpression regExp("^.(.*)\\+?Style$"); - QString defaultStyle = QApplication::style()->metaObject()->className(); - QRegularExpressionMatch match = regExp.match(defaultStyle); - - if (match.hasMatch()) - defaultStyle = match.captured(1); - - ui.styleCombo->addItems(QStyleFactory::keys()); - ui.styleCombo->setCurrentIndex(ui.styleCombo->findText(defaultStyle, Qt::MatchContains)); - ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Coffee")); - loadStyleSheet("Coffee"); -} - -void StyleSheetEditor::setStyleName(const QString &styleName) -{ - qApp->setStyle(styleName); - ui.applyButton->setEnabled(false); -} - -void StyleSheetEditor::setStyleSheetName(const QString &sheetName) -{ - loadStyleSheet(sheetName); -} - -void StyleSheetEditor::setModified() -{ - ui.applyButton->setEnabled(true); -} - -void StyleSheetEditor::apply() -{ - qApp->setStyleSheet(ui.styleTextEdit->toPlainText()); - ui.applyButton->setEnabled(false); -} - -void StyleSheetEditor::loadStyleSheet(const QString &sheetName) -{ - QFile file(":/qss/" + sheetName.toLower() + ".qss"); - file.open(QFile::ReadOnly); - QString styleSheet = QString::fromLatin1(file.readAll()); - - ui.styleTextEdit->setPlainText(styleSheet); - qApp->setStyleSheet(styleSheet); - ui.applyButton->setEnabled(false); -} diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.h b/examples/widgets/widgets/stylesheet/stylesheeteditor.h deleted file mode 100644 index 4105d61d5d..0000000000 --- a/examples/widgets/widgets/stylesheet/stylesheeteditor.h +++ /dev/null @@ -1,77 +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 STYLESHEETEDITOR_H -#define STYLESHEETEDITOR_H - -#include <QDialog> - -#include "ui_stylesheeteditor.h" - -class StyleSheetEditor : public QDialog -{ - Q_OBJECT - -public: - StyleSheetEditor(QWidget *parent = nullptr); - -private slots: - void setStyleName(const QString &styleName); - void setStyleSheetName(const QString &styleSheetName); - void setModified(); - void apply(); - -private: - void loadStyleSheet(const QString &sheetName); - - Ui::StyleSheetEditor ui; -}; - -#endif diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.ui b/examples/widgets/widgets/stylesheet/stylesheeteditor.ui deleted file mode 100644 index 34cd7f6d04..0000000000 --- a/examples/widgets/widgets/stylesheet/stylesheeteditor.ui +++ /dev/null @@ -1,171 +0,0 @@ -<ui version="4.0" > - <class>StyleSheetEditor</class> - <widget class="QWidget" name="StyleSheetEditor" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>445</width> - <height>289</height> - </rect> - </property> - <property name="windowTitle" > - <string>Style Editor</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="6" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>32</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::MinimumExpanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>32</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="5" > - <widget class="QComboBox" name="styleSheetCombo" > - <item> - <property name="text" > - <string>Default</string> - </property> - </item> - <item> - <property name="text" > - <string>Coffee</string> - </property> - </item> - <item> - <property name="text" > - <string>Pagefold</string> - </property> - </item> - </widget> - </item> - <item row="0" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" > - <size> - <width>10</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="2" > - <widget class="QComboBox" name="styleCombo" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLabel" name="label_7" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>Style:</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="7" > - <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>321</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="applyButton" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="text" > - <string>&Apply</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" colspan="7" > - <widget class="QTextEdit" name="styleTextEdit" /> - </item> - <item row="0" column="4" > - <widget class="QLabel" name="label_8" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>Style Sheet:</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/widgets/widgets/tablet/CMakeLists.txt b/examples/widgets/widgets/tablet/CMakeLists.txt index c411cc4fef..caf9922741 100644 --- a/examples/widgets/widgets/tablet/CMakeLists.txt +++ b/examples/widgets/widgets/tablet/CMakeLists.txt @@ -1,23 +1,12 @@ -# Generated from tablet.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(qttablet LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/tablet") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(qttablet main.cpp @@ -25,16 +14,17 @@ qt_add_executable(qttablet tabletapplication.cpp tabletapplication.h tabletcanvas.cpp tabletcanvas.h ) + set_target_properties(qttablet PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(qttablet PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) +target_link_libraries(qttablet PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets +) # Resources: set(images_resource_files @@ -44,7 +34,7 @@ set(images_resource_files "images/cursor-pencil.png" ) -qt6_add_resources(qttablet "images" +qt_add_resources(qttablet "images" PREFIX "/" FILES @@ -52,7 +42,14 @@ qt6_add_resources(qttablet "images" ) install(TARGETS qttablet - 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 qttablet + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/tablet/main.cpp b/examples/widgets/widgets/tablet/main.cpp index 0fec526de0..6fe3a65acd 100644 --- a/examples/widgets/widgets/tablet/main.cpp +++ b/examples/widgets/widgets/tablet/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 "mainwindow.h" #include "tabletapplication.h" diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp index 102fb813b8..1c5209195f 100644 --- a/examples/widgets/widgets/tablet/mainwindow.cpp +++ b/examples/widgets/widgets/tablet/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 "tabletcanvas.h" @@ -155,13 +108,13 @@ void MainWindow::about() void MainWindow::createMenus() { QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - fileMenu->addAction(tr("&Open..."), this, &MainWindow::load, QKeySequence::Open); - fileMenu->addAction(tr("&Save As..."), this, &MainWindow::save, QKeySequence::SaveAs); - fileMenu->addAction(tr("&New"), this, &MainWindow::clear, QKeySequence::New); - fileMenu->addAction(tr("E&xit"), this, &MainWindow::close, QKeySequence::Quit); + fileMenu->addAction(tr("&Open..."), QKeySequence::Open, this, &MainWindow::load); + fileMenu->addAction(tr("&Save As..."), QKeySequence::SaveAs, this, &MainWindow::save); + fileMenu->addAction(tr("&New"), QKeySequence::New, this, &MainWindow::clear); + fileMenu->addAction(tr("E&xit"), QKeySequence::Quit, this, &MainWindow::close); QMenu *brushMenu = menuBar()->addMenu(tr("&Brush")); - brushMenu->addAction(tr("&Brush Color..."), this, &MainWindow::setBrushColor, tr("Ctrl+B")); + brushMenu->addAction(tr("&Brush Color..."), tr("Ctrl+B"), this, &MainWindow::setBrushColor); //! [8] QMenu *tabletMenu = menuBar()->addMenu(tr("&Tablet")); diff --git a/examples/widgets/widgets/tablet/mainwindow.h b/examples/widgets/widgets/tablet/mainwindow.h index 3ea9af7ccf..c67065b6bf 100644 --- a/examples/widgets/widgets/tablet/mainwindow.h +++ b/examples/widgets/widgets/tablet/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/widgets/tablet/tabletapplication.cpp b/examples/widgets/widgets/tablet/tabletapplication.cpp index a27491a86c..0d50ef685a 100644 --- a/examples/widgets/widgets/tablet/tabletapplication.cpp +++ b/examples/widgets/widgets/tablet/tabletapplication.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 "tabletapplication.h" diff --git a/examples/widgets/widgets/tablet/tabletapplication.h b/examples/widgets/widgets/tablet/tabletapplication.h index 9b4a4f1886..cf18ae9cfb 100644 --- a/examples/widgets/widgets/tablet/tabletapplication.h +++ b/examples/widgets/widgets/tablet/tabletapplication.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 TABLETAPPLICATION_H #define TABLETAPPLICATION_H diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp index e397d70cd6..f28f765e36 100644 --- a/examples/widgets/widgets/tablet/tabletcanvas.cpp +++ b/examples/widgets/widgets/tablet/tabletcanvas.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 "tabletcanvas.h" diff --git a/examples/widgets/widgets/tablet/tabletcanvas.h b/examples/widgets/widgets/tablet/tabletcanvas.h index 4c10731b0f..8219b4d545 100644 --- a/examples/widgets/widgets/tablet/tabletcanvas.h +++ b/examples/widgets/widgets/tablet/tabletcanvas.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 TABLETCANVAS_H #define TABLETCANVAS_H diff --git a/examples/widgets/widgets/tetrix/CMakeLists.txt b/examples/widgets/widgets/tetrix/CMakeLists.txt deleted file mode 100644 index 58237e2962..0000000000 --- a/examples/widgets/widgets/tetrix/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# Generated from tetrix.pro. - -cmake_minimum_required(VERSION 3.14) -project(tetrix 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/widgets/tetrix") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(tetrix - main.cpp - tetrixboard.cpp tetrixboard.h - tetrixpiece.cpp tetrixpiece.h - tetrixwindow.cpp tetrixwindow.h -) -set_target_properties(tetrix PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(tetrix PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS tetrix - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/tetrix/main.cpp b/examples/widgets/widgets/tetrix/main.cpp deleted file mode 100644 index 92f245ca14..0000000000 --- a/examples/widgets/widgets/tetrix/main.cpp +++ /dev/null @@ -1,61 +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 "tetrixwindow.h" - -#include <QApplication> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - TetrixWindow window; - window.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/tetrix/tetrix.pro b/examples/widgets/widgets/tetrix/tetrix.pro deleted file mode 100644 index bb9f855fb0..0000000000 --- a/examples/widgets/widgets/tetrix/tetrix.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += widgets - -HEADERS = tetrixboard.h \ - tetrixpiece.h \ - tetrixwindow.h -SOURCES = main.cpp \ - tetrixboard.cpp \ - tetrixpiece.cpp \ - tetrixwindow.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/tetrix -INSTALLS += target diff --git a/examples/widgets/widgets/tetrix/tetrixboard.cpp b/examples/widgets/widgets/tetrix/tetrixboard.cpp deleted file mode 100644 index c1192f264d..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixboard.cpp +++ /dev/null @@ -1,418 +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 "tetrixboard.h" - -#include <QKeyEvent> -#include <QLabel> -#include <QPainter> - -//! [0] -TetrixBoard::TetrixBoard(QWidget *parent) - : QFrame(parent), isStarted(false), isPaused(false) -{ - setFrameStyle(QFrame::Panel | QFrame::Sunken); - setFocusPolicy(Qt::StrongFocus); - clearBoard(); - - nextPiece.setRandomShape(); -} -//! [0] - -//! [1] -void TetrixBoard::setNextPieceLabel(QLabel *label) -{ - nextPieceLabel = label; -} -//! [1] - -//! [2] -QSize TetrixBoard::sizeHint() const -{ - return QSize(BoardWidth * 15 + frameWidth() * 2, - BoardHeight * 15 + frameWidth() * 2); -} - -QSize TetrixBoard::minimumSizeHint() const -//! [2] //! [3] -{ - return QSize(BoardWidth * 5 + frameWidth() * 2, - BoardHeight * 5 + frameWidth() * 2); -} -//! [3] - -//! [4] -void TetrixBoard::start() -{ - if (isPaused) - return; - - isStarted = true; - isWaitingAfterLine = false; - numLinesRemoved = 0; - numPiecesDropped = 0; - score = 0; - level = 1; - clearBoard(); - - emit linesRemovedChanged(numLinesRemoved); - emit scoreChanged(score); - emit levelChanged(level); - - newPiece(); - timer.start(timeoutTime(), this); -} -//! [4] - -//! [5] -void TetrixBoard::pause() -{ - if (!isStarted) - return; - - isPaused = !isPaused; - if (isPaused) { - timer.stop(); - } else { - timer.start(timeoutTime(), this); - } - update(); -//! [5] //! [6] -} -//! [6] - -//! [7] -void TetrixBoard::paintEvent(QPaintEvent *event) -{ - QFrame::paintEvent(event); - - QPainter painter(this); - QRect rect = contentsRect(); -//! [7] - - if (isPaused) { - painter.drawText(rect, Qt::AlignCenter, tr("Pause")); - return; - } - -//! [8] - int boardTop = rect.bottom() - BoardHeight*squareHeight(); - - for (int i = 0; i < BoardHeight; ++i) { - for (int j = 0; j < BoardWidth; ++j) { - TetrixShape shape = shapeAt(j, BoardHeight - i - 1); - if (shape != NoShape) - drawSquare(painter, rect.left() + j * squareWidth(), - boardTop + i * squareHeight(), shape); - } -//! [8] //! [9] - } -//! [9] - -//! [10] - if (curPiece.shape() != NoShape) { - for (int i = 0; i < 4; ++i) { - int x = curX + curPiece.x(i); - int y = curY - curPiece.y(i); - drawSquare(painter, rect.left() + x * squareWidth(), - boardTop + (BoardHeight - y - 1) * squareHeight(), - curPiece.shape()); - } -//! [10] //! [11] - } -//! [11] //! [12] -} -//! [12] - -//! [13] -void TetrixBoard::keyPressEvent(QKeyEvent *event) -{ - if (!isStarted || isPaused || curPiece.shape() == NoShape) { - QFrame::keyPressEvent(event); - return; - } -//! [13] - -//! [14] - switch (event->key()) { - case Qt::Key_Left: - tryMove(curPiece, curX - 1, curY); - break; - case Qt::Key_Right: - tryMove(curPiece, curX + 1, curY); - break; - case Qt::Key_Down: - tryMove(curPiece.rotatedRight(), curX, curY); - break; - case Qt::Key_Up: - tryMove(curPiece.rotatedLeft(), curX, curY); - break; - case Qt::Key_Space: - dropDown(); - break; - case Qt::Key_D: - oneLineDown(); - break; - default: - QFrame::keyPressEvent(event); - } -//! [14] -} - -//! [15] -void TetrixBoard::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == timer.timerId()) { - if (isWaitingAfterLine) { - isWaitingAfterLine = false; - newPiece(); - timer.start(timeoutTime(), this); - } else { - oneLineDown(); - } - } else { - QFrame::timerEvent(event); -//! [15] //! [16] - } -//! [16] //! [17] -} -//! [17] - -//! [18] -void TetrixBoard::clearBoard() -{ - for (int i = 0; i < BoardHeight * BoardWidth; ++i) - board[i] = NoShape; -} -//! [18] - -//! [19] -void TetrixBoard::dropDown() -{ - int dropHeight = 0; - int newY = curY; - while (newY > 0) { - if (!tryMove(curPiece, curX, newY - 1)) - break; - --newY; - ++dropHeight; - } - pieceDropped(dropHeight); -//! [19] //! [20] -} -//! [20] - -//! [21] -void TetrixBoard::oneLineDown() -{ - if (!tryMove(curPiece, curX, curY - 1)) - pieceDropped(0); -} -//! [21] - -//! [22] -void TetrixBoard::pieceDropped(int dropHeight) -{ - for (int i = 0; i < 4; ++i) { - int x = curX + curPiece.x(i); - int y = curY - curPiece.y(i); - shapeAt(x, y) = curPiece.shape(); - } - - ++numPiecesDropped; - if (numPiecesDropped % 25 == 0) { - ++level; - timer.start(timeoutTime(), this); - emit levelChanged(level); - } - - score += dropHeight + 7; - emit scoreChanged(score); - removeFullLines(); - - if (!isWaitingAfterLine) - newPiece(); -//! [22] //! [23] -} -//! [23] - -//! [24] -void TetrixBoard::removeFullLines() -{ - int numFullLines = 0; - - for (int i = BoardHeight - 1; i >= 0; --i) { - bool lineIsFull = true; - - for (int j = 0; j < BoardWidth; ++j) { - if (shapeAt(j, i) == NoShape) { - lineIsFull = false; - break; - } - } - - if (lineIsFull) { -//! [24] //! [25] - ++numFullLines; - for (int k = i; k < BoardHeight - 1; ++k) { - for (int j = 0; j < BoardWidth; ++j) - shapeAt(j, k) = shapeAt(j, k + 1); - } -//! [25] //! [26] - for (int j = 0; j < BoardWidth; ++j) - shapeAt(j, BoardHeight - 1) = NoShape; - } -//! [26] //! [27] - } -//! [27] - -//! [28] - if (numFullLines > 0) { - numLinesRemoved += numFullLines; - score += 10 * numFullLines; - emit linesRemovedChanged(numLinesRemoved); - emit scoreChanged(score); - - timer.start(500, this); - isWaitingAfterLine = true; - curPiece.setShape(NoShape); - update(); - } -//! [28] //! [29] -} -//! [29] - -//! [30] -void TetrixBoard::newPiece() -{ - curPiece = nextPiece; - nextPiece.setRandomShape(); - showNextPiece(); - curX = BoardWidth / 2 + 1; - curY = BoardHeight - 1 + curPiece.minY(); - - if (!tryMove(curPiece, curX, curY)) { - curPiece.setShape(NoShape); - timer.stop(); - isStarted = false; - } -//! [30] //! [31] -} -//! [31] - -//! [32] -void TetrixBoard::showNextPiece() -{ - if (!nextPieceLabel) - return; - - int dx = nextPiece.maxX() - nextPiece.minX() + 1; - int dy = nextPiece.maxY() - nextPiece.minY() + 1; - - QPixmap pixmap(dx * squareWidth(), dy * squareHeight()); - QPainter painter(&pixmap); - painter.fillRect(pixmap.rect(), nextPieceLabel->palette().window()); - - for (int i = 0; i < 4; ++i) { - int x = nextPiece.x(i) - nextPiece.minX(); - int y = nextPiece.y(i) - nextPiece.minY(); - drawSquare(painter, x * squareWidth(), y * squareHeight(), - nextPiece.shape()); - } - nextPieceLabel->setPixmap(pixmap); -//! [32] //! [33] -} -//! [33] - -//! [34] -bool TetrixBoard::tryMove(const TetrixPiece &newPiece, int newX, int newY) -{ - for (int i = 0; i < 4; ++i) { - int x = newX + newPiece.x(i); - int y = newY - newPiece.y(i); - if (x < 0 || x >= BoardWidth || y < 0 || y >= BoardHeight) - return false; - if (shapeAt(x, y) != NoShape) - return false; - } -//! [34] - -//! [35] - curPiece = newPiece; - curX = newX; - curY = newY; - update(); - return true; -} -//! [35] - -//! [36] -void TetrixBoard::drawSquare(QPainter &painter, int x, int y, TetrixShape shape) -{ - static constexpr QRgb colorTable[8] = { - 0x000000, 0xCC6666, 0x66CC66, 0x6666CC, - 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00 - }; - - QColor color = colorTable[int(shape)]; - painter.fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2, - color); - - painter.setPen(color.lighter()); - painter.drawLine(x, y + squareHeight() - 1, x, y); - painter.drawLine(x, y, x + squareWidth() - 1, y); - - painter.setPen(color.darker()); - painter.drawLine(x + 1, y + squareHeight() - 1, - x + squareWidth() - 1, y + squareHeight() - 1); - painter.drawLine(x + squareWidth() - 1, y + squareHeight() - 1, - x + squareWidth() - 1, y + 1); -} -//! [36] diff --git a/examples/widgets/widgets/tetrix/tetrixboard.h b/examples/widgets/widgets/tetrix/tetrixboard.h deleted file mode 100644 index 86bcfa4d6e..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixboard.h +++ /dev/null @@ -1,126 +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 TETRIXBOARD_H -#define TETRIXBOARD_H - -#include <QBasicTimer> -#include <QFrame> -#include <QPointer> - -#include "tetrixpiece.h" - -QT_BEGIN_NAMESPACE -class QLabel; -QT_END_NAMESPACE - -//! [0] -class TetrixBoard : public QFrame -{ - Q_OBJECT - -public: - TetrixBoard(QWidget *parent = nullptr); - - void setNextPieceLabel(QLabel *label); - QSize sizeHint() const override; - QSize minimumSizeHint() const override; - -public slots: - void start(); - void pause(); - -signals: - void scoreChanged(int score); - void levelChanged(int level); - void linesRemovedChanged(int numLines); - -protected: - void paintEvent(QPaintEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - void timerEvent(QTimerEvent *event) override; -//! [0] - -//! [1] -private: - enum { BoardWidth = 10, BoardHeight = 22 }; - - TetrixShape &shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; } - int timeoutTime() { return 1000 / (1 + level); } - int squareWidth() { return contentsRect().width() / BoardWidth; } - int squareHeight() { return contentsRect().height() / BoardHeight; } - void clearBoard(); - void dropDown(); - void oneLineDown(); - void pieceDropped(int dropHeight); - void removeFullLines(); - void newPiece(); - void showNextPiece(); - bool tryMove(const TetrixPiece &newPiece, int newX, int newY); - void drawSquare(QPainter &painter, int x, int y, TetrixShape shape); - - QBasicTimer timer; - QPointer<QLabel> nextPieceLabel; - bool isStarted; - bool isPaused; - bool isWaitingAfterLine; - TetrixPiece curPiece; - TetrixPiece nextPiece; - int curX; - int curY; - int numLinesRemoved; - int numPiecesDropped; - int score; - int level; - TetrixShape board[BoardWidth * BoardHeight]; -}; -//! [1] - -#endif diff --git a/examples/widgets/widgets/tetrix/tetrixpiece.cpp b/examples/widgets/widgets/tetrix/tetrixpiece.cpp deleted file mode 100644 index 9f6f6e863a..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixpiece.cpp +++ /dev/null @@ -1,153 +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 "tetrixpiece.h" - -#include <QtCore> - -//! [0] -void TetrixPiece::setRandomShape() -{ - setShape(TetrixShape(QRandomGenerator::global()->bounded(7) + 1)); -} -//! [0] - -//! [1] -void TetrixPiece::setShape(TetrixShape shape) -{ - static constexpr int coordsTable[8][4][2] = { - { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }, - { { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } }, - { { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } }, - { { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 } }, - { { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } }, - { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } }, - { { -1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } }, - { { 1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } } - }; - - for (int i = 0; i < 4 ; i++) { - for (int j = 0; j < 2; ++j) - coords[i][j] = coordsTable[shape][i][j]; - } - pieceShape = shape; -//! [1] //! [2] -} -//! [2] - -//! [3] -int TetrixPiece::minX() const -{ - int min = coords[0][0]; - for (int i = 1; i < 4; ++i) - min = qMin(min, coords[i][0]); - return min; -} - -int TetrixPiece::maxX() const -//! [3] //! [4] -{ - int max = coords[0][0]; - for (int i = 1; i < 4; ++i) - max = qMax(max, coords[i][0]); - return max; -} -//! [4] - -//! [5] -int TetrixPiece::minY() const -{ - int min = coords[0][1]; - for (int i = 1; i < 4; ++i) - min = qMin(min, coords[i][1]); - return min; -} - -int TetrixPiece::maxY() const -//! [5] //! [6] -{ - int max = coords[0][1]; - for (int i = 1; i < 4; ++i) - max = qMax(max, coords[i][1]); - return max; -} -//! [6] - -//! [7] -TetrixPiece TetrixPiece::rotatedLeft() const -{ - if (pieceShape == SquareShape) - return *this; - - TetrixPiece result; - result.pieceShape = pieceShape; - for (int i = 0; i < 4; ++i) { - result.setX(i, y(i)); - result.setY(i, -x(i)); - } -//! [7] - return result; -} - -//! [9] -TetrixPiece TetrixPiece::rotatedRight() const -{ - if (pieceShape == SquareShape) - return *this; - - TetrixPiece result; - result.pieceShape = pieceShape; - for (int i = 0; i < 4; ++i) { - result.setX(i, -y(i)); - result.setY(i, x(i)); - } -//! [9] - return result; -} diff --git a/examples/widgets/widgets/tetrix/tetrixpiece.h b/examples/widgets/widgets/tetrix/tetrixpiece.h deleted file mode 100644 index 0a01c23423..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixpiece.h +++ /dev/null @@ -1,85 +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 TETRIXPIECE_H -#define TETRIXPIECE_H - -enum TetrixShape { NoShape, ZShape, SShape, LineShape, TShape, SquareShape, - LShape, MirroredLShape }; - -//! [0] -class TetrixPiece -{ -public: - TetrixPiece() { setShape(NoShape); } - - void setRandomShape(); - void setShape(TetrixShape shape); - - TetrixShape shape() const { return pieceShape; } - int x(int index) const { return coords[index][0]; } - int y(int index) const { return coords[index][1]; } - int minX() const; - int maxX() const; - int minY() const; - int maxY() const; - TetrixPiece rotatedLeft() const; - TetrixPiece rotatedRight() const; - -private: - void setX(int index, int x) { coords[index][0] = x; } - void setY(int index, int y) { coords[index][1] = y; } - - TetrixShape pieceShape; - int coords[4][2]; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.cpp b/examples/widgets/widgets/tetrix/tetrixwindow.cpp deleted file mode 100644 index 5aa5c3f615..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixwindow.cpp +++ /dev/null @@ -1,138 +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 "tetrixboard.h" -#include "tetrixwindow.h" - -#include <QCoreApplication> -#include <QGridLayout> -#include <QLabel> -#include <QLCDNumber> -#include <QPushButton> - -//! [0] -TetrixWindow::TetrixWindow(QWidget *parent) - : QWidget(parent), board(new TetrixBoard) -{ -//! [0] - nextPieceLabel = new QLabel; - nextPieceLabel->setFrameStyle(QFrame::Box | QFrame::Raised); - nextPieceLabel->setAlignment(Qt::AlignCenter); - board->setNextPieceLabel(nextPieceLabel); -//! [1] - scoreLcd = new QLCDNumber(5); - scoreLcd->setSegmentStyle(QLCDNumber::Filled); -//! [1] - levelLcd = new QLCDNumber(2); - levelLcd->setSegmentStyle(QLCDNumber::Filled); - linesLcd = new QLCDNumber(5); - linesLcd->setSegmentStyle(QLCDNumber::Filled); - -//! [2] - startButton = new QPushButton(tr("&Start")); - startButton->setFocusPolicy(Qt::NoFocus); - quitButton = new QPushButton(tr("&Quit")); - quitButton->setFocusPolicy(Qt::NoFocus); - pauseButton = new QPushButton(tr("&Pause")); -//! [2] //! [3] - pauseButton->setFocusPolicy(Qt::NoFocus); -//! [3] //! [4] - - connect(startButton, &QPushButton::clicked, board, &TetrixBoard::start); -//! [4] //! [5] - connect(quitButton , &QPushButton::clicked, qApp, &QCoreApplication::quit); - connect(pauseButton, &QPushButton::clicked, board, &TetrixBoard::pause); -#if __cplusplus >= 201402L - connect(board, &TetrixBoard::scoreChanged, - scoreLcd, qOverload<int>(&QLCDNumber::display)); - connect(board, &TetrixBoard::levelChanged, - levelLcd, qOverload<int>(&QLCDNumber::display)); - connect(board, &TetrixBoard::linesRemovedChanged, - linesLcd, qOverload<int>(&QLCDNumber::display)); -#else - connect(board, &TetrixBoard::scoreChanged, - scoreLcd, QOverload<int>::of(&QLCDNumber::display)); - connect(board, &TetrixBoard::levelChanged, - levelLcd, QOverload<int>::of(&QLCDNumber::display)); - connect(board, &TetrixBoard::linesRemovedChanged, - linesLcd, QOverload<int>::of(&QLCDNumber::display)); -#endif -//! [5] - -//! [6] - QGridLayout *layout = new QGridLayout; - layout->addWidget(createLabel(tr("NEXT")), 0, 0); - layout->addWidget(nextPieceLabel, 1, 0); - layout->addWidget(createLabel(tr("LEVEL")), 2, 0); - layout->addWidget(levelLcd, 3, 0); - layout->addWidget(startButton, 4, 0); - layout->addWidget(board, 0, 1, 6, 1); - layout->addWidget(createLabel(tr("SCORE")), 0, 2); - layout->addWidget(scoreLcd, 1, 2); - layout->addWidget(createLabel(tr("LINES REMOVED")), 2, 2); - layout->addWidget(linesLcd, 3, 2); - layout->addWidget(quitButton, 4, 2); - layout->addWidget(pauseButton, 5, 2); - setLayout(layout); - - setWindowTitle(tr("Tetrix")); - resize(550, 370); -} -//! [6] - -//! [7] -QLabel *TetrixWindow::createLabel(const QString &text) -{ - QLabel *label = new QLabel(text); - label->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); - return label; -} -//! [7] - diff --git a/examples/widgets/widgets/tetrix/tetrixwindow.h b/examples/widgets/widgets/tetrix/tetrixwindow.h deleted file mode 100644 index 3743d6cd2a..0000000000 --- a/examples/widgets/widgets/tetrix/tetrixwindow.h +++ /dev/null @@ -1,85 +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 TETRIXWINDOW_H -#define TETRIXWINDOW_H - -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QLCDNumber; -class QLabel; -class QPushButton; -QT_END_NAMESPACE -class TetrixBoard; - -//! [0] -class TetrixWindow : public QWidget -{ - Q_OBJECT - -public: - TetrixWindow(QWidget *parent = nullptr); - -private: - QLabel *createLabel(const QString &text); - - TetrixBoard *board; - QLabel *nextPieceLabel; - QLCDNumber *scoreLcd; - QLCDNumber *levelLcd; - QLCDNumber *linesLcd; - QPushButton *startButton; - QPushButton *quitButton; - QPushButton *pauseButton; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/tooltips/CMakeLists.txt b/examples/widgets/widgets/tooltips/CMakeLists.txt deleted file mode 100644 index bde6e4fc27..0000000000 --- a/examples/widgets/widgets/tooltips/CMakeLists.txt +++ /dev/null @@ -1,56 +0,0 @@ -# Generated from tooltips.pro. - -cmake_minimum_required(VERSION 3.14) -project(tooltips 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/widgets/tooltips") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(tooltips - main.cpp - shapeitem.cpp shapeitem.h - sortingbox.cpp sortingbox.h -) -set_target_properties(tooltips PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(tooltips PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(tooltips_resource_files - "images/circle.png" - "images/square.png" - "images/triangle.png" -) - -qt6_add_resources(tooltips "tooltips" - PREFIX - "/" - FILES - ${tooltips_resource_files} -) - -install(TARGETS tooltips - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/tooltips/images/circle.png b/examples/widgets/widgets/tooltips/images/circle.png Binary files differdeleted file mode 100644 index dc392cb3f7..0000000000 --- a/examples/widgets/widgets/tooltips/images/circle.png +++ /dev/null diff --git a/examples/widgets/widgets/tooltips/images/square.png b/examples/widgets/widgets/tooltips/images/square.png Binary files differdeleted file mode 100644 index c0fd2d540a..0000000000 --- a/examples/widgets/widgets/tooltips/images/square.png +++ /dev/null diff --git a/examples/widgets/widgets/tooltips/images/triangle.png b/examples/widgets/widgets/tooltips/images/triangle.png Binary files differdeleted file mode 100644 index 2ee15f8f1f..0000000000 --- a/examples/widgets/widgets/tooltips/images/triangle.png +++ /dev/null diff --git a/examples/widgets/widgets/tooltips/main.cpp b/examples/widgets/widgets/tooltips/main.cpp deleted file mode 100644 index 0890020f77..0000000000 --- a/examples/widgets/widgets/tooltips/main.cpp +++ /dev/null @@ -1,63 +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 "sortingbox.h" - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(tooltips); - - QApplication app(argc, argv); - SortingBox sortingBox; - sortingBox.show(); - return app.exec(); -} diff --git a/examples/widgets/widgets/tooltips/shapeitem.cpp b/examples/widgets/widgets/tooltips/shapeitem.cpp deleted file mode 100644 index 68cc744b84..0000000000 --- a/examples/widgets/widgets/tooltips/shapeitem.cpp +++ /dev/null @@ -1,107 +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 "shapeitem.h" - -//! [0] -QPainterPath ShapeItem::path() const -{ - return myPath; -} -//! [0] - -//! [1] -QPoint ShapeItem::position() const -{ - return myPosition; -} -//! [1] - -//! [2] -QColor ShapeItem::color() const -{ - return myColor; -} -//! [2] - -//! [3] -QString ShapeItem::toolTip() const -{ - return myToolTip; -} -//! [3] - -//! [4] -void ShapeItem::setPath(const QPainterPath &path) -{ - myPath = path; -} -//! [4] - -//! [5] -void ShapeItem::setToolTip(const QString &toolTip) -{ - myToolTip = toolTip; -} -//! [5] - -//! [6] -void ShapeItem::setPosition(const QPoint &position) -{ - myPosition = position; -} -//! [6] - -//! [7] -void ShapeItem::setColor(const QColor &color) -{ - myColor = color; -} -//! [7] diff --git a/examples/widgets/widgets/tooltips/shapeitem.h b/examples/widgets/widgets/tooltips/shapeitem.h deleted file mode 100644 index 6ca7ac278e..0000000000 --- a/examples/widgets/widgets/tooltips/shapeitem.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SHAPEITEM_H -#define SHAPEITEM_H - -#include <QColor> -#include <QPainterPath> -#include <QPoint> - -//! [0] -class ShapeItem -{ -public: - void setPath(const QPainterPath &path); - void setToolTip(const QString &toolTip); - void setPosition(const QPoint &position); - void setColor(const QColor &color); - - QPainterPath path() const; - QPoint position() const; - QColor color() const; - QString toolTip() const; - -private: - QPainterPath myPath; - QPoint myPosition; - QColor myColor; - QString myToolTip; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp deleted file mode 100644 index d993b098b2..0000000000 --- a/examples/widgets/widgets/tooltips/sortingbox.cpp +++ /dev/null @@ -1,316 +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 "sortingbox.h" - -#include <QMouseEvent> -#include <QIcon> -#include <QPainter> -#include <QRandomGenerator> -#include <QStyle> -#include <QToolButton> -#include <QToolTip> - -//! [0] -SortingBox::SortingBox(QWidget *parent) - : QWidget(parent) -{ -//! [0] //! [1] - setMouseTracking(true); -//! [1] //! [2] - setBackgroundRole(QPalette::Base); -//! [2] - - itemInMotion = nullptr; - -//! [3] - newCircleButton = createToolButton(tr("New Circle"), - QIcon(":/images/circle.png"), - SLOT(createNewCircle())); - - newSquareButton = createToolButton(tr("New Square"), - QIcon(":/images/square.png"), - SLOT(createNewSquare())); - - newTriangleButton = createToolButton(tr("New Triangle"), - QIcon(":/images/triangle.png"), - SLOT(createNewTriangle())); - - circlePath.addEllipse(QRect(0, 0, 100, 100)); - squarePath.addRect(QRect(0, 0, 100, 100)); - - qreal x = trianglePath.currentPosition().x(); - qreal y = trianglePath.currentPosition().y(); - trianglePath.moveTo(x + 120 / 2, y); - trianglePath.lineTo(0, 100); - trianglePath.lineTo(120, 100); - trianglePath.lineTo(x + 120 / 2, y); - -//! [3] //! [4] - setWindowTitle(tr("Tool Tips")); - resize(500, 300); - - createShapeItem(circlePath, tr("Circle"), initialItemPosition(circlePath), - initialItemColor()); - createShapeItem(squarePath, tr("Square"), initialItemPosition(squarePath), - initialItemColor()); - createShapeItem(trianglePath, tr("Triangle"), - initialItemPosition(trianglePath), initialItemColor()); -} -//! [4] - -//! [5] -bool SortingBox::event(QEvent *event) -{ -//! [5] //! [6] - if (event->type() == QEvent::ToolTip) { - QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); - int index = itemAt(helpEvent->pos()); - if (index != -1) { - QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip()); - } else { - QToolTip::hideText(); - event->ignore(); - } - - return true; - } - return QWidget::event(event); -} -//! [6] - -//! [7] -void SortingBox::resizeEvent(QResizeEvent * /* event */) -{ - int margin = style()->pixelMetric(QStyle::PM_LayoutTopMargin); - int x = width() - margin; - int y = height() - margin; - - y = updateButtonGeometry(newCircleButton, x, y); - y = updateButtonGeometry(newSquareButton, x, y); - updateButtonGeometry(newTriangleButton, x, y); -} -//! [7] - -//! [8] -void SortingBox::paintEvent(QPaintEvent * /* event */) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - for (const ShapeItem &shapeItem : qAsConst(shapeItems)) { -//! [8] //! [9] - painter.translate(shapeItem.position()); -//! [9] //! [10] - painter.setBrush(shapeItem.color()); - painter.drawPath(shapeItem.path()); - painter.translate(-shapeItem.position()); - } -} -//! [10] - -//! [11] -void SortingBox::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - int index = itemAt(event->position().toPoint()); - if (index != -1) { - itemInMotion = &shapeItems[index]; - previousPosition = event->position().toPoint(); - shapeItems.move(index, shapeItems.size() - 1); - update(); - } - } -} -//! [11] - -//! [12] -void SortingBox::mouseMoveEvent(QMouseEvent *event) -{ - if ((event->buttons() & Qt::LeftButton) && itemInMotion) - moveItemTo(event->position().toPoint()); -} -//! [12] - -//! [13] -void SortingBox::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton && itemInMotion) { - moveItemTo(event->position().toPoint()); - itemInMotion = nullptr; - } -} -//! [13] - -//! [14] -void SortingBox::createNewCircle() -{ - static int count = 1; - createShapeItem(circlePath, tr("Circle <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [14] - -//! [15] -void SortingBox::createNewSquare() -{ - static int count = 1; - createShapeItem(squarePath, tr("Square <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [15] - -//! [16] -void SortingBox::createNewTriangle() -{ - static int count = 1; - createShapeItem(trianglePath, tr("Triangle <%1>").arg(++count), - randomItemPosition(), randomItemColor()); -} -//! [16] - -//! [17] -int SortingBox::itemAt(const QPoint &pos) -{ - for (int i = shapeItems.size() - 1; i >= 0; --i) { - const ShapeItem &item = shapeItems[i]; - if (item.path().contains(pos - item.position())) - return i; - } - return -1; -} -//! [17] - -//! [18] -void SortingBox::moveItemTo(const QPoint &pos) -{ - QPoint offset = pos - previousPosition; - itemInMotion->setPosition(itemInMotion->position() + offset); -//! [18] //! [19] - previousPosition = pos; - update(); -} -//! [19] - -//! [20] -int SortingBox::updateButtonGeometry(QToolButton *button, int x, int y) -{ - QSize size = button->sizeHint(); - button->setGeometry(x - size.rwidth(), y - size.rheight(), - size.rwidth(), size.rheight()); - - return y - size.rheight() - - style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing); -} -//! [20] - -//! [21] -void SortingBox::createShapeItem(const QPainterPath &path, - const QString &toolTip, const QPoint &pos, - const QColor &color) -{ - ShapeItem shapeItem; - shapeItem.setPath(path); - shapeItem.setToolTip(toolTip); - shapeItem.setPosition(pos); - shapeItem.setColor(color); - shapeItems.append(shapeItem); - update(); -} -//! [21] - -//! [22] -QToolButton *SortingBox::createToolButton(const QString &toolTip, - const QIcon &icon, const char *member) -{ - QToolButton *button = new QToolButton(this); - button->setToolTip(toolTip); - button->setIcon(icon); - button->setIconSize(QSize(32, 32)); - connect(button, SIGNAL(clicked()), this, member); - - return button; -} -//! [22] - -//! [23] -QPoint SortingBox::initialItemPosition(const QPainterPath &path) -{ - int x; - int y = (height() - qRound(path.controlPointRect().height()) / 2); - if (shapeItems.size() == 0) - x = ((3 * width()) / 2 - qRound(path.controlPointRect().width())) / 2; - else - x = (width() / shapeItems.size() - - qRound(path.controlPointRect().width())) / 2; - - return QPoint(x, y); -} -//! [23] - -//! [24] -QPoint SortingBox::randomItemPosition() -{ - return QPoint(QRandomGenerator::global()->bounded(width() - 120), QRandomGenerator::global()->bounded(height() - 120)); -} -//! [24] - -//! [25] -QColor SortingBox::initialItemColor() -{ - return QColor::fromHsv(((shapeItems.size() + 1) * 85) % 256, 255, 190); -} -//! [25] - -//! [26] -QColor SortingBox::randomItemColor() -{ - return QColor::fromHsv(QRandomGenerator::global()->bounded(256), 255, 190); -} -//! [26] diff --git a/examples/widgets/widgets/tooltips/sortingbox.h b/examples/widgets/widgets/tooltips/sortingbox.h deleted file mode 100644 index 3d0cecea2b..0000000000 --- a/examples/widgets/widgets/tooltips/sortingbox.h +++ /dev/null @@ -1,116 +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 SORTINGBOX_H -#define SORTINGBOX_H - -#include "shapeitem.h" - -#include <QWidget> - -QT_BEGIN_NAMESPACE -class QAction; -class QPoint; -class QToolButton; -QT_END_NAMESPACE - -//! [0] -class SortingBox : public QWidget -{ - Q_OBJECT - -public: - SortingBox(QWidget *parent = nullptr); - -protected: - bool event(QEvent *event) override; - void resizeEvent(QResizeEvent *event) override; - void paintEvent(QPaintEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - -private slots: - void createNewCircle(); - void createNewSquare(); - void createNewTriangle(); -//! [0] - -//! [1] -private: - int updateButtonGeometry(QToolButton *button, int x, int y); - void createShapeItem(const QPainterPath &path, const QString &toolTip, - const QPoint &pos, const QColor &color); - int itemAt(const QPoint &pos); - void moveItemTo(const QPoint &pos); - QPoint initialItemPosition(const QPainterPath &path); - QPoint randomItemPosition(); - QColor initialItemColor(); - QColor randomItemColor(); - QToolButton *createToolButton(const QString &toolTip, const QIcon &icon, -//! [1] - const char *member); - -//! [2] - QList<ShapeItem> shapeItems; - QPainterPath circlePath; - QPainterPath squarePath; - QPainterPath trianglePath; - - QPoint previousPosition; - ShapeItem *itemInMotion; - - QToolButton *newCircleButton; - QToolButton *newSquareButton; - QToolButton *newTriangleButton; -}; -//! [2] - -#endif diff --git a/examples/widgets/widgets/tooltips/tooltips.pro b/examples/widgets/widgets/tooltips/tooltips.pro deleted file mode 100644 index d14b8295ba..0000000000 --- a/examples/widgets/widgets/tooltips/tooltips.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets - -HEADERS = shapeitem.h \ - sortingbox.h -SOURCES = main.cpp \ - shapeitem.cpp \ - sortingbox.cpp -RESOURCES = tooltips.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/tooltips -INSTALLS += target diff --git a/examples/widgets/widgets/tooltips/tooltips.qrc b/examples/widgets/widgets/tooltips/tooltips.qrc deleted file mode 100644 index dabc894e9b..0000000000 --- a/examples/widgets/widgets/tooltips/tooltips.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>images/circle.png</file> - <file>images/square.png</file> - <file>images/triangle.png</file> -</qresource> -</RCC> diff --git a/examples/widgets/widgets/validators/CMakeLists.txt b/examples/widgets/widgets/validators/CMakeLists.txt deleted file mode 100644 index d5ea9b833e..0000000000 --- a/examples/widgets/widgets/validators/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Generated from validators.pro. - -cmake_minimum_required(VERSION 3.14) -project(validators 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/widgets/validators") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(validators - ledwidget.cpp ledwidget.h - localeselector.cpp localeselector.h - main.cpp - validators.ui - validatorwidget.cpp validatorwidget.h -) -set_target_properties(validators PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(validators PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(validators_resource_files - "ledoff.png" - "ledon.png" -) - -qt6_add_resources(validators "validators" - PREFIX - "/" - FILES - ${validators_resource_files} -) - -install(TARGETS validators - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/validators/ledoff.png b/examples/widgets/widgets/validators/ledoff.png Binary files differdeleted file mode 100644 index 8b1f2ed123..0000000000 --- a/examples/widgets/widgets/validators/ledoff.png +++ /dev/null diff --git a/examples/widgets/widgets/validators/ledon.png b/examples/widgets/widgets/validators/ledon.png Binary files differdeleted file mode 100644 index 601c34d5a8..0000000000 --- a/examples/widgets/widgets/validators/ledon.png +++ /dev/null diff --git a/examples/widgets/widgets/validators/ledwidget.cpp b/examples/widgets/widgets/validators/ledwidget.cpp deleted file mode 100644 index 462f416c86..0000000000 --- a/examples/widgets/widgets/validators/ledwidget.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 "ledwidget.h" - -LEDWidget::LEDWidget(QWidget *parent) - : QLabel(parent), onPixmap(":/ledon.png"), offPixmap(":/ledoff.png") -{ - setPixmap(offPixmap); - flashTimer.setInterval(200); - flashTimer.setSingleShot(true); - connect(&flashTimer, &QTimer::timeout, this, &LEDWidget::extinguish); -}; - -void LEDWidget::extinguish() -{ - setPixmap(offPixmap); -} - -void LEDWidget::flash() -{ - setPixmap(onPixmap); - flashTimer.start(); -} - diff --git a/examples/widgets/widgets/validators/ledwidget.h b/examples/widgets/widgets/validators/ledwidget.h deleted file mode 100644 index c4b406db23..0000000000 --- a/examples/widgets/widgets/validators/ledwidget.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 LEDWIDGET_H -#define LEDWIDGET_H - -#include <QLabel> -#include <QPixmap> -#include <QTimer> - -class LEDWidget : public QLabel -{ - Q_OBJECT -public: - LEDWidget(QWidget *parent = nullptr); -public slots: - void flash(); - -private slots: - void extinguish(); - -private: - QPixmap onPixmap, offPixmap; - QTimer flashTimer; -}; - -#endif // LEDWIDGET_H diff --git a/examples/widgets/widgets/validators/localeselector.cpp b/examples/widgets/widgets/validators/localeselector.cpp deleted file mode 100644 index 3dcd04d9ff..0000000000 --- a/examples/widgets/widgets/validators/localeselector.cpp +++ /dev/null @@ -1,95 +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 "localeselector.h" - -#include <QLocale> - -LocaleSelector::LocaleSelector(QWidget *parent) - : QComboBox(parent) -{ - int curIndex = -1; - int index = 0; - for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { - QLocale::Language lang = static_cast<QLocale::Language>(_lang); - const QList<QLocale> locales = - QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyCountry); - for (const QLocale &l : locales) { - QString label = QLocale::languageToString(l.language()); - label += QLatin1Char('/'); - label += QLocale::countryToString(l.country()); - // distinguish locales by script, if there are more than one script for a language/country pair - if (QLocale::matchingLocales(l.language(), QLocale::AnyScript, l.country()).size() > 1) - label += QLatin1String(" (") + QLocale::scriptToString(l.script()) + QLatin1Char(')'); - - addItem(label, QVariant::fromValue(l)); - - if (l.language() == locale().language() && l.country() == locale().country() - && (locale().script() == QLocale::AnyScript || l.script() == locale().script())) { - curIndex = index; - } - ++index; - } - } - if (curIndex != -1) - setCurrentIndex(curIndex); - - connect(this, QOverload<int>::of(&LocaleSelector::activated), - this, &LocaleSelector::emitLocaleSelected); -} - -void LocaleSelector::emitLocaleSelected(int index) -{ - QVariant v = itemData(index); - if (!v.isValid()) - return; - const QLocale l = qvariant_cast<QLocale>(v); - emit localeSelected(l); -} diff --git a/examples/widgets/widgets/validators/localeselector.h b/examples/widgets/widgets/validators/localeselector.h deleted file mode 100644 index 611e2da66e..0000000000 --- a/examples/widgets/widgets/validators/localeselector.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 LOCALESELECTOR_H -#define LOCALESELECTOR_H - -#include <QComboBox> - -class LocaleSelector : public QComboBox -{ - Q_OBJECT - -public: - LocaleSelector(QWidget *parent = nullptr); - -signals: - void localeSelected(const QLocale &locale); - -private slots: - void emitLocaleSelected(int index); -}; - -#endif //LOCALESELECTOR_H diff --git a/examples/widgets/widgets/validators/main.cpp b/examples/widgets/widgets/validators/main.cpp deleted file mode 100644 index 1fbf12410d..0000000000 --- a/examples/widgets/widgets/validators/main.cpp +++ /dev/null @@ -1,65 +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 "validatorwidget.h" - -#include <QApplication> - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(validators); - - QApplication app(argc, argv); - - ValidatorWidget w; - w.show(); - - return app.exec(); -} diff --git a/examples/widgets/widgets/validators/validators.pro b/examples/widgets/widgets/validators/validators.pro deleted file mode 100644 index 029cf95aca..0000000000 --- a/examples/widgets/widgets/validators/validators.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += widgets -requires(qtConfig(combobox)) - -FORMS += validators.ui -RESOURCES += validators.qrc - -SOURCES += main.cpp ledwidget.cpp localeselector.cpp validatorwidget.cpp -HEADERS += ledwidget.h localeselector.h validatorwidget.h - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/validators -INSTALLS += target diff --git a/examples/widgets/widgets/validators/validators.qrc b/examples/widgets/widgets/validators/validators.qrc deleted file mode 100644 index 94874317a8..0000000000 --- a/examples/widgets/widgets/validators/validators.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/" > - <file>ledoff.png</file> - <file>ledon.png</file> - </qresource> -</RCC> diff --git a/examples/widgets/widgets/validators/validators.ui b/examples/widgets/widgets/validators/validators.ui deleted file mode 100644 index cd984e6b97..0000000000 --- a/examples/widgets/widgets/validators/validators.ui +++ /dev/null @@ -1,468 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ValidatorsForm</class> - <widget class="QWidget" name="ValidatorsForm"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>526</width> - <height>443</height> - </rect> - </property> - <property name="windowTitle"> - <string>Validators</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <widget class="LocaleSelector" name="localeSelector"/> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>QIntValidator</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <layout class="QGridLayout"> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Min:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="minVal"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <number>-1000000</number> - </property> - <property name="maximum"> - <number>1000000</number> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Max:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="maxVal"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <number>-1000000</number> - </property> - <property name="maximum"> - <number>1000000</number> - </property> - <property name="value"> - <number>1000</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QFrame" name="frame"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="LEDWidget" name="ledWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="pixmap"> - <pixmap resource="validators.qrc">:/ledoff.png</pixmap> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>editingFinished()</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLineEdit" name="editor"/> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>QDoubleValidator</string> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <layout class="QGridLayout"> - <property name="margin"> - <number>0</number> - </property> - <property name="spacing"> - <number>6</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Min:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QDoubleSpinBox" name="doubleMinVal"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <double>-100000.000000000000000</double> - </property> - <property name="maximum"> - <double>100000.000000000000000</double> - </property> - <property name="value"> - <double>0.000000000000000</double> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Format:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QComboBox" name="doubleFormat"> - <item> - <property name="text"> - <string>Standard</string> - </property> - </item> - <item> - <property name="text"> - <string>Scientific</string> - </property> - </item> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Max:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QDoubleSpinBox" name="doubleMaxVal"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimum"> - <double>-100000.000000000000000</double> - </property> - <property name="maximum"> - <double>100000.000000000000000</double> - </property> - <property name="value"> - <double>1000.000000000000000</double> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Decimals:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="3"> - <widget class="QSpinBox" name="doubleDecimals"> - <property name="value"> - <number>2</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QFrame" name="frame_2"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <layout class="QVBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>9</number> - </property> - <item> - <widget class="LEDWidget" name="doubleLedWidget"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="validators.qrc">:/ledoff.png</pixmap> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>editingFinished()</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLineEdit" name="doubleEditor"/> - </item> - </layout> - </widget> - </item> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>111</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QHBoxLayout"> - <property name="spacing"> - <number>6</number> - </property> - <property name="margin"> - <number>0</number> - </property> - <item> - <spacer> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>Quit</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>LEDWidget</class> - <extends>QLabel</extends> - <header>ledwidget.h</header> - </customwidget> - <customwidget> - <class>LocaleSelector</class> - <extends>QComboBox</extends> - <header>localeselector.h</header> - </customwidget> - </customwidgets> - <resources> - <include location="validators.qrc"/> - </resources> - <connections> - <connection> - <sender>pushButton</sender> - <signal>clicked()</signal> - <receiver>ValidatorsForm</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel"> - <x>94</x> - <y>274</y> - </hint> - <hint type="destinationlabel"> - <x>131</x> - <y>260</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/examples/widgets/widgets/validators/validatorwidget.cpp b/examples/widgets/widgets/validators/validatorwidget.cpp deleted file mode 100644 index 504eec4fe7..0000000000 --- a/examples/widgets/widgets/validators/validatorwidget.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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 "validatorwidget.h" - -#include <QIntValidator> - -ValidatorWidget::ValidatorWidget(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - - connect(localeSelector, &LocaleSelector::localeSelected, - this, &ValidatorWidget::setLocale); - connect(localeSelector, &LocaleSelector::localeSelected, - this, &ValidatorWidget::updateValidator); - connect(localeSelector, &LocaleSelector::localeSelected, - this, &ValidatorWidget::updateDoubleValidator); - - connect(minVal, &QSpinBox::editingFinished, - this, &ValidatorWidget::updateValidator); - connect(maxVal, &QSpinBox::editingFinished, - this, &ValidatorWidget::updateValidator); - connect(editor, &QLineEdit::editingFinished, - ledWidget, &LEDWidget::flash); - - connect(doubleMaxVal, &QDoubleSpinBox::editingFinished, - this, &ValidatorWidget::updateDoubleValidator); - connect(doubleMinVal, &QDoubleSpinBox::editingFinished, - this, &ValidatorWidget::updateDoubleValidator); - connect(doubleDecimals, &QSpinBox::valueChanged, - this, &ValidatorWidget::updateDoubleValidator); - connect(doubleFormat, &QComboBox::activated, - this, &ValidatorWidget::updateDoubleValidator); - connect(doubleEditor, &QLineEdit::editingFinished, - doubleLedWidget, &LEDWidget::flash); - - updateValidator(); - updateDoubleValidator(); -} - -void ValidatorWidget::updateValidator() -{ - QIntValidator *v = new QIntValidator(minVal->value(), maxVal->value(), this); - v->setLocale(locale()); - delete editor->validator(); - editor->setValidator(v); - - QString s = editor->text(); - int i = 0; - if (v->validate(s, i) == QValidator::Invalid) { - editor->clear(); - } else { - editor->setText(s); - } -} - -void ValidatorWidget::updateDoubleValidator() -{ - QDoubleValidator *v - = new QDoubleValidator(doubleMinVal->value(), doubleMaxVal->value(), - doubleDecimals->value(), this); - v->setNotation(static_cast<QDoubleValidator::Notation>(doubleFormat->currentIndex())); - v->setLocale(locale()); - delete doubleEditor->validator(); - doubleEditor->setValidator(v); - - QString s = doubleEditor->text(); - int i = 0; - if (v->validate(s, i) == QValidator::Invalid) { - doubleEditor->clear(); - } else { - doubleEditor->setText(s); - } -} diff --git a/examples/widgets/widgets/validators/validatorwidget.h b/examples/widgets/widgets/validators/validatorwidget.h deleted file mode 100644 index bcc4a9b91e..0000000000 --- a/examples/widgets/widgets/validators/validatorwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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 <QWidget> - -#include "ui_validators.h" - -class ValidatorWidget : public QWidget, public Ui::ValidatorsForm -{ - Q_OBJECT -public: - ValidatorWidget(QWidget *parent = nullptr); - -private slots: - void updateValidator(); - void updateDoubleValidator(); -}; diff --git a/examples/widgets/widgets/widgets.pro b/examples/widgets/widgets/widgets.pro index fe3e289944..5dd8f5eedc 100644 --- a/examples/widgets/widgets/widgets.pro +++ b/examples/widgets/widgets/widgets.pro @@ -2,25 +2,10 @@ TEMPLATE = subdirs SUBDIRS = analogclock \ calculator \ calendarwidget \ - charactermap \ - codeeditor \ - digitalclock \ - elidedlabel \ - groupbox \ - icons \ - imageviewer \ lineedits \ - movie \ - mousebuttons \ scribble \ shapedclock \ sliders \ spinboxes \ - styles \ - stylesheet \ tablet \ - tetrix \ - tooltips \ - validators \ - wiggly \ windowflags diff --git a/examples/widgets/widgets/wiggly/CMakeLists.txt b/examples/widgets/widgets/wiggly/CMakeLists.txt deleted file mode 100644 index daf816d46e..0000000000 --- a/examples/widgets/widgets/wiggly/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# Generated from wiggly.pro. - -cmake_minimum_required(VERSION 3.14) -project(wiggly 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/widgets/wiggly") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -qt_add_executable(wiggly - dialog.cpp dialog.h - main.cpp - wigglywidget.cpp wigglywidget.h -) -set_target_properties(wiggly PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(wiggly PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS wiggly - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/widgets/wiggly/dialog.cpp b/examples/widgets/widgets/wiggly/dialog.cpp deleted file mode 100644 index a7a72b3570..0000000000 --- a/examples/widgets/widgets/wiggly/dialog.cpp +++ /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$ -** -****************************************************************************/ - -#include "dialog.h" -#include "wigglywidget.h" - -#include <QLineEdit> -#include <QVBoxLayout> - -//! [0] -Dialog::Dialog(QWidget *parent) - : QDialog(parent) -{ - WigglyWidget *wigglyWidget = new WigglyWidget; - QLineEdit *lineEdit = new QLineEdit; - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->addWidget(wigglyWidget); - layout->addWidget(lineEdit); - - connect(lineEdit, &QLineEdit::textChanged, wigglyWidget, &WigglyWidget::setText); - lineEdit->setText(tr("Hello world!")); - - setWindowTitle(tr("Wiggly")); - resize(360, 145); -} -//! [0] diff --git a/examples/widgets/widgets/wiggly/dialog.h b/examples/widgets/widgets/wiggly/dialog.h deleted file mode 100644 index 357b6354b5..0000000000 --- a/examples/widgets/widgets/wiggly/dialog.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 DIALOG_H -#define DIALOG_H - -#include <QDialog> - -//! [0] -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = nullptr); -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/wiggly/main.cpp b/examples/widgets/widgets/wiggly/main.cpp deleted file mode 100644 index cd888c4084..0000000000 --- a/examples/widgets/widgets/wiggly/main.cpp +++ /dev/null @@ -1,63 +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 "dialog.h" - -#include <QApplication> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - Dialog dialog; - dialog.show(); - - return app.exec(); -} diff --git a/examples/widgets/widgets/wiggly/wiggly.pro b/examples/widgets/widgets/wiggly/wiggly.pro deleted file mode 100644 index 0e39f18add..0000000000 --- a/examples/widgets/widgets/wiggly/wiggly.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += widgets - -HEADERS = wigglywidget.h \ - dialog.h -SOURCES = wigglywidget.cpp \ - dialog.cpp \ - main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/widgets/wiggly -INSTALLS += target diff --git a/examples/widgets/widgets/wiggly/wigglywidget.cpp b/examples/widgets/widgets/wiggly/wigglywidget.cpp deleted file mode 100644 index ab549ef07c..0000000000 --- a/examples/widgets/widgets/wiggly/wigglywidget.cpp +++ /dev/null @@ -1,111 +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 "wigglywidget.h" - -#include <QFontMetrics> -#include <QPainter> -#include <QTimerEvent> - -//! [0] -WigglyWidget::WigglyWidget(QWidget *parent) - : QWidget(parent), step(0) -{ - setBackgroundRole(QPalette::Midlight); - setAutoFillBackground(true); - - QFont newFont = font(); - newFont.setPointSize(newFont.pointSize() + 20); - setFont(newFont); - - timer.start(60, this); -} -//! [0] - -//! [1] -void WigglyWidget::paintEvent(QPaintEvent * /* event */) -//! [1] //! [2] -{ - static constexpr int sineTable[16] = { - 0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38 - }; - - QFontMetrics metrics(font()); - int x = (width() - metrics.horizontalAdvance(text)) / 2; - int y = (height() + metrics.ascent() - metrics.descent()) / 2; - QColor color; -//! [2] - -//! [3] - QPainter painter(this); -//! [3] //! [4] - for (int i = 0; i < text.size(); ++i) { - int index = (step + i) % 16; - color.setHsv((15 - index) * 16, 255, 191); - painter.setPen(color); - painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400), - QString(text[i])); - x += metrics.horizontalAdvance(text[i]); - } -} -//! [4] - -//! [5] -void WigglyWidget::timerEvent(QTimerEvent *event) -//! [5] //! [6] -{ - if (event->timerId() == timer.timerId()) { - ++step; - update(); - } else { - QWidget::timerEvent(event); - } -//! [6] -} diff --git a/examples/widgets/widgets/wiggly/wigglywidget.h b/examples/widgets/widgets/wiggly/wigglywidget.h deleted file mode 100644 index 1d909c34da..0000000000 --- a/examples/widgets/widgets/wiggly/wigglywidget.h +++ /dev/null @@ -1,79 +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 WIGGLYWIDGET_H -#define WIGGLYWIDGET_H - -#include <QBasicTimer> -#include <QWidget> - -//! [0] -class WigglyWidget : public QWidget -{ - Q_OBJECT - -public: - WigglyWidget(QWidget *parent = nullptr); - -public slots: - void setText(const QString &newText) { text = newText; } - -protected: - void paintEvent(QPaintEvent *event) override; - void timerEvent(QTimerEvent *event) override; - -private: - QBasicTimer timer; - QString text; - int step; -}; -//! [0] - -#endif diff --git a/examples/widgets/widgets/windowflags/CMakeLists.txt b/examples/widgets/widgets/windowflags/CMakeLists.txt index 93ab0d9dbf..fbc1bf217b 100644 --- a/examples/widgets/widgets/windowflags/CMakeLists.txt +++ b/examples/widgets/widgets/windowflags/CMakeLists.txt @@ -1,41 +1,39 @@ -# Generated from windowflags.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(windowflags LANGUAGES CXX) -set(CMAKE_INCLUDE_CURRENT_DIR ON) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/widgets/windowflags") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) +qt_standard_project_setup() qt_add_executable(windowflags controllerwindow.cpp controllerwindow.h main.cpp previewwindow.cpp previewwindow.h ) + set_target_properties(windowflags PROPERTIES WIN32_EXECUTABLE TRUE MACOSX_BUNDLE TRUE ) -target_link_libraries(windowflags PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets + +target_link_libraries(windowflags PRIVATE + Qt6::Core + Qt6::Gui + Qt6::Widgets ) install(TARGETS windowflags - 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 windowflags + OUTPUT_SCRIPT deploy_script + NO_UNSUPPORTED_PLATFORM_ERROR ) +install(SCRIPT ${deploy_script}) diff --git a/examples/widgets/widgets/windowflags/controllerwindow.cpp b/examples/widgets/widgets/windowflags/controllerwindow.cpp index 0e9a916988..80d5f9e59b 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.cpp +++ b/examples/widgets/widgets/windowflags/controllerwindow.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 "controllerwindow.h" diff --git a/examples/widgets/widgets/windowflags/controllerwindow.h b/examples/widgets/widgets/windowflags/controllerwindow.h index 43ec67e27f..de76efbd20 100644 --- a/examples/widgets/widgets/windowflags/controllerwindow.h +++ b/examples/widgets/widgets/windowflags/controllerwindow.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 CONTROLLERWINDOW_H #define CONTROLLERWINDOW_H diff --git a/examples/widgets/widgets/windowflags/main.cpp b/examples/widgets/widgets/windowflags/main.cpp index 6732678047..b01716ddae 100644 --- a/examples/widgets/widgets/windowflags/main.cpp +++ b/examples/widgets/widgets/windowflags/main.cpp @@ -1,52 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QApplication> diff --git a/examples/widgets/widgets/windowflags/previewwindow.cpp b/examples/widgets/widgets/windowflags/previewwindow.cpp index d7ebed7b3c..bd4b7b4f40 100644 --- a/examples/widgets/widgets/windowflags/previewwindow.cpp +++ b/examples/widgets/widgets/windowflags/previewwindow.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 "previewwindow.h" @@ -124,6 +77,8 @@ void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) text += "\n| Qt::WindowShadeButtonHint"; if (flags & Qt::WindowStaysOnTopHint) text += "\n| Qt::WindowStaysOnTopHint"; + if (flags & Qt::WindowStaysOnBottomHint) + text += "\n| Qt::WindowStaysOnBottomHint"; if (flags & Qt::CustomizeWindowHint) text += "\n| Qt::CustomizeWindowHint"; diff --git a/examples/widgets/widgets/windowflags/previewwindow.h b/examples/widgets/widgets/windowflags/previewwindow.h index 9bb487e8ab..ada83c4c28 100644 --- a/examples/widgets/widgets/windowflags/previewwindow.h +++ b/examples/widgets/widgets/windowflags/previewwindow.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 PREVIEWWINDOW_H #define PREVIEWWINDOW_H |