summaryrefslogtreecommitdiffstats
path: root/examples/widgets/animation/stickman
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/animation/stickman')
-rw-r--r--examples/widgets/animation/stickman/CMakeLists.txt57
-rw-r--r--examples/widgets/animation/stickman/animation.cpp193
-rw-r--r--examples/widgets/animation/stickman/animation.h92
-rw-r--r--examples/widgets/animation/stickman/animations/chilling.binbin6508 -> 0 bytes
-rw-r--r--examples/widgets/animation/stickman/animations/dancing.binbin2348 -> 0 bytes
-rw-r--r--examples/widgets/animation/stickman/animations/dead.binbin268 -> 0 bytes
-rw-r--r--examples/widgets/animation/stickman/animations/jumping.binbin1308 -> 0 bytes
-rw-r--r--examples/widgets/animation/stickman/graphicsview.cpp68
-rw-r--r--examples/widgets/animation/stickman/graphicsview.h70
-rw-r--r--examples/widgets/animation/stickman/lifecycle.cpp234
-rw-r--r--examples/widgets/animation/stickman/lifecycle.h91
-rw-r--r--examples/widgets/animation/stickman/main.cpp116
-rw-r--r--examples/widgets/animation/stickman/node.cpp102
-rw-r--r--examples/widgets/animation/stickman/node.h80
-rw-r--r--examples/widgets/animation/stickman/rectbutton.cpp78
-rw-r--r--examples/widgets/animation/stickman/rectbutton.h75
-rw-r--r--examples/widgets/animation/stickman/stickman.cpp329
-rw-r--r--examples/widgets/animation/stickman/stickman.h108
-rw-r--r--examples/widgets/animation/stickman/stickman.pro21
-rw-r--r--examples/widgets/animation/stickman/stickman.qrc8
20 files changed, 0 insertions, 1722 deletions
diff --git a/examples/widgets/animation/stickman/CMakeLists.txt b/examples/widgets/animation/stickman/CMakeLists.txt
deleted file mode 100644
index 07f3d96ea0..0000000000
--- a/examples/widgets/animation/stickman/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated from stickman.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(stickman 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/animation/stickman")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(stickman
- animation.cpp animation.h
- graphicsview.cpp graphicsview.h
- lifecycle.cpp lifecycle.h
- main.cpp
- node.cpp node.h
- rectbutton.cpp rectbutton.h
- stickman.cpp stickman.h
-)
-target_link_libraries(stickman PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-
-# Resources:
-set(stickman_resource_files
- "animations/chilling.bin"
- "animations/dancing.bin"
- "animations/dead.bin"
- "animations/jumping.bin"
-)
-
-qt6_add_resources(stickman "stickman"
- PREFIX
- "/"
- FILES
- ${stickman_resource_files}
-)
-
-install(TARGETS stickman
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/animation/stickman/animation.cpp b/examples/widgets/animation/stickman/animation.cpp
deleted file mode 100644
index 77a1875be3..0000000000
--- a/examples/widgets/animation/stickman/animation.cpp
+++ /dev/null
@@ -1,193 +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 "animation.h"
-
-#include <QIODevice>
-#include <QDataStream>
-
-class Frame
-{
-public:
- Frame() = default;
-
- int nodeCount() const
- {
- return m_nodePositions.size();
- }
-
- void setNodeCount(int nodeCount)
- {
- m_nodePositions.resize(nodeCount);
- }
-
- QPointF nodePos(int idx) const
- {
- return m_nodePositions.at(idx);
- }
-
- void setNodePos(int idx, const QPointF &pos)
- {
- m_nodePositions[idx] = pos;
- }
-
-private:
- QList<QPointF> m_nodePositions;
-};
-
-Animation::Animation() : m_currentFrame(0)
-{
- m_frames.append(new Frame);
-}
-
-Animation::~Animation()
-{
- qDeleteAll(m_frames);
-}
-
-void Animation::setTotalFrames(int totalFrames)
-{
- while (m_frames.size() < totalFrames)
- m_frames.append(new Frame);
-
- while (totalFrames < m_frames.size())
- delete m_frames.takeLast();
-
- setCurrentFrame(m_currentFrame);
-}
-
-int Animation::totalFrames() const
-{
- return m_frames.size();
-}
-
-void Animation::setCurrentFrame(int currentFrame)
-{
- m_currentFrame = qBound(0, currentFrame, totalFrames() - 1);
-}
-
-int Animation::currentFrame() const
-{
- return m_currentFrame;
-}
-
-void Animation::setNodeCount(int nodeCount)
-{
- Frame *frame = m_frames.at(m_currentFrame);
- frame->setNodeCount(nodeCount);
-}
-
-int Animation::nodeCount() const
-{
- Frame *frame = m_frames.at(m_currentFrame);
- return frame->nodeCount();
-}
-
-void Animation::setNodePos(int idx, const QPointF &pos)
-{
- Frame *frame = m_frames.at(m_currentFrame);
- frame->setNodePos(idx, pos);
-}
-
-QPointF Animation::nodePos(int idx) const
-{
- Frame *frame = m_frames.at(m_currentFrame);
- return frame->nodePos(idx);
-}
-
-QString Animation::name() const
-{
- return m_name;
-}
-
-void Animation::setName(const QString &name)
-{
- m_name = name;
-}
-
-void Animation::save(QIODevice *device) const
-{
- QDataStream stream(device);
- stream << m_name;
- stream << m_frames.size();
- for (const Frame *frame : qAsConst(m_frames)) {
- stream << frame->nodeCount();
- for (int i = 0; i < frame->nodeCount(); ++i)
- stream << frame->nodePos(i);
- }
-}
-
-void Animation::load(QIODevice *device)
-{
- qDeleteAll(m_frames);
- m_frames.clear();
-
- QDataStream stream(device);
- stream >> m_name;
-
- int frameCount;
- stream >> frameCount;
-
- for (int i = 0; i < frameCount; ++i) {
- int nodeCount;
- stream >> nodeCount;
-
- Frame *frame = new Frame;
- frame->setNodeCount(nodeCount);
-
- for (int j = 0; j < nodeCount; ++j) {
- QPointF pos;
- stream >> pos;
- frame->setNodePos(j, pos);
- }
-
- m_frames.append(frame);
- }
-}
diff --git a/examples/widgets/animation/stickman/animation.h b/examples/widgets/animation/stickman/animation.h
deleted file mode 100644
index 93caff48a2..0000000000
--- a/examples/widgets/animation/stickman/animation.h
+++ /dev/null
@@ -1,92 +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 ANIMATION_H
-#define ANIMATION_H
-
-#include <QPointF>
-#include <QString>
-#include <QList>
-
-class Frame;
-QT_BEGIN_NAMESPACE
-class QIODevice;
-QT_END_NAMESPACE
-class Animation
-{
-public:
- Animation();
- ~Animation();
-
- void setTotalFrames(int totalFrames);
- int totalFrames() const;
-
- void setCurrentFrame(int currentFrame);
- int currentFrame() const;
-
- void setNodeCount(int nodeCount);
- int nodeCount() const;
-
- void setNodePos(int idx, const QPointF &pos);
- QPointF nodePos(int idx) const;
-
- QString name() const;
- void setName(const QString &name);
-
- void save(QIODevice *device) const;
- void load(QIODevice *device);
-
-private:
- QString m_name;
- QList<Frame *> m_frames;
- int m_currentFrame;
-};
-
-#endif
diff --git a/examples/widgets/animation/stickman/animations/chilling.bin b/examples/widgets/animation/stickman/animations/chilling.bin
deleted file mode 100644
index a81fc7a18c..0000000000
--- a/examples/widgets/animation/stickman/animations/chilling.bin
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/animation/stickman/animations/dancing.bin b/examples/widgets/animation/stickman/animations/dancing.bin
deleted file mode 100644
index 462f66f89b..0000000000
--- a/examples/widgets/animation/stickman/animations/dancing.bin
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/animation/stickman/animations/dead.bin b/examples/widgets/animation/stickman/animations/dead.bin
deleted file mode 100644
index 9859b4b4cd..0000000000
--- a/examples/widgets/animation/stickman/animations/dead.bin
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/animation/stickman/animations/jumping.bin b/examples/widgets/animation/stickman/animations/jumping.bin
deleted file mode 100644
index 12661a15f8..0000000000
--- a/examples/widgets/animation/stickman/animations/jumping.bin
+++ /dev/null
Binary files differ
diff --git a/examples/widgets/animation/stickman/graphicsview.cpp b/examples/widgets/animation/stickman/graphicsview.cpp
deleted file mode 100644
index 0f5800cff3..0000000000
--- a/examples/widgets/animation/stickman/graphicsview.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the 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 "graphicsview.h"
-#include "stickman.h"
-
-#include <QKeyEvent>
-#include <QGraphicsScene>
-
-void GraphicsView::keyPressEvent(QKeyEvent *e)
-{
- if (e->key() == Qt::Key_Escape)
- close();
- emit keyPressed(Qt::Key(e->key()));
-}
-
-void GraphicsView::resizeEvent(QResizeEvent *e)
-{
- fitInView(scene()->sceneRect());
- QGraphicsView::resizeEvent(e);
-}
diff --git a/examples/widgets/animation/stickman/graphicsview.h b/examples/widgets/animation/stickman/graphicsview.h
deleted file mode 100644
index 29f4c6237e..0000000000
--- a/examples/widgets/animation/stickman/graphicsview.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 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 GRAPHICSVIEW_H
-#define GRAPHICSVIEW_H
-
-#include <QGraphicsView>
-
-class GraphicsView: public QGraphicsView
-{
- Q_OBJECT
-public:
- using QGraphicsView::QGraphicsView;
-
-protected:
- void resizeEvent(QResizeEvent *e) override;
- void keyPressEvent(QKeyEvent *e) override;
-
-signals:
- void keyPressed(int key);
-};
-
-#endif
diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp
deleted file mode 100644
index 5ad284c590..0000000000
--- a/examples/widgets/animation/stickman/lifecycle.cpp
+++ /dev/null
@@ -1,234 +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 "lifecycle.h"
-#include "stickman.h"
-#include "node.h"
-#include "animation.h"
-#include "graphicsview.h"
-
-#include <QEventTransition>
-#include <QFile>
-#include <QParallelAnimationGroup>
-#include <QPropertyAnimation>
-#include <QRandomGenerator>
-#include <QSignalTransition>
-#include <QState>
-#include <QStateMachine>
-#include <QTimer>
-
-class KeyPressTransition: public QSignalTransition
-{
-public:
- KeyPressTransition(GraphicsView *receiver, Qt::Key key)
- : QSignalTransition(receiver, &GraphicsView::keyPressed), m_key(key)
- {
- }
- KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target)
- : QSignalTransition(receiver, &GraphicsView::keyPressed), m_key(key)
- {
- setTargetState(target);
- }
-
- bool eventTest(QEvent *e) override
- {
- if (QSignalTransition::eventTest(e)) {
- QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0);
- return (key.toInt() == int(m_key));
- }
-
- return false;
- }
-private:
- Qt::Key m_key;
-};
-
-//! [4]
-class LightningStrikesTransition: public QEventTransition
-{
-public:
- LightningStrikesTransition(QAbstractState *target)
- : QEventTransition(this, QEvent::Timer)
- {
- setTargetState(target);
- startTimer(1000);
- }
-
- bool eventTest(QEvent *e) override
- {
- return QEventTransition::eventTest(e) && QRandomGenerator::global()->bounded(50) == 0;
- }
-};
-//! [4]
-
-LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver)
- : m_stickMan(stickMan), m_keyReceiver(keyReceiver)
-{
- // Create animation group to be used for all transitions
- m_animationGroup = new QParallelAnimationGroup();
- const int stickManNodeCount = m_stickMan->nodeCount();
- for (int i = 0; i < stickManNodeCount; ++i) {
- QPropertyAnimation *pa = new QPropertyAnimation(m_stickMan->node(i), "pos");
- m_animationGroup->addAnimation(pa);
- }
-
- // Set up initial state graph
-//! [3]
- m_machine = new QStateMachine();
- m_machine->addDefaultAnimation(m_animationGroup);
-//! [3]
-
- m_alive = new QState(m_machine);
- m_alive->setObjectName("alive");
-
- // Make it blink when lightning strikes before entering dead animation
- QState *lightningBlink = new QState(m_machine);
- lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::white));
- lightningBlink->assignProperty(m_stickMan, "penColor", QColor(Qt::black));
- lightningBlink->assignProperty(m_stickMan, "fillColor", QColor(Qt::white));
- lightningBlink->assignProperty(m_stickMan, "isDead", true);
-
-//! [5]
- QTimer *timer = new QTimer(lightningBlink);
- timer->setSingleShot(true);
- timer->setInterval(100);
- QObject::connect(lightningBlink, &QAbstractState::entered,
- timer, QOverload<>::of(&QTimer::start));
- QObject::connect(lightningBlink, &QAbstractState::exited,
- timer, &QTimer::stop);
-//! [5]
-
- m_dead = new QState(m_machine);
- m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::black));
- m_dead->assignProperty(m_stickMan, "penColor", QColor(Qt::white));
- m_dead->assignProperty(m_stickMan, "fillColor", QColor(Qt::black));
- m_dead->setObjectName("dead");
-
- // Idle state (sets no properties)
- m_idle = new QState(m_alive);
- m_idle->setObjectName("idle");
-
- m_alive->setInitialState(m_idle);
-
- // Lightning strikes at random
- m_alive->addTransition(new LightningStrikesTransition(lightningBlink));
-//! [0]
- lightningBlink->addTransition(timer, &QTimer::timeout, m_dead);
-//! [0]
-
- m_machine->setInitialState(m_alive);
-}
-
-void LifeCycle::setDeathAnimation(const QString &fileName)
-{
- QState *deathAnimation = makeState(m_dead, fileName);
- m_dead->setInitialState(deathAnimation);
-}
-
-void LifeCycle::start()
-{
- m_machine->start();
-}
-
-void LifeCycle::addActivity(const QString &fileName, Qt::Key key, QObject *sender, const char *signal)
-{
- QState *state = makeState(m_alive, fileName);
- m_alive->addTransition(new KeyPressTransition(m_keyReceiver, key, state));
-
- if (sender && signal)
- m_alive->addTransition(sender, signal, state);
-}
-
-QState *LifeCycle::makeState(QState *parentState, const QString &animationFileName)
-{
- QState *topLevel = new QState(parentState);
-
- Animation animation;
- {
- QFile file(animationFileName);
- if (file.open(QIODevice::ReadOnly))
- animation.load(&file);
- }
-
- const int frameCount = animation.totalFrames();
- QState *previousState = nullptr;
- for (int i = 0; i < frameCount; ++i) {
- animation.setCurrentFrame(i);
-
-//! [1]
- QState *frameState = new QState(topLevel);
- const int nodeCount = animation.nodeCount();
- for (int j = 0; j < nodeCount; ++j)
- frameState->assignProperty(m_stickMan->node(j), "pos", animation.nodePos(j));
-//! [1]
-
- frameState->setObjectName(QString::fromLatin1("frame %0").arg(i));
- if (previousState == nullptr)
- topLevel->setInitialState(frameState);
- else
-//! [2]
- previousState->addTransition(previousState, &QState::propertiesAssigned, frameState);
-//! [2]
-
- previousState = frameState;
- }
-
- // Loop
- previousState->addTransition(previousState, &QState::propertiesAssigned, topLevel->initialState());
-
- return topLevel;
-
-}
-
-LifeCycle::~LifeCycle()
-{
- delete m_machine;
- delete m_animationGroup;
-}
diff --git a/examples/widgets/animation/stickman/lifecycle.h b/examples/widgets/animation/stickman/lifecycle.h
deleted file mode 100644
index 21ab99276d..0000000000
--- a/examples/widgets/animation/stickman/lifecycle.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the 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 LIFECYCLE_H
-#define LIFECYCLE_H
-
-#include <Qt>
-
-QT_BEGIN_NAMESPACE
-class QAbstractState;
-class QAbstractTransition;
-class QAnimationGroup;
-class QObject;
-class QState;
-class QStateMachine;
-QT_END_NAMESPACE
-class GraphicsView;
-class StickMan;
-class LifeCycle
-{
-public:
- LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver);
- ~LifeCycle();
-
- void setDeathAnimation(const QString &fileName);
- void addActivity(const QString &fileName, Qt::Key key,
- QObject *sender = nullptr, const char *signal = nullptr);
-
- void start();
-
-private:
- QState *makeState(QState *parentState, const QString &animationFileName);
-
- StickMan *m_stickMan;
- QStateMachine *m_machine;
- QAnimationGroup *m_animationGroup;
- GraphicsView *m_keyReceiver;
-
- QState *m_alive;
- QState *m_dead;
- QState *m_idle;
-};
-
-#endif
diff --git a/examples/widgets/animation/stickman/main.cpp b/examples/widgets/animation/stickman/main.cpp
deleted file mode 100644
index 5142c4fee9..0000000000
--- a/examples/widgets/animation/stickman/main.cpp
+++ /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 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 "animation.h"
-#include "node.h"
-#include "lifecycle.h"
-#include "stickman.h"
-#include "graphicsview.h"
-#include "rectbutton.h"
-
-#include <QtCore>
-#include <QtWidgets>
-
-int main(int argc, char **argv)
-{
- Q_INIT_RESOURCE(stickman);
- QApplication app(argc, argv);
-
- StickMan *stickMan = new StickMan;
- stickMan->setDrawSticks(false);
-
- QGraphicsTextItem *textItem = new QGraphicsTextItem();
- textItem->setHtml("<font color=\"white\"><b>Stickman</b>"
- "<p>"
- "Tell the stickman what to do!"
- "</p>"
- "<p><i>"
- "<li>Press <font color=\"purple\">J</font> to make the stickman jump.</li>"
- "<li>Press <font color=\"purple\">D</font> to make the stickman dance.</li>"
- "<li>Press <font color=\"purple\">C</font> to make him chill out.</li>"
- "<li>When you are done, press <font color=\"purple\">Escape</font>.</li>"
- "</i></p>"
- "<p>If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again."
- "</p></font>");
- qreal w = textItem->boundingRect().width();
- QRectF stickManBoundingRect = stickMan->mapToScene(stickMan->boundingRect()).boundingRect();
- textItem->setPos(-w / 2.0, stickManBoundingRect.bottom() + 25.0);
-
- QGraphicsScene scene;
- scene.addItem(stickMan);
-
- scene.addItem(textItem);
- scene.setBackgroundBrush(Qt::black);
-
- GraphicsView view;
- view.setRenderHints(QPainter::Antialiasing);
- view.setTransformationAnchor(QGraphicsView::NoAnchor);
- view.setScene(&scene);
-
- QRectF sceneRect = scene.sceneRect();
- // making enough room in the scene for stickman to jump and die
- view.resize(sceneRect.width() + 100, sceneRect.height() + 100);
- view.setSceneRect(sceneRect);
-
- view.show();
- view.setFocus();
-
- LifeCycle cycle(stickMan, &view);
- cycle.setDeathAnimation(":/animations/dead.bin");
-
- cycle.addActivity(":/animations/jumping.bin", Qt::Key_J);
- cycle.addActivity(":/animations/dancing.bin", Qt::Key_D);
- cycle.addActivity(":/animations/chilling.bin", Qt::Key_C);
-
- cycle.start();
-
-
- return app.exec();
-}
diff --git a/examples/widgets/animation/stickman/node.cpp b/examples/widgets/animation/stickman/node.cpp
deleted file mode 100644
index 43a9c93de8..0000000000
--- a/examples/widgets/animation/stickman/node.cpp
+++ /dev/null
@@ -1,102 +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 "node.h"
-#include "stickman.h"
-
-#include <QRectF>
-#include <QPainter>
-#include <QGraphicsSceneMouseEvent>
-
-Node::Node(const QPointF &pos, QGraphicsItem *parent)
- : QGraphicsObject(parent), m_dragging(false)
-{
- setPos(pos);
- setFlag(QGraphicsItem::ItemSendsGeometryChanges);
-}
-
-Node::~Node()
-{
-}
-
-QRectF Node::boundingRect() const
-{
- return QRectF(-6.0, -6.0, 12.0, 12.0);
-}
-
-void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
-{
- painter->setPen(Qt::white);
- painter->drawEllipse(QPointF(0.0, 0.0), 5.0, 5.0);
-}
-
-QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- if (change == QGraphicsItem::ItemPositionChange)
- emit positionChanged();
-
- return QGraphicsObject::itemChange(change, value);
-}
-
-void Node::mousePressEvent(QGraphicsSceneMouseEvent *)
-{
- m_dragging = true;
-}
-
-void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if (m_dragging)
- setPos(mapToParent(event->pos()));
-}
-
-void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
-{
- m_dragging = false;
-}
diff --git a/examples/widgets/animation/stickman/node.h b/examples/widgets/animation/stickman/node.h
deleted file mode 100644
index 2b393c60c1..0000000000
--- a/examples/widgets/animation/stickman/node.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 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 NODE_H
-#define NODE_H
-
-#include <QGraphicsObject>
-
-class Node: public QGraphicsObject
-{
- Q_OBJECT
-public:
- explicit Node(const QPointF &pos, QGraphicsItem *parent = nullptr);
- ~Node();
-
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
-
-signals:
- void positionChanged();
-
-protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
-
- void mousePressEvent(QGraphicsSceneMouseEvent *) override;
- void mouseMoveEvent(QGraphicsSceneMouseEvent *) override;
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
-
-private:
- bool m_dragging;
-};
-
-#endif
diff --git a/examples/widgets/animation/stickman/rectbutton.cpp b/examples/widgets/animation/stickman/rectbutton.cpp
deleted file mode 100644
index 5174d0aeaf..0000000000
--- a/examples/widgets/animation/stickman/rectbutton.cpp
+++ /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 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 "rectbutton.h"
-#include <QPainter>
-
-RectButton::RectButton(const QString &buttonText) : m_ButtonText(buttonText)
-{
-}
-
-
-void RectButton::mousePressEvent (QGraphicsSceneMouseEvent *)
-{
- emit clicked();
-}
-
-
-QRectF RectButton::boundingRect() const
-{
- return QRectF(0.0, 0.0, 90.0, 40.0);
-}
-
-
-void RectButton::paint(QPainter *painter, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */)
-{
- painter->setBrush(Qt::gray);
- painter->drawRoundedRect(boundingRect(), 5, 5);
-
- painter->setPen(Qt::white);
- painter->drawText(20, 25, m_ButtonText);
-}
diff --git a/examples/widgets/animation/stickman/rectbutton.h b/examples/widgets/animation/stickman/rectbutton.h
deleted file mode 100644
index ee6cd3f530..0000000000
--- a/examples/widgets/animation/stickman/rectbutton.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the 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 RECTBUTTON_H
-#define RECTBUTTON_H
-
-#include <QGraphicsObject>
-
-class RectButton : public QGraphicsObject
-{
- Q_OBJECT
-public:
- RectButton(const QString &buttonText);
-
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
-
-protected:
- void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
-
-signals:
- void clicked();
-
-private:
- QString m_ButtonText;
-};
-
-#endif // RECTBUTTON_H
diff --git a/examples/widgets/animation/stickman/stickman.cpp b/examples/widgets/animation/stickman/stickman.cpp
deleted file mode 100644
index 3f373b6b52..0000000000
--- a/examples/widgets/animation/stickman/stickman.cpp
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the 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 "stickman.h"
-#include "node.h"
-
-#include <QPainter>
-#include <QtMath>
-
-static constexpr qreal Coords[NodeCount * 2] = {
- 0.0, -150.0, // head, #0
-
- 0.0, -100.0, // body pentagon, top->bottom, left->right, #1 - 5
- -50.0, -50.0,
- 50.0, -50.0,
- -25.0, 50.0,
- 25.0, 50.0,
-
- -100.0, 0.0, // right arm, #6 - 7
- -125.0, 50.0,
-
- 100.0, 0.0, // left arm, #8 - 9
- 125.0, 50.0,
-
- -35.0, 75.0, // lower body, #10 - 11
- 35.0, 75.0,
-
- -25.0, 200.0, // right leg, #12 - 13
- -30.0, 300.0,
-
- 25.0, 200.0, // left leg, #14 - 15
- 30.0, 300.0
-
-};
-
-static constexpr int Bones[BoneCount * 2] = {
- 0, 1, // neck
-
- 1, 2, // body
- 1, 3,
- 1, 4,
- 1, 5,
- 2, 3,
- 2, 4,
- 2, 5,
- 3, 4,
- 3, 5,
- 4, 5,
-
- 2, 6, // right arm
- 6, 7,
-
- 3, 8, // left arm
- 8, 9,
-
- 4, 10, // lower body
- 4, 11,
- 5, 10,
- 5, 11,
- 10, 11,
-
- 10, 12, // right leg
- 12, 13,
-
- 11, 14, // left leg
- 14, 15
-
-};
-
-StickMan::StickMan()
-{
- // Set up start position of limbs
- for (int i = 0; i < NodeCount; ++i) {
- m_nodes[i] = new Node(QPointF(Coords[i * 2], Coords[i * 2 + 1]), this);
- connect(m_nodes[i], &Node::positionChanged, this, &StickMan::childPositionChanged);
- }
-
- for (int i = 0; i < BoneCount; ++i) {
- int n1 = Bones[i * 2];
- int n2 = Bones[i * 2 + 1];
-
- Node *node1 = m_nodes[n1];
- Node *node2 = m_nodes[n2];
-
- QPointF dist = node1->pos() - node2->pos();
- m_perfectBoneLengths[i] = sqrt(pow(dist.x(), 2) + pow(dist.y(), 2));
- }
-
- startTimer(10);
-}
-
-void StickMan::childPositionChanged()
-{
- prepareGeometryChange();
-}
-
-void StickMan::setDrawSticks(bool on)
-{
- m_sticks = on;
- for (int i = 0; i < nodeCount(); ++i) {
- Node *node = m_nodes[i];
- node->setVisible(on);
- }
-}
-
-QRectF StickMan::boundingRect() const
-{
- // account for head radius=50.0 plus pen which is 5.0
- return childrenBoundingRect().adjusted(-55.0, -55.0, 55.0, 55.0);
-}
-
-int StickMan::nodeCount() const
-{
- return NodeCount;
-}
-
-Node *StickMan::node(int idx) const
-{
- if (idx >= 0 && idx < NodeCount)
- return m_nodes[idx];
- return nullptr;
-}
-
-void StickMan::timerEvent(QTimerEvent *)
-{
- update();
-}
-
-void StickMan::stabilize()
-{
- static const qreal threshold = 0.001;
-
- for (int i = 0; i < BoneCount; ++i) {
- int n1 = Bones[i * 2];
- int n2 = Bones[i * 2 + 1];
-
- Node *node1 = m_nodes[n1];
- Node *node2 = m_nodes[n2];
-
- QPointF pos1 = node1->pos();
- QPointF pos2 = node2->pos();
-
- QPointF dist = pos1 - pos2;
- qreal length = sqrt(pow(dist.x(),2) + pow(dist.y(),2));
- qreal diff = (length - m_perfectBoneLengths[i]) / length;
-
- QPointF p = dist * (0.5 * diff);
- if (p.x() > threshold && p.y() > threshold) {
- pos1 -= p;
- pos2 += p;
-
- node1->setPos(pos1);
- node2->setPos(pos2);
- }
- }
-}
-
-QPointF StickMan::posFor(int idx) const
-{
- return m_nodes[idx]->pos();
-}
-
-//#include <QTime>
-void StickMan::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
-{
- /* static int frames = 0;
- static QTime time;
- if (frames++ % 100 == 0) {
- frames = 1;
- time.restart();
- }
-
- if (time.elapsed() > 0) {
- painter->setPen(Qt::white);
- painter->drawText(0, 0, QString::number(frames / (time.elapsed() / 1000.0)));
- }*/
-
- stabilize();
- if (m_sticks) {
- painter->setPen(Qt::white);
- for (int i = 0; i < BoneCount; ++i) {
- int n1 = Bones[i * 2];
- int n2 = Bones[i * 2 + 1];
-
- Node *node1 = m_nodes[n1];
- Node *node2 = m_nodes[n2];
-
- painter->drawLine(node1->pos(), node2->pos());
- }
- } else {
- // first bone is neck and will be used for head
-
- QPainterPath path;
- path.moveTo(posFor(0));
- path.lineTo(posFor(1));
-
- // right arm
- path.lineTo(posFor(2));
- path.lineTo(posFor(6));
- path.lineTo(posFor(7));
-
- // left arm
- path.moveTo(posFor(3));
- path.lineTo(posFor(8));
- path.lineTo(posFor(9));
-
- // body
- path.moveTo(posFor(2));
- path.lineTo(posFor(4));
- path.lineTo(posFor(10));
- path.lineTo(posFor(11));
- path.lineTo(posFor(5));
- path.lineTo(posFor(3));
- path.lineTo(posFor(1));
-
- // right leg
- path.moveTo(posFor(10));
- path.lineTo(posFor(12));
- path.lineTo(posFor(13));
-
- // left leg
- path.moveTo(posFor(11));
- path.lineTo(posFor(14));
- path.lineTo(posFor(15));
-
- painter->setPen(QPen(m_penColor, 5.0, Qt::SolidLine, Qt::RoundCap));
- painter->drawPath(path);
-
- {
- int n1 = Bones[0];
- int n2 = Bones[1];
- Node *node1 = m_nodes[n1];
- Node *node2 = m_nodes[n2];
-
- QPointF dist = node2->pos() - node1->pos();
-
- qreal sinAngle = dist.x() / sqrt(pow(dist.x(), 2) + pow(dist.y(), 2));
- qreal angle = qRadiansToDegrees(asin(sinAngle));
-
- QPointF headPos = node1->pos();
- painter->translate(headPos);
- painter->rotate(-angle);
-
- painter->setBrush(m_fillColor);
- painter->drawEllipse(QPointF(0,0), 50.0, 50.0);
-
- painter->setBrush(m_penColor);
- painter->setPen(QPen(m_penColor, 2.5, Qt::SolidLine, Qt::RoundCap));
-
- // eyes
- if (m_isDead) {
- painter->drawLine(-30.0, -30.0, -20.0, -20.0);
- painter->drawLine(-20.0, -30.0, -30.0, -20.0);
-
- painter->drawLine(20.0, -30.0, 30.0, -20.0);
- painter->drawLine(30.0, -30.0, 20.0, -20.0);
- } else {
- painter->drawChord(QRectF(-30.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16);
- painter->drawChord(QRectF(5.0, -30.0, 25.0, 70.0), 30.0*16, 120.0*16);
- }
-
- // mouth
- if (m_isDead) {
- painter->drawLine(-28.0, 2.0, 29.0, 2.0);
- } else {
- painter->setBrush(QColor(128, 0, 64 ));
- painter->drawChord(QRectF(-28.0, 2.0-55.0/2.0, 57.0, 55.0), 0.0, -180.0*16);
- }
-
- // pupils
- if (!m_isDead) {
- painter->setPen(QPen(m_fillColor, 1.0, Qt::SolidLine, Qt::RoundCap));
- painter->setBrush(m_fillColor);
- painter->drawEllipse(QPointF(-12.0, -25.0), 5.0, 5.0);
- painter->drawEllipse(QPointF(22.0, -25.0), 5.0, 5.0);
- }
- }
- }
-}
-
-
-
diff --git a/examples/widgets/animation/stickman/stickman.h b/examples/widgets/animation/stickman/stickman.h
deleted file mode 100644
index 63c02abc8f..0000000000
--- a/examples/widgets/animation/stickman/stickman.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the 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 STICKMAN_H
-#define STICKMAN_H
-
-#include <QGraphicsObject>
-
-static const int NodeCount = 16;
-static const int BoneCount = 24;
-
-class Node;
-class StickMan: public QGraphicsObject
-{
- Q_OBJECT
- Q_PROPERTY(QColor penColor WRITE setPenColor READ penColor)
- Q_PROPERTY(QColor fillColor WRITE setFillColor READ fillColor)
- Q_PROPERTY(bool isDead WRITE setIsDead READ isDead)
-public:
- StickMan();
-
- QRectF boundingRect() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
-
- int nodeCount() const;
- Node *node(int idx) const;
-
- void setDrawSticks(bool on);
- bool drawSticks() const { return m_sticks; }
-
- QColor penColor() const { return m_penColor; }
- void setPenColor(const QColor &color) { m_penColor = color; }
-
- QColor fillColor() const { return m_fillColor; }
- void setFillColor(const QColor &color) { m_fillColor = color; }
-
- bool isDead() const { return m_isDead; }
- void setIsDead(bool isDead) { m_isDead = isDead; }
-
-public slots:
- void stabilize();
- void childPositionChanged();
-
-protected:
- void timerEvent(QTimerEvent *e) override;
-
-private:
-
- QPointF posFor(int idx) const;
-
- Node *m_nodes[NodeCount];
- qreal m_perfectBoneLengths[BoneCount];
-
- bool m_sticks = true;
- bool m_isDead = false;
-
- QColor m_penColor = Qt::white;
- QColor m_fillColor = Qt::black;
-};
-
-#endif // STICKMAN_H
diff --git a/examples/widgets/animation/stickman/stickman.pro b/examples/widgets/animation/stickman/stickman.pro
deleted file mode 100644
index a803acf624..0000000000
--- a/examples/widgets/animation/stickman/stickman.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-QT += widgets
-
-HEADERS += stickman.h \
- animation.h \
- node.h \
- lifecycle.h \
- graphicsview.h \
- rectbutton.h
-SOURCES += main.cpp \
- stickman.cpp \
- animation.cpp \
- node.cpp \
- lifecycle.cpp \
- graphicsview.cpp \
- rectbutton.cpp
-
-RESOURCES += stickman.qrc
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/stickman
-INSTALLS += target
diff --git a/examples/widgets/animation/stickman/stickman.qrc b/examples/widgets/animation/stickman/stickman.qrc
deleted file mode 100644
index 4cf3ba3828..0000000000
--- a/examples/widgets/animation/stickman/stickman.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>animations/chilling.bin</file>
- <file>animations/dancing.bin</file>
- <file>animations/dead.bin</file>
- <file>animations/jumping.bin</file>
-</qresource>
-</RCC>