aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/customitems/painteditem
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/customitems/painteditem')
-rw-r--r--examples/quick/customitems/painteditem/CMakeLists.txt82
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt28
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/plugin.h12
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/qmldir (renamed from examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir)1
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp56
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.h31
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.pro28
-rw-r--r--examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc5
-rw-r--r--examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h59
-rw-r--r--examples/quick/customitems/painteditem/doc/src/textballoons.qdoc51
-rw-r--r--examples/quick/customitems/painteditem/main.cpp4
-rw-r--r--examples/quick/customitems/painteditem/painteditem.pro31
-rw-r--r--examples/quick/customitems/painteditem/painteditem.qrc3
-rw-r--r--examples/quick/customitems/painteditem/textballoon.cpp103
-rw-r--r--examples/quick/customitems/painteditem/textballoon.h78
-rw-r--r--examples/quick/customitems/painteditem/textballoons.qml63
-rw-r--r--examples/quick/customitems/painteditem/textballoonuser.pro10
17 files changed, 228 insertions, 417 deletions
diff --git a/examples/quick/customitems/painteditem/CMakeLists.txt b/examples/quick/customitems/painteditem/CMakeLists.txt
index 533396a7cd..ca23161b1c 100644
--- a/examples/quick/customitems/painteditem/CMakeLists.txt
+++ b/examples/quick/customitems/painteditem/CMakeLists.txt
@@ -1,70 +1,46 @@
-# Generated from painteditem.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-cmake_minimum_required(VERSION 3.14)
-project(qmltextballoonplugin LANGUAGES CXX)
+cmake_minimum_required(VERSION 3.16)
+project(painteditem 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()
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick)
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/quick/customitems/painteditem/TextBalloonPlugin")
+qt_standard_project_setup(REQUIRES 6.5)
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Quick)
+add_subdirectory(TextBalloon)
-qt6_add_qml_module(qmltextballoonplugin
- OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/TextBalloonPlugin"
- VERSION 1.0
- URI "TextBalloonPlugin"
- INSTALL_LOCATION ${INSTALL_EXAMPLEDIR}
-)
+qt_add_executable(painteditemexample WIN32 MACOSX_BUNDLE main.cpp)
-target_sources(qmltextballoonplugin PRIVATE
- TextBalloonPlugin/plugin.h
- textballoon.cpp textballoon.h
-)
-set_target_properties(qmltextballoonplugin PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(qmltextballoonplugin PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::Quick
+qt_add_qml_module(painteditemexample
+ URI painteditem
+ QML_FILES
+ "textballoons.qml"
)
-
-# Resources:
-set(painteditem_resource_files
- "textballoon.h"
- "textballoons.qml"
+target_link_libraries(painteditemexample PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
)
-qt6_add_resources(qmltextballoonplugin "painteditem"
- PREFIX
- "/painteditem"
- FILES
- ${painteditem_resource_files}
-)
+add_dependencies(painteditemexample qmltextballoon)
-install(TARGETS qmltextballoonplugin
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+install(TARGETS painteditemexample
+ BUNDLE DESTINATION .
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-set_target_properties(qmltextballoonplugin PROPERTIES
- QT_QML_MODULE_VERSION 1.0
- QT_QML_MODULE_URI TextBalloonPlugin
+qt_generate_deploy_qml_app_script(
+ TARGET painteditemexample
+ OUTPUT_SCRIPT deploy_script
+ MACOS_BUNDLE_POST_BUILD
+ NO_UNSUPPORTED_PLATFORM_ERROR
+ DEPLOY_USER_QML_MODULES_ON_UNSUPPORTED_PLATFORM
)
-
-qt6_qml_type_registration(qmltextballoonplugin)
+install(SCRIPT ${deploy_script})
diff --git a/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt
new file mode 100644
index 0000000000..b94b297aeb
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ message(FATAL_ERROR "TextBalloon should be built as part of the 'painteditem' project, and not in isolation.")
+endif()
+
+qt_add_qml_module(qmltextballoon
+ URI "TextBalloon"
+ PLUGIN_TARGET qmltextballoon
+ SOURCES
+ textballoon.cpp textballoon.h
+)
+
+target_link_libraries(qmltextballoon PRIVATE
+ Qt6::Core
+ Qt6::Gui
+ Qt6::Qml
+ Qt6::Quick
+)
+
+install(TARGETS qmltextballoon
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/TextBalloon"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}/TextBalloon"
+)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
+ DESTINATION "${CMAKE_INSTALL_BINDIR}/TextBalloon"
+)
diff --git a/examples/quick/customitems/painteditem/TextBalloon/plugin.h b/examples/quick/customitems/painteditem/TextBalloon/plugin.h
new file mode 100644
index 0000000000..e598501b7e
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/plugin.h
@@ -0,0 +1,12 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QQmlEngineExtensionPlugin>
+
+#include "textballoon.h"
+
+class TextBalloonPlugin : public QQmlEngineExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
+};
diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir b/examples/quick/customitems/painteditem/TextBalloon/qmldir
index e8a08ae9d3..3b72e9a44d 100644
--- a/examples/quick/customitems/painteditem/TextBalloonPlugin/qmldir
+++ b/examples/quick/customitems/painteditem/TextBalloon/qmldir
@@ -1 +1,2 @@
+module TextBalloon
plugin qmltextballoonplugin
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp b/examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp
new file mode 100644
index 0000000000..e7fe911147
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.cpp
@@ -0,0 +1,56 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "textballoon.h"
+#include <QPainter>
+
+//! [0]
+TextBalloon::TextBalloon(QQuickItem *parent)
+ : QQuickPaintedItem(parent)
+ , rightAligned(false)
+{
+}
+//! [0]
+
+//! [1]
+void TextBalloon::paint(QPainter *painter)
+{
+ QBrush brush(QColor("#007430"));
+
+ painter->setBrush(brush);
+ painter->setPen(Qt::NoPen);
+ painter->setRenderHint(QPainter::Antialiasing);
+
+ QSizeF itemSize = size();
+ painter->drawRoundedRect(0, 0, itemSize.width(), itemSize.height() - 10, 10, 10);
+
+ if (rightAligned)
+ {
+ const QPointF points[3] = {
+ QPointF(itemSize.width() - 10.0, itemSize.height() - 10.0),
+ QPointF(itemSize.width() - 20.0, itemSize.height()),
+ QPointF(itemSize.width() - 30.0, itemSize.height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+ else
+ {
+ const QPointF points[3] = {
+ QPointF(10.0, itemSize.height() - 10.0),
+ QPointF(20.0, itemSize.height()),
+ QPointF(30.0, itemSize.height() - 10.0),
+ };
+ painter->drawConvexPolygon(points, 3);
+ }
+}
+//! [1]
+
+bool TextBalloon::isRightAligned() const
+{
+ return this->rightAligned;
+}
+
+void TextBalloon::setRightAligned(bool rightAligned)
+{
+ this->rightAligned = rightAligned;
+}
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.h b/examples/quick/customitems/painteditem/TextBalloon/textballoon.h
new file mode 100644
index 0000000000..a52db11ce7
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.h
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef TEXTBALLOON_H
+#define TEXTBALLOON_H
+
+#include <QtQuick>
+
+//! [0]
+class TextBalloon : public QQuickPaintedItem
+{
+ Q_OBJECT
+ Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged)
+ QML_ELEMENT
+
+ public:
+ TextBalloon(QQuickItem *parent = nullptr);
+ void paint(QPainter *painter) override;
+
+ bool isRightAligned() const;
+ void setRightAligned(bool rightAligned);
+
+ private:
+ bool rightAligned;
+
+ signals:
+ void rightAlignedChanged();
+};
+//! [0]
+
+#endif
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro b/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro
new file mode 100644
index 0000000000..7f7662b451
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.pro
@@ -0,0 +1,28 @@
+TEMPLATE = lib
+CONFIG += plugin qmltypes
+QT += qml quick
+
+QML_IMPORT_NAME = TextBalloon
+QML_IMPORT_MAJOR_VERSION = 1
+
+TARGET = qmltextballoonplugin
+
+HEADERS += \
+ plugin.h \
+ textballoon.h
+
+SOURCES += textballoon.cpp
+
+RESOURCES += textballoon.qrc
+
+qmldir_output.files = qmldir
+qmldir_output.path = $$OUT_PWD
+COPIES += qmldir_output
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
+qmldir_install.files = qmldir
+qmldir_install.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
+
+INSTALLS += qmldir_install target
+
+CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc b/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc
new file mode 100644
index 0000000000..42c42bd0a6
--- /dev/null
+++ b/examples/quick/customitems/painteditem/TextBalloon/textballoon.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextBalloon">
+ <file>qmldir</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h
deleted file mode 100644
index 4abf2cf3dc..0000000000
--- a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QQmlEngineExtensionPlugin>
-
-#include "../textballoon.h"
-
-class TextBalloonPlugin : public QQmlEngineExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
-};
diff --git a/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
index 4541ba0bd9..a0194759bd 100644
--- a/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
+++ b/examples/quick/customitems/painteditem/doc/src/textballoons.qdoc
@@ -1,34 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\title Scene Graph - Painted Item
\brief Shows how to implement QPainter-based custom scenegraph items.
\example customitems/painteditem
\ingroup qtquickexamples
+ \examplecategory {Graphics}
The Painted Item example shows how to use the QML Scene Graph framework to
implement custom scenegraph items using QPainter.
@@ -38,16 +15,14 @@
The QQuickPaintedItem class is a class derived from QQuickItem for implementing
custom QML Scene Graph items using the QPainter interfaces.
- The example consists of an item class, a plugin class and a QML file
- to use this plugin. The \c TextBalloon class represents the individual
- text balloons extending QQuickPaintedItem, the \c TextBalloonPlugin class
- represents the skeleton code for a \l {Qt Quick} plugin and the
- \c textballoons.qml file is used to load the plugin and display the text
- balloons.
+ The example consists of an item class and a QML file to use the item. The
+ \c TextBalloon class represents the individual text balloons extending
+ QQuickPaintedItem and the \c textballoons.qml file is used to load the module
+ containing the TextBalloon QML type and display the text balloons.
We will focus on the \c TextBalloon class first and continue with the
- \c textballoons.qml file. For an example on how to implement a \l {Qt Quick}
- plugin please look at \l{Chapter 6: Writing an Extension Plugin}
+ \c textballoons.qml file. For an example on how to implement a plugin for a
+ QML module please look at \l{Chapter 6: Writing an Extension Plugin}
{Writing an Extension Plugin}
\section1 TextBalloon Class Declaration
@@ -56,7 +31,7 @@
is the base class for all QPainter based items in the QML Scene Graph
framework.
- \snippet customitems/painteditem/textballoon.h 0
+ \snippet customitems/painteditem/TextBalloon/textballoon.h 0
To implement a QQuickPaintedItem you must implement QQuickPaintedIem's pure
virtual function \l {QQuickPaintedItem::}{paint()} which implements the
@@ -67,13 +42,13 @@
We have to be sure to initialize the rightAligned property for a
TextBalloon item.
- \snippet customitems/painteditem/textballoon.cpp 0
+ \snippet customitems/painteditem/TextBalloon/textballoon.cpp 0
Then we implement the \c paint() function which is automatically called by
the Scene Graph framework to paint the contents of the item. The function
paints the item in local coordinates.
- \snippet customitems/painteditem/textballoon.cpp 1
+ \snippet customitems/painteditem/TextBalloon/textballoon.cpp 1
We start with setting the pen and brush on the item to define the look of
the item. After that we start drawing. Note that the \l {QQuickPaintedItem::}{contentsBoundingRect()}
@@ -81,7 +56,7 @@
returned by the \l {QQuickPaintedItem::}{contentsBoundingRect()} function is the size
of the item as defined in the QML file.
- \section1 Textballoons.qml File
+ \section1 textballoons.qml File
The Interface consists of two main parts. The scrollable area with the
textballoons and the controls button to add new balloons.
diff --git a/examples/quick/customitems/painteditem/main.cpp b/examples/quick/customitems/painteditem/main.cpp
new file mode 100644
index 0000000000..698db7e67c
--- /dev/null
+++ b/examples/quick/customitems/painteditem/main.cpp
@@ -0,0 +1,4 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(painteditem/textballoons)
diff --git a/examples/quick/customitems/painteditem/painteditem.pro b/examples/quick/customitems/painteditem/painteditem.pro
index 641833f3aa..7c26304b26 100644
--- a/examples/quick/customitems/painteditem/painteditem.pro
+++ b/examples/quick/customitems/painteditem/painteditem.pro
@@ -1,29 +1,2 @@
-TEMPLATE = lib
-CONFIG += plugin qmltypes
-QT += qml quick
-
-QML_IMPORT_NAME = TextBalloonPlugin
-QML_IMPORT_MAJOR_VERSION = 1
-
-TARGET = qmltextballoonplugin
-
-HEADERS += \
- TextBalloonPlugin/plugin.h \
- textballoon.h
-
-SOURCES += textballoon.cpp
-
-RESOURCES += painteditem.qrc
-
-DESTDIR = $$QML_IMPORT_NAME
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
-qmldir.files = $$QML_IMPORT_NAME/qmldir
-qmldir.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem/$$QML_IMPORT_NAME
-
-INSTALLS += qmldir target
-
-CONFIG += install_ok # Do not cargo-cult this!
-
-OTHER_FILES += \
- textballoons.qml
+TEMPLATE = subdirs
+SUBDIRS = TextBalloon/textballoon.pro textballoonuser.pro
diff --git a/examples/quick/customitems/painteditem/painteditem.qrc b/examples/quick/customitems/painteditem/painteditem.qrc
index c240be02a1..95305efaca 100644
--- a/examples/quick/customitems/painteditem/painteditem.qrc
+++ b/examples/quick/customitems/painteditem/painteditem.qrc
@@ -1,6 +1,5 @@
<RCC>
- <qresource prefix="/painteditem">
- <file>textballoon.h</file>
+ <qresource prefix="/qt/qml/painteditem">
<file>textballoons.qml</file>
</qresource>
</RCC>
diff --git a/examples/quick/customitems/painteditem/textballoon.cpp b/examples/quick/customitems/painteditem/textballoon.cpp
deleted file mode 100644
index de34d67103..0000000000
--- a/examples/quick/customitems/painteditem/textballoon.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "textballoon.h"
-#include <QPainter>
-
-//! [0]
-TextBalloon::TextBalloon(QQuickItem *parent)
- : QQuickPaintedItem(parent)
- , rightAligned(false)
-{
-}
-//! [0]
-
-//! [1]
-void TextBalloon::paint(QPainter *painter)
-{
- QBrush brush(QColor("#007430"));
-
- painter->setBrush(brush);
- painter->setPen(Qt::NoPen);
- painter->setRenderHint(QPainter::Antialiasing);
-
- QSizeF itemSize = size();
- painter->drawRoundedRect(0, 0, itemSize.width(), itemSize.height() - 10, 10, 10);
-
- if (rightAligned)
- {
- const QPointF points[3] = {
- QPointF(itemSize.width() - 10.0, itemSize.height() - 10.0),
- QPointF(itemSize.width() - 20.0, itemSize.height()),
- QPointF(itemSize.width() - 30.0, itemSize.height() - 10.0),
- };
- painter->drawConvexPolygon(points, 3);
- }
- else
- {
- const QPointF points[3] = {
- QPointF(10.0, itemSize.height() - 10.0),
- QPointF(20.0, itemSize.height()),
- QPointF(30.0, itemSize.height() - 10.0),
- };
- painter->drawConvexPolygon(points, 3);
- }
-}
-//! [1]
-
-bool TextBalloon::isRightAligned()
-{
- return this->rightAligned;
-}
-
-void TextBalloon::setRightAligned(bool rightAligned)
-{
- this->rightAligned = rightAligned;
-}
diff --git a/examples/quick/customitems/painteditem/textballoon.h b/examples/quick/customitems/painteditem/textballoon.h
deleted file mode 100644
index eb72804602..0000000000
--- a/examples/quick/customitems/painteditem/textballoon.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 demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef TEXTBALLOON_H
-#define TEXTBALLOON_H
-
-#include <QtQuick>
-
-//! [0]
-class TextBalloon : public QQuickPaintedItem
-{
- Q_OBJECT
- Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged)
- QML_ELEMENT
-
- public:
- TextBalloon(QQuickItem *parent = 0);
- void paint(QPainter *painter);
-
- bool isRightAligned();
- void setRightAligned(bool rightAligned);
-
- private:
- bool rightAligned;
-
- signals:
- void rightAlignedChanged();
-};
-//! [0]
-
-#endif
diff --git a/examples/quick/customitems/painteditem/textballoons.qml b/examples/quick/customitems/painteditem/textballoons.qml
index 2c749bb440..1ef491f061 100644
--- a/examples/quick/customitems/painteditem/textballoons.qml
+++ b/examples/quick/customitems/painteditem/textballoons.qml
@@ -1,55 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import QtQuick 2.0
-import "TextBalloonPlugin" 1.0
+import QtQuick
+import TextBalloon
Item {
height: 480
@@ -67,14 +20,14 @@ Item {
}
ListView {
+ id: balloonView
anchors.bottom: controls.top
anchors.bottomMargin: 2
anchors.top: parent.top
- id: balloonView
delegate: TextBalloon {
- anchors.right: index % 2 == 0 ? undefined : parent.right
+ anchors.right: index % 2 != 0 ? parent?.right : undefined
height: 60
- rightAligned: index % 2 == 0 ? false : true
+ rightAligned: index % 2 != 0
width: balloonWidth
}
model: balloonModel
@@ -97,7 +50,7 @@ Item {
Text {
anchors.centerIn: parent
- text: "Add another balloon"
+ text: qsTr("Add another balloon")
}
MouseArea {
diff --git a/examples/quick/customitems/painteditem/textballoonuser.pro b/examples/quick/customitems/painteditem/textballoonuser.pro
new file mode 100644
index 0000000000..7504542f4c
--- /dev/null
+++ b/examples/quick/customitems/painteditem/textballoonuser.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += qml quick
+
+TARGET = painteditem
+SOURCES += main.cpp
+RESOURCES += painteditem.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/customitems/painteditem
+INSTALLS += target