diff options
-rw-r--r-- | examples/statemachine/CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/statemachine/animation/CMakeLists.txt | 4 | ||||
-rw-r--r-- | examples/statemachine/animation/README | 8 | ||||
-rw-r--r-- | examples/statemachine/animation/animation.pro | 2 | ||||
-rw-r--r-- | examples/statemachine/doc/src/moveblocks.qdoc | 34 | ||||
-rw-r--r-- | examples/statemachine/doc/src/pingpong.qdoc | 16 | ||||
-rw-r--r-- | examples/statemachine/doc/src/rogue.qdoc | 24 | ||||
-rw-r--r-- | examples/statemachine/doc/src/trafficlight.qdoc | 12 | ||||
-rw-r--r-- | examples/statemachine/moveblocks/CMakeLists.txt (renamed from examples/statemachine/animation/moveblocks/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | examples/statemachine/moveblocks/main.cpp (renamed from examples/statemachine/animation/moveblocks/main.cpp) | 0 | ||||
-rw-r--r-- | examples/statemachine/moveblocks/moveblocks.pro (renamed from examples/statemachine/animation/moveblocks/moveblocks.pro) | 0 | ||||
-rw-r--r-- | examples/statemachine/pingpong/CMakeLists.txt (renamed from examples/statemachine/statemachine/pingpong/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | examples/statemachine/pingpong/main.cpp (renamed from examples/statemachine/statemachine/pingpong/main.cpp) | 0 | ||||
-rw-r--r-- | examples/statemachine/pingpong/pingpong.pro (renamed from examples/statemachine/statemachine/pingpong/pingpong.pro) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/CMakeLists.txt (renamed from examples/statemachine/statemachine/rogue/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/main.cpp (renamed from examples/statemachine/statemachine/rogue/main.cpp) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/movementtransition.h (renamed from examples/statemachine/statemachine/rogue/movementtransition.h) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/rogue.pro (renamed from examples/statemachine/statemachine/rogue/rogue.pro) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/window.cpp (renamed from examples/statemachine/statemachine/rogue/window.cpp) | 0 | ||||
-rw-r--r-- | examples/statemachine/rogue/window.h (renamed from examples/statemachine/statemachine/rogue/window.h) | 0 | ||||
-rw-r--r-- | examples/statemachine/statemachine.pro | 13 | ||||
-rw-r--r-- | examples/statemachine/statemachine/CMakeLists.txt | 8 | ||||
-rw-r--r-- | examples/statemachine/statemachine/README | 6 | ||||
-rw-r--r-- | examples/statemachine/statemachine/statemachine.pro | 8 | ||||
-rw-r--r-- | examples/statemachine/trafficlight/CMakeLists.txt (renamed from examples/statemachine/statemachine/trafficlight/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | examples/statemachine/trafficlight/main.cpp (renamed from examples/statemachine/statemachine/trafficlight/main.cpp) | 0 | ||||
-rw-r--r-- | examples/statemachine/trafficlight/trafficlight.pro (renamed from examples/statemachine/statemachine/trafficlight/trafficlight.pro) | 0 |
27 files changed, 55 insertions, 86 deletions
diff --git a/examples/statemachine/CMakeLists.txt b/examples/statemachine/CMakeLists.txt index 5da90e2..86db7fb 100644 --- a/examples/statemachine/CMakeLists.txt +++ b/examples/statemachine/CMakeLists.txt @@ -1,10 +1,12 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -add_subdirectory(statemachine) +qt_internal_add_example(pingpong) if(TARGET Qt::Widgets) + qt_internal_add_example(rogue) + qt_internal_add_example(trafficlight) if(QT_FEATURE_animation) - add_subdirectory(animation) + qt_internal_add_example(moveblocks) endif() endif() diff --git a/examples/statemachine/animation/CMakeLists.txt b/examples/statemachine/animation/CMakeLists.txt deleted file mode 100644 index cf86192..0000000 --- a/examples/statemachine/animation/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -qt_internal_add_example(moveblocks) diff --git a/examples/statemachine/animation/README b/examples/statemachine/animation/README deleted file mode 100644 index e723a28..0000000 --- a/examples/statemachine/animation/README +++ /dev/null @@ -1,8 +0,0 @@ -The animation framework aims to provide an easy way for creating animated and -smooth GUI's. By animating Qt properties, the framework provides great freedom -for animating widgets and other QObjects. The framework can also be used with -the Graphics View framework. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/statemachine/animation/animation.pro b/examples/statemachine/animation/animation.pro deleted file mode 100644 index bab7d8d..0000000 --- a/examples/statemachine/animation/animation.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = moveblocks diff --git a/examples/statemachine/doc/src/moveblocks.qdoc b/examples/statemachine/doc/src/moveblocks.qdoc index 420e134..6dcb6fa 100644 --- a/examples/statemachine/doc/src/moveblocks.qdoc +++ b/examples/statemachine/doc/src/moveblocks.qdoc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example animation/moveblocks + \example moveblocks \title Move Blocks Example \ingroup examples-qtstatemachine @@ -39,7 +39,7 @@ After QApplication has been initialized, we set up the QGraphicsScene with its \c{QGraphicsRectWidget}s. - \snippet animation/moveblocks/main.cpp 1 + \snippet moveblocks/main.cpp 1 After adding the scene to a QGraphicsView, it is time to build the state graph. Let's first look at a statechart of what we are @@ -52,7 +52,7 @@ graph will be examined line-by-line, and will show how the graph works. First off, we construct the \c group state: - \snippet animation/moveblocks/main.cpp 2 + \snippet moveblocks/main.cpp 2 The timer is used to add a delay between each time the blocks are moved. The timer is started when \c group is entered. As we will @@ -61,9 +61,9 @@ machine, so an animation will be scheduled when the example is started. - \snippet animation/moveblocks/main.cpp 3 + \snippet moveblocks/main.cpp 3 \dots - \snippet animation/moveblocks/main.cpp 4 + \snippet moveblocks/main.cpp 4 \c createGeometryState() returns a QState that will set the geometry of our items upon entry. It also assigns \c group as the @@ -75,20 +75,20 @@ properties and the values in the target state. We add animated transitions to the state graph later. - \snippet animation/moveblocks/main.cpp 5 + \snippet moveblocks/main.cpp 5 We move the items in parallel. Each item is added to \c animationGroup, which is the animation that is inserted into the transitions. - \snippet animation/moveblocks/main.cpp 6 + \snippet moveblocks/main.cpp 6 The sequential animation group, \c subGroup, helps us insert a delay between the animation of each item. - \snippet animation/moveblocks/main.cpp 7 + \snippet moveblocks/main.cpp 7 \dots - \snippet animation/moveblocks/main.cpp 8 + \snippet moveblocks/main.cpp 8 A StateSwitchTransition is added to the state switcher in \c StateSwitcher::addState(). We also add the animation in this @@ -99,7 +99,7 @@ As mentioned previously, we add a transition to the state switcher that triggers when the timer times out. - \snippet animation/moveblocks/main.cpp 9 + \snippet moveblocks/main.cpp 9 Finally, we can create the state machine, add our initial state, and start execution of the state graph. @@ -109,7 +109,7 @@ In \c createGeometryState(), we set up the geometry for each graphics item. - \snippet animation/moveblocks/main.cpp 13 + \snippet moveblocks/main.cpp 13 As mentioned before, QAbstractTransition will set up an animation added with \l [CPP] {QAbstractTransition::}{addAnimation()} using @@ -124,20 +124,20 @@ All functions in \c StateSwitcher are inlined. We'll step through its definition. - \snippet animation/moveblocks/main.cpp 10 + \snippet moveblocks/main.cpp 10 \c StateSwitcher is a state designed for a particular purpose and will always be a top-level state. We use \c m_stateCount to keep track of how many states we are managing, and \c m_lastIndex to remember which state was the last state to which we transitioned. - \snippet animation/moveblocks/main.cpp 11 + \snippet moveblocks/main.cpp 11 We select the next state we are going to transition to, and post a \c StateSwitchEvent, which we know will trigger the \c StateSwitchTransition to the selected state. - \snippet animation/moveblocks/main.cpp 12 + \snippet moveblocks/main.cpp 12 This is where the magic happens. We assign a number to each state added. This number is given to both a StateSwitchTransition and to @@ -151,7 +151,7 @@ let's take a look at its \l [CPP] {QAbstractTransition::}{eventTest()} function, which is the only function that we define.. - \snippet animation/moveblocks/main.cpp 14 + \snippet moveblocks/main.cpp 14 \c eventTest is called by QStateMachine when it checks whether a transition should be triggered--a return value of true means that @@ -165,7 +165,7 @@ \c StateSwitcher. We have already seen how it is used to trigger \c{StateSwitchTransition}s in \c StateSwitcher. - \snippet animation/moveblocks/main.cpp 15 + \snippet moveblocks/main.cpp 15 We only have inlined functions in this class, so a look at its definition will do. @@ -177,7 +177,7 @@ which is the only function we define. Here is the QGraphicsRectWidget class definition: - \snippet animation/moveblocks/main.cpp 16 + \snippet moveblocks/main.cpp 16 \section1 Moving On diff --git a/examples/statemachine/doc/src/pingpong.qdoc b/examples/statemachine/doc/src/pingpong.qdoc index 30b5b8c..c0455d8 100644 --- a/examples/statemachine/doc/src/pingpong.qdoc +++ b/examples/statemachine/doc/src/pingpong.qdoc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example statemachine/pingpong + \example pingpong \title Ping Pong States Example \ingroup examples-qtstatemachine @@ -22,35 +22,35 @@ ponger state will respond by posting a \c pong event; this will cause the \c pinger state to post a new \c ping event; and so on. - \snippet statemachine/pingpong/main.cpp 0 + \snippet pingpong/main.cpp 0 Two custom events are defined, \c PingEvent and \c PongEvent. - \snippet statemachine/pingpong/main.cpp 1 + \snippet pingpong/main.cpp 1 The \c Pinger class defines a state that posts a \c PingEvent to the state machine when the state is entered. - \snippet statemachine/pingpong/main.cpp 2 + \snippet pingpong/main.cpp 2 The \c PingTransition class defines a transition that is triggered by events of type \c PingEvent, and that posts a \c PongEvent (with a delay of 500 milliseconds) to the state machine when the transition is triggered. - \snippet statemachine/pingpong/main.cpp 3 + \snippet pingpong/main.cpp 3 The \c PongTransition class defines a transition that is triggered by events of type \c PongEvent, and that posts a \c PingEvent (with a delay of 500 milliseconds) to the state machine when the transition is triggered. - \snippet statemachine/pingpong/main.cpp 4 + \snippet pingpong/main.cpp 4 The main() function begins by creating a state machine and a parallel state group. - \snippet statemachine/pingpong/main.cpp 5 + \snippet pingpong/main.cpp 5 Next, the \c pinger and \c ponger states are created, with the parallel state group as their parent state. Note that the transitions are \e @@ -59,7 +59,7 @@ be called, and the state machine's configuration will remain the same, which is precisely what we want in this case. - \snippet statemachine/pingpong/main.cpp 6 + \snippet pingpong/main.cpp 6 Finally, the group is added to the state machine, the machine is started, and the application event loop is entered. diff --git a/examples/statemachine/doc/src/rogue.qdoc b/examples/statemachine/doc/src/rogue.qdoc index 02020c4..8c41104 100644 --- a/examples/statemachine/doc/src/rogue.qdoc +++ b/examples/statemachine/doc/src/rogue.qdoc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example statemachine/rogue + \example rogue \title Rogue Example \ingroup examples-qtstatemachine @@ -72,7 +72,7 @@ connects the states in the machine. It is the key events from this widget that are used by the machine. - \snippet statemachine/rogue/window.h 0 + \snippet rogue/window.h 0 \c Direction specifies the direction in which the rogue is to move. We use this in \c movePlayer(), which moves the rogue and @@ -82,7 +82,7 @@ setting any Qt \l{Qt's Property System}{property} when entered. More on this later. - \snippet statemachine/rogue/window.h 1 + \snippet rogue/window.h 1 The \c map is an array with the characters that are currently displayed. We set up the array in \c setupMap(), and update it @@ -101,15 +101,15 @@ Here is the constructor of \c Window: - \snippet statemachine/rogue/window.cpp 0 + \snippet rogue/window.cpp 0 \dots - \snippet statemachine/rogue/window.cpp 1 + \snippet rogue/window.cpp 1 The player starts off at position (5, 5). We then set up the map and statemachine. Let's proceed with the \c buildMachine() function: - \snippet statemachine/rogue/window.cpp 2 + \snippet rogue/window.cpp 2 We enter \c inputState when the machine is started and from the \c quitState if the user wants to continue playing. We then set the @@ -124,7 +124,7 @@ inputState as the target state, we would first have left and then entered the \c inputState again. - \snippet statemachine/rogue/window.cpp 3 + \snippet rogue/window.cpp 3 When we enter \c quitState, we update the status bar of the window. @@ -134,12 +134,12 @@ specify the key on which the transition should trigger and the target state of the transition. - \snippet statemachine/rogue/window.cpp 4 + \snippet rogue/window.cpp 4 The transition from \c inputState allows triggering the quit state when the player types \c {q}. - \snippet statemachine/rogue/window.cpp 5 + \snippet rogue/window.cpp 5 The machine is set up, so it's time to start it. @@ -149,13 +149,13 @@ rogue to be moved (by typing 2, 4, 6, or 8) when the machine is in the \c inputState. - \snippet statemachine/rogue/movementtransition.h 0 + \snippet rogue/movementtransition.h 0 In the constructor, we tell QEventTransition to only send \l{QEvent::}{KeyPress} events to the \l [CPP] {QAbstractTransition::}{eventTest()} function: - \snippet statemachine/rogue/movementtransition.h 1 + \snippet rogue/movementtransition.h 1 The KeyPress events come wrapped in \l{QStateMachine::WrappedEvent}s. \c event must be confirmed to be a wrapped event because Qt uses other @@ -164,7 +164,7 @@ Let's move on to the \c onTransition() function: - \snippet statemachine/rogue/movementtransition.h 2 + \snippet rogue/movementtransition.h 2 When \c onTransition() is invoked, we know that we have a \l{QEvent::}{KeyPress} event with 2, 4, 6, or 8, and can ask \c diff --git a/examples/statemachine/doc/src/trafficlight.qdoc b/examples/statemachine/doc/src/trafficlight.qdoc index be52925..a30cd47 100644 --- a/examples/statemachine/doc/src/trafficlight.qdoc +++ b/examples/statemachine/doc/src/trafficlight.qdoc @@ -2,7 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! - \example statemachine/trafficlight + \example trafficlight \title Traffic Light Example \ingroup examples-qtstatemachine @@ -16,20 +16,20 @@ one light to another (red to yellow to green to yellow to red again) at certain intervals. - \snippet statemachine/trafficlight/main.cpp 0 + \snippet trafficlight/main.cpp 0 The LightWidget class represents a single light of the traffic light. It provides an \c on property and two slots, turnOn() and turnOff(), to turn the light on and off, respectively. The widget paints itself in the color that's passed to the constructor. - \snippet statemachine/trafficlight/main.cpp 1 + \snippet trafficlight/main.cpp 1 The TrafficLightWidget class represents the visual part of the traffic light; it's a widget that contains three lights arranged vertically, and provides accessor functions for these. - \snippet statemachine/trafficlight/main.cpp 2 + \snippet trafficlight/main.cpp 2 The createLightState() function creates a state that turns a light on when the state is entered, and off when the state is exited. The state uses a @@ -38,7 +38,7 @@ \image trafficlight-example1.png - \snippet statemachine/trafficlight/main.cpp 3 + \snippet trafficlight/main.cpp 3 The TrafficLight class combines the TrafficLightWidget with a state machine. The state graph has four states: red-to-yellow, yellow-to-green, @@ -49,7 +49,7 @@ \image trafficlight-example2.png - \snippet statemachine/trafficlight/main.cpp 4 + \snippet trafficlight/main.cpp 4 The main() function constructs a TrafficLight and shows it. diff --git a/examples/statemachine/animation/moveblocks/CMakeLists.txt b/examples/statemachine/moveblocks/CMakeLists.txt index a4ac7e1..a4ac7e1 100644 --- a/examples/statemachine/animation/moveblocks/CMakeLists.txt +++ b/examples/statemachine/moveblocks/CMakeLists.txt diff --git a/examples/statemachine/animation/moveblocks/main.cpp b/examples/statemachine/moveblocks/main.cpp index 9a00a2f..9a00a2f 100644 --- a/examples/statemachine/animation/moveblocks/main.cpp +++ b/examples/statemachine/moveblocks/main.cpp diff --git a/examples/statemachine/animation/moveblocks/moveblocks.pro b/examples/statemachine/moveblocks/moveblocks.pro index 405a949..405a949 100644 --- a/examples/statemachine/animation/moveblocks/moveblocks.pro +++ b/examples/statemachine/moveblocks/moveblocks.pro diff --git a/examples/statemachine/statemachine/pingpong/CMakeLists.txt b/examples/statemachine/pingpong/CMakeLists.txt index 4810bf2..4810bf2 100644 --- a/examples/statemachine/statemachine/pingpong/CMakeLists.txt +++ b/examples/statemachine/pingpong/CMakeLists.txt diff --git a/examples/statemachine/statemachine/pingpong/main.cpp b/examples/statemachine/pingpong/main.cpp index 27ca34e..27ca34e 100644 --- a/examples/statemachine/statemachine/pingpong/main.cpp +++ b/examples/statemachine/pingpong/main.cpp diff --git a/examples/statemachine/statemachine/pingpong/pingpong.pro b/examples/statemachine/pingpong/pingpong.pro index 1e08cd0..1e08cd0 100644 --- a/examples/statemachine/statemachine/pingpong/pingpong.pro +++ b/examples/statemachine/pingpong/pingpong.pro diff --git a/examples/statemachine/statemachine/rogue/CMakeLists.txt b/examples/statemachine/rogue/CMakeLists.txt index 922aa96..922aa96 100644 --- a/examples/statemachine/statemachine/rogue/CMakeLists.txt +++ b/examples/statemachine/rogue/CMakeLists.txt diff --git a/examples/statemachine/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp index 0720f50..0720f50 100644 --- a/examples/statemachine/statemachine/rogue/main.cpp +++ b/examples/statemachine/rogue/main.cpp diff --git a/examples/statemachine/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h index 9e1c257..9e1c257 100644 --- a/examples/statemachine/statemachine/rogue/movementtransition.h +++ b/examples/statemachine/rogue/movementtransition.h diff --git a/examples/statemachine/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro index 7260d76..7260d76 100644 --- a/examples/statemachine/statemachine/rogue/rogue.pro +++ b/examples/statemachine/rogue/rogue.pro diff --git a/examples/statemachine/statemachine/rogue/window.cpp b/examples/statemachine/rogue/window.cpp index 6dfba59..6dfba59 100644 --- a/examples/statemachine/statemachine/rogue/window.cpp +++ b/examples/statemachine/rogue/window.cpp diff --git a/examples/statemachine/statemachine/rogue/window.h b/examples/statemachine/rogue/window.h index faca764..faca764 100644 --- a/examples/statemachine/statemachine/rogue/window.h +++ b/examples/statemachine/rogue/window.h diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro index fe9a96e..5c0e501 100644 --- a/examples/statemachine/statemachine.pro +++ b/examples/statemachine/statemachine.pro @@ -1,8 +1,11 @@ -requires(qtHaveModule(widgets)) - TEMPLATE = subdirs -CONFIG += no_docs_target -SUBDIRS = statemachine +SUBDIRS += pingpong \ -qtConfig(animation): SUBDIRS += animation +qtHaveModule(widgets) { + SUBDIRS += rogue \ + trafficlight + qtConfig(animation) { + SUBDIRS += moveblocks \ + } +} diff --git a/examples/statemachine/statemachine/CMakeLists.txt b/examples/statemachine/statemachine/CMakeLists.txt deleted file mode 100644 index af5e9c3..0000000 --- a/examples/statemachine/statemachine/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -qt_internal_add_example(pingpong) -if(TARGET Qt::Widgets) - qt_internal_add_example(rogue) - qt_internal_add_example(trafficlight) -endif() diff --git a/examples/statemachine/statemachine/README b/examples/statemachine/statemachine/README deleted file mode 100644 index a0ac35a..0000000 --- a/examples/statemachine/statemachine/README +++ /dev/null @@ -1,6 +0,0 @@ -Qt is provided with a powerful hierchical finite state machine through -the Qt State Machine classes. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/statemachine/statemachine/statemachine.pro b/examples/statemachine/statemachine/statemachine.pro deleted file mode 100644 index a33dc14..0000000 --- a/examples/statemachine/statemachine/statemachine.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = pingpong - -qtHaveModule(widgets) { - SUBDIRS += rogue \ - trafficlight -} diff --git a/examples/statemachine/statemachine/trafficlight/CMakeLists.txt b/examples/statemachine/trafficlight/CMakeLists.txt index e566324..e566324 100644 --- a/examples/statemachine/statemachine/trafficlight/CMakeLists.txt +++ b/examples/statemachine/trafficlight/CMakeLists.txt diff --git a/examples/statemachine/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp index a2478dc..a2478dc 100644 --- a/examples/statemachine/statemachine/trafficlight/main.cpp +++ b/examples/statemachine/trafficlight/main.cpp diff --git a/examples/statemachine/statemachine/trafficlight/trafficlight.pro b/examples/statemachine/trafficlight/trafficlight.pro index 0865787..0865787 100644 --- a/examples/statemachine/statemachine/trafficlight/trafficlight.pro +++ b/examples/statemachine/trafficlight/trafficlight.pro |