From a735038376e1c229c293c36bd67800851323baf1 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Tue, 18 Aug 2020 14:26:50 +0200 Subject: Move QStateMachine from QtCore to QtScxml Task-number: QTBUG-80316 Change-Id: I2ee74110fd55e94d86321d3b3dc5bb8297424ed4 Reviewed-by: Maurice Kalinowski --- examples/widgets/.prev_CMakeLists.txt | 1 - examples/widgets/CMakeLists.txt | 1 - examples/widgets/animation/CMakeLists.txt | 5 - .../widgets/animation/animatedtiles/CMakeLists.txt | 54 - .../animation/animatedtiles/animatedtiles.pro | 8 - .../animation/animatedtiles/animatedtiles.qrc | 11 - .../animatedtiles/images/Time-For-Lunch-2.jpg | Bin 32471 -> 0 bytes .../animation/animatedtiles/images/centered.png | Bin 892 -> 0 bytes .../animation/animatedtiles/images/ellipse.png | Bin 10767 -> 0 bytes .../animation/animatedtiles/images/figure8.png | Bin 14050 -> 0 bytes .../animation/animatedtiles/images/kinetic.png | Bin 5055 -> 0 bytes .../animation/animatedtiles/images/random.png | Bin 14969 -> 0 bytes .../animation/animatedtiles/images/tile.png | Bin 16337 -> 0 bytes examples/widgets/animation/animatedtiles/main.cpp | 268 ---- examples/widgets/animation/animation.pro | 8 +- .../widgets/animation/moveblocks/CMakeLists.txt | 35 - examples/widgets/animation/moveblocks/main.cpp | 330 ----- .../widgets/animation/moveblocks/moveblocks.pro | 7 - examples/widgets/animation/states/CMakeLists.txt | 53 - .../animation/states/accessories-dictionary.png | Bin 5396 -> 0 bytes examples/widgets/animation/states/akregator.png | Bin 4873 -> 0 bytes examples/widgets/animation/states/digikam.png | Bin 3334 -> 0 bytes examples/widgets/animation/states/help-browser.png | Bin 6984 -> 0 bytes examples/widgets/animation/states/k3b.png | Bin 8220 -> 0 bytes examples/widgets/animation/states/kchart.png | Bin 4887 -> 0 bytes examples/widgets/animation/states/main.cpp | 295 ---- examples/widgets/animation/states/states.pro | 8 - examples/widgets/animation/states/states.qrc | 10 - examples/widgets/animation/stickman/CMakeLists.txt | 57 - examples/widgets/animation/stickman/animation.cpp | 193 --- examples/widgets/animation/stickman/animation.h | 92 -- .../animation/stickman/animations/chilling.bin | Bin 6508 -> 0 bytes .../animation/stickman/animations/dancing.bin | Bin 2348 -> 0 bytes .../widgets/animation/stickman/animations/dead.bin | Bin 268 -> 0 bytes .../animation/stickman/animations/jumping.bin | Bin 1308 -> 0 bytes .../widgets/animation/stickman/graphicsview.cpp | 68 - examples/widgets/animation/stickman/graphicsview.h | 70 - examples/widgets/animation/stickman/lifecycle.cpp | 234 ---- examples/widgets/animation/stickman/lifecycle.h | 91 -- examples/widgets/animation/stickman/main.cpp | 116 -- examples/widgets/animation/stickman/node.cpp | 102 -- examples/widgets/animation/stickman/node.h | 80 -- examples/widgets/animation/stickman/rectbutton.cpp | 78 -- examples/widgets/animation/stickman/rectbutton.h | 75 - examples/widgets/animation/stickman/stickman.cpp | 329 ----- examples/widgets/animation/stickman/stickman.h | 108 -- examples/widgets/animation/stickman/stickman.pro | 21 - examples/widgets/animation/stickman/stickman.qrc | 8 - .../animation/sub-attaq/.prev_CMakeLists.txt | 196 --- .../widgets/animation/sub-attaq/CMakeLists.txt | 197 --- .../animation/sub-attaq/animationmanager.cpp | 98 -- .../widgets/animation/sub-attaq/animationmanager.h | 82 -- examples/widgets/animation/sub-attaq/boat.cpp | 281 ---- examples/widgets/animation/sub-attaq/boat.h | 103 -- examples/widgets/animation/sub-attaq/boat_p.h | 246 ---- examples/widgets/animation/sub-attaq/bomb.cpp | 128 -- examples/widgets/animation/sub-attaq/bomb.h | 76 - examples/widgets/animation/sub-attaq/data.xml | 39 - .../widgets/animation/sub-attaq/graphicsscene.cpp | 301 ---- .../widgets/animation/sub-attaq/graphicsscene.h | 130 -- examples/widgets/animation/sub-attaq/main.cpp | 64 - .../widgets/animation/sub-attaq/mainwindow.cpp | 84 -- examples/widgets/animation/sub-attaq/mainwindow.h | 72 - .../animation/sub-attaq/pics/big/background.png | Bin 48858 -> 0 bytes .../widgets/animation/sub-attaq/pics/big/boat.png | Bin 5198 -> 0 bytes .../widgets/animation/sub-attaq/pics/big/bomb.png | Bin 760 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step1.png | Bin 5760 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step2.png | Bin 9976 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step3.png | Bin 12411 -> 0 bytes .../sub-attaq/pics/big/explosion/boat/step4.png | Bin 15438 -> 0 bytes .../pics/big/explosion/submarine/step1.png | Bin 3354 -> 0 bytes .../pics/big/explosion/submarine/step2.png | Bin 6205 -> 0 bytes .../pics/big/explosion/submarine/step3.png | Bin 6678 -> 0 bytes .../pics/big/explosion/submarine/step4.png | Bin 6666 -> 0 bytes .../animation/sub-attaq/pics/big/submarine.png | Bin 3202 -> 0 bytes .../animation/sub-attaq/pics/big/surface.png | Bin 575 -> 0 bytes .../animation/sub-attaq/pics/big/torpedo.png | Bin 951 -> 0 bytes .../sub-attaq/pics/scalable/background-n810.svg | 171 --- .../sub-attaq/pics/scalable/background.svg | 171 --- .../animation/sub-attaq/pics/scalable/boat.svg | 279 ---- .../animation/sub-attaq/pics/scalable/bomb.svg | 138 -- .../animation/sub-attaq/pics/scalable/sand.svg | 103 -- .../animation/sub-attaq/pics/scalable/see.svg | 44 - .../animation/sub-attaq/pics/scalable/sky.svg | 45 - .../sub-attaq/pics/scalable/sub-attaq.svg | 1473 -------------------- .../sub-attaq/pics/scalable/submarine.svg | 214 --- .../animation/sub-attaq/pics/scalable/surface.svg | 49 - .../animation/sub-attaq/pics/scalable/torpedo.svg | 127 -- .../animation/sub-attaq/pics/small/background.png | Bin 34634 -> 0 bytes .../animation/sub-attaq/pics/small/boat.png | Bin 2394 -> 0 bytes .../animation/sub-attaq/pics/small/bomb.png | Bin 760 -> 0 bytes .../animation/sub-attaq/pics/small/submarine.png | Bin 1338 -> 0 bytes .../animation/sub-attaq/pics/small/surface.png | Bin 502 -> 0 bytes .../animation/sub-attaq/pics/small/torpedo.png | Bin 951 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-a.png | Bin 5972 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-a2.png | Bin 5969 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-b.png | Bin 6869 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-dash.png | Bin 2255 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-excl.png | Bin 2740 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-q.png | Bin 7016 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-s.png | Bin 5817 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-t.png | Bin 3717 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-t2.png | Bin 3688 -> 0 bytes .../animation/sub-attaq/pics/welcome/logo-u.png | Bin 5374 -> 0 bytes .../widgets/animation/sub-attaq/pixmapitem.cpp | 87 -- examples/widgets/animation/sub-attaq/pixmapitem.h | 72 - .../widgets/animation/sub-attaq/progressitem.cpp | 77 - .../widgets/animation/sub-attaq/progressitem.h | 70 - .../animation/sub-attaq/qanimationstate.cpp | 154 -- .../widgets/animation/sub-attaq/qanimationstate.h | 85 -- examples/widgets/animation/sub-attaq/states.cpp | 335 ----- examples/widgets/animation/sub-attaq/states.h | 180 --- examples/widgets/animation/sub-attaq/sub-attaq.pro | 33 - examples/widgets/animation/sub-attaq/subattaq.qrc | 39 - examples/widgets/animation/sub-attaq/submarine.cpp | 187 --- examples/widgets/animation/sub-attaq/submarine.h | 99 -- examples/widgets/animation/sub-attaq/submarine_p.h | 147 -- .../animation/sub-attaq/textinformationitem.cpp | 64 - .../animation/sub-attaq/textinformationitem.h | 64 - examples/widgets/animation/sub-attaq/torpedo.cpp | 124 -- examples/widgets/animation/sub-attaq/torpedo.h | 76 - examples/widgets/doc/images/factorial-example.png | Bin 4032 -> 0 bytes examples/widgets/doc/images/pingpong-example.png | Bin 7843 -> 0 bytes .../widgets/doc/images/trafficlight-example1.png | Bin 3694 -> 0 bytes .../widgets/doc/images/trafficlight-example2.png | Bin 7257 -> 0 bytes examples/widgets/doc/src/animatedtiles.qdoc | 36 - examples/widgets/doc/src/eventtransitions.qdoc | 85 -- examples/widgets/doc/src/factorial.qdoc | 88 -- examples/widgets/doc/src/moveblocks.qdoc | 214 --- examples/widgets/doc/src/padnavigator.qdoc | 586 -------- examples/widgets/doc/src/pingpong.qdoc | 93 -- examples/widgets/doc/src/rogue.qdoc | 208 --- examples/widgets/doc/src/states.qdoc | 36 - examples/widgets/doc/src/stickman.qdoc | 102 -- examples/widgets/doc/src/sub-attaq.qdoc | 41 - examples/widgets/doc/src/trafficlight.qdoc | 85 -- examples/widgets/doc/src/twowaybutton.qdoc | 68 - examples/widgets/graphicsview/CMakeLists.txt | 1 - examples/widgets/graphicsview/graphicsview.pro | 1 - .../graphicsview/padnavigator/.prev_CMakeLists.txt | 68 - .../graphicsview/padnavigator/CMakeLists.txt | 69 - .../graphicsview/padnavigator/flippablepad.cpp | 108 -- .../graphicsview/padnavigator/flippablepad.h | 71 - examples/widgets/graphicsview/padnavigator/form.ui | 208 --- .../padnavigator/images/artsfftscope.png | Bin 1291 -> 0 bytes .../padnavigator/images/blue_angle_swirl.jpg | Bin 11826 -> 0 bytes .../padnavigator/images/kontact_contacts.png | Bin 4382 -> 0 bytes .../padnavigator/images/kontact_journal.png | Bin 3261 -> 0 bytes .../padnavigator/images/kontact_mail.png | Bin 3202 -> 0 bytes .../padnavigator/images/kontact_notes.png | Bin 3893 -> 0 bytes .../padnavigator/images/kopeteavailable.png | Bin 2380 -> 0 bytes .../padnavigator/images/metacontact_online.png | Bin 2545 -> 0 bytes .../graphicsview/padnavigator/images/minitools.png | Bin 2087 -> 0 bytes .../widgets/graphicsview/padnavigator/main.cpp | 65 - .../graphicsview/padnavigator/padnavigator.cpp | 318 ----- .../graphicsview/padnavigator/padnavigator.h | 72 - .../graphicsview/padnavigator/padnavigator.pro | 27 - .../graphicsview/padnavigator/padnavigator.qrc | 13 - .../graphicsview/padnavigator/roundrectitem.cpp | 125 -- .../graphicsview/padnavigator/roundrectitem.h | 85 -- .../graphicsview/padnavigator/splashitem.cpp | 93 -- .../widgets/graphicsview/padnavigator/splashitem.h | 71 - examples/widgets/statemachine/CMakeLists.txt | 10 - examples/widgets/statemachine/README | 6 - .../statemachine/eventtransitions/CMakeLists.txt | 35 - .../eventtransitions/eventtransitions.pro | 7 - .../widgets/statemachine/eventtransitions/main.cpp | 130 -- .../widgets/statemachine/factorial/CMakeLists.txt | 31 - .../widgets/statemachine/factorial/factorial.pro | 10 - examples/widgets/statemachine/factorial/main.cpp | 181 --- .../widgets/statemachine/pingpong/CMakeLists.txt | 31 - examples/widgets/statemachine/pingpong/main.cpp | 149 -- .../widgets/statemachine/pingpong/pingpong.pro | 10 - examples/widgets/statemachine/rogue/CMakeLists.txt | 37 - examples/widgets/statemachine/rogue/main.cpp | 64 - .../statemachine/rogue/movementtransition.h | 122 -- examples/widgets/statemachine/rogue/rogue.pro | 10 - examples/widgets/statemachine/rogue/window.cpp | 261 ---- examples/widgets/statemachine/rogue/window.h | 100 -- examples/widgets/statemachine/statemachine.pro | 12 - .../statemachine/trafficlight/CMakeLists.txt | 35 - .../widgets/statemachine/trafficlight/main.cpp | 200 --- .../statemachine/trafficlight/trafficlight.pro | 9 - .../statemachine/twowaybutton/CMakeLists.txt | 35 - .../widgets/statemachine/twowaybutton/main.cpp | 91 -- .../statemachine/twowaybutton/twowaybutton.pro | 9 - examples/widgets/widgets.pro | 1 - 187 files changed, 1 insertion(+), 14242 deletions(-) delete mode 100644 examples/widgets/animation/animatedtiles/CMakeLists.txt delete mode 100644 examples/widgets/animation/animatedtiles/animatedtiles.pro delete mode 100644 examples/widgets/animation/animatedtiles/animatedtiles.qrc delete mode 100644 examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg delete mode 100644 examples/widgets/animation/animatedtiles/images/centered.png delete mode 100644 examples/widgets/animation/animatedtiles/images/ellipse.png delete mode 100644 examples/widgets/animation/animatedtiles/images/figure8.png delete mode 100644 examples/widgets/animation/animatedtiles/images/kinetic.png delete mode 100644 examples/widgets/animation/animatedtiles/images/random.png delete mode 100644 examples/widgets/animation/animatedtiles/images/tile.png delete mode 100644 examples/widgets/animation/animatedtiles/main.cpp delete mode 100644 examples/widgets/animation/moveblocks/CMakeLists.txt delete mode 100644 examples/widgets/animation/moveblocks/main.cpp delete mode 100644 examples/widgets/animation/moveblocks/moveblocks.pro delete mode 100644 examples/widgets/animation/states/CMakeLists.txt delete mode 100644 examples/widgets/animation/states/accessories-dictionary.png delete mode 100644 examples/widgets/animation/states/akregator.png delete mode 100644 examples/widgets/animation/states/digikam.png delete mode 100644 examples/widgets/animation/states/help-browser.png delete mode 100644 examples/widgets/animation/states/k3b.png delete mode 100644 examples/widgets/animation/states/kchart.png delete mode 100644 examples/widgets/animation/states/main.cpp delete mode 100644 examples/widgets/animation/states/states.pro delete mode 100644 examples/widgets/animation/states/states.qrc delete mode 100644 examples/widgets/animation/stickman/CMakeLists.txt delete mode 100644 examples/widgets/animation/stickman/animation.cpp delete mode 100644 examples/widgets/animation/stickman/animation.h delete mode 100644 examples/widgets/animation/stickman/animations/chilling.bin delete mode 100644 examples/widgets/animation/stickman/animations/dancing.bin delete mode 100644 examples/widgets/animation/stickman/animations/dead.bin delete mode 100644 examples/widgets/animation/stickman/animations/jumping.bin delete mode 100644 examples/widgets/animation/stickman/graphicsview.cpp delete mode 100644 examples/widgets/animation/stickman/graphicsview.h delete mode 100644 examples/widgets/animation/stickman/lifecycle.cpp delete mode 100644 examples/widgets/animation/stickman/lifecycle.h delete mode 100644 examples/widgets/animation/stickman/main.cpp delete mode 100644 examples/widgets/animation/stickman/node.cpp delete mode 100644 examples/widgets/animation/stickman/node.h delete mode 100644 examples/widgets/animation/stickman/rectbutton.cpp delete mode 100644 examples/widgets/animation/stickman/rectbutton.h delete mode 100644 examples/widgets/animation/stickman/stickman.cpp delete mode 100644 examples/widgets/animation/stickman/stickman.h delete mode 100644 examples/widgets/animation/stickman/stickman.pro delete mode 100644 examples/widgets/animation/stickman/stickman.qrc delete mode 100644 examples/widgets/animation/sub-attaq/.prev_CMakeLists.txt delete mode 100644 examples/widgets/animation/sub-attaq/CMakeLists.txt delete mode 100644 examples/widgets/animation/sub-attaq/animationmanager.cpp delete mode 100644 examples/widgets/animation/sub-attaq/animationmanager.h delete mode 100644 examples/widgets/animation/sub-attaq/boat.cpp delete mode 100644 examples/widgets/animation/sub-attaq/boat.h delete mode 100644 examples/widgets/animation/sub-attaq/boat_p.h delete mode 100644 examples/widgets/animation/sub-attaq/bomb.cpp delete mode 100644 examples/widgets/animation/sub-attaq/bomb.h delete mode 100644 examples/widgets/animation/sub-attaq/data.xml delete mode 100644 examples/widgets/animation/sub-attaq/graphicsscene.cpp delete mode 100644 examples/widgets/animation/sub-attaq/graphicsscene.h delete mode 100644 examples/widgets/animation/sub-attaq/main.cpp delete mode 100644 examples/widgets/animation/sub-attaq/mainwindow.cpp delete mode 100644 examples/widgets/animation/sub-attaq/mainwindow.h delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/background.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/boat.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/bomb.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/submarine.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/surface.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/big/torpedo.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/background.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/boat.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sand.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/see.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sky.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/surface.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/background.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/boat.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/bomb.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/submarine.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/surface.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/small/torpedo.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png delete mode 100644 examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png delete mode 100644 examples/widgets/animation/sub-attaq/pixmapitem.cpp delete mode 100644 examples/widgets/animation/sub-attaq/pixmapitem.h delete mode 100644 examples/widgets/animation/sub-attaq/progressitem.cpp delete mode 100644 examples/widgets/animation/sub-attaq/progressitem.h delete mode 100644 examples/widgets/animation/sub-attaq/qanimationstate.cpp delete mode 100644 examples/widgets/animation/sub-attaq/qanimationstate.h delete mode 100644 examples/widgets/animation/sub-attaq/states.cpp delete mode 100644 examples/widgets/animation/sub-attaq/states.h delete mode 100644 examples/widgets/animation/sub-attaq/sub-attaq.pro delete mode 100644 examples/widgets/animation/sub-attaq/subattaq.qrc delete mode 100644 examples/widgets/animation/sub-attaq/submarine.cpp delete mode 100644 examples/widgets/animation/sub-attaq/submarine.h delete mode 100644 examples/widgets/animation/sub-attaq/submarine_p.h delete mode 100644 examples/widgets/animation/sub-attaq/textinformationitem.cpp delete mode 100644 examples/widgets/animation/sub-attaq/textinformationitem.h delete mode 100644 examples/widgets/animation/sub-attaq/torpedo.cpp delete mode 100644 examples/widgets/animation/sub-attaq/torpedo.h delete mode 100644 examples/widgets/doc/images/factorial-example.png delete mode 100644 examples/widgets/doc/images/pingpong-example.png delete mode 100644 examples/widgets/doc/images/trafficlight-example1.png delete mode 100644 examples/widgets/doc/images/trafficlight-example2.png delete mode 100644 examples/widgets/doc/src/animatedtiles.qdoc delete mode 100644 examples/widgets/doc/src/eventtransitions.qdoc delete mode 100644 examples/widgets/doc/src/factorial.qdoc delete mode 100644 examples/widgets/doc/src/moveblocks.qdoc delete mode 100644 examples/widgets/doc/src/padnavigator.qdoc delete mode 100644 examples/widgets/doc/src/pingpong.qdoc delete mode 100644 examples/widgets/doc/src/rogue.qdoc delete mode 100644 examples/widgets/doc/src/states.qdoc delete mode 100644 examples/widgets/doc/src/stickman.qdoc delete mode 100644 examples/widgets/doc/src/sub-attaq.qdoc delete mode 100644 examples/widgets/doc/src/trafficlight.qdoc delete mode 100644 examples/widgets/doc/src/twowaybutton.qdoc delete mode 100644 examples/widgets/graphicsview/padnavigator/.prev_CMakeLists.txt delete mode 100644 examples/widgets/graphicsview/padnavigator/CMakeLists.txt delete mode 100644 examples/widgets/graphicsview/padnavigator/flippablepad.cpp delete mode 100644 examples/widgets/graphicsview/padnavigator/flippablepad.h delete mode 100644 examples/widgets/graphicsview/padnavigator/form.ui delete mode 100644 examples/widgets/graphicsview/padnavigator/images/artsfftscope.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/blue_angle_swirl.jpg delete mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_contacts.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_journal.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_mail.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/kontact_notes.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/kopeteavailable.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/metacontact_online.png delete mode 100644 examples/widgets/graphicsview/padnavigator/images/minitools.png delete mode 100644 examples/widgets/graphicsview/padnavigator/main.cpp delete mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.cpp delete mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.h delete mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.pro delete mode 100644 examples/widgets/graphicsview/padnavigator/padnavigator.qrc delete mode 100644 examples/widgets/graphicsview/padnavigator/roundrectitem.cpp delete mode 100644 examples/widgets/graphicsview/padnavigator/roundrectitem.h delete mode 100644 examples/widgets/graphicsview/padnavigator/splashitem.cpp delete mode 100644 examples/widgets/graphicsview/padnavigator/splashitem.h delete mode 100644 examples/widgets/statemachine/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/README delete mode 100644 examples/widgets/statemachine/eventtransitions/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/eventtransitions/eventtransitions.pro delete mode 100644 examples/widgets/statemachine/eventtransitions/main.cpp delete mode 100644 examples/widgets/statemachine/factorial/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/factorial/factorial.pro delete mode 100644 examples/widgets/statemachine/factorial/main.cpp delete mode 100644 examples/widgets/statemachine/pingpong/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/pingpong/main.cpp delete mode 100644 examples/widgets/statemachine/pingpong/pingpong.pro delete mode 100644 examples/widgets/statemachine/rogue/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/rogue/main.cpp delete mode 100644 examples/widgets/statemachine/rogue/movementtransition.h delete mode 100644 examples/widgets/statemachine/rogue/rogue.pro delete mode 100644 examples/widgets/statemachine/rogue/window.cpp delete mode 100644 examples/widgets/statemachine/rogue/window.h delete mode 100644 examples/widgets/statemachine/statemachine.pro delete mode 100644 examples/widgets/statemachine/trafficlight/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/trafficlight/main.cpp delete mode 100644 examples/widgets/statemachine/trafficlight/trafficlight.pro delete mode 100644 examples/widgets/statemachine/twowaybutton/CMakeLists.txt delete mode 100644 examples/widgets/statemachine/twowaybutton/main.cpp delete mode 100644 examples/widgets/statemachine/twowaybutton/twowaybutton.pro (limited to 'examples/widgets') diff --git a/examples/widgets/.prev_CMakeLists.txt b/examples/widgets/.prev_CMakeLists.txt index 8eca336c88..ea87c3c027 100644 --- a/examples/widgets/.prev_CMakeLists.txt +++ b/examples/widgets/.prev_CMakeLists.txt @@ -17,7 +17,6 @@ add_subdirectory(layouts) add_subdirectory(painting) add_subdirectory(richtext) add_subdirectory(scroller) -add_subdirectory(statemachine) add_subdirectory(tools) add_subdirectory(touch) add_subdirectory(tutorials) diff --git a/examples/widgets/CMakeLists.txt b/examples/widgets/CMakeLists.txt index 6f4ce76e6e..5026a40a80 100644 --- a/examples/widgets/CMakeLists.txt +++ b/examples/widgets/CMakeLists.txt @@ -17,7 +17,6 @@ add_subdirectory(layouts) add_subdirectory(painting) add_subdirectory(richtext) add_subdirectory(scroller) -add_subdirectory(statemachine) add_subdirectory(tools) add_subdirectory(touch) add_subdirectory(tutorials) diff --git a/examples/widgets/animation/CMakeLists.txt b/examples/widgets/animation/CMakeLists.txt index 15f62728da..e3382787aa 100644 --- a/examples/widgets/animation/CMakeLists.txt +++ b/examples/widgets/animation/CMakeLists.txt @@ -1,8 +1,3 @@ # Generated from animation.pro. -add_subdirectory(animatedtiles) add_subdirectory(easing) -add_subdirectory(moveblocks) -add_subdirectory(states) -add_subdirectory(stickman) -add_subdirectory(sub-attaq) diff --git a/examples/widgets/animation/animatedtiles/CMakeLists.txt b/examples/widgets/animation/animatedtiles/CMakeLists.txt deleted file mode 100644 index 318ac77f8f..0000000000 --- a/examples/widgets/animation/animatedtiles/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Generated from animatedtiles.pro. - -cmake_minimum_required(VERSION 3.14) -project(animatedtiles 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/animatedtiles") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(animatedtiles - main.cpp -) -target_link_libraries(animatedtiles PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(animatedtiles_resource_files - "images/Time-For-Lunch-2.jpg" - "images/centered.png" - "images/ellipse.png" - "images/figure8.png" - "images/kinetic.png" - "images/random.png" - "images/tile.png" -) - -qt6_add_resources(animatedtiles "animatedtiles" - PREFIX - "/" - FILES - ${animatedtiles_resource_files} -) - -install(TARGETS animatedtiles - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.pro b/examples/widgets/animation/animatedtiles/animatedtiles.pro deleted file mode 100644 index 04c2b8f3d0..0000000000 --- a/examples/widgets/animation/animatedtiles/animatedtiles.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT += widgets - -SOURCES = main.cpp -RESOURCES = animatedtiles.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/animatedtiles -INSTALLS += target diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.qrc b/examples/widgets/animation/animatedtiles/animatedtiles.qrc deleted file mode 100644 index c43a979723..0000000000 --- a/examples/widgets/animation/animatedtiles/animatedtiles.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - images/Time-For-Lunch-2.jpg - images/centered.png - images/ellipse.png - images/figure8.png - images/kinetic.png - images/random.png - images/tile.png - - diff --git a/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg b/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg deleted file mode 100644 index c57a555490..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/Time-For-Lunch-2.jpg and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/centered.png b/examples/widgets/animation/animatedtiles/images/centered.png deleted file mode 100644 index e416156a0e..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/centered.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/ellipse.png b/examples/widgets/animation/animatedtiles/images/ellipse.png deleted file mode 100644 index 2c3ba881c5..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/ellipse.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/figure8.png b/examples/widgets/animation/animatedtiles/images/figure8.png deleted file mode 100644 index 6b058041c4..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/figure8.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/kinetic.png b/examples/widgets/animation/animatedtiles/images/kinetic.png deleted file mode 100644 index d5fc0af0f2..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/kinetic.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/random.png b/examples/widgets/animation/animatedtiles/images/random.png deleted file mode 100644 index 415d96f856..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/random.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/images/tile.png b/examples/widgets/animation/animatedtiles/images/tile.png deleted file mode 100644 index c8f39d8d40..0000000000 Binary files a/examples/widgets/animation/animatedtiles/images/tile.png and /dev/null differ diff --git a/examples/widgets/animation/animatedtiles/main.cpp b/examples/widgets/animation/animatedtiles/main.cpp deleted file mode 100644 index 553b620e41..0000000000 --- a/examples/widgets/animation/animatedtiles/main.cpp +++ /dev/null @@ -1,268 +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 -#include -#include -#include - -class Pixmap : public QObject, public QGraphicsPixmapItem -{ - Q_OBJECT - Q_PROPERTY(QPointF pos READ pos WRITE setPos) -public: - Pixmap(const QPixmap &pix) - : QObject(), QGraphicsPixmapItem(pix) - { - setCacheMode(DeviceCoordinateCache); - } -}; - -class Button : public QGraphicsWidget -{ - Q_OBJECT -public: - Button(const QPixmap &pixmap, QGraphicsItem *parent = nullptr) - : QGraphicsWidget(parent), _pix(pixmap) - { - setAcceptHoverEvents(true); - setCacheMode(DeviceCoordinateCache); - } - - QRectF boundingRect() const override - { - return QRectF(-65, -65, 130, 130); - } - - QPainterPath shape() const override - { - QPainterPath path; - path.addEllipse(boundingRect()); - return path; - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) override - { - bool down = option->state & QStyle::State_Sunken; - QRectF r = boundingRect(); - QLinearGradient grad(r.topLeft(), r.bottomRight()); - grad.setColorAt(down ? 1 : 0, option->state & QStyle::State_MouseOver ? Qt::white : Qt::lightGray); - grad.setColorAt(down ? 0 : 1, Qt::darkGray); - painter->setPen(Qt::darkGray); - painter->setBrush(grad); - painter->drawEllipse(r); - QLinearGradient grad2(r.topLeft(), r.bottomRight()); - grad.setColorAt(down ? 1 : 0, Qt::darkGray); - grad.setColorAt(down ? 0 : 1, Qt::lightGray); - painter->setPen(Qt::NoPen); - painter->setBrush(grad); - if (down) - painter->translate(2, 2); - painter->drawEllipse(r.adjusted(5, 5, -5, -5)); - painter->drawPixmap(-_pix.width()/2, -_pix.height()/2, _pix); - } - -signals: - void pressed(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *) override - { - emit pressed(); - update(); - } - - void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override - { - update(); - } - -private: - QPixmap _pix; -}; - -class View : public QGraphicsView -{ -public: - View(QGraphicsScene *scene) : QGraphicsView(scene) { } - -protected: - void resizeEvent(QResizeEvent *event) override - { - QGraphicsView::resizeEvent(event); - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - -int main(int argc, char **argv) -{ - Q_INIT_RESOURCE(animatedtiles); - - QApplication app(argc, argv); - - QPixmap kineticPix(":/images/kinetic.png"); - QPixmap bgPix(":/images/Time-For-Lunch-2.jpg"); - - QGraphicsScene scene(-350, -350, 700, 700); - - QList items; - for (int i = 0; i < 64; ++i) { - Pixmap *item = new Pixmap(kineticPix); - item->setOffset(-kineticPix.width()/2, -kineticPix.height()/2); - item->setZValue(i); - items << item; - scene.addItem(item); - } - - // Buttons - QGraphicsItem *buttonParent = new QGraphicsRectItem; - Button *ellipseButton = new Button(QPixmap(":/images/ellipse.png"), buttonParent); - Button *figure8Button = new Button(QPixmap(":/images/figure8.png"), buttonParent); - Button *randomButton = new Button(QPixmap(":/images/random.png"), buttonParent); - Button *tiledButton = new Button(QPixmap(":/images/tile.png"), buttonParent); - Button *centeredButton = new Button(QPixmap(":/images/centered.png"), buttonParent); - - ellipseButton->setPos(-100, -100); - figure8Button->setPos(100, -100); - randomButton->setPos(0, 0); - tiledButton->setPos(-100, 100); - centeredButton->setPos(100, 100); - - scene.addItem(buttonParent); - buttonParent->setTransform(QTransform::fromScale(0.75, 0.75), true); - buttonParent->setPos(200, 200); - buttonParent->setZValue(65); - - // States - QState *rootState = new QState; - QState *ellipseState = new QState(rootState); - QState *figure8State = new QState(rootState); - QState *randomState = new QState(rootState); - QState *tiledState = new QState(rootState); - QState *centeredState = new QState(rootState); - - // Values - for (int i = 0; i < items.count(); ++i) { - Pixmap *item = items.at(i); - // Ellipse - ellipseState->assignProperty(item, "pos", - QPointF(qCos((i / 63.0) * 6.28) * 250, - qSin((i / 63.0) * 6.28) * 250)); - - // Figure 8 - figure8State->assignProperty(item, "pos", - QPointF(qSin((i / 63.0) * 6.28) * 250, - qSin(((i * 2)/63.0) * 6.28) * 250)); - - // Random - randomState->assignProperty(item, "pos", - QPointF(-250 + QRandomGenerator::global()->bounded(500), - -250 + QRandomGenerator::global()->bounded(500))); - - // Tiled - tiledState->assignProperty(item, "pos", - QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, - ((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2)); - - // Centered - centeredState->assignProperty(item, "pos", QPointF()); - } - - // Ui - View *view = new View(&scene); - view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Animated Tiles")); - view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - view->setBackgroundBrush(bgPix); - view->setCacheMode(QGraphicsView::CacheBackground); - view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - view->show(); - - QStateMachine states; - states.addState(rootState); - states.setInitialState(rootState); - rootState->setInitialState(centeredState); - - QParallelAnimationGroup *group = new QParallelAnimationGroup; - for (int i = 0; i < items.count(); ++i) { - QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); - anim->setDuration(750 + i * 25); - anim->setEasingCurve(QEasingCurve::InOutBack); - group->addAnimation(anim); - } - QAbstractTransition *trans = rootState->addTransition(ellipseButton, &Button::pressed, ellipseState); - trans->addAnimation(group); - - trans = rootState->addTransition(figure8Button, &Button::pressed, figure8State); - trans->addAnimation(group); - - trans = rootState->addTransition(randomButton, &Button::pressed, randomState); - trans->addAnimation(group); - - trans = rootState->addTransition(tiledButton, &Button::pressed, tiledState); - trans->addAnimation(group); - - trans = rootState->addTransition(centeredButton, &Button::pressed, centeredState); - trans->addAnimation(group); - - QTimer timer; - timer.start(125); - timer.setSingleShot(true); - trans = rootState->addTransition(&timer, &QTimer::timeout, ellipseState); - trans->addAnimation(group); - - states.start(); - -#ifdef QT_KEYPAD_NAVIGATION - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif - return app.exec(); -} - -#include "main.moc" diff --git a/examples/widgets/animation/animation.pro b/examples/widgets/animation/animation.pro index 19b79caf15..3b4aa0f100 100644 --- a/examples/widgets/animation/animation.pro +++ b/examples/widgets/animation/animation.pro @@ -1,9 +1,3 @@ TEMPLATE = \ subdirs -SUBDIRS += \ - animatedtiles \ - easing \ - moveblocks \ - states \ - stickman \ - sub-attaq \ +SUBDIRS += easing diff --git a/examples/widgets/animation/moveblocks/CMakeLists.txt b/examples/widgets/animation/moveblocks/CMakeLists.txt deleted file mode 100644 index ed17097f5d..0000000000 --- a/examples/widgets/animation/moveblocks/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Generated from moveblocks.pro. - -cmake_minimum_required(VERSION 3.14) -project(moveblocks 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/moveblocks") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(moveblocks - main.cpp -) -target_link_libraries(moveblocks PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS moveblocks - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/animation/moveblocks/main.cpp b/examples/widgets/animation/moveblocks/main.cpp deleted file mode 100644 index d03b57cd5e..0000000000 --- a/examples/widgets/animation/moveblocks/main.cpp +++ /dev/null @@ -1,330 +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 -#include - -//![15] -class StateSwitchEvent: public QEvent -{ -public: - StateSwitchEvent() - : QEvent(Type(StateSwitchType)) - { - } - - explicit StateSwitchEvent(int rand) - : QEvent(Type(StateSwitchType)), - m_rand(rand) - { - } - - enum { StateSwitchType = QEvent::User + 256 }; - - int rand() const { return m_rand; } - -private: - int m_rand; -}; -//![15] - -//![16] -class QGraphicsRectWidget : public QGraphicsWidget -{ -public: - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, - QWidget *) override - { - painter->fillRect(rect(), Qt::blue); - } -}; -//![16] - -class StateSwitchTransition: public QAbstractTransition -{ -public: - StateSwitchTransition(int rand) - : QAbstractTransition(), - m_rand(rand) - { - } - -protected: -//![14] - bool eventTest(QEvent *event) override - { - return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) - && (static_cast(event)->rand() == m_rand); - } -//![14] - - void onTransition(QEvent *) override {} - -private: - int m_rand; -}; - -//![10] -class StateSwitcher : public QState -{ - Q_OBJECT -public: - StateSwitcher(QStateMachine *machine) - : QState(machine), m_stateCount(0), m_lastIndex(0) - { } -//![10] - -//![11] - void onEntry(QEvent *) override - { - int n; - while ((n = QRandomGenerator::global()->bounded(m_stateCount) + 1) == m_lastIndex) - { } - m_lastIndex = n; - machine()->postEvent(new StateSwitchEvent(n)); - } - void onExit(QEvent *) override {} -//![11] - -//![12] - void addState(QState *state, QAbstractAnimation *animation) { - StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount); - trans->setTargetState(state); - addTransition(trans); - trans->addAnimation(animation); - } -//![12] - -private: - int m_stateCount; - int m_lastIndex; -}; - -//![13] -QState *createGeometryState(QObject *w1, const QRect &rect1, - QObject *w2, const QRect &rect2, - QObject *w3, const QRect &rect3, - QObject *w4, const QRect &rect4, - QState *parent) -{ - QState *result = new QState(parent); - result->assignProperty(w1, "geometry", rect1); - result->assignProperty(w2, "geometry", rect2); - result->assignProperty(w3, "geometry", rect3); - result->assignProperty(w4, "geometry", rect4); - - return result; -} -//![13] - - -class GraphicsView : public QGraphicsView -{ - Q_OBJECT -public: - GraphicsView(QGraphicsScene *scene, QWidget *parent = nullptr) - : QGraphicsView(scene, parent) - { - } - -protected: - void resizeEvent(QResizeEvent *event) override - { - fitInView(scene()->sceneRect()); - QGraphicsView::resizeEvent(event); - } -}; - - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - -//![1] - QGraphicsRectWidget *button1 = new QGraphicsRectWidget; - QGraphicsRectWidget *button2 = new QGraphicsRectWidget; - QGraphicsRectWidget *button3 = new QGraphicsRectWidget; - QGraphicsRectWidget *button4 = new QGraphicsRectWidget; - button2->setZValue(1); - button3->setZValue(2); - button4->setZValue(3); - QGraphicsScene scene(0, 0, 300, 300); - scene.setBackgroundBrush(Qt::black); - scene.addItem(button1); - scene.addItem(button2); - scene.addItem(button3); - scene.addItem(button4); -//![1] - GraphicsView window(&scene); - window.setFrameStyle(0); - window.setAlignment(Qt::AlignLeft | Qt::AlignTop); - window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -//![2] - QStateMachine machine; - - QState *group = new QState(); - group->setObjectName("group"); - QTimer timer; - timer.setInterval(1250); - timer.setSingleShot(true); - QObject::connect(group, &QState::entered, &timer, QOverload<>::of(&QTimer::start)); -//![2] - -//![3] - QState *state1; - QState *state2; - QState *state3; - QState *state4; - QState *state5; - QState *state6; - QState *state7; - - state1 = createGeometryState(button1, QRect(100, 0, 50, 50), - button2, QRect(150, 0, 50, 50), - button3, QRect(200, 0, 50, 50), - button4, QRect(250, 0, 50, 50), - group); -//![3] - state2 = createGeometryState(button1, QRect(250, 100, 50, 50), - button2, QRect(250, 150, 50, 50), - button3, QRect(250, 200, 50, 50), - button4, QRect(250, 250, 50, 50), - group); - state3 = createGeometryState(button1, QRect(150, 250, 50, 50), - button2, QRect(100, 250, 50, 50), - button3, QRect(50, 250, 50, 50), - button4, QRect(0, 250, 50, 50), - group); - state4 = createGeometryState(button1, QRect(0, 150, 50, 50), - button2, QRect(0, 100, 50, 50), - button3, QRect(0, 50, 50, 50), - button4, QRect(0, 0, 50, 50), - group); - state5 = createGeometryState(button1, QRect(100, 100, 50, 50), - button2, QRect(150, 100, 50, 50), - button3, QRect(100, 150, 50, 50), - button4, QRect(150, 150, 50, 50), - group); - state6 = createGeometryState(button1, QRect(50, 50, 50, 50), - button2, QRect(200, 50, 50, 50), - button3, QRect(50, 200, 50, 50), - button4, QRect(200, 200, 50, 50), - group); -//![4] - state7 = createGeometryState(button1, QRect(0, 0, 50, 50), - button2, QRect(250, 0, 50, 50), - button3, QRect(0, 250, 50, 50), - button4, QRect(250, 250, 50, 50), - group); - group->setInitialState(state1); -//![4] - -//![5] - QParallelAnimationGroup animationGroup; - QSequentialAnimationGroup *subGroup; - - QPropertyAnimation *anim = new QPropertyAnimation(button4, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - animationGroup.addAnimation(anim); -//![5] - -//![6] - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(100); - anim = new QPropertyAnimation(button3, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); -//![6] - - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(150); - anim = new QPropertyAnimation(button2, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); - - subGroup = new QSequentialAnimationGroup(&animationGroup); - subGroup->addPause(200); - anim = new QPropertyAnimation(button1, "geometry"); - anim->setDuration(1000); - anim->setEasingCurve(QEasingCurve::OutElastic); - subGroup->addAnimation(anim); - -//![7] - StateSwitcher *stateSwitcher = new StateSwitcher(&machine); - stateSwitcher->setObjectName("stateSwitcher"); - group->addTransition(&timer, &QTimer::timeout, stateSwitcher); - stateSwitcher->addState(state1, &animationGroup); - stateSwitcher->addState(state2, &animationGroup); -//![7] - stateSwitcher->addState(state3, &animationGroup); - stateSwitcher->addState(state4, &animationGroup); - stateSwitcher->addState(state5, &animationGroup); - stateSwitcher->addState(state6, &animationGroup); -//![8] - stateSwitcher->addState(state7, &animationGroup); -//![8] - -//![9] - machine.addState(group); - machine.setInitialState(group); - machine.start(); -//![9] - - window.resize(300, 300); - window.show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/widgets/animation/moveblocks/moveblocks.pro b/examples/widgets/animation/moveblocks/moveblocks.pro deleted file mode 100644 index 1397246b3f..0000000000 --- a/examples/widgets/animation/moveblocks/moveblocks.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += widgets - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/moveblocks -INSTALLS += target diff --git a/examples/widgets/animation/states/CMakeLists.txt b/examples/widgets/animation/states/CMakeLists.txt deleted file mode 100644 index 6dd9847f03..0000000000 --- a/examples/widgets/animation/states/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Generated from states.pro. - -cmake_minimum_required(VERSION 3.14) -project(states 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/states") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(states - main.cpp -) -target_link_libraries(states PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(states_resource_files - "accessories-dictionary.png" - "akregator.png" - "digikam.png" - "help-browser.png" - "k3b.png" - "kchart.png" -) - -qt6_add_resources(states "states" - PREFIX - "/" - FILES - ${states_resource_files} -) - -install(TARGETS states - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/animation/states/accessories-dictionary.png b/examples/widgets/animation/states/accessories-dictionary.png deleted file mode 100644 index e9bd55d918..0000000000 Binary files a/examples/widgets/animation/states/accessories-dictionary.png and /dev/null differ diff --git a/examples/widgets/animation/states/akregator.png b/examples/widgets/animation/states/akregator.png deleted file mode 100644 index a086f45ab6..0000000000 Binary files a/examples/widgets/animation/states/akregator.png and /dev/null differ diff --git a/examples/widgets/animation/states/digikam.png b/examples/widgets/animation/states/digikam.png deleted file mode 100644 index 9de9fb2f80..0000000000 Binary files a/examples/widgets/animation/states/digikam.png and /dev/null differ diff --git a/examples/widgets/animation/states/help-browser.png b/examples/widgets/animation/states/help-browser.png deleted file mode 100644 index db92faa4e7..0000000000 Binary files a/examples/widgets/animation/states/help-browser.png and /dev/null differ diff --git a/examples/widgets/animation/states/k3b.png b/examples/widgets/animation/states/k3b.png deleted file mode 100644 index bbcafcfba1..0000000000 Binary files a/examples/widgets/animation/states/k3b.png and /dev/null differ diff --git a/examples/widgets/animation/states/kchart.png b/examples/widgets/animation/states/kchart.png deleted file mode 100644 index 1dd115be87..0000000000 Binary files a/examples/widgets/animation/states/kchart.png and /dev/null differ diff --git a/examples/widgets/animation/states/main.cpp b/examples/widgets/animation/states/main.cpp deleted file mode 100644 index 0f61b7457a..0000000000 --- a/examples/widgets/animation/states/main.cpp +++ /dev/null @@ -1,295 +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 - -class Pixmap : public QGraphicsObject -{ - Q_OBJECT -public: - Pixmap(const QPixmap &pix) : QGraphicsObject(), p(pix) - { - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override - { - painter->drawPixmap(QPointF(), p); - } - - QRectF boundingRect() const override - { - return QRectF( QPointF(0, 0), p.size()); - } - -private: - QPixmap p; -}; - -class GraphicsView : public QGraphicsView -{ -public: - GraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) - { - } - - void resizeEvent(QResizeEvent *) override - { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - -int main(int argc, char *argv[]) -{ - Q_INIT_RESOURCE(states); - - QApplication app(argc, argv); - - // Text edit and button - QTextEdit *edit = new QTextEdit; - edit->setText("asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy " - "asdf lkjha yuoiqwe asd iuaysd u iasyd uiy!"); - - QPushButton *button = new QPushButton; - QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; - buttonProxy->setWidget(button); - QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; - editProxy->setWidget(edit); - - QGroupBox *box = new QGroupBox; - box->setFlat(true); - box->setTitle("Options"); - - QVBoxLayout *layout2 = new QVBoxLayout; - box->setLayout(layout2); - layout2->addWidget(new QRadioButton("Herring")); - layout2->addWidget(new QRadioButton("Blue Parrot")); - layout2->addWidget(new QRadioButton("Petunias")); - layout2->addStretch(); - - QGraphicsProxyWidget *boxProxy = new QGraphicsProxyWidget; - boxProxy->setWidget(box); - - // Parent widget - QGraphicsWidget *widget = new QGraphicsWidget; - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget); - layout->addItem(editProxy); - layout->addItem(buttonProxy); - widget->setLayout(layout); - - Pixmap *p1 = new Pixmap(QPixmap(":/digikam.png")); - Pixmap *p2 = new Pixmap(QPixmap(":/akregator.png")); - Pixmap *p3 = new Pixmap(QPixmap(":/accessories-dictionary.png")); - Pixmap *p4 = new Pixmap(QPixmap(":/k3b.png")); - Pixmap *p5 = new Pixmap(QPixmap(":/help-browser.png")); - Pixmap *p6 = new Pixmap(QPixmap(":/kchart.png")); - - QGraphicsScene scene(0, 0, 400, 300); - scene.setBackgroundBrush(scene.palette().window()); - scene.addItem(widget); - scene.addItem(boxProxy); - scene.addItem(p1); - scene.addItem(p2); - scene.addItem(p3); - scene.addItem(p4); - scene.addItem(p5); - scene.addItem(p6); - - QStateMachine machine; - QState *state1 = new QState(&machine); - QState *state2 = new QState(&machine); - QState *state3 = new QState(&machine); - machine.setInitialState(state1); - - // State 1 - state1->assignProperty(button, "text", "Switch to state 2"); - state1->assignProperty(widget, "geometry", QRectF(0, 0, 400, 150)); - state1->assignProperty(box, "geometry", QRect(-200, 150, 200, 150)); - state1->assignProperty(p1, "pos", QPointF(68, 200)); // 185)); - state1->assignProperty(p2, "pos", QPointF(168, 200)); // 185)); - state1->assignProperty(p3, "pos", QPointF(268, 200)); // 185)); - state1->assignProperty(p4, "pos", QPointF(68 - 150, 48 - 150)); - state1->assignProperty(p5, "pos", QPointF(168, 48 - 150)); - state1->assignProperty(p6, "pos", QPointF(268 + 150, 48 - 150)); - state1->assignProperty(p1, "rotation", qreal(0)); - state1->assignProperty(p2, "rotation", qreal(0)); - state1->assignProperty(p3, "rotation", qreal(0)); - state1->assignProperty(p4, "rotation", qreal(-270)); - state1->assignProperty(p5, "rotation", qreal(-90)); - state1->assignProperty(p6, "rotation", qreal(270)); - state1->assignProperty(boxProxy, "opacity", qreal(0)); - state1->assignProperty(p1, "opacity", qreal(1)); - state1->assignProperty(p2, "opacity", qreal(1)); - state1->assignProperty(p3, "opacity", qreal(1)); - state1->assignProperty(p4, "opacity", qreal(0)); - state1->assignProperty(p5, "opacity", qreal(0)); - state1->assignProperty(p6, "opacity", qreal(0)); - - // State 2 - state2->assignProperty(button, "text", "Switch to state 3"); - state2->assignProperty(widget, "geometry", QRectF(200, 150, 200, 150)); - state2->assignProperty(box, "geometry", QRect(9, 150, 190, 150)); - state2->assignProperty(p1, "pos", QPointF(68 - 150, 185 + 150)); - state2->assignProperty(p2, "pos", QPointF(168, 185 + 150)); - state2->assignProperty(p3, "pos", QPointF(268 + 150, 185 + 150)); - state2->assignProperty(p4, "pos", QPointF(64, 48)); - state2->assignProperty(p5, "pos", QPointF(168, 48)); - state2->assignProperty(p6, "pos", QPointF(268, 48)); - state2->assignProperty(p1, "rotation", qreal(-270)); - state2->assignProperty(p2, "rotation", qreal(90)); - state2->assignProperty(p3, "rotation", qreal(270)); - state2->assignProperty(p4, "rotation", qreal(0)); - state2->assignProperty(p5, "rotation", qreal(0)); - state2->assignProperty(p6, "rotation", qreal(0)); - state2->assignProperty(boxProxy, "opacity", qreal(1)); - state2->assignProperty(p1, "opacity", qreal(0)); - state2->assignProperty(p2, "opacity", qreal(0)); - state2->assignProperty(p3, "opacity", qreal(0)); - state2->assignProperty(p4, "opacity", qreal(1)); - state2->assignProperty(p5, "opacity", qreal(1)); - state2->assignProperty(p6, "opacity", qreal(1)); - - // State 3 - state3->assignProperty(button, "text", "Switch to state 1"); - state3->assignProperty(p1, "pos", QPointF(0, 5)); - state3->assignProperty(p2, "pos", QPointF(0, 5 + 64 + 5)); - state3->assignProperty(p3, "pos", QPointF(5, 5 + (64 + 5) + 64)); - state3->assignProperty(p4, "pos", QPointF(5 + 64 + 5, 5)); - state3->assignProperty(p5, "pos", QPointF(5 + 64 + 5, 5 + 64 + 5)); - state3->assignProperty(p6, "pos", QPointF(5 + 64 + 5, 5 + (64 + 5) + 64)); - state3->assignProperty(widget, "geometry", QRectF(138, 5, 400 - 138, 200)); - state3->assignProperty(box, "geometry", QRect(5, 205, 400, 90)); - state3->assignProperty(p1, "opacity", qreal(1)); - state3->assignProperty(p2, "opacity", qreal(1)); - state3->assignProperty(p3, "opacity", qreal(1)); - state3->assignProperty(p4, "opacity", qreal(1)); - state3->assignProperty(p5, "opacity", qreal(1)); - state3->assignProperty(p6, "opacity", qreal(1)); - - QAbstractTransition *t1 = state1->addTransition(button, &QAbstractButton::clicked, state2); - QSequentialAnimationGroup *animation1SubGroup = new QSequentialAnimationGroup; - animation1SubGroup->addPause(250); - animation1SubGroup->addAnimation(new QPropertyAnimation(box, "geometry")); - t1->addAnimation(animation1SubGroup); - t1->addAnimation(new QPropertyAnimation(widget, "geometry")); - t1->addAnimation(new QPropertyAnimation(p1, "pos")); - t1->addAnimation(new QPropertyAnimation(p2, "pos")); - t1->addAnimation(new QPropertyAnimation(p3, "pos")); - t1->addAnimation(new QPropertyAnimation(p4, "pos")); - t1->addAnimation(new QPropertyAnimation(p5, "pos")); - t1->addAnimation(new QPropertyAnimation(p6, "pos")); - t1->addAnimation(new QPropertyAnimation(p1, "rotation")); - t1->addAnimation(new QPropertyAnimation(p2, "rotation")); - t1->addAnimation(new QPropertyAnimation(p3, "rotation")); - t1->addAnimation(new QPropertyAnimation(p4, "rotation")); - t1->addAnimation(new QPropertyAnimation(p5, "rotation")); - t1->addAnimation(new QPropertyAnimation(p6, "rotation")); - t1->addAnimation(new QPropertyAnimation(p1, "opacity")); - t1->addAnimation(new QPropertyAnimation(p2, "opacity")); - t1->addAnimation(new QPropertyAnimation(p3, "opacity")); - t1->addAnimation(new QPropertyAnimation(p4, "opacity")); - t1->addAnimation(new QPropertyAnimation(p5, "opacity")); - t1->addAnimation(new QPropertyAnimation(p6, "opacity")); - - QAbstractTransition *t2 = state2->addTransition(button, &QAbstractButton::clicked, state3); - t2->addAnimation(new QPropertyAnimation(box, "geometry")); - t2->addAnimation(new QPropertyAnimation(widget, "geometry")); - t2->addAnimation(new QPropertyAnimation(p1, "pos")); - t2->addAnimation(new QPropertyAnimation(p2, "pos")); - t2->addAnimation(new QPropertyAnimation(p3, "pos")); - t2->addAnimation(new QPropertyAnimation(p4, "pos")); - t2->addAnimation(new QPropertyAnimation(p5, "pos")); - t2->addAnimation(new QPropertyAnimation(p6, "pos")); - t2->addAnimation(new QPropertyAnimation(p1, "rotation")); - t2->addAnimation(new QPropertyAnimation(p2, "rotation")); - t2->addAnimation(new QPropertyAnimation(p3, "rotation")); - t2->addAnimation(new QPropertyAnimation(p4, "rotation")); - t2->addAnimation(new QPropertyAnimation(p5, "rotation")); - t2->addAnimation(new QPropertyAnimation(p6, "rotation")); - t2->addAnimation(new QPropertyAnimation(p1, "opacity")); - t2->addAnimation(new QPropertyAnimation(p2, "opacity")); - t2->addAnimation(new QPropertyAnimation(p3, "opacity")); - t2->addAnimation(new QPropertyAnimation(p4, "opacity")); - t2->addAnimation(new QPropertyAnimation(p5, "opacity")); - t2->addAnimation(new QPropertyAnimation(p6, "opacity")); - - QAbstractTransition *t3 = state3->addTransition(button, &QAbstractButton::clicked, state1); - t3->addAnimation(new QPropertyAnimation(box, "geometry")); - t3->addAnimation(new QPropertyAnimation(widget, "geometry")); - t3->addAnimation(new QPropertyAnimation(p1, "pos")); - t3->addAnimation(new QPropertyAnimation(p2, "pos")); - t3->addAnimation(new QPropertyAnimation(p3, "pos")); - t3->addAnimation(new QPropertyAnimation(p4, "pos")); - t3->addAnimation(new QPropertyAnimation(p5, "pos")); - t3->addAnimation(new QPropertyAnimation(p6, "pos")); - t3->addAnimation(new QPropertyAnimation(p1, "rotation")); - t3->addAnimation(new QPropertyAnimation(p2, "rotation")); - t3->addAnimation(new QPropertyAnimation(p3, "rotation")); - t3->addAnimation(new QPropertyAnimation(p4, "rotation")); - t3->addAnimation(new QPropertyAnimation(p5, "rotation")); - t3->addAnimation(new QPropertyAnimation(p6, "rotation")); - t3->addAnimation(new QPropertyAnimation(p1, "opacity")); - t3->addAnimation(new QPropertyAnimation(p2, "opacity")); - t3->addAnimation(new QPropertyAnimation(p3, "opacity")); - t3->addAnimation(new QPropertyAnimation(p4, "opacity")); - t3->addAnimation(new QPropertyAnimation(p5, "opacity")); - t3->addAnimation(new QPropertyAnimation(p6, "opacity")); - - machine.start(); - - GraphicsView view(&scene); - - view.show(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/widgets/animation/states/states.pro b/examples/widgets/animation/states/states.pro deleted file mode 100644 index 491d557a8d..0000000000 --- a/examples/widgets/animation/states/states.pro +++ /dev/null @@ -1,8 +0,0 @@ -QT += widgets - -SOURCES += main.cpp -RESOURCES += states.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/states -INSTALLS += target diff --git a/examples/widgets/animation/states/states.qrc b/examples/widgets/animation/states/states.qrc deleted file mode 100644 index 60ab3f7a60..0000000000 --- a/examples/widgets/animation/states/states.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - accessories-dictionary.png - akregator.png - digikam.png - help-browser.png - k3b.png - kchart.png - - 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 -#include - -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 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 -#include -#include - -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 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 Binary files a/examples/widgets/animation/stickman/animations/chilling.bin and /dev/null 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 Binary files a/examples/widgets/animation/stickman/animations/dancing.bin and /dev/null 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 Binary files a/examples/widgets/animation/stickman/animations/dead.bin and /dev/null 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 Binary files a/examples/widgets/animation/stickman/animations/jumping.bin and /dev/null 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 -#include - -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 - -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 -#include -#include -#include -#include -#include -#include -#include -#include - -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(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_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 -#include - -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("Stickman" - "

" - "Tell the stickman what to do!" - "

" - "

" - "

  • Press J to make the stickman jump.
  • " - "
  • Press D to make the stickman dance.
  • " - "
  • Press C to make him chill out.
  • " - "
  • When you are done, press Escape.
  • " - "

    " - "

    If he is unlucky, the stickman will get struck by lightning, and never jump, dance or chill out again." - "

    "); - 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 -#include -#include - -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 - -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 - -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 - -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 -#include - -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 -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 - -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 @@ - - - animations/chilling.bin - animations/dancing.bin - animations/dead.bin - animations/jumping.bin - - diff --git a/examples/widgets/animation/sub-attaq/.prev_CMakeLists.txt b/examples/widgets/animation/sub-attaq/.prev_CMakeLists.txt deleted file mode 100644 index 4967673c69..0000000000 --- a/examples/widgets/animation/sub-attaq/.prev_CMakeLists.txt +++ /dev/null @@ -1,196 +0,0 @@ -# Generated from sub-attaq.pro. - -cmake_minimum_required(VERSION 3.14) -project(sub-attaq 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/sub-attaq") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(sub-attaq - animationmanager.cpp animationmanager.h - boat.cpp boat.h boat_p.h - bomb.cpp bomb.h - graphicsscene.cpp graphicsscene.h - main.cpp - mainwindow.cpp mainwindow.h - pixmapitem.cpp pixmapitem.h - progressitem.cpp progressitem.h - qanimationstate.cpp qanimationstate.h - states.cpp states.h - submarine.cpp submarine.h submarine_p.h - textinformationitem.cpp textinformationitem.h - torpedo.cpp torpedo.h -) -target_link_libraries(sub-attaq PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("pics/big/background.png" - PROPERTIES QT_RESOURCE_ALIAS "big/background" -) -set_source_files_properties("pics/big/boat.png" - PROPERTIES QT_RESOURCE_ALIAS "big/boat" -) -set_source_files_properties("pics/big/bomb.png" - PROPERTIES QT_RESOURCE_ALIAS "big/bomb" -) -set_source_files_properties("pics/big/explosion/boat/step1.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step1" -) -set_source_files_properties("pics/big/explosion/boat/step2.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step2" -) -set_source_files_properties("pics/big/explosion/boat/step3.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step3" -) -set_source_files_properties("pics/big/explosion/boat/step4.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step4" -) -set_source_files_properties("pics/big/explosion/submarine/step1.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step1" -) -set_source_files_properties("pics/big/explosion/submarine/step2.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step2" -) -set_source_files_properties("pics/big/explosion/submarine/step3.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step3" -) -set_source_files_properties("pics/big/explosion/submarine/step4.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step4" -) -set_source_files_properties("pics/big/submarine.png" - PROPERTIES QT_RESOURCE_ALIAS "big/submarine" -) -set_source_files_properties("pics/big/surface.png" - PROPERTIES QT_RESOURCE_ALIAS "big/surface" -) -set_source_files_properties("pics/big/torpedo.png" - PROPERTIES QT_RESOURCE_ALIAS "big/torpedo" -) -set_source_files_properties("pics/scalable/boat.svg" - PROPERTIES QT_RESOURCE_ALIAS "boat" -) -set_source_files_properties("pics/scalable/sub-attaq.svg" - PROPERTIES QT_RESOURCE_ALIAS "all" -) -set_source_files_properties("pics/scalable/submarine.svg" - PROPERTIES QT_RESOURCE_ALIAS "submarine" -) -set_source_files_properties("pics/scalable/torpedo.svg" - PROPERTIES QT_RESOURCE_ALIAS "torpedo" -) -set_source_files_properties("pics/small/background.png" - PROPERTIES QT_RESOURCE_ALIAS "small/background" -) -set_source_files_properties("pics/small/boat.png" - PROPERTIES QT_RESOURCE_ALIAS "small/boat" -) -set_source_files_properties("pics/small/bomb.png" - PROPERTIES QT_RESOURCE_ALIAS "small/bomb" -) -set_source_files_properties("pics/small/submarine.png" - PROPERTIES QT_RESOURCE_ALIAS "small/submarine" -) -set_source_files_properties("pics/small/surface.png" - PROPERTIES QT_RESOURCE_ALIAS "small/surface" -) -set_source_files_properties("pics/small/torpedo.png" - PROPERTIES QT_RESOURCE_ALIAS "small/torpedo" -) -set_source_files_properties("pics/welcome/logo-a.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-a" -) -set_source_files_properties("pics/welcome/logo-a2.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-a2" -) -set_source_files_properties("pics/welcome/logo-b.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-b" -) -set_source_files_properties("pics/welcome/logo-dash.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-dash" -) -set_source_files_properties("pics/welcome/logo-excl.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-excl" -) -set_source_files_properties("pics/welcome/logo-q.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-q" -) -set_source_files_properties("pics/welcome/logo-s.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-s" -) -set_source_files_properties("pics/welcome/logo-t.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-t" -) -set_source_files_properties("pics/welcome/logo-t2.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-t2" -) -set_source_files_properties("pics/welcome/logo-u.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-u" -) -set(subattaq_resource_files - "data.xml" - "pics/big/background.png" - "pics/big/boat.png" - "pics/big/bomb.png" - "pics/big/explosion/boat/step1.png" - "pics/big/explosion/boat/step2.png" - "pics/big/explosion/boat/step3.png" - "pics/big/explosion/boat/step4.png" - "pics/big/explosion/submarine/step1.png" - "pics/big/explosion/submarine/step2.png" - "pics/big/explosion/submarine/step3.png" - "pics/big/explosion/submarine/step4.png" - "pics/big/submarine.png" - "pics/big/surface.png" - "pics/big/torpedo.png" - "pics/scalable/boat.svg" - "pics/scalable/sub-attaq.svg" - "pics/scalable/submarine.svg" - "pics/scalable/torpedo.svg" - "pics/small/background.png" - "pics/small/boat.png" - "pics/small/bomb.png" - "pics/small/submarine.png" - "pics/small/surface.png" - "pics/small/torpedo.png" - "pics/welcome/logo-a.png" - "pics/welcome/logo-a2.png" - "pics/welcome/logo-b.png" - "pics/welcome/logo-dash.png" - "pics/welcome/logo-excl.png" - "pics/welcome/logo-q.png" - "pics/welcome/logo-s.png" - "pics/welcome/logo-t.png" - "pics/welcome/logo-t2.png" - "pics/welcome/logo-u.png" -) - -qt6_add_resources(sub-attaq "subattaq" - PREFIX - "/" - FILES - ${subattaq_resource_files} -) - -install(TARGETS sub-attaq - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/animation/sub-attaq/CMakeLists.txt b/examples/widgets/animation/sub-attaq/CMakeLists.txt deleted file mode 100644 index a2249ea03b..0000000000 --- a/examples/widgets/animation/sub-attaq/CMakeLists.txt +++ /dev/null @@ -1,197 +0,0 @@ -# Generated from sub-attaq.pro. - -cmake_minimum_required(VERSION 3.14) -project(sub-attaq 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/sub-attaq") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS OpenGL) # special case - -add_qt_gui_executable(sub-attaq - animationmanager.cpp animationmanager.h - boat.cpp boat.h boat_p.h - bomb.cpp bomb.h - graphicsscene.cpp graphicsscene.h - main.cpp - mainwindow.cpp mainwindow.h - pixmapitem.cpp pixmapitem.h - progressitem.cpp progressitem.h - qanimationstate.cpp qanimationstate.h - states.cpp states.h - submarine.cpp submarine.h submarine_p.h - textinformationitem.cpp textinformationitem.h - torpedo.cpp torpedo.h -) -target_link_libraries(sub-attaq PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set_source_files_properties("pics/big/background.png" - PROPERTIES QT_RESOURCE_ALIAS "big/background" -) -set_source_files_properties("pics/big/boat.png" - PROPERTIES QT_RESOURCE_ALIAS "big/boat" -) -set_source_files_properties("pics/big/bomb.png" - PROPERTIES QT_RESOURCE_ALIAS "big/bomb" -) -set_source_files_properties("pics/big/explosion/boat/step1.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step1" -) -set_source_files_properties("pics/big/explosion/boat/step2.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step2" -) -set_source_files_properties("pics/big/explosion/boat/step3.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step3" -) -set_source_files_properties("pics/big/explosion/boat/step4.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/boat/step4" -) -set_source_files_properties("pics/big/explosion/submarine/step1.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step1" -) -set_source_files_properties("pics/big/explosion/submarine/step2.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step2" -) -set_source_files_properties("pics/big/explosion/submarine/step3.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step3" -) -set_source_files_properties("pics/big/explosion/submarine/step4.png" - PROPERTIES QT_RESOURCE_ALIAS "big/explosion/submarine/step4" -) -set_source_files_properties("pics/big/submarine.png" - PROPERTIES QT_RESOURCE_ALIAS "big/submarine" -) -set_source_files_properties("pics/big/surface.png" - PROPERTIES QT_RESOURCE_ALIAS "big/surface" -) -set_source_files_properties("pics/big/torpedo.png" - PROPERTIES QT_RESOURCE_ALIAS "big/torpedo" -) -set_source_files_properties("pics/scalable/boat.svg" - PROPERTIES QT_RESOURCE_ALIAS "boat" -) -set_source_files_properties("pics/scalable/sub-attaq.svg" - PROPERTIES QT_RESOURCE_ALIAS "all" -) -set_source_files_properties("pics/scalable/submarine.svg" - PROPERTIES QT_RESOURCE_ALIAS "submarine" -) -set_source_files_properties("pics/scalable/torpedo.svg" - PROPERTIES QT_RESOURCE_ALIAS "torpedo" -) -set_source_files_properties("pics/small/background.png" - PROPERTIES QT_RESOURCE_ALIAS "small/background" -) -set_source_files_properties("pics/small/boat.png" - PROPERTIES QT_RESOURCE_ALIAS "small/boat" -) -set_source_files_properties("pics/small/bomb.png" - PROPERTIES QT_RESOURCE_ALIAS "small/bomb" -) -set_source_files_properties("pics/small/submarine.png" - PROPERTIES QT_RESOURCE_ALIAS "small/submarine" -) -set_source_files_properties("pics/small/surface.png" - PROPERTIES QT_RESOURCE_ALIAS "small/surface" -) -set_source_files_properties("pics/small/torpedo.png" - PROPERTIES QT_RESOURCE_ALIAS "small/torpedo" -) -set_source_files_properties("pics/welcome/logo-a.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-a" -) -set_source_files_properties("pics/welcome/logo-a2.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-a2" -) -set_source_files_properties("pics/welcome/logo-b.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-b" -) -set_source_files_properties("pics/welcome/logo-dash.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-dash" -) -set_source_files_properties("pics/welcome/logo-excl.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-excl" -) -set_source_files_properties("pics/welcome/logo-q.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-q" -) -set_source_files_properties("pics/welcome/logo-s.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-s" -) -set_source_files_properties("pics/welcome/logo-t.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-t" -) -set_source_files_properties("pics/welcome/logo-t2.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-t2" -) -set_source_files_properties("pics/welcome/logo-u.png" - PROPERTIES QT_RESOURCE_ALIAS "logo-u" -) -set(subattaq_resource_files - "data.xml" - "pics/big/background.png" - "pics/big/boat.png" - "pics/big/bomb.png" - "pics/big/explosion/boat/step1.png" - "pics/big/explosion/boat/step2.png" - "pics/big/explosion/boat/step3.png" - "pics/big/explosion/boat/step4.png" - "pics/big/explosion/submarine/step1.png" - "pics/big/explosion/submarine/step2.png" - "pics/big/explosion/submarine/step3.png" - "pics/big/explosion/submarine/step4.png" - "pics/big/submarine.png" - "pics/big/surface.png" - "pics/big/torpedo.png" - "pics/scalable/boat.svg" - "pics/scalable/sub-attaq.svg" - "pics/scalable/submarine.svg" - "pics/scalable/torpedo.svg" - "pics/small/background.png" - "pics/small/boat.png" - "pics/small/bomb.png" - "pics/small/submarine.png" - "pics/small/surface.png" - "pics/small/torpedo.png" - "pics/welcome/logo-a.png" - "pics/welcome/logo-a2.png" - "pics/welcome/logo-b.png" - "pics/welcome/logo-dash.png" - "pics/welcome/logo-excl.png" - "pics/welcome/logo-q.png" - "pics/welcome/logo-s.png" - "pics/welcome/logo-t.png" - "pics/welcome/logo-t2.png" - "pics/welcome/logo-u.png" -) - -qt6_add_resources(sub-attaq "subattaq" - PREFIX - "/" - FILES - ${subattaq_resource_files} -) - -install(TARGETS sub-attaq - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/animation/sub-attaq/animationmanager.cpp b/examples/widgets/animation/sub-attaq/animationmanager.cpp deleted file mode 100644 index 261cbd1e1c..0000000000 --- a/examples/widgets/animation/sub-attaq/animationmanager.cpp +++ /dev/null @@ -1,98 +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$ -** -****************************************************************************/ - -//Own -#include "animationmanager.h" - -#include - -AnimationManager *AnimationManager::self() -{ - // the universe's only animation manager - static AnimationManager s_instance; - return &s_instance; -} - -void AnimationManager::registerAnimation(QAbstractAnimation *anim) -{ - QObject::connect(anim, &QObject::destroyed, this, &AnimationManager::unregisterAnimation_helper); - animations.append(anim); -} - -void AnimationManager::unregisterAnimation_helper(QObject *obj) -{ - unregisterAnimation(static_cast(obj)); -} - -void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) -{ - QObject::disconnect(anim, &QObject::destroyed, this, &AnimationManager::unregisterAnimation_helper); - animations.removeAll(anim); -} - -void AnimationManager::unregisterAllAnimations() -{ - animations.clear(); -} - -void AnimationManager::pauseAll() -{ - for (QAbstractAnimation *animation : qAsConst(animations)) { - if (animation->state() == QAbstractAnimation::Running) - animation->pause(); - } -} -void AnimationManager::resumeAll() -{ - for (QAbstractAnimation *animation : qAsConst(animations)) { - if (animation->state() == QAbstractAnimation::Paused) - animation->resume(); - } -} diff --git a/examples/widgets/animation/sub-attaq/animationmanager.h b/examples/widgets/animation/sub-attaq/animationmanager.h deleted file mode 100644 index a097e7508e..0000000000 --- a/examples/widgets/animation/sub-attaq/animationmanager.h +++ /dev/null @@ -1,82 +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 ANIMATIONMANAGER_H -#define ANIMATIONMANAGER_H - -#include - -QT_BEGIN_NAMESPACE -class QAbstractAnimation; -QT_END_NAMESPACE - -class AnimationManager : public QObject -{ - Q_OBJECT - AnimationManager() = default; - ~AnimationManager() = default; -public: - void registerAnimation(QAbstractAnimation *anim); - void unregisterAnimation(QAbstractAnimation *anim); - void unregisterAllAnimations(); - static AnimationManager *self(); - -public slots: - void pauseAll(); - void resumeAll(); - -private slots: - void unregisterAnimation_helper(QObject *obj); - -private: - QList animations; -}; - -#endif // ANIMATIONMANAGER_H diff --git a/examples/widgets/animation/sub-attaq/boat.cpp b/examples/widgets/animation/sub-attaq/boat.cpp deleted file mode 100644 index d5fa314b60..0000000000 --- a/examples/widgets/animation/sub-attaq/boat.cpp +++ /dev/null @@ -1,281 +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$ -** -****************************************************************************/ - -//Own -#include "boat.h" -#include "boat_p.h" -#include "bomb.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -//Qt -#include -#include -#include -#include -#include -#include - -static QAbstractAnimation *setupDestroyAnimation(Boat *boat) -{ - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat); - for (int i = 1; i <= 4; i++) { - PixmapItem *step = new PixmapItem(QString("explosion/boat/step%1").arg(i),GraphicsScene::Big, boat); - step->setZValue(6); - step->setOpacity(0); - - //fade-in - QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity"); - anim->setEndValue(1); - anim->setDuration(100); - group->insertAnimation(i-1, anim); - - //and then fade-out - QPropertyAnimation *anim2 = new QPropertyAnimation(step, "opacity"); - anim2->setEndValue(0); - anim2->setDuration(100); - group->addAnimation(anim2); - } - - AnimationManager::self()->registerAnimation(group); - return group; -} - - - -Boat::Boat() - : PixmapItem(QString("boat"), GraphicsScene::Big), - speed(0), bombsAlreadyLaunched(0), direction(Boat::None) -{ - setZValue(4); - setFlags(QGraphicsItem::ItemIsFocusable); - - //The movement animation used to animate the boat - movementAnimation = new QPropertyAnimation(this, "pos"); - - //The destroy animation used to explode the boat - destroyAnimation = setupDestroyAnimation(this); - - //We setup the state machine of the boat - machine = new QStateMachine(this); - QState *moving = new QState(machine); - StopState *stopState = new StopState(this, moving); - machine->setInitialState(moving); - moving->setInitialState(stopState); - MoveStateRight *moveStateRight = new MoveStateRight(this, moving); - MoveStateLeft *moveStateLeft = new MoveStateLeft(this, moving); - LaunchStateRight *launchStateRight = new LaunchStateRight(this, machine); - LaunchStateLeft *launchStateLeft = new LaunchStateLeft(this, machine); - - //then setup the transitions for the rightMove state - KeyStopTransition *leftStopRight = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Left); - leftStopRight->setTargetState(stopState); - KeyMoveTransition *leftMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Left); - leftMoveRight->setTargetState(moveStateRight); - KeyMoveTransition *rightMoveRight = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveRight->setTargetState(moveStateRight); - KeyMoveTransition *rightMoveStop = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveStop->setTargetState(moveStateRight); - - //then setup the transitions for the leftMove state - KeyStopTransition *rightStopLeft = new KeyStopTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightStopLeft->setTargetState(stopState); - KeyMoveTransition *rightMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress, Qt::Key_Right); - rightMoveLeft->setTargetState(moveStateLeft); - KeyMoveTransition *leftMoveLeft = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); - leftMoveLeft->setTargetState(moveStateLeft); - KeyMoveTransition *leftMoveStop = new KeyMoveTransition(this, QEvent::KeyPress,Qt::Key_Left); - leftMoveStop->setTargetState(moveStateLeft); - - //We set up the right move state - moveStateRight->addTransition(leftStopRight); - moveStateRight->addTransition(leftMoveRight); - moveStateRight->addTransition(rightMoveRight); - stopState->addTransition(rightMoveStop); - - //We set up the left move state - moveStateLeft->addTransition(rightStopLeft); - moveStateLeft->addTransition(leftMoveLeft); - moveStateLeft->addTransition(rightMoveLeft); - stopState->addTransition(leftMoveStop); - - //The animation is finished, it means we reached the border of the screen, the boat is stopped so we move to the stop state - moveStateLeft->addTransition(movementAnimation, &QAbstractAnimation::finished, stopState); - moveStateRight->addTransition(movementAnimation, &QAbstractAnimation::finished, stopState); - - //We set up the keys for dropping bombs - KeyLaunchTransition *upFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireLeft->setTargetState(launchStateRight); - KeyLaunchTransition *upFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireRight->setTargetState(launchStateRight); - KeyLaunchTransition *upFireStop = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Up); - upFireStop->setTargetState(launchStateRight); - KeyLaunchTransition *downFireLeft = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireLeft->setTargetState(launchStateLeft); - KeyLaunchTransition *downFireRight = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireRight->setTargetState(launchStateLeft); - KeyLaunchTransition *downFireMove = new KeyLaunchTransition(this, QEvent::KeyPress, Qt::Key_Down); - downFireMove->setTargetState(launchStateLeft); - - //We set up transitions for fire up - moveStateRight->addTransition(upFireRight); - moveStateLeft->addTransition(upFireLeft); - stopState->addTransition(upFireStop); - - //We set up transitions for fire down - moveStateRight->addTransition(downFireRight); - moveStateLeft->addTransition(downFireLeft); - stopState->addTransition(downFireMove); - - //Finally the launch state should come back to its original state - QHistoryState *historyState = new QHistoryState(moving); - launchStateLeft->addTransition(historyState); - launchStateRight->addTransition(historyState); - - QFinalState *finalState = new QFinalState(machine); - - //This state play the destroyed animation - QAnimationState *destroyedState = new QAnimationState(machine); - destroyedState->setAnimation(destroyAnimation); - - //Play a nice animation when the boat is destroyed - moving->addTransition(this, &Boat::boatDestroyed, destroyedState); - - //Transition to final state when the destroyed animation is finished - destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, finalState); - - //The machine has finished to be executed, then the boat is dead - connect(machine, &QState::finished, this, &Boat::boatExecutionFinished); - -} - -void Boat::run() -{ - //We register animations - AnimationManager::self()->registerAnimation(movementAnimation); - AnimationManager::self()->registerAnimation(destroyAnimation); - machine->start(); -} - -void Boat::stop() -{ - movementAnimation->stop(); - machine->stop(); -} - -void Boat::updateBoatMovement() -{ - if (speed == 0 || direction == Boat::None) { - movementAnimation->stop(); - return; - } - - movementAnimation->stop(); - - if (direction == Boat::Left) { - movementAnimation->setEndValue(QPointF(0,y())); - movementAnimation->setDuration(x()/speed*15); - } - else /*if (direction == Boat::Right)*/ { - movementAnimation->setEndValue(QPointF(scene()->width()-size().width(),y())); - movementAnimation->setDuration((scene()->width()-size().width()-x())/speed*15); - } - movementAnimation->start(); -} - -void Boat::destroy() -{ - movementAnimation->stop(); - emit boatDestroyed(); -} - -int Boat::bombsLaunched() const -{ - return bombsAlreadyLaunched; -} - -void Boat::setBombsLaunched(int number) -{ - if (number > MAX_BOMB) { - qWarning("Boat::setBombsLaunched : It impossible to launch that number of bombs"); - return; - } - bombsAlreadyLaunched = number; -} - -int Boat::currentSpeed() const -{ - return speed; -} - -void Boat::setCurrentSpeed(int speed) -{ - if (speed > 3 || speed < 0) { - qWarning("Boat::setCurrentSpeed: The boat can't run on that speed"); - return; - } - this->speed = speed; -} - -enum Boat::Movement Boat::currentDirection() const -{ - return direction; -} - -void Boat::setCurrentDirection(Movement direction) -{ - this->direction = direction; -} - -int Boat::type() const -{ - return Type; -} diff --git a/examples/widgets/animation/sub-attaq/boat.h b/examples/widgets/animation/sub-attaq/boat.h deleted file mode 100644 index 22f2f0f7c1..0000000000 --- a/examples/widgets/animation/sub-attaq/boat.h +++ /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 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 BOAT_H -#define BOAT_H - -#include "pixmapitem.h" - -QT_BEGIN_NAMESPACE -class QVariantAnimation; -class QAbstractAnimation; -class QStateMachine; -QT_END_NAMESPACE - -class Boat : public PixmapItem -{ -Q_OBJECT -public: - enum Movement { - None = 0, - Left, - Right - }; - enum { Type = UserType + 2 }; - Boat(); - void destroy(); - void run(); - void stop(); - - int bombsLaunched() const; - void setBombsLaunched(int number); - - int currentSpeed() const; - void setCurrentSpeed(int speed); - - enum Movement currentDirection() const; - void setCurrentDirection(Movement direction); - - void updateBoatMovement(); - - int type() const override; - -signals: - void boatDestroyed(); - void boatExecutionFinished(); - -private: - int speed; - int bombsAlreadyLaunched; - Movement direction; - QVariantAnimation *movementAnimation; - QAbstractAnimation *destroyAnimation; - QStateMachine *machine; -}; - -#endif // BOAT_H diff --git a/examples/widgets/animation/sub-attaq/boat_p.h b/examples/widgets/animation/sub-attaq/boat_p.h deleted file mode 100644 index bb1a783392..0000000000 --- a/examples/widgets/animation/sub-attaq/boat_p.h +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOAT_P_H -#define BOAT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -//Own -#include "bomb.h" -#include "graphicsscene.h" - -// Qt -#include -#include -#include - -static const int MAX_BOMB = 5; - - -//These transtion test if we have to stop the boat (i.e current speed is 1) -class KeyStopTransition : public QKeyEventTransition -{ -public: - KeyStopTransition(Boat *b, QEvent::Type t, int k) - : QKeyEventTransition(b, t, k), boat(b) - { - } -protected: - bool eventTest(QEvent *event) override - { - if (!QKeyEventTransition::eventTest(event)) - return false; - return (boat->currentSpeed() == 1); - } -private: - Boat *boat; -}; - -//These transtion test if we have to move the boat (i.e current speed was 0 or another value) - class KeyMoveTransition : public QKeyEventTransition -{ -public: - KeyMoveTransition(Boat *b, QEvent::Type t, int k) - : QKeyEventTransition(b, t, k), boat(b), key(k) - { - } -protected: - bool eventTest(QEvent *event) override - { - if (!QKeyEventTransition::eventTest(event)) - return false; - return (boat->currentSpeed() >= 0); - } - void onTransition(QEvent *) override - { - //We decrease the speed if needed - if (key == Qt::Key_Left && boat->currentDirection() == Boat::Right) - boat->setCurrentSpeed(boat->currentSpeed() - 1); - else if (key == Qt::Key_Right && boat->currentDirection() == Boat::Left) - boat->setCurrentSpeed(boat->currentSpeed() - 1); - else if (boat->currentSpeed() < 3) - boat->setCurrentSpeed(boat->currentSpeed() + 1); - boat->updateBoatMovement(); - } -private: - Boat *boat; - int key; -}; - -//This transition trigger the bombs launch - class KeyLaunchTransition : public QKeyEventTransition -{ -public: - KeyLaunchTransition(Boat *boat, QEvent::Type type, int key) - : QKeyEventTransition(boat, type, key), boat(boat) - { - } -protected: - bool eventTest(QEvent *event) override - { - if (!QKeyEventTransition::eventTest(event)) - return false; - //We have enough bomb? - return (boat->bombsLaunched() < MAX_BOMB); - } -private: - Boat *boat; -}; - -//This state is describing when the boat is moving right -class MoveStateRight : public QState -{ -public: - explicit MoveStateRight(Boat *boat, QState *parent = nullptr) - : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) override - { - boat->setCurrentDirection(Boat::Right); - boat->updateBoatMovement(); - } -private: - Boat *boat; -}; - - //This state is describing when the boat is moving left -class MoveStateLeft : public QState -{ -public: - explicit MoveStateLeft(Boat *boat, QState *parent = nullptr) - : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) override - { - boat->setCurrentDirection(Boat::Left); - boat->updateBoatMovement(); - } -private: - Boat *boat; -}; - -//This state is describing when the boat is in a stand by position -class StopState : public QState -{ -public: - explicit StopState(Boat *boat, QState *parent = nullptr) - : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) override - { - boat->setCurrentSpeed(0); - boat->setCurrentDirection(Boat::None); - boat->updateBoatMovement(); - } -private: - Boat *boat; -}; - -//This state is describing the launch of the torpedo on the right -class LaunchStateRight : public QState -{ -public: - explicit LaunchStateRight(Boat *boat, QState *parent = nullptr) - : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) override - { - Bomb *b = new Bomb; - b->setPos(boat->x()+boat->size().width(),boat->y()); - GraphicsScene *scene = static_cast(boat->scene()); - scene->addItem(b); - b->launch(Bomb::Right); - boat->setBombsLaunched(boat->bombsLaunched() + 1); - } -private: - Boat *boat; -}; - -//This state is describing the launch of the torpedo on the left -class LaunchStateLeft : public QState -{ -public: - explicit LaunchStateLeft(Boat *boat, QState *parent = nullptr) - : QState(parent), boat(boat) - { - } -protected: - void onEntry(QEvent *) override - { - Bomb *b = new Bomb; - b->setPos(boat->x() - b->size().width(), boat->y()); - GraphicsScene *scene = static_cast(boat->scene()); - scene->addItem(b); - b->launch(Bomb::Left); - boat->setBombsLaunched(boat->bombsLaunched() + 1); - } -private: - Boat *boat; -}; - -#endif // BOAT_P_H diff --git a/examples/widgets/animation/sub-attaq/bomb.cpp b/examples/widgets/animation/sub-attaq/bomb.cpp deleted file mode 100644 index 0b9c365662..0000000000 --- a/examples/widgets/animation/sub-attaq/bomb.cpp +++ /dev/null @@ -1,128 +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$ -** -****************************************************************************/ - -//Own -#include "bomb.h" -#include "submarine.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -//Qt -#include -#include -#include -#include - -Bomb::Bomb() : PixmapItem(QString("bomb"), GraphicsScene::Big) -{ - setZValue(2); -} - -void Bomb::launch(Bomb::Direction direction) -{ - QSequentialAnimationGroup *launchAnimation = new QSequentialAnimationGroup; - AnimationManager::self()->registerAnimation(launchAnimation); - qreal delta = direction == Right ? 20 : - 20; - QPropertyAnimation *anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta,y() - 20)); - anim->setDuration(150); - launchAnimation->addAnimation(anim); - anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta*2, y() )); - anim->setDuration(150); - launchAnimation->addAnimation(anim); - anim = new QPropertyAnimation(this, "pos"); - anim->setEndValue(QPointF(x() + delta*2,scene()->height())); - anim->setDuration(y()/2*60); - launchAnimation->addAnimation(anim); - connect(anim, &QVariantAnimation::valueChanged, this, &Bomb::onAnimationLaunchValueChanged); - connect(this, &Bomb::bombExploded, launchAnimation, &QAbstractAnimation::stop); - //We setup the state machine of the bomb - QStateMachine *machine = new QStateMachine(this); - - //This state is when the launch animation is playing - QAnimationState *launched = new QAnimationState(machine); - launched->setAnimation(launchAnimation); - - //End - QFinalState *finalState = new QFinalState(machine); - - machine->setInitialState(launched); - - //### Add a nice animation when the bomb is destroyed - launched->addTransition(this, &Bomb::bombExploded, finalState); - - //If the animation is finished, then we move to the final state - launched->addTransition(launched, &QAnimationState::animationFinished, finalState); - - //The machine has finished to be executed, then the boat is dead - connect(machine,&QState::finished, this, &Bomb::bombExecutionFinished); - - machine->start(); - -} - -void Bomb::onAnimationLaunchValueChanged(const QVariant &) -{ - const QList colItems = - collidingItems(Qt::IntersectsItemBoundingRect); - for (QGraphicsItem *item : colItems) { - if (item->type() == SubMarine::Type) { - SubMarine *s = static_cast(item); - destroy(); - s->destroy(); - } - } -} - -void Bomb::destroy() -{ - emit bombExploded(); -} diff --git a/examples/widgets/animation/sub-attaq/bomb.h b/examples/widgets/animation/sub-attaq/bomb.h deleted file mode 100644 index 9ae54b4d81..0000000000 --- a/examples/widgets/animation/sub-attaq/bomb.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 BOMB_H -#define BOMB_H - -#include "pixmapitem.h" - -class Bomb : public PixmapItem -{ -Q_OBJECT -public: - enum Direction { - Left = 0, - Right - }; - Bomb(); - void launch(Direction direction); - void destroy(); - -signals: - void bombExploded(); - void bombExecutionFinished(); - -private slots: - void onAnimationLaunchValueChanged(const QVariant &); -}; - -#endif // BOMB_H diff --git a/examples/widgets/animation/sub-attaq/data.xml b/examples/widgets/animation/sub-attaq/data.xml deleted file mode 100644 index 0f30515ddf..0000000000 --- a/examples/widgets/animation/sub-attaq/data.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/graphicsscene.cpp b/examples/widgets/animation/sub-attaq/graphicsscene.cpp deleted file mode 100644 index 5248ed9f92..0000000000 --- a/examples/widgets/animation/sub-attaq/graphicsscene.cpp +++ /dev/null @@ -1,301 +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$ -** -****************************************************************************/ - -//Own -#include "graphicsscene.h" -#include "states.h" -#include "boat.h" -#include "submarine.h" -#include "torpedo.h" -#include "bomb.h" -#include "animationmanager.h" -#include "qanimationstate.h" -#include "progressitem.h" -#include "textinformationitem.h" - -//Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include - -GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent) - : QGraphicsScene(x, y, width, height, parent), mode(mode), boat(new Boat) -{ - PixmapItem *backgroundItem = new PixmapItem(QStringLiteral("background"), mode); - backgroundItem->setZValue(1); - backgroundItem->setPos(0,0); - addItem(backgroundItem); - - PixmapItem *surfaceItem = new PixmapItem(QStringLiteral("surface"), mode); - surfaceItem->setZValue(3); - surfaceItem->setPos(0, sealLevel() - surfaceItem->boundingRect().height() / 2); - addItem(surfaceItem); - - //The item that display score and level - progressItem = new ProgressItem(backgroundItem); - - textInformationItem = new TextInformationItem(backgroundItem); - textInformationItem->hide(); - //We create the boat - addItem(boat); - boat->setPos(this->width()/2, sealLevel() - boat->size().height()); - boat->hide(); - - //parse the xml that contain all data of the game - QXmlStreamReader reader; - QFile file(":data.xml"); - file.open(QIODevice::ReadOnly); - reader.setDevice(&file); - LevelDescription currentLevel; - while (!reader.atEnd()) { - reader.readNext(); - if (reader.tokenType() == QXmlStreamReader::StartElement) { - if (reader.name() == u"submarine") { - SubmarineDescription desc; - desc.name = reader.attributes().value("name").toString(); - desc.points = reader.attributes().value("points").toInt(); - desc.type = reader.attributes().value("type").toInt(); - submarinesData.append(desc); - } else if (reader.name() == u"level") { - currentLevel.id = reader.attributes().value("id").toInt(); - currentLevel.name = reader.attributes().value("name").toString(); - } else if (reader.name() == u"subinstance") { - currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toInt(), - reader.attributes().value("nb").toInt())); - } - } else if (reader.tokenType() == QXmlStreamReader::EndElement) { - if (reader.name() == u"level") { - levelsData.insert(currentLevel.id, currentLevel); - currentLevel.submarines.clear(); - } - } - } -} - -qreal GraphicsScene::sealLevel() const -{ - return (mode == Big) ? 220 : 160; -} - -void GraphicsScene::setupScene(QAction *newAction, QAction *quitAction) -{ - static constexpr int nLetters = 10; - static constexpr struct { - char const *pix; - qreal initX, initY; - qreal destX, destY; - } logoData[nLetters] = { - {"s", -1000, -1000, 300, 150 }, - {"u", -800, -1000, 350, 150 }, - {"b", -600, -1000, 400, 120 }, - {"dash", -400, -1000, 460, 150 }, - {"a", 1000, 2000, 350, 250 }, - {"t", 800, 2000, 400, 250 }, - {"t2", 600, 2000, 430, 250 }, - {"a2", 400, 2000, 465, 250 }, - {"q", 200, 2000, 510, 250 }, - {"excl", 0, 2000, 570, 220 } }; - - QSequentialAnimationGroup *lettersGroupMoving = new QSequentialAnimationGroup(this); - QParallelAnimationGroup *lettersGroupFading = new QParallelAnimationGroup(this); - - for (int i = 0; i < nLetters; ++i) { - PixmapItem *logo = new PixmapItem(QLatin1String(":/logo-") + logoData[i].pix, this); - logo->setPos(logoData[i].initX, logoData[i].initY); - logo->setZValue(i + 3); - //creation of the animations for moving letters - QPropertyAnimation *moveAnim = new QPropertyAnimation(logo, "pos", lettersGroupMoving); - moveAnim->setEndValue(QPointF(logoData[i].destX, logoData[i].destY)); - moveAnim->setDuration(200); - moveAnim->setEasingCurve(QEasingCurve::OutElastic); - lettersGroupMoving->addPause(50); - //creation of the animations for fading out the letters - QPropertyAnimation *fadeAnim = new QPropertyAnimation(logo, "opacity", lettersGroupFading); - fadeAnim->setDuration(800); - fadeAnim->setEndValue(0); - fadeAnim->setEasingCurve(QEasingCurve::OutQuad); - } - - QStateMachine *machine = new QStateMachine(this); - - //This state is when the player is playing - PlayState *gameState = new PlayState(this, machine); - - //Final state - QFinalState *finalState = new QFinalState(machine); - - //Animation when the player enter in the game - QAnimationState *lettersMovingState = new QAnimationState(machine); - lettersMovingState->setAnimation(lettersGroupMoving); - - //Animation when the welcome screen disappear - QAnimationState *lettersFadingState = new QAnimationState(machine); - lettersFadingState->setAnimation(lettersGroupFading); - - //if new game then we fade out the welcome screen and start playing - lettersMovingState->addTransition(newAction, &QAction::triggered, lettersFadingState); - lettersFadingState->addTransition(lettersFadingState, &QAnimationState::animationFinished, gameState); - - //New Game is triggered then player start playing - gameState->addTransition(newAction, &QAction::triggered, gameState); - - //Wanna quit, then connect to CTRL+Q - gameState->addTransition(quitAction, &QAction::triggered, finalState); - lettersMovingState->addTransition(quitAction, &QAction::triggered, finalState); - - //Welcome screen is the initial state - machine->setInitialState(lettersMovingState); - - machine->start(); - - //We reach the final state, then we quit - connect(machine, &QStateMachine::finished, qApp, &QApplication::quit); -} - -void GraphicsScene::addItem(Bomb *bomb) -{ - bombs.insert(bomb); - connect(bomb, &Bomb::bombExecutionFinished, - this, &GraphicsScene::onBombExecutionFinished); - QGraphicsScene::addItem(bomb); -} - -void GraphicsScene::addItem(Torpedo *torpedo) -{ - torpedos.insert(torpedo); - connect(torpedo, &Torpedo::torpedoExecutionFinished, - this, &GraphicsScene::onTorpedoExecutionFinished); - QGraphicsScene::addItem(torpedo); -} - -void GraphicsScene::addItem(SubMarine *submarine) -{ - submarines.insert(submarine); - connect(submarine, &SubMarine::subMarineExecutionFinished, - this, &GraphicsScene::onSubMarineExecutionFinished); - QGraphicsScene::addItem(submarine); -} - -void GraphicsScene::addItem(QGraphicsItem *item) -{ - QGraphicsScene::addItem(item); -} - -void GraphicsScene::onBombExecutionFinished() -{ - Bomb *bomb = qobject_cast(sender()); - if (!bomb) - return; - bombs.remove(bomb); - bomb->deleteLater(); - boat->setBombsLaunched(boat->bombsLaunched() - 1); -} - -void GraphicsScene::onTorpedoExecutionFinished() -{ - Torpedo *torpedo = qobject_cast(sender()); - if (!torpedo) - return; - torpedos.remove(torpedo); - torpedo->deleteLater(); -} - -void GraphicsScene::onSubMarineExecutionFinished() -{ - SubMarine *submarine = qobject_cast(sender()); - if (!submarine) - return; - submarines.remove(submarine); - if (submarines.count() == 0) - emit allSubMarineDestroyed(submarine->points()); - else - emit subMarineDestroyed(submarine->points()); - submarine->deleteLater(); -} - -void GraphicsScene::clearScene() -{ - for (SubMarine *sub : qAsConst(submarines)) { - // make sure to not go into onSubMarineExecutionFinished - sub->disconnect(this); - sub->destroy(); - sub->deleteLater(); - } - - for (Torpedo *torpedo : qAsConst(torpedos)) { - // make sure to not go into onTorpedoExecutionFinished - torpedo->disconnect(this); - torpedo->destroy(); - torpedo->deleteLater(); - } - - for (Bomb *bomb : qAsConst(bombs)) { - // make sure to not go into onBombExecutionFinished - bomb->disconnect(this); - bomb->destroy(); - bomb->deleteLater(); - } - - submarines.clear(); - bombs.clear(); - torpedos.clear(); - - AnimationManager::self()->unregisterAllAnimations(); - - boat->stop(); - boat->hide(); - boat->setEnabled(true); -} diff --git a/examples/widgets/animation/sub-attaq/graphicsscene.h b/examples/widgets/animation/sub-attaq/graphicsscene.h deleted file mode 100644 index ce9ee115ca..0000000000 --- a/examples/widgets/animation/sub-attaq/graphicsscene.h +++ /dev/null @@ -1,130 +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 GRAPHICSSCENE_H -#define GRAPHICSSCENE_H - -//Qt -#include -#include - - -class Boat; -class SubMarine; -class Torpedo; -class Bomb; -class PixmapItem; -class ProgressItem; -class TextInformationItem; -QT_BEGIN_NAMESPACE -class QAction; -QT_END_NAMESPACE - -class GraphicsScene : public QGraphicsScene -{ -Q_OBJECT -public: - enum Mode { - Big = 0, - Small - }; - - struct SubmarineDescription { - int type = 0; - int points = 0; - QString name; - }; - - struct LevelDescription { - int id = 0; - QString name; - QList> submarines; - }; - - GraphicsScene(int x, int y, int width, int height, Mode mode, QObject *parent = nullptr); - qreal sealLevel() const; - void setupScene(QAction *newAction, QAction *quitAction); - void addItem(Bomb *bomb); - void addItem(Torpedo *torpedo); - void addItem(SubMarine *submarine); - void addItem(QGraphicsItem *item); - void clearScene(); - -signals: - void subMarineDestroyed(int); - void allSubMarineDestroyed(int); - -private slots: - void onBombExecutionFinished(); - void onTorpedoExecutionFinished(); - void onSubMarineExecutionFinished(); - -private: - Mode mode; - ProgressItem *progressItem; - TextInformationItem *textInformationItem; - Boat *boat; - QSet submarines; - QSet bombs; - QSet torpedos; - QList submarinesData; - QHash levelsData; - - friend class PauseState; - friend class PlayState; - friend class LevelState; - friend class LostState; - friend class WinState; - friend class WinTransition; - friend class UpdateScoreTransition; -}; - -#endif // GRAPHICSSCENE_H - diff --git a/examples/widgets/animation/sub-attaq/main.cpp b/examples/widgets/animation/sub-attaq/main.cpp deleted file mode 100644 index 9b28d8c40f..0000000000 --- a/examples/widgets/animation/sub-attaq/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 - -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(subattaq); - - MainWindow w; - w.show(); - - return app.exec(); -} diff --git a/examples/widgets/animation/sub-attaq/mainwindow.cpp b/examples/widgets/animation/sub-attaq/mainwindow.cpp deleted file mode 100644 index 0c152c9180..0000000000 --- a/examples/widgets/animation/sub-attaq/mainwindow.cpp +++ /dev/null @@ -1,84 +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$ -** -****************************************************************************/ - -//Own -#include "mainwindow.h" -#include "graphicsscene.h" - -//Qt -#include -#include -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - QMenu *file = menuBar()->addMenu(tr("&File")); - - QAction *newAction = file->addAction(tr("New Game")); - newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); - QAction *quitAction = file->addAction(tr("Quit")); - quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); - - if (QApplication::arguments().contains("-fullscreen")) { - scene = new GraphicsScene(0, 0, 750, 400, GraphicsScene::Small, this); - setWindowState(Qt::WindowFullScreen); - } else { - scene = new GraphicsScene(0, 0, 880, 630, GraphicsScene::Big, this); - layout()->setSizeConstraint(QLayout::SetFixedSize); - } - - view = new QGraphicsView(scene, this); - view->setAlignment(Qt::AlignLeft | Qt::AlignTop); - scene->setupScene(newAction, quitAction); - setCentralWidget(view); -} diff --git a/examples/widgets/animation/sub-attaq/mainwindow.h b/examples/widgets/animation/sub-attaq/mainwindow.h deleted file mode 100644 index 660acfaa0a..0000000000 --- a/examples/widgets/animation/sub-attaq/mainwindow.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 MAINWINDOW_H -#define MAINWINDOW_H - -//Qt -#include -class GraphicsScene; -QT_BEGIN_NAMESPACE -class QGraphicsView; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ -Q_OBJECT -public: - MainWindow(QWidget *parent = nullptr); - -private: - GraphicsScene *scene; - QGraphicsView *view; -}; - -#endif // MAINWINDOW_H diff --git a/examples/widgets/animation/sub-attaq/pics/big/background.png b/examples/widgets/animation/sub-attaq/pics/big/background.png deleted file mode 100644 index 9f581571fa..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/background.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/boat.png b/examples/widgets/animation/sub-attaq/pics/big/boat.png deleted file mode 100644 index be82dff62a..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/boat.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/bomb.png b/examples/widgets/animation/sub-attaq/pics/big/bomb.png deleted file mode 100644 index 3af5f2f29c..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/bomb.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png deleted file mode 100644 index c9fd8b0984..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step1.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png deleted file mode 100644 index 7528f2d2da..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step2.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png deleted file mode 100644 index aae9c9c184..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step3.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png deleted file mode 100644 index d697c1bae8..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/boat/step4.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png deleted file mode 100644 index 88ca5144b7..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step1.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png deleted file mode 100644 index 524f5890ee..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step2.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png deleted file mode 100644 index 2cca1e80fe..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step3.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png b/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png deleted file mode 100644 index 82100a8260..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/explosion/submarine/step4.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/submarine.png b/examples/widgets/animation/sub-attaq/pics/big/submarine.png deleted file mode 100644 index df435dc47d..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/submarine.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/surface.png b/examples/widgets/animation/sub-attaq/pics/big/surface.png deleted file mode 100644 index 4eba29e9cd..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/surface.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/big/torpedo.png b/examples/widgets/animation/sub-attaq/pics/big/torpedo.png deleted file mode 100644 index f9c26873f1..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/big/torpedo.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg b/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg deleted file mode 100644 index ece9f7aaf1..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/background-n810.svg +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/background.svg b/examples/widgets/animation/sub-attaq/pics/scalable/background.svg deleted file mode 100644 index 0be268010e..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/background.svg +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg b/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg deleted file mode 100644 index 5298821ba8..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/boat.svg +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg b/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg deleted file mode 100644 index 294771a6dd..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/bomb.svg +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg deleted file mode 100644 index 8af11b7a66..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/sand.svg +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/see.svg b/examples/widgets/animation/sub-attaq/pics/scalable/see.svg deleted file mode 100644 index 0666691215..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/see.svg +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg deleted file mode 100644 index 1546c087a7..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/sky.svg +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg b/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg deleted file mode 100644 index b075179b46..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/sub-attaq.svg +++ /dev/null @@ -1,1473 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg b/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg deleted file mode 100644 index 8a0ffddbca..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/submarine.svg +++ /dev/null @@ -1,214 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg b/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg deleted file mode 100644 index 40ed239638..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/surface.svg +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg b/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg deleted file mode 100644 index 48e429d2bf..0000000000 --- a/examples/widgets/animation/sub-attaq/pics/scalable/torpedo.svg +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/widgets/animation/sub-attaq/pics/small/background.png b/examples/widgets/animation/sub-attaq/pics/small/background.png deleted file mode 100644 index 5ad3db660a..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/background.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/boat.png b/examples/widgets/animation/sub-attaq/pics/small/boat.png deleted file mode 100644 index 114ccc310e..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/boat.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/bomb.png b/examples/widgets/animation/sub-attaq/pics/small/bomb.png deleted file mode 100644 index 3af5f2f29c..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/bomb.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/submarine.png b/examples/widgets/animation/sub-attaq/pics/small/submarine.png deleted file mode 100644 index 0c0c350600..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/submarine.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/surface.png b/examples/widgets/animation/sub-attaq/pics/small/surface.png deleted file mode 100644 index 06d0e47a5c..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/surface.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/small/torpedo.png b/examples/widgets/animation/sub-attaq/pics/small/torpedo.png deleted file mode 100644 index f9c26873f1..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/small/torpedo.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png deleted file mode 100644 index 67dd76dac0..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png deleted file mode 100644 index 17668b07de..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-a2.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png deleted file mode 100644 index cf6c04560b..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-b.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png deleted file mode 100644 index 219233ce6b..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-dash.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png deleted file mode 100644 index 8dd0a2eb86..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-excl.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png deleted file mode 100644 index 86e588d4d8..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-q.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png deleted file mode 100644 index 7b6a36e93a..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-s.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png deleted file mode 100644 index b2e3526bea..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png deleted file mode 100644 index b11a77886e..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-t2.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png b/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png deleted file mode 100644 index 24eede887a..0000000000 Binary files a/examples/widgets/animation/sub-attaq/pics/welcome/logo-u.png and /dev/null differ diff --git a/examples/widgets/animation/sub-attaq/pixmapitem.cpp b/examples/widgets/animation/sub-attaq/pixmapitem.cpp deleted file mode 100644 index a8581d881a..0000000000 --- a/examples/widgets/animation/sub-attaq/pixmapitem.cpp +++ /dev/null @@ -1,87 +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$ -** -****************************************************************************/ - -//Own -#include "pixmapitem.h" - -//Qt -#include - -PixmapItem::PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem *parent) - : QGraphicsObject(parent) -{ - if (mode == GraphicsScene::Big) - pix = QPixmap(QStringLiteral(":/big/") + fileName); - else - pix = QPixmap(QStringLiteral(":/small/") + fileName); -} - -PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) - : QGraphicsObject(), pix(fileName) -{ - scene->addItem(this); -} - -QSizeF PixmapItem::size() const -{ - return pix.size(); -} - -QRectF PixmapItem::boundingRect() const -{ - return QRectF(QPointF(0, 0), pix.size()); -} - -void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - painter->drawPixmap(0, 0, pix); -} - - diff --git a/examples/widgets/animation/sub-attaq/pixmapitem.h b/examples/widgets/animation/sub-attaq/pixmapitem.h deleted file mode 100644 index 45e2ca806f..0000000000 --- a/examples/widgets/animation/sub-attaq/pixmapitem.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 PIXMAPITEM_H -#define PIXMAPITEM_H - -//Own -#include "graphicsscene.h" - -//Qt -#include - -class PixmapItem : public QGraphicsObject -{ -public: - PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem *parent = nullptr); - PixmapItem(const QString &fileName, QGraphicsScene *scene); - QSizeF size() const; - QRectF boundingRect() const override; - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; -private: - QPixmap pix; -}; - -#endif // PIXMAPITEM_H diff --git a/examples/widgets/animation/sub-attaq/progressitem.cpp b/examples/widgets/animation/sub-attaq/progressitem.cpp deleted file mode 100644 index 350dbb7bbd..0000000000 --- a/examples/widgets/animation/sub-attaq/progressitem.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 "progressitem.h" - -#include - -ProgressItem::ProgressItem(QGraphicsItem *parent) - : QGraphicsTextItem(parent) -{ - setFont(QFont("Comic Sans MS")); - setPos(parentItem()->boundingRect().topRight() - QPointF(180, -5)); -} - -void ProgressItem::setLevel(int level) -{ - currentLevel = level; - updateProgress(); -} - -void ProgressItem::setScore(int score) -{ - currentScore = score; - updateProgress(); -} - -void ProgressItem::updateProgress() -{ - setHtml(QString("Level : %1 Score : %2").arg(currentLevel).arg(currentScore)); -} diff --git a/examples/widgets/animation/sub-attaq/progressitem.h b/examples/widgets/animation/sub-attaq/progressitem.h deleted file mode 100644 index f76b168151..0000000000 --- a/examples/widgets/animation/sub-attaq/progressitem.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 PROGRESSITEM_H -#define PROGRESSITEM_H - -//Qt -#include - -class ProgressItem : public QGraphicsTextItem -{ -public: - ProgressItem(QGraphicsItem *parent = nullptr); - void setLevel(int level); - void setScore(int score); - -private: - void updateProgress(); - int currentLevel = 1; - int currentScore = 0; -}; - -#endif // PROGRESSITEM_H diff --git a/examples/widgets/animation/sub-attaq/qanimationstate.cpp b/examples/widgets/animation/sub-attaq/qanimationstate.cpp deleted file mode 100644 index 6da085561b..0000000000 --- a/examples/widgets/animation/sub-attaq/qanimationstate.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui 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 "qanimationstate.h" - -#include - -QT_BEGIN_NAMESPACE - -/*! -\class QAnimationState - -\brief The QAnimationState class provides state that handle an animation and emit -a signal when this animation is finished. - -\ingroup statemachine - -QAnimationState provides a state that handle an animation. It will start this animation -when the state is entered and stop it when it is leaved. When the animation has finished the -state emit animationFinished signal. -QAnimationState is part of \l{The State Machine Framework}. - -\code -QStateMachine machine; -QAnimationState *s = new QAnimationState(machine->rootState()); -QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos"); -s->setAnimation(animation); -QState *s2 = new QState(machine->rootState()); -s->addTransition(s, &QAnimationState::animationFinished, s2); -machine.start(); -\endcode - -\sa QState, {The Animation Framework} -*/ - -/*! - Constructs a new state with the given \a parent state. -*/ -QAnimationState::QAnimationState(QState *parent) - : QState(parent), m_animation(nullptr) -{ -} - -/*! - Destroys the animation state. -*/ -QAnimationState::~QAnimationState() -{ -} - -/*! - Set an \a animation for this QAnimationState. If an animation was previously handle by this - state then it won't emit animationFinished for the old animation. The QAnimationState doesn't - take the ownership of the animation. -*/ -void QAnimationState::setAnimation(QAbstractAnimation *animation) -{ - if (animation == m_animation) - return; - - //Disconnect from the previous animation if exist - if (m_animation) - disconnect(m_animation, &QAbstractAnimation::finished, this, &QAnimationState::animationFinished); - - m_animation = animation; - - if (m_animation) { - //connect the new animation - connect(m_animation, &QAbstractAnimation::finished, this, &QAnimationState::animationFinished); - } -} - -/*! - Returns the animation handle by this animation state, or \nullptr if there is no animation. -*/ -QAbstractAnimation* QAnimationState::animation() const -{ - return m_animation; -} - -/*! - \reimp -*/ -void QAnimationState::onEntry(QEvent *) -{ - if (m_animation) - m_animation->start(); -} - -/*! - \reimp -*/ -void QAnimationState::onExit(QEvent *) -{ - if (m_animation) - m_animation->stop(); -} - -/*! - \reimp -*/ -bool QAnimationState::event(QEvent *e) -{ - return QState::event(e); -} - -QT_END_NAMESPACE diff --git a/examples/widgets/animation/sub-attaq/qanimationstate.h b/examples/widgets/animation/sub-attaq/qanimationstate.h deleted file mode 100644 index 24759851ba..0000000000 --- a/examples/widgets/animation/sub-attaq/qanimationstate.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui 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 QANIMATIONSTATE_H -#define QANIMATIONSTATE_H - -#include - -QT_BEGIN_NAMESPACE - -class QAbstractAnimation; - -class QAnimationState : public QState -{ - Q_OBJECT -public: - QAnimationState(QState *parent = nullptr); - ~QAnimationState(); - - void setAnimation(QAbstractAnimation *animation); - QAbstractAnimation* animation() const; - -signals: - void animationFinished(); - -protected: - void onEntry(QEvent *) override; - void onExit(QEvent *) override; - bool event(QEvent *e) override; - -private: - Q_DISABLE_COPY(QAnimationState) - QAbstractAnimation *m_animation; -}; - -QT_END_NAMESPACE - -#endif // QANIMATIONSTATE_H diff --git a/examples/widgets/animation/sub-attaq/states.cpp b/examples/widgets/animation/sub-attaq/states.cpp deleted file mode 100644 index c7e2738aad..0000000000 --- a/examples/widgets/animation/sub-attaq/states.cpp +++ /dev/null @@ -1,335 +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$ -** -****************************************************************************/ - -//Own -#include "states.h" -#include "graphicsscene.h" -#include "boat.h" -#include "submarine.h" -#include "torpedo.h" -#include "animationmanager.h" -#include "progressitem.h" -#include "textinformationitem.h" - -//Qt -#include -#include -#include -#include -#include -#include - -PlayState::PlayState(GraphicsScene *scene, QState *parent) - : QState(parent), scene(scene), machine(nullptr), - currentLevel(0), score(0) -{ -} - -PlayState::~PlayState() -{ - delete machine; -} - -void PlayState::onEntry(QEvent *) -{ - //We are now playing? - if (machine) { - machine->stop(); - //we hide the information - scene->textInformationItem->hide(); - scene->clearScene(); - currentLevel = 0; - score = 0; - delete machine; - } - - machine = new QStateMachine; - - //This state is when player is playing - LevelState *levelState = new LevelState(scene, this, machine); - - //This state is when the player is actually playing but the game is not paused - QState *playingState = new QState(levelState); - levelState->setInitialState(playingState); - - //This state is when the game is paused - PauseState *pauseState = new PauseState(scene, levelState); - - //We have one view, it receive the key press event - QKeyEventTransition *pressPplay = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); - pressPplay->setTargetState(pauseState); - QKeyEventTransition *pressPpause = new QKeyEventTransition(scene->views().at(0), QEvent::KeyPress, Qt::Key_P); - pressPpause->setTargetState(playingState); - - //Pause "P" is triggered, the player pause the game - playingState->addTransition(pressPplay); - - //To get back playing when the game has been paused - pauseState->addTransition(pressPpause); - - //This state is when player have lost - LostState *lostState = new LostState(scene, this, machine); - - //This state is when player have won - WinState *winState = new WinState(scene, this, machine); - - //The boat has been destroyed then the game is finished - levelState->addTransition(scene->boat, &Boat::boatExecutionFinished,lostState); - - //This transition check if we won or not - WinTransition *winTransition = new WinTransition(scene, this, winState); - - //The boat has been destroyed then the game is finished - levelState->addTransition(winTransition); - - //This state is an animation when the score changed - UpdateScoreState *scoreState = new UpdateScoreState(levelState); - - //This transition update the score when a submarine die - UpdateScoreTransition *scoreTransition = new UpdateScoreTransition(scene, this, levelState); - scoreTransition->setTargetState(scoreState); - - //The boat has been destroyed then the game is finished - playingState->addTransition(scoreTransition); - - //We go back to play state - scoreState->addTransition(playingState); - - //We start playing!!! - machine->setInitialState(levelState); - - //Final state - QFinalState *finalState = new QFinalState(machine); - - //This transition is triggered when the player press space after completing a level - CustomSpaceTransition *spaceTransition = new CustomSpaceTransition(scene->views().at(0), this, QEvent::KeyPress, Qt::Key_Space); - spaceTransition->setTargetState(levelState); - winState->addTransition(spaceTransition); - - //We lost we should reach the final state - lostState->addTransition(lostState, &QState::finished, finalState); - - machine->start(); -} - -LevelState::LevelState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} -void LevelState::onEntry(QEvent *) -{ - initializeLevel(); -} - -void LevelState::initializeLevel() -{ - //we re-init the boat - scene->boat->setPos(scene->width()/2, scene->sealLevel() - scene->boat->size().height()); - scene->boat->setCurrentSpeed(0); - scene->boat->setCurrentDirection(Boat::None); - scene->boat->setBombsLaunched(0); - scene->boat->show(); - scene->setFocusItem(scene->boat, Qt::OtherFocusReason); - scene->boat->run(); - - scene->progressItem->setScore(game->score); - scene->progressItem->setLevel(game->currentLevel + 1); - - const GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(game->currentLevel); - for (const QPair &subContent : currentLevelDescription.submarines) { - - GraphicsScene::SubmarineDescription submarineDesc = scene->submarinesData.at(subContent.first); - - for (int j = 0; j < subContent.second; ++j ) { - SubMarine *sub = new SubMarine(submarineDesc.type, submarineDesc.name, submarineDesc.points); - scene->addItem(sub); - int random = QRandomGenerator::global()->bounded(15) + 1; - qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width(); - qreal y = scene->height() -(QRandomGenerator::global()->bounded(150) + 1) - sub->size().height(); - sub->setPos(x,y); - sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left); - sub->setCurrentSpeed(QRandomGenerator::global()->bounded(3) + 1); - } - } -} - -/** Pause State */ -PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent), scene(scene) -{ -} - -void PauseState::onEntry(QEvent *) -{ - AnimationManager::self()->pauseAll(); - scene->boat->setEnabled(false); -} -void PauseState::onExit(QEvent *) -{ - AnimationManager::self()->resumeAll(); - scene->boat->setEnabled(true); - scene->boat->setFocus(); -} - -/** Lost State */ -LostState::LostState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} - -void LostState::onEntry(QEvent *) -{ - //The message to display - QString message = QString("You lose on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); - - //We set the level back to 0 - game->currentLevel = 0; - - //We set the score back to 0 - game->score = 0; - - //We clear the scene - scene->clearScene(); - - //We inform the player - scene->textInformationItem->setMessage(message); - scene->textInformationItem->show(); -} - -void LostState::onExit(QEvent *) -{ - //we hide the information - scene->textInformationItem->hide(); -} - -/** Win State */ -WinState::WinState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) -{ -} - -void WinState::onEntry(QEvent *) -{ - //We clear the scene - scene->clearScene(); - - QString message; - if (scene->levelsData.size() - 1 != game->currentLevel) { - message = QString("You win the level %1. Your score is %2.\nPress Space to continue.").arg(game->currentLevel+1).arg(game->score); - //We increment the level number - game->currentLevel++; - } else { - message = QString("You finish the game on level %1. Your score is %2.").arg(game->currentLevel+1).arg(game->score); - //We set the level back to 0 - game->currentLevel = 0; - //We set the score back to 0 - game->score = 0; - } - - //We inform the player - scene->textInformationItem->setMessage(message); - scene->textInformationItem->show(); -} - -void WinState::onExit(QEvent *) -{ - //we hide the information - scene->textInformationItem->hide(); -} - -/** UpdateScore State */ -UpdateScoreState::UpdateScoreState(QState *parent) : QState(parent) -{ -} - -/** Win transition */ -UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene, &GraphicsScene::subMarineDestroyed), - game(game), scene(scene) -{ - setTargetState(target); -} - -bool UpdateScoreTransition::eventTest(QEvent *event) -{ - if (!QSignalTransition::eventTest(event)) - return false; - QStateMachine::SignalEvent *se = static_cast(event); - game->score += se->arguments().at(0).toInt(); - scene->progressItem->setScore(game->score); - return true; -} - -/** Win transition */ -WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) - : QSignalTransition(scene, &GraphicsScene::allSubMarineDestroyed), - game(game), scene(scene) -{ - setTargetState(target); -} - -bool WinTransition::eventTest(QEvent *event) -{ - if (!QSignalTransition::eventTest(event)) - return false; - QStateMachine::SignalEvent *se = static_cast(event); - game->score += se->arguments().at(0).toInt(); - scene->progressItem->setScore(game->score); - return true; -} - -/** Space transition */ -CustomSpaceTransition::CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key) - : QKeyEventTransition(widget, type, key), game(game) -{ -} - -bool CustomSpaceTransition::eventTest(QEvent *event) -{ - if (!QKeyEventTransition::eventTest(event)) - return false; - return (game->currentLevel != 0); -} diff --git a/examples/widgets/animation/sub-attaq/states.h b/examples/widgets/animation/sub-attaq/states.h deleted file mode 100644 index b3651e1c82..0000000000 --- a/examples/widgets/animation/sub-attaq/states.h +++ /dev/null @@ -1,180 +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 STATES_H -#define STATES_H - -//Qt -#include -#include -#include - -class GraphicsScene; -QT_BEGIN_NAMESPACE -class QStateMachine; -QT_END_NAMESPACE - -class PlayState : public QState -{ -public: - explicit PlayState(GraphicsScene *scene, QState *parent = nullptr); - ~PlayState(); - - protected: - void onEntry(QEvent *) override; - -private : - GraphicsScene *scene; - QStateMachine *machine; - int currentLevel; - int score; - - friend class UpdateScoreState; - friend class UpdateScoreTransition; - friend class WinTransition; - friend class CustomSpaceTransition; - friend class WinState; - friend class LostState; - friend class LevelState; -}; - -class LevelState : public QState -{ -public: - LevelState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr); -protected: - void onEntry(QEvent *) override; -private : - void initializeLevel(); - GraphicsScene *scene; - PlayState *game; -}; - -class PauseState : public QState -{ -public: - explicit PauseState(GraphicsScene *scene, QState *parent = nullptr); - -protected: - void onEntry(QEvent *) override; - void onExit(QEvent *) override; -private : - GraphicsScene *scene; -}; - -class LostState : public QState -{ -public: - LostState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr); - -protected: - void onEntry(QEvent *) override; - void onExit(QEvent *) override; -private : - GraphicsScene *scene; - PlayState *game; -}; - -class WinState : public QState -{ -public: - WinState(GraphicsScene *scene, PlayState *game, QState *parent = nullptr); - -protected: - void onEntry(QEvent *) override; - void onExit(QEvent *) override; -private : - GraphicsScene *scene; - PlayState *game; -}; - -class UpdateScoreState : public QState -{ -public: - UpdateScoreState(QState *parent); -private: -}; - -//These transtion is used to update the score -class UpdateScoreTransition : public QSignalTransition -{ -public: - UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); -protected: - bool eventTest(QEvent *event) override; -private: - PlayState *game; - GraphicsScene *scene; -}; - -//These transtion test if we have won the game -class WinTransition : public QSignalTransition -{ -public: - WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); -protected: - bool eventTest(QEvent *event) override; -private: - PlayState *game; - GraphicsScene *scene; -}; - -//These transtion is true if one level has been completed and the player want to continue - class CustomSpaceTransition : public QKeyEventTransition -{ -public: - CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key); -protected: - bool eventTest(QEvent *event) override; -private: - PlayState *game; -}; - -#endif // STATES_H diff --git a/examples/widgets/animation/sub-attaq/sub-attaq.pro b/examples/widgets/animation/sub-attaq/sub-attaq.pro deleted file mode 100644 index ea44253fa1..0000000000 --- a/examples/widgets/animation/sub-attaq/sub-attaq.pro +++ /dev/null @@ -1,33 +0,0 @@ -QT += widgets -HEADERS += boat.h \ - bomb.h \ - mainwindow.h \ - submarine.h \ - torpedo.h \ - pixmapitem.h \ - graphicsscene.h \ - animationmanager.h \ - states.h \ - boat_p.h \ - submarine_p.h \ - qanimationstate.h \ - progressitem.h \ - textinformationitem.h -SOURCES += boat.cpp \ - bomb.cpp \ - main.cpp \ - mainwindow.cpp \ - submarine.cpp \ - torpedo.cpp \ - pixmapitem.cpp \ - graphicsscene.cpp \ - animationmanager.cpp \ - states.cpp \ - qanimationstate.cpp \ - progressitem.cpp \ - textinformationitem.cpp -RESOURCES += subattaq.qrc - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/animation/sub-attaq -INSTALLS += target diff --git a/examples/widgets/animation/sub-attaq/subattaq.qrc b/examples/widgets/animation/sub-attaq/subattaq.qrc deleted file mode 100644 index 80a3af11cc..0000000000 --- a/examples/widgets/animation/sub-attaq/subattaq.qrc +++ /dev/null @@ -1,39 +0,0 @@ - - - pics/scalable/sub-attaq.svg - pics/scalable/submarine.svg - pics/scalable/boat.svg - pics/scalable/torpedo.svg - pics/welcome/logo-s.png - pics/welcome/logo-u.png - pics/welcome/logo-b.png - pics/welcome/logo-dash.png - pics/welcome/logo-a.png - pics/welcome/logo-t.png - pics/welcome/logo-t2.png - pics/welcome/logo-a2.png - pics/welcome/logo-q.png - pics/welcome/logo-excl.png - pics/big/background.png - pics/big/boat.png - pics/big/bomb.png - pics/big/submarine.png - pics/big/surface.png - pics/big/torpedo.png - pics/small/background.png - pics/small/boat.png - pics/small/bomb.png - pics/small/submarine.png - pics/small/surface.png - pics/small/torpedo.png - pics/big/explosion/boat/step1.png - pics/big/explosion/boat/step2.png - pics/big/explosion/boat/step3.png - pics/big/explosion/boat/step4.png - pics/big/explosion/submarine/step1.png - pics/big/explosion/submarine/step2.png - pics/big/explosion/submarine/step3.png - pics/big/explosion/submarine/step4.png - data.xml - - diff --git a/examples/widgets/animation/sub-attaq/submarine.cpp b/examples/widgets/animation/sub-attaq/submarine.cpp deleted file mode 100644 index a4ca376045..0000000000 --- a/examples/widgets/animation/sub-attaq/submarine.cpp +++ /dev/null @@ -1,187 +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$ -** -****************************************************************************/ - -//Own -#include "submarine.h" -#include "submarine_p.h" -#include "torpedo.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -#include -#include -#include -#include - -static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub) -{ - QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub); - for (int i = 1; i <= 4; ++i) { - PixmapItem *step = new PixmapItem(QString::fromLatin1("explosion/submarine/step%1").arg(i), GraphicsScene::Big, sub); - step->setZValue(6); - step->setOpacity(0); - QPropertyAnimation *anim = new QPropertyAnimation(step, "opacity", group); - anim->setDuration(100); - anim->setEndValue(1); - } - AnimationManager::self()->registerAnimation(group); - return group; -} - - -SubMarine::SubMarine(int type, const QString &name, int points) : PixmapItem(QString("submarine"), GraphicsScene::Big), - subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None) -{ - setZValue(5); - setTransformOriginPoint(boundingRect().center()); - - graphicsRotation = new QGraphicsRotation(this); - graphicsRotation->setAxis(Qt::YAxis); - graphicsRotation->setOrigin(QVector3D(size().width() / 2, size().height() / 2, 0)); - QList r({graphicsRotation}); - setTransformations(r); - - //We setup the state machine of the submarine - QStateMachine *machine = new QStateMachine(this); - - //This state is when the boat is moving/rotating - QState *moving = new QState(machine); - - //This state is when the boat is moving from left to right - MovementState *movement = new MovementState(this, moving); - - //This state is when the boat is moving from left to right - ReturnState *rotation = new ReturnState(this, moving); - - //This is the initial state of the moving root state - moving->setInitialState(movement); - - movement->addTransition(this, &SubMarine::subMarineStateChanged, moving); - - //This is the initial state of the machine - machine->setInitialState(moving); - - //End - QFinalState *finalState = new QFinalState(machine); - - //If the moving animation is finished we move to the return state - movement->addTransition(movement, &QAnimationState::animationFinished, rotation); - - //If the return animation is finished we move to the moving state - rotation->addTransition(rotation, &QAnimationState::animationFinished, movement); - - //This state play the destroyed animation - QAnimationState *destroyedState = new QAnimationState(machine); - destroyedState->setAnimation(setupDestroyAnimation(this)); - - //Play a nice animation when the submarine is destroyed - moving->addTransition(this, &SubMarine::subMarineDestroyed, destroyedState); - - //Transition to final state when the destroyed animation is finished - destroyedState->addTransition(destroyedState, &QAnimationState::animationFinished, finalState); - - //The machine has finished to be executed, then the submarine is dead - connect(machine,&QState::finished,this, &SubMarine::subMarineExecutionFinished); - - machine->start(); -} - -int SubMarine::points() const -{ - return subPoints; -} - -void SubMarine::setCurrentDirection(SubMarine::Movement direction) -{ - if (this->direction == direction) - return; - if (direction == SubMarine::Right && this->direction == SubMarine::None) - graphicsRotation->setAngle(180); - this->direction = direction; -} - -enum SubMarine::Movement SubMarine::currentDirection() const -{ - return direction; -} - -void SubMarine::setCurrentSpeed(int speed) -{ - if (speed < 0 || speed > 3) - qWarning("SubMarine::setCurrentSpeed : The speed is invalid"); - this->speed = speed; - emit subMarineStateChanged(); -} - -int SubMarine::currentSpeed() const -{ - return speed; -} - -void SubMarine::launchTorpedo(int speed) -{ - Torpedo *torp = new Torpedo; - GraphicsScene *scene = static_cast(this->scene()); - scene->addItem(torp); - torp->setPos(pos()); - torp->setCurrentSpeed(speed); - torp->launch(); -} - -void SubMarine::destroy() -{ - emit subMarineDestroyed(); -} - -int SubMarine::type() const -{ - return Type; -} diff --git a/examples/widgets/animation/sub-attaq/submarine.h b/examples/widgets/animation/sub-attaq/submarine.h deleted file mode 100644 index 256683ec70..0000000000 --- a/examples/widgets/animation/sub-attaq/submarine.h +++ /dev/null @@ -1,99 +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 SUBMARINE_H -#define SUBMARINE_H - -#include "pixmapitem.h" - -#include - -class SubMarine : public PixmapItem -{ -Q_OBJECT -public: - enum Movement { - None = 0, - Left, - Right - }; - enum { Type = UserType + 1 }; - SubMarine(int type, const QString &name, int points); - - int points() const; - - void setCurrentDirection(Movement direction); - enum Movement currentDirection() const; - - void setCurrentSpeed(int speed); - int currentSpeed() const; - - void launchTorpedo(int speed); - void destroy(); - - int type() const override; - - QGraphicsRotation *rotation() const { return graphicsRotation; } - -signals: - void subMarineDestroyed(); - void subMarineExecutionFinished(); - void subMarineStateChanged(); - -private: - int subType; - QString subName; - int subPoints; - int speed; - Movement direction; - QGraphicsRotation *graphicsRotation; -}; - -#endif // SUBMARINE_H diff --git a/examples/widgets/animation/sub-attaq/submarine_p.h b/examples/widgets/animation/sub-attaq/submarine_p.h deleted file mode 100644 index 36807dade3..0000000000 --- a/examples/widgets/animation/sub-attaq/submarine_p.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SUBMARINE_P_H -#define SUBMARINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -//Own -#include "animationmanager.h" -#include "submarine.h" -#include "qanimationstate.h" - -//Qt -#include -#include - -//This state is describing when the boat is moving right -class MovementState : public QAnimationState -{ -Q_OBJECT -public: - explicit MovementState(SubMarine *submarine, QState *parent = nullptr) : QAnimationState(parent) - { - movementAnimation = new QPropertyAnimation(submarine, "pos"); - connect(movementAnimation, &QPropertyAnimation::valueChanged, - this, &MovementState::onAnimationMovementValueChanged); - setAnimation(movementAnimation); - AnimationManager::self()->registerAnimation(movementAnimation); - this->submarine = submarine; - } - -protected slots: - void onAnimationMovementValueChanged(const QVariant &) - { - if (QRandomGenerator::global()->bounded(200) + 1 == 3) - submarine->launchTorpedo(QRandomGenerator::global()->bounded(3) + 1); - } - -protected: - void onEntry(QEvent *e) override - { - if (submarine->currentDirection() == SubMarine::Left) { - movementAnimation->setEndValue(QPointF(0,submarine->y())); - movementAnimation->setDuration(submarine->x()/submarine->currentSpeed()*12); - } - else /*if (submarine->currentDirection() == SubMarine::Right)*/ { - movementAnimation->setEndValue(QPointF(submarine->scene()->width()-submarine->size().width(),submarine->y())); - movementAnimation->setDuration((submarine->scene()->width()-submarine->size().width()-submarine->x())/submarine->currentSpeed()*12); - } - QAnimationState::onEntry(e); - } - -private: - SubMarine *submarine; - QPropertyAnimation *movementAnimation; -}; - -//This state is describing when the boat is moving right -class ReturnState : public QAnimationState -{ -public: - explicit ReturnState(SubMarine *submarine, QState *parent = nullptr) : QAnimationState(parent) - { - returnAnimation = new QPropertyAnimation(submarine->rotation(), "angle"); - returnAnimation->setDuration(500); - AnimationManager::self()->registerAnimation(returnAnimation); - setAnimation(returnAnimation); - this->submarine = submarine; - } - -protected: - void onEntry(QEvent *e) override - { - returnAnimation->stop(); - returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.); - QAnimationState::onEntry(e); - } - - void onExit(QEvent *e) override - { - submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right); - QAnimationState::onExit(e); - } - -private: - SubMarine *submarine; - QPropertyAnimation *returnAnimation; -}; - -#endif // SUBMARINE_P_H diff --git a/examples/widgets/animation/sub-attaq/textinformationitem.cpp b/examples/widgets/animation/sub-attaq/textinformationitem.cpp deleted file mode 100644 index 4d4934f63d..0000000000 --- a/examples/widgets/animation/sub-attaq/textinformationitem.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 "textinformationitem.h" -#include "pixmapitem.h" - -TextInformationItem::TextInformationItem (QGraphicsItem *parent) - : QGraphicsTextItem(parent) -{ - setFont(QFont("Comic Sans MS", 15)); -} - -void TextInformationItem::setMessage(const QString &text) -{ - setHtml(text); - setPos(parentItem()->boundingRect().center().x() - boundingRect().size().width() / 2, - parentItem()->boundingRect().center().y()); -} diff --git a/examples/widgets/animation/sub-attaq/textinformationitem.h b/examples/widgets/animation/sub-attaq/textinformationitem.h deleted file mode 100644 index 0a0b618460..0000000000 --- a/examples/widgets/animation/sub-attaq/textinformationitem.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 TEXTINFORMATIONITEM_H -#define TEXTINFORMATIONITEM_H - -//Qt -#include - -class TextInformationItem : public QGraphicsTextItem -{ -public: - TextInformationItem(QGraphicsItem *parent = nullptr); - void setMessage(const QString &text); -}; - -#endif // TEXTINFORMATIONITEM_H diff --git a/examples/widgets/animation/sub-attaq/torpedo.cpp b/examples/widgets/animation/sub-attaq/torpedo.cpp deleted file mode 100644 index 7395aa39ac..0000000000 --- a/examples/widgets/animation/sub-attaq/torpedo.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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$ -** -****************************************************************************/ - -//Own -#include "torpedo.h" -#include "boat.h" -#include "graphicsscene.h" -#include "animationmanager.h" -#include "qanimationstate.h" - -#include -#include -#include - -Torpedo::Torpedo() : PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big), - currentSpeed(0) -{ - setZValue(2); -} - -void Torpedo::launch() -{ - QPropertyAnimation *launchAnimation = new QPropertyAnimation(this, "pos"); - AnimationManager::self()->registerAnimation(launchAnimation); - launchAnimation->setEndValue(QPointF(x(), qobject_cast(scene())->sealLevel() - 15)); - launchAnimation->setEasingCurve(QEasingCurve::InQuad); - launchAnimation->setDuration(y() / currentSpeed * 10); - connect(launchAnimation, &QVariantAnimation::valueChanged, this, &Torpedo::onAnimationLaunchValueChanged); - connect(this, &Torpedo::torpedoExploded, launchAnimation, &QAbstractAnimation::stop); - - //We setup the state machine of the torpedo - QStateMachine *machine = new QStateMachine(this); - - //This state is when the launch animation is playing - QAnimationState *launched = new QAnimationState(machine); - launched->setAnimation(launchAnimation); - - //End - QFinalState *finalState = new QFinalState(machine); - - machine->setInitialState(launched); - - //### Add a nice animation when the torpedo is destroyed - launched->addTransition(this, &Torpedo::torpedoExploded, finalState); - - //If the animation is finished, then we move to the final state - launched->addTransition(launched, &QAnimationState::animationFinished, finalState); - - //The machine has finished to be executed, then the boat is dead - connect(machine, &QState::finished, this, &Torpedo::torpedoExecutionFinished); - - machine->start(); -} - -void Torpedo::setCurrentSpeed(int speed) -{ - if (speed < 0) { - qWarning("Torpedo::setCurrentSpeed : The speed is invalid"); - return; - } - currentSpeed = speed; -} - -void Torpedo::onAnimationLaunchValueChanged(const QVariant &) -{ - const QList colItems = - collidingItems(Qt::IntersectsItemBoundingRect); - for (QGraphicsItem *item : colItems) { - if (Boat *b = qgraphicsitem_cast(item)) - b->destroy(); - } -} - -void Torpedo::destroy() -{ - emit torpedoExploded(); -} diff --git a/examples/widgets/animation/sub-attaq/torpedo.h b/examples/widgets/animation/sub-attaq/torpedo.h deleted file mode 100644 index 7ac853d4e9..0000000000 --- a/examples/widgets/animation/sub-attaq/torpedo.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 TORPEDO_H -#define TORPEDO_H - -#include "pixmapitem.h" - -class Torpedo : public PixmapItem -{ -Q_OBJECT -public: - Torpedo(); - void launch(); - void setCurrentSpeed(int speed); - void destroy(); - -signals: - void torpedoExploded(); - void torpedoExecutionFinished(); - -private slots: - void onAnimationLaunchValueChanged(const QVariant &); - -private: - int currentSpeed; -}; - -#endif // TORPEDO_H diff --git a/examples/widgets/doc/images/factorial-example.png b/examples/widgets/doc/images/factorial-example.png deleted file mode 100644 index 8fb1cc6925..0000000000 Binary files a/examples/widgets/doc/images/factorial-example.png and /dev/null differ diff --git a/examples/widgets/doc/images/pingpong-example.png b/examples/widgets/doc/images/pingpong-example.png deleted file mode 100644 index af707e4633..0000000000 Binary files a/examples/widgets/doc/images/pingpong-example.png and /dev/null differ diff --git a/examples/widgets/doc/images/trafficlight-example1.png b/examples/widgets/doc/images/trafficlight-example1.png deleted file mode 100644 index ec8c7ffedc..0000000000 Binary files a/examples/widgets/doc/images/trafficlight-example1.png and /dev/null differ diff --git a/examples/widgets/doc/images/trafficlight-example2.png b/examples/widgets/doc/images/trafficlight-example2.png deleted file mode 100644 index a12e4db03e..0000000000 Binary files a/examples/widgets/doc/images/trafficlight-example2.png and /dev/null differ diff --git a/examples/widgets/doc/src/animatedtiles.qdoc b/examples/widgets/doc/src/animatedtiles.qdoc deleted file mode 100644 index 9f1d912b0d..0000000000 --- a/examples/widgets/doc/src/animatedtiles.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example animation/animatedtiles - \title Animated Tiles Example - - \brief The Animated Tiles example animates items in a graphics scene. - - \image animatedtiles-example.png -*/ - diff --git a/examples/widgets/doc/src/eventtransitions.qdoc b/examples/widgets/doc/src/eventtransitions.qdoc deleted file mode 100644 index e74831b14b..0000000000 --- a/examples/widgets/doc/src/eventtransitions.qdoc +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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$ -** -****************************************************************************/ - -/*! - \example statemachine/eventtransitions - \title Event Transitions Example - - \brief The Event Transitions example shows how to use event transitions, - a feature of \l{The State Machine Framework}. - - The Event Transitions Example illustrates how states change when a - user enters or leaves the area of a button. The states are handled by - a QStateMachine object. The screen consists of a QVBoxLayout with a - central button. - - When the mouse is outside the button, the text in the button displays - "Outside". When the mouse enters the button, it displays "Inside". - - \borderedimage transitions.png - - \snippet statemachine/eventtransitions/main.cpp 0 - - The \c Window class's constructors begins by creating a button. - This button is added to \c layout, which is a QVBoxLayout object. - Then two states are created: \c s1 is the state - "Outside", and \c s2 is the state "Inside". - - \snippet statemachine/eventtransitions/main.cpp 1 - - State \c s1 is the state "Outside" and state \c s2 is state "Inside". - - \snippet statemachine/eventtransitions/main.cpp 2 - - When the button receives an event of type QEvent::Enter and the state - machine is in state \c s1, the machine will transition to state \c s2. - - \snippet statemachine/eventtransitions/main.cpp 3 - - When the button receives an event of type QEvent::Leave and the state - machine is in state \c s2, the machine will transition back to state \c - s1. - - \snippet statemachine/eventtransitions/main.cpp 4 - - Next, state \c s3 is created. \c s3 will be entered when the button - receives an event of type QEvent::MouseButtonPress and the state machine - is in state \c s2. When the button receives an event of type - QEvent::MouseButtonRelease and the state machine is in state \c s3, the - machine will revert to state \c s2. - - \snippet statemachine/eventtransitions/main.cpp 5 - - Finally, the states are added to the machine as top-level states, the - initial state is set to be \c s1 ("Outside"), and the machine is started. - - \snippet statemachine/eventtransitions/main.cpp 6 - - The main() function constructs a Window object that displays the QVBoxLayout - object \c layout with its \c button. - -*/ diff --git a/examples/widgets/doc/src/factorial.qdoc b/examples/widgets/doc/src/factorial.qdoc deleted file mode 100644 index a0ace96cd3..0000000000 --- a/examples/widgets/doc/src/factorial.qdoc +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example statemachine/factorial - \title Factorial States Example - - \brief The Factorial States example shows how to use \l{The State Machine - Framework} to calculate the factorial of an integer. - - The statechart for calculating the factorial looks as follows: - - \image factorial-example.png - \omit - \caption This is a caption - \endomit - - In other words, the state machine calculates the factorial of 6 and prints - the result. - - \snippet statemachine/factorial/main.cpp 0 - - The Factorial class is used to hold the data of the computation, \c x and - \c fac. It also provides a signal that's emitted whenever the value of \c - x changes. - - \snippet statemachine/factorial/main.cpp 1 - - The FactorialLoopTransition class implements the guard (\c x > 1) and - calculations (\c fac = \c x * \c fac; \c x = \c x - 1) of the factorial - loop. - - \snippet statemachine/factorial/main.cpp 2 - - The FactorialDoneTransition class implements the guard (\c x <= 1) that - terminates the factorial computation. It also prints the final result to - standard output. - - \snippet statemachine/factorial/main.cpp 3 - - The application's main() function first creates the application object, a - Factorial object and a state machine. - - \snippet statemachine/factorial/main.cpp 4 - - The \c compute state is created, and the initial values of \c x and \c fac - are defined. A FactorialLoopTransition object is created and added to the - state. - - \snippet statemachine/factorial/main.cpp 5 - - A final state, \c done, is created, and a FactorialDoneTransition object - is created with \c done as its target state. The transition is then added - to the \c compute state. - - \snippet statemachine/factorial/main.cpp 6 - - The machine's initial state is set to be the \c compute state. We connect - the QStateMachine::finished() signal to the QCoreApplication::quit() slot, - so the application will quit when the state machine's work is - done. Finally, the state machine is started, and the application's event - loop is entered. - - */ diff --git a/examples/widgets/doc/src/moveblocks.qdoc b/examples/widgets/doc/src/moveblocks.qdoc deleted file mode 100644 index 64045f1c4f..0000000000 --- a/examples/widgets/doc/src/moveblocks.qdoc +++ /dev/null @@ -1,214 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example animation/moveblocks - \title Move Blocks Example - - \brief The Move Blocks example shows how to animate items in a - QGraphicsScene using a QStateMachine with a custom transition. - - \image moveblocks-example.png - - The example animates the blue blocks that you can see in the image - above. The animation moves the blocks between four preset positions. - - The example consists of the following classes: - - \list - \li \c StateSwitcher inherits QState and can add - \c {StateSwitchTransition}s to other states. - When entered, it will randomly transition to one of these - states. - \li \c StateSwitchTransition is a custom transition that - triggers on \c{StateSwitchEvent}s. - \li \c StateSwitchEvent is a QEvent that triggers \c{StateSwitchTransition}s. - \li \c QGraphicsRectWidget is a QGraphicsWidget that simply - paints its background in a solid \l{Qt::}{blue} color. - \endlist - - The blocks are instances of \c QGraphicsRectWidget and are - animated in a QGraphicsScene. We do this by building a state - graph, which we insert animations into. The graph is then executed - in a QStateMachine. All this is done in \c main(). - Let's look at the \c main() function first. - - \section1 The \c main() Function - - After QApplication has been initialized, we set up the - QGraphicsScene with its \c{QGraphicsRectWidget}s. - - \snippet animation/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 - trying to build. - - \image move-blocks-chart.png - - Note that the \c group has seven sub states, but we have only - included three of them in the diagram. The code that builds this - 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 - - 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 - see later, \c group has a transition back to the \c StateSwitcher - when the timer times out. \c group is the initial state in the - machine, so an animation will be scheduled when the example is - started. - - \snippet animation/moveblocks/main.cpp 3 - \dots - \snippet animation/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 - parent of this state. - - A QPropertyAnimation inserted into a transition will use the - values assigned to a QState (with QState::assignProperty()), i.e., - the animation will interpolate between the current values of the - properties and the values in the target state. We add animated - transitions to the state graph later. - - \snippet animation/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 - - The sequential animation group, \c subGroup, helps us insert a - delay between the animation of each item. - - \snippet animation/moveblocks/main.cpp 7 - \dots - \snippet animation/moveblocks/main.cpp 8 - - A StateSwitchTransition is added to the state switcher - in \c StateSwitcher::addState(). We also add the animation in this - function. Since QPropertyAnimation uses the values from the - states, we can insert the same QPropertyAnimation instance in all - \c {StateSwitchTransition}s. - - As mentioned previously, we add a transition to the state switcher - that triggers when the timer times out. - - \snippet animation/moveblocks/main.cpp 9 - - Finally, we can create the state machine, add our initial state, - and start execution of the state graph. - - \section2 The \c createGeometryState() Function - - In \c createGeometryState(), we set up the geometry for each - graphics item. - - \snippet animation/moveblocks/main.cpp 13 - - As mentioned before, QAbstractTransition will set up an animation - added with \l{QAbstractTransition::}{addAnimation()} using - property values set with \l{QState::}{assignProperty()}. - - \section1 The StateSwitcher Class - - \c StateSwitcher has state switch transitions to each \l{QState}s - we created with \c createGeometryState(). Its job is to transition - to one of these states at random when it is entered. - - All functions in \c StateSwitcher are inlined. We'll step through - its definition. - - \snippet animation/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 - - 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 - - This is where the magic happens. We assign a number to each state - added. This number is given to both a StateSwitchTransition and to - StateSwitchEvents. As we have seen, state switch events will - trigger a transition with the same number. - - \section1 The StateSwitchTransition Class - - \c StateSwitchTransition inherits QAbstractTransition and triggers - on \c{StateSwitchEvent}s. It contains only inline functions, so - let's take a look at its \l{QAbstractTransition::}{eventTest()} - function, which is the only function that we define.. - - \snippet animation/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 - it will. We simply check if our assigned number is equal to the - event's number (in which case we fire away). - - \section1 The StateSwitchEvent Class - - \c StateSwitchEvent inherits QEvent, and holds a number that has - been assigned to a state and state switch transition by - \c StateSwitcher. We have already seen how it is used to trigger - \c{StateSwitchTransition}s in \c StateSwitcher. - - \snippet animation/moveblocks/main.cpp 15 - - We only have inlined functions in this class, so a look at its - definition will do. - - \section1 The QGraphicsRectWidget Class - - QGraphicsRectWidget inherits QGraphicsWidget and simply paints its - \l{QWidget::}{rect()} blue. We inline \l{QWidget::}{paintEvent()}, - which is the only function we define. Here is the - QGraphicsRectWidget class definition: - - \snippet animation/moveblocks/main.cpp 16 - - \section1 Moving On - - The technique shown in this example works equally well for all - \l{QPropertyAnimation}s. As long as the value to be animated is a - Qt property, you can insert an animation of it into a state graph. - - QState::addAnimation() takes a QAbstractAnimation, so any type - of animation can be inserted into the graph. -*/ - diff --git a/examples/widgets/doc/src/padnavigator.qdoc b/examples/widgets/doc/src/padnavigator.qdoc deleted file mode 100644 index 31440b650f..0000000000 --- a/examples/widgets/doc/src/padnavigator.qdoc +++ /dev/null @@ -1,586 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example graphicsview/padnavigator - \title Pad Navigator Example - \ingroup examples-graphicsview - \brief Demonstrates how to create animated user interface. - - The Pad Navigator Example shows how you can use Graphics View together with - embedded widgets and Qt's \l{The State Machine Framework}{state machine - framework} to create a simple but useful, dynamic, animated user interface. - - \image padnavigator-example.png - - The interface consists of a flippable, rotating pad with icons that can be - selected using the arrow keys on your keyboard or keypad. Pressing enter - will flip the pad around and reveal its back side, which has a form - embedded into a QGraphicsProxyWidget. You can interact with the form, and - press the enter key to flip back to the front side of the pad at any time. - - Graphics View provides the QGraphicsScene class for managing and - interacting with a large number of custom-made 2D graphical items derived - from the QGraphicsItem class, and a QGraphicsView widget for visualizing - the items, with support for zooming and rotation. - - This example consists of a \c RoundRectItem class, a \c FlippablePad class, - a \c PadNavigator class, a \c SplashItem class, and a \c main() function. - - \section1 RoundRectItem Class Definition - - The \c RoundRectItem class is used by itself to display the icons on the - pad, and as a base class for \c FlippablePad, the class for the pad itself. - The role of the class is to paint a round rectangle of a specified size and - gradient color, and optionally to paint a pixmap icon on top. To support \c - FlippablePad it also allows filling its contents with a plain window - background color. - - Let's start by reviewing the \c RoundRectItem class declaration. - - \snippet graphicsview/padnavigator/roundrectitem.h 0 - - \c RoundRectItem inherits QGraphicsObject, which makes it easy to control - its properties using QPropertyAnimation. Its constructor takes a rectangle - to determine its bounds, and a color. - - Besides implementing the mandatory \l{QGraphicsItem::paint()}{paint()} and - \l{QGraphicsItem::boundingRect()}{boundingRect()} pure virtual functions, - it also provides the \c pixmap and \c fill properties. - - The \c pixmap property sets an optional pixmap that is drawn on top of the - round rectangle. The \c fill property will, when true, fill the round - rectangle contents with a fixed QPalette::Window background color. - Otherwise the contents are filled using a gradient based on the color - passed to \c RoundRectItem's constructor. - - \snippet graphicsview/padnavigator/roundrectitem.h 1 - - The private data members are: - - \list - \li \c pix: The optional pixmap that is drawn on top of the rectangle. - \li \c fillRect: Corresponds to the \c fill property. - \li \c color: The configurable gradient color fill of the rectangle. - \li \c bounds: The bounds of the rectangle. - \li \c gradient: A precalculated gradient used to fill the rectangle. - \endlist - - We will now review the \c RoundRectItem implementation. Let's start by - looking at its constructor: - - \snippet graphicsview/padnavigator/roundrectitem.cpp 0 - - The constructor initializes its member variables and forwards the \c parent - argument to QGraphicsObject's constructor. It then constructs the linear - gradient that is used in \l{QGraphicsItem::paint()}{paint()} to draw the - round rectangle's gradient background. The linear gradient's starting point - is at the top-left corner of the bounds, and the end is at the bottom-left - corner. The start color is identical to the color passed as an argument, - and a slightly darker color is chosen for the final stop. - - We store this gradient as a member variable to avoid having to recreate the - gradient every time the item is repainted. - - Finally we set the cache mode - \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache}. This mode - causes the item's rendering to be cached into an off-screen pixmap that - remains persistent as we move and transform the item. This mode is ideal - for this example, and works particularly well with OpenGL and OpenGL ES. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 1 - - The \c pixmap property implementation simple returns the member pixmap, or - sets it and then calls \l{QGraphicsItem::update()}{update()}. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 2 - - As the \l{QGraphicsItem::paint()}{paint()} implementation below draws a - simple drop shadow down and to the right of the item, we return a slightly - adjusted rectangle from \l{QGraphicsItem::boundingRect()}{boundingRect()}. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 3 - - The \l{QGraphicsItem::paint()}{paint()} implementation starts by rendering - a semi transparent black round rectangle drop shadow, two units down and to - the right of the main item. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 4 - - We then draw the "foreground" round rectangle itself. The fill depends on - the \c fill property; if true, we will with a plain QPalette::Window color. - We get the current brush from QApplication::palette(). We assign a single - unit wide pen for the stroke, assign the brush, and then draw the - rectangle. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 5 - - If a pixmap has been assigned to the \e pixmap property, we draw this - pixmap in the center of the rectangle item. The pixmaps are scaled to match - the size of the icons; in arguably a better approach would have been to - store the icons with the right size in the first places. - - \snippet graphicsview/padnavigator/roundrectitem.cpp 6 - - Finally, for completeness we include the \c fill property implementation. - It returns the \c fill member variable's value, and when assigned to, it - calls \l{QGraphicsItem::update()}{update()}. - - As mentioned already, \c RoundRectItem is the base class for \c - FlippablePad, which is the class representing the tilting pad itself. We - will proceed to reviewing \c FlippablePad. - - \section1 FlippablePad Class Definition - - \c FlippablePad is, in addition to its inherited \c RoundRectItem - responsibilities, responsible for creating and managing a grid of icons. - - \snippet graphicsview/padnavigator/flippablepad.h 0 - - Its declaration is very simple: It inherits \c RoundRectItem and does not - need any special polymorphic behavior. It's suitable to declare its own - constructor, and a getter-function that allows \c PadNavigator to access - the icons in the grid by (row, column). - - The example has no "real" behavior or logic of any kind, and because of - that, the icons do not need to provide any \e behavior or special - interactions management. In a real application, however, it would be - natural for the \c FlippablePad and its icons to handle more of the - navigation logic. In this example, we have chosen to leave this to - the \c PadNavigator class, which we will get back to below. - - We will now review the \c FlippablePad implementation. This implementation - starts with two helper functions: \c boundsFromSize() and \c - posForLocation(): - - \snippet graphicsview/padnavigator/flippablepad.cpp 0 - - \c boundsForSize() takes a QSize argument, and returns the bounding - rectangle of the flippable pad item. The QSize determines how many rows and - columns the icon grid should have. Each icon is given 150x150 units of - space, and this determines the bounds. - - \snippet graphicsview/padnavigator/flippablepad.cpp 1 - - \c posForLocation() returns the position of an icon given its row and - column position. Like \c boundsForSize(), the function assumes each icon is - given 150x150 units of space, and that all icons are centered around the - flippable pad item's origin (0, 0). - - \snippet graphicsview/padnavigator/flippablepad.cpp 2 - - The \c FlippablePad constructor passes suitable bounds (using \c - boundsForSize()) and specific color to \c RoundRectItem's constructor. - - \snippet graphicsview/padnavigator/flippablepad.cpp 3 - - It then loads pixmaps from compiled-in resources to use for its icons. - QDirIterator is very useful in this context, as it allows us to fetch all - resource "*.png" files inside the \c :/images directory without explicitly - naming the files. - - We also make sure not to load more pixmaps than we need. - - \snippet graphicsview/padnavigator/flippablepad.cpp 4 - - Now that we have the pixmaps, we can create icons, position then and assign - pixmaps. We start by finding a suitable size and color for the icons, and - initializing a convenient grid structure for storing the icons. This \c - iconGrid is also used later to find the icon for a specific (column, row) - location. - - For each row and column in our grid, we proceed to constructing each icon - as an instance of \c RoundRectItem. The item is placed by using the \c - posForLocation() helper function. To make room for the slip-behind - selection item, we give each icon a \l{QGraphicsItem::zValue()}{Z-value} of - 1. The pixmaps are distributed to the icons in round-robin fasion. - - Again, this approach is only suitable for example purposes. In a real-life - application where each icon represents a specific action, it would be more - natural to assign the pixmaps directly, or that the icons themselves - provide suitable pixmaps. - - \snippet graphicsview/padnavigator/flippablepad.cpp 5 - - Finally, the \c iconAt() function returns a pointer to the icon at a - specific row and column. It makes a somewhat bold assumption that the input - is valid, which is fair because the \c PadNavigator class only calls this - function with correct input. - - We will now review the \c SplashItem class. - - \section1 SplashItem Class Definition - - The \c SplashItem class represents the "splash window", a semitransparent - white overlay with text that appears immediately after the application has - started, and disappears after pressing any key. The animation is controlled - by \c PadNavigator; this class is very simple by itself. - - \snippet graphicsview/padnavigator/splashitem.h 0 - - The class declaration shows that \c SplashItem inherits QGraphicsObject to - allow it to be controlled by QPropertyAnimation. It reimplements the - mandatory \l{QGraphicsItem::paint()}{paint()} and - \l{QGraphicsItem::boundingRect()}{boundingRect()} pure virtual functions, - and keeps a \c text member variable which will contain the information text - displayed on this splash item. - - Let's look at its implementation. - - \snippet graphicsview/padnavigator/splashitem.cpp 0 - - The constructor forwards to QGraphicsObject as expected, assigns a text - message to the \c text member variable, and enables - \l{QGraphicsItem::DeviceCoordinateCache}{DeviceCoordinateCache}. This cache - mode is suitable because the splash item only moves and is never - transformed, and because it contains text, it's important that it has a - pixel perfect visual appearance (in constrast to - \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache}, where the - visual appearance is not as good). - - We use caching to avoid having to relayout and rerender the text for each - frame. An alterative approach would be to use the new QStaticText class. - - \snippet graphicsview/padnavigator/splashitem.cpp 1 - - \c SplashItem's bounding rectangle is fixed at (400x175). - - \snippet graphicsview/padnavigator/splashitem.cpp 2 - - The \l{QGraphicsItem::paint()}{paint()} implementation draws a clipped - round rectangle with a thick 2-unit border and a semi-transparent white - background. It proceeds to finding a suitable text area by adjusting the - splash item's bounding rectangle with 10 units in each side. The text is - rendered inside this rectangle, with top-left alignment, and with word - wrapping enabled. - - The main class now remains. We will proceed to reviewing \c PadNavigator. - - \section1 PadNavigator Class Definition - - \c PadNavigator represents the main window of our Pad Navigator Example - application. It creates and controls a somewhat complex state machine, and - several animations. Its class declaration is very simple: - - \snippet graphicsview/padnavigator/padnavigator.h 0 - - It inherits QGraphicsView and reimplements only one function: - \l{QGraphicsView::resizeEvent()}{resizeEvent()}, to ensure the scene is - scaled to fit inside the view when resizing the main window. - - The \c PadNavigator constructor takes a QSize argument that determines the - number or rows and columns in the grid. - - It also keeps a private member instance, \c form, which is the generated - code for the pad's back side item's QGraphicsProxyWidget-embedded form. - - \snippet graphicsview/padnavigator/padnavigator.cpp 0 - - \c PadNavigator's constructor is a bit long. In short, its job is to create - all items, including the \c FlippablePad, the \c SplashItem and the - QGraphicsProxyWidget \c backItem, and then to set up all animations, states - and transitions that control the behavior of the application. - - It starts out simple, by forwarding to QGraphicsView's constructor. - - \snippet graphicsview/padnavigator/padnavigator.cpp 1 - - The first item to be created is \c SplashItem. This is going to be a top-level - item in the scene, next to \c FlippablePad, and stacked on top of it, so we - assign it a \l{QGraphicsItem::zValue()}{Z-value} of 1. - - \snippet graphicsview/padnavigator/padnavigator.cpp 2 - - Now we construct the \c FlippablePad item, passing its column-row count to - its constructor. - - The pad is controlled by three transformations, and we create one - QGraphicsRotation object for each of these. - - \list - \li \c flipRotation: Rotates the grid around its Qt::YAxis. This rotation is - animated from 0 to 180, and eventually back, when enter is pressed on the - keyboard, flipping the pad around. - \li \c xRotation: Rotates the grid around its Qt::XAxis. This is used to - tilt the pad vertically corresponding to which item is currently selected. - This way, the selected item is always kept in front. - \li \c yRotation: Rotates the grid around its Qt::YAxis. This is used to - tilt the pad horizontally corresponding to which item is selected. This - way, the selected item is always kept in front. - \endlist - - The combination of all three rotations is assigned via - QGraphicsItem::setTransformations(). - - \snippet graphicsview/padnavigator/padnavigator.cpp 3 - - Now we construct the QGraphicsProxyWidget-embedded \c backItem. The proxy - widget is created as a child of the pad. We create a new QWidget and - populate it with the \c form member. To ensure the \c hostName line edit is - the first to receive input focus when this item is shown, we call - \l{QWidget::setFocus()}{setFocus()} immediately. This will not give the - widget focus right away; it will only prepare the item to automatically - receive focus once it is shown. - - The QWidget based form is embedded into the proxy widget. The proxy is - hidden initially; we only want to show it when the pad is rotated at least - 90 degrees, and we also rotate the proxy itself by 180 degrees. This way we - give the impression that the proxy widget is "behind" the flipped pad, when - in fact, it's actually \e{on top of it}. - - We enable \l{QGraphicsItem::ItemCoordinateCache}{ItemCoordinateCache} to - ensure the flip animation can run smoothly. - - \snippet graphicsview/padnavigator/padnavigator.cpp 4 - - We now create the selection item. This is simply another instance of \c - RoundRectItem that is slightly larger than the icons on the pad. We create - it as an immediate child of the \c FlippablePad, so the selection item is a - sibling to all the icons. By giving it a - \l{QGraphicsItem::zValue()}{Z-value} of 0.5 we ensure it will slide between - the pad and its icons. - - What follows now is a series of animation initializations. - - \snippet graphicsview/padnavigator/padnavigator.cpp 5 - - We begin with the animations that apply to the splash item. The first - animation, \c smoothSplashMove, ensures that the "y" property of \c splash - will be animated with a 250-millisecond duration - \l{QEasingCurve::InQuad}{InQuad} easing function. \c smoothSplashOpacity - ensures the opacity of \c splash eases in and out in 250 milliseconds. - - The values are assigned by \c PadNavigator's state machine, which is - created later. - - \snippet graphicsview/padnavigator/padnavigator.cpp 6 - - These are the animations that control the selection item's movement and the - \c xRotation and \c yRotation QGraphicsRotation objects that tilt the pad. - All animations have a duration of 125 milliseconds, and they all use the - \l{QEasingCurve::InOutQuad}{InOutQuad} easing function. - - \snippet graphicsview/padnavigator/padnavigator.cpp 7 - - We now create the animations that control the flip-effect when you press - the enter key. The main goal is to rotate the pad by 180 degrees or back. - - \list - \li \c smoothFlipRotation: Animates the main 180 degree rotation of the pad. - \li \c smoothFlipScale: Scales the pad out and then in again while the pad is rotating. - \li \c flipAnimation: A parallel animation group that ensures the above animations are run in parallel. - \endlist - - All animations are given a 500 millisecond duration and an - \l{QEasingCurve::InOutQuad}{InOutQuad} easing function. - - It's worth taking a close look at \c smoothFlipScale. This animation's - start and end values are both 1.0, but at animation step 0.5 the - animation's value is 0.7. This means that after 50% of the animation's - duration, or 250 milliseconds, the pad will be scaled down to 0.7x of its - original size, which gives a great visual effect while flipping. - - \snippet graphicsview/padnavigator/padnavigator.cpp 8 - - This section uses a trick to ensure that certain properties are assigned - precisely when the flip animation passes 50%, or 90 degrees, rotation. In - short, the pad's icons and selection item are all hidden, the pad's \c fill - property is enabled, and \c backItem is shown when flipping over. When - flipping back, the reverse properties are applied. - - The way this is achieved is by running a sequential animation in parallel - to the other animations. This sequence, dubbed \c setVariablesSequence, - starts with a 250 millisecond pause, and then executes several animations - with a duration of 0. Each animation will ensure that properties are set - immediate at this point. - - This approach can also be used to call functions or set any other - properties at a specific time while an animation is running. - - \snippet graphicsview/padnavigator/padnavigator.cpp 9 - - We will now create the state machine. The whole \c PadNavigator state - machinery is controlled by one single state machine that has a - straight-forward state structure. The state engine itself is created - as a child of the \c PadNavigator itself. We then create three top level - states: - - \list - \li \c splashState: The initial state where the splash item is visible. - \li \c frontState: The base state where the splash is gone and we can see - the front side of the pad, and navigate the selection item. - \li \c backState: The flipped state where the \c backItem is visible, and we - can interact with the QGraphicsProxyWidget-embedded form. - \endlist - - \snippet graphicsview/padnavigator/padnavigator.cpp 10 - - Each state assigns specific properties to objects on entry. Most - interesting perhaps is the assignment of the value 0.0 to the pad's \c - flipRotation angle property when in \c frontState, and 180.0 when in \c - backState. - - At the end of this section we register default animations with the state - engine; these animations will apply to their respective objects and - properties for any state transition. Otherwise it's common to assign - animations to specific transitions. - - Specifically, we use default animations to control the selection item's - movement and tilt rotations. The tilt rotations are set to 0 when the pad - is flipped, and restored back to their original values when flipped back. - - The \c splashState state is set as the initial state. This is required - before we start the state engine. We proceed with creating some - transitions. - - \snippet graphicsview/padnavigator/padnavigator.cpp 11 - - QEventTransition defines a very flexible transition type. You can use this - class to trigger a transition based on an object receiving an event of a - specific type. In this case, we would like to transition from \c - splashState into \c frontState if \c PadNavigator receives any key press - event (QEvent::KeyPress). - - We register the \c splashItem's animations to this transition to ensure they - are used to animate the item's movement and opacity. - - \snippet graphicsview/padnavigator/padnavigator.cpp 12 - - We use QKeyEventTransition to capture specific key events. In this case, we - detect that the user presses Qt::Key_Return or Qt::Key_Enter, and use this - to trigger transitions between \c frontState and backState. We register \c - flipAnimation, our complex parallel animation group, with these - transitions. - - We continue by defining the states for each of the icons in the grid. - - \snippet graphicsview/padnavigator/padnavigator.cpp 13 - - We will use state groups to control transitions between icons. Each icon - represents a \e substate of \c frontState. We will then define transitions - between the states by detecting key presses, using QKeyEventTransition. - - We start by creating all the substates, and at the same time we create a - temporary grid structure for the states to make it easier to find which - states represents icons that are up, down, left and to the right each - other. - - Once the first substate is known, we set this up as the initial substate of - \c frontState. We will use the (0, 0), or top-left, icon for the initial - substate. We initialze the selection item's position to be exactly where - the top-left icon is. - - \snippet graphicsview/padnavigator/padnavigator.cpp 14 - - We can now create four transitions for each icon. Each transition ensures - that we move to the state corresponding to which arrow key has been - pressed. It's clear from this techinique that we could design any other - specific transitions to and from each of the sub states depending on these - and other keys. - - \snippet graphicsview/padnavigator/padnavigator.cpp 15 - - Also, for each of the icons, we assign suitable values to the \c xRotation - and \c yRotation objects' "angle"-properties. If you recall, these - properties "tilt" the pad corresponding to which item is currently - selected. We ensure each icon is invisible when the pad is flipped, and - visible when the pad is not flipped. To ensure the visible property is - assigned at the right time, we add property-controlling animations to the - \c setVariableSequence animation defined earlier. - - \snippet graphicsview/padnavigator/padnavigator.cpp 16 - - We are now finished with all states, transitions, and animations. We now - create the scene that will contain all our items. The scene gets a defined - background pixmap, and we disable item indexing (as most items in this - scene are animated). We add our \c pad item to the scene, and use its - bounding rectangle to fixate the scene rectangle. This rectangle is used by - the view to find a suitable size for the application window. - - Then the scene is assigned to the view, or in our case, \c PadNavigator - itself. - - \snippet graphicsview/padnavigator/padnavigator.cpp 17 - - Now that the scene has received its final size, we can position the splash - item at the very top, find its fade-out position, and add it to the scene. - - \snippet graphicsview/padnavigator/padnavigator.cpp 18 - - The view toggles a few necessary properties: - - \list - \li It disables its scroll bars - this application has no use for scroll bars. - \li It assigns a minimum size. This is necessary to avoid numerical errors - in our fit-in-view \c resizeEvent() implementation. - \li It sets \l{QGraphicsView::FullViewportUpdate}{FullViewportUpdate}, to - ensure QGraphicsView doesn't spend time figuring out precisely what needs - to be redrawn. This application is very simple - if anything changes, - everything is updated. - \li It enables background caching - this makes no performance difference - with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the - background pixmap. - \li It sets render hints that increase rendering quality. - \li If OpenGL is supported, a QOpenGLWidget viewport is assigned to the view. - \endlist - - Finally, we start the state engine. - - \snippet graphicsview/padnavigator/padnavigator.cpp 19 - - The \l{QGraphicsView::resizeEvent()}{resizeEvent()} implementation calls - the base implementation, and then calls QGraphicsView::fitInView() to scale - the scene so that it fits perfectly inside the view. - - By resizing the main application window, you can see this effect yourself. - The scene contents grow when you make the window larger, and shrink when - you make it smaller, while keeping the aspect ratio intact. - - \section1 The main() Function - - \snippet graphicsview/padnavigator/main.cpp 0 - - The \c main function creates the QApplication instance, uses - Q_INIT_RESOURCE to ensure our compiled-in resources aren't removed by the - linker, and then creates a 3x3 \c PadNavigator instance and shows it. - - Our flippable pad shows up with a suitable splash item once control returns - to the event loop. - - \section1 Performance Notes - - The example uses OpenGL if this is available, to achieve optimal - performance; otherwise perspective tranformations can be quite costly. - - Although this example does use QGraphicsProxyWidget to demonstrate - integration of Qt widget components integrated into Graphics View, using - QGraphicsProxyWidget comes with a performance penalty, and is therefore not - recommended for embedded development. - - This example uses extensive item caching to avoid rerendering of static - elements, at the expense of graphics memory. -*/ diff --git a/examples/widgets/doc/src/pingpong.qdoc b/examples/widgets/doc/src/pingpong.qdoc deleted file mode 100644 index 9545058500..0000000000 --- a/examples/widgets/doc/src/pingpong.qdoc +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example statemachine/pingpong - \title Ping Pong States Example - - \brief The Ping Pong States example shows how to use parallel states together - with custom events and transitions in \l{The State Machine Framework}. - - This example implements a statechart where two states communicate by - posting events to the state machine. The state chart looks as follows: - - \image pingpong-example.png - \omit - \caption This is a caption - \endomit - - The \c pinger and \c ponger states are parallel states, i.e. they are - entered simultaneously and will take transitions independently of - eachother. - - The \c pinger state will post the first \c ping event upon entry; the \c - 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 - - Two custom events are defined, \c PingEvent and \c PongEvent. - - \snippet statemachine/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 - - 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 - - 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 - - The main() function begins by creating a state machine and a parallel - state group. - - \snippet statemachine/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 - targetless. When such a transition is triggered, the source state won't be - exited and re-entered; only the transition's onTransition() function will - 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 - - Finally, the group is added to the state machine, the machine is started, - and the application event loop is entered. - - */ diff --git a/examples/widgets/doc/src/rogue.qdoc b/examples/widgets/doc/src/rogue.qdoc deleted file mode 100644 index b8b7cb15d6..0000000000 --- a/examples/widgets/doc/src/rogue.qdoc +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example statemachine/rogue - \title Rogue Example - - \brief The Rogue example shows how to use the Qt state machine for event - handling. - - \image rogue-example.png - - This example implements a simple text based game. Do you see the - \c{@} in the screenshot? That's you, the rogue. The \c{#} - characters are walls, and the dots represent floor. In a real - game, other ASCII characters would represent all kinds of objects - and creatures, for instance, ancient dragons (\c{D}s) or food - rations (\c{%}s). But let's not get carried away. In this game, - the rogue is simply running around in an empty room. - - The rogue is moved with the keypad (2, 4, 8, 6). That aside, we - have implemented a \c quit command that triggers if the player - types \c {q}. The player is then asked if he/she really wants to - quit. - - Most games have commands that need more than one key press (we - think of consecutive presses, i.e., not of several keys being - pressed at the same time). In this game, only the \c quit command - falls under this category, but for the sake of argument, let's - imagine a fully-fledged game with a rich set of commands. If we - were to implement these by catching key events in - \l{QWidget::}{keyPressEvent()}, we would have to keep a lot of - class member variables to track the sequence of keys already typed - (or find some other way of deducing the current state of a - command). This can easily lead to spaghetti, which is--as we all - well know, I'm sure--unpleasant. With a state machine, on the - other hand, separate states can wait for a single key press, and - that makes our lives a lot simpler. - - The example consists of two classes: - - \list - \li \c Window draws the text display of the game and sets - up the state machine. The window also has a status bar - above the area in which the rouge moves. - \li \c MovementTransition is a transition that carries out - a single move of the rogue. - \endlist - - Before we embark on a code walkthrough, it is necessary to take a - closer look at the design of the machine. Here is a state chart - that shows what we want to achieve: - - \image rogue-statechart.png - - The input state waits for a key press to start a new command. - When receiving a key it recognizes, it transitions to one of the - two commands of the game; though, as we will see, movement is - handled by the transition itself. The quit state waits for the - player to answer yes or no (by typing \c y or \c n) when asked - whether he/she really wants to quit the game. - - The chart demonstrates how we use one state to wait for a single - key press. The press received may trigger one of the transitions - connected to the state. - - \section1 Window Class Definition - - The \c Window class is a widget that draws the text display of the - game. It also sets up the state machine, i.e., creates and - 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 - - \c Direction specifies the direction in which the rogue is to - move. We use this in \c movePlayer(), which moves the rogue and - repaints the window. The game has a status line above the area in - which the rogue moves. The \c status property contains the text of - this line. We use a property because the QState class allows - setting any Qt \l{Qt's Property System}{property} when entered. - More on this later. - - \snippet statemachine/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 - when the rogue is moved. \c pX and \c pY is the current position - of the rogue. \c WIDTH and \c HEIGHT are macros specifying the - dimensions of the map. - - The \c paintEvent() function is left out of this walkthrough. We - also do not discuss other code that does not concern the state - machine (the \c setupMap(), \c status(), \c setStatus(), \c - movePlayer(), and \c sizeHint() functions). If you wish to take a - look at the code, click on the link for the \c window.cpp file at - the top of this page. - - \section1 Window Class Implementation - - Here is the constructor of \c Window: - - \snippet statemachine/rogue/window.cpp 0 - \dots - \snippet statemachine/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 - - 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 - status to a helpful reminder of how to play the game. - - First, the \c Movement transition is added to the input state. - This will enable the rogue to be moved with the keypad. Notice - that we don't set a target state for the movement transition. This - will cause the transition to be triggered (and the - \l{QAbstractTransition::}{onTransition()} function to be invoked), - but the machine will not leave the \c inputState. If we had set \c - inputState as the target state, we would first have left and then - entered the \c inputState again. - - \snippet statemachine/rogue/window.cpp 3 - - When we enter \c quitState, we update the status bar of the - window. - - \c QKeyEventTransition is a utility class that removes the hassle - of implementing transitions for \l{QKeyEvent}s. We simply need to - specify the key on which the transition should trigger and the - target state of the transition. - - \snippet statemachine/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 - - The machine is set up, so it's time to start it. - - \section1 The MovementTransition Class - - \c MovementTransition is triggered when the player request the - 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 - - In the constructor, we tell QEventTransition to only send - \l{QEvent::}{KeyPress} events to the - \l{QAbstractTransition::}{eventTest()} function: - - \snippet statemachine/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 - events internally. After that, it is simply a matter of checking - which key has been pressed. - - Let's move on to the \c onTransition() function: - - \snippet statemachine/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 - Window to move the player. - - \section1 The Roguelike Tradition - - You might have been wondering why the game features a rogue. Well, - these kinds of text based dungeon exploration games date back to a - game called, yes, "Rogue". Although outflanked by the technology - of modern 3D computer games, roguelikes have a solid community of - hard-core, devoted followers. - - Playing these games can be surprisingly addictive (despite the - lack of graphics). Angband, the perhaps most well-known rougelike, - is found here: \l{http://rephial.org/}. -*/ - diff --git a/examples/widgets/doc/src/states.qdoc b/examples/widgets/doc/src/states.qdoc deleted file mode 100644 index 1ae379f918..0000000000 --- a/examples/widgets/doc/src/states.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example animation/states - \title States Example - - \brief The States example shows how to use the Qt state machine to play - animations. - - \image states-example.png -*/ diff --git a/examples/widgets/doc/src/stickman.qdoc b/examples/widgets/doc/src/stickman.qdoc deleted file mode 100644 index ffc736674b..0000000000 --- a/examples/widgets/doc/src/stickman.qdoc +++ /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 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$ -** -****************************************************************************/ - -/*! - \example animation/stickman - \title Stickman Example - - \brief The Stickman example shows how to animate transitions in a state - machine to implement key frame animations. - - \image stickman-example.png - - In this example, we will write a small application which animates the joints in a skeleton and - projects a stickman figure on top. The stickman can be either "alive" or "dead", and when in the - "alive" state, he can be performing different actions defined by key frame animations. - - Animations are implemented as composite states. Each child state of the animation state - represents a frame in the animation by setting the position of each joint in the stickman's - skeleton to the positions defined for the particular frame. The frames are then bound together - with animated transitions that trigger on the source state's propertiesAssigned() signal. Thus, - the machine will enter the state representing the next frame in the animation immediately after - it has finished animating into the previous frame. - - \image stickman-example1.png - - The states for an animation is constructed by reading a custom animation file format and - creating states that assign values to the "position" properties of each of the nodes in the - skeleton graph. - - \snippet animation/stickman/lifecycle.cpp 1 - - The states are then bound together with signal transitions that listen to the - propertiesAssigned() signal. - - \snippet animation/stickman/lifecycle.cpp 2 - - The last frame state is given a transition to the first one, so that the animation will loop - until it is interrupted when a transition out from the animation state is taken. To get smooth - animations between the different key frames, we set a default animation on the state machine. - This is a parallel animation group which contains animations for all the "position" properties - and will be selected by default when taking any transition that leads into a state that assigns - values to these properties. - - \snippet animation/stickman/lifecycle.cpp 3 - - Several such animation states are constructed, and are placed together as children of a top - level "alive" state which represents the stickman life cycle. Transitions go from the parent - state to the child state to ensure that each of the child states inherit them. - - \image stickman-example2.png - - This saves us the effort of connect every state to every state with identical transitions. The - state machine makes sure that transitions between the key frame animations are also smooth by - applying the default animation when interrupting one and starting another. - - Finally, there is a transition out from the "alive" state and into the "dead" state. This is - a custom transition type called LightningSrikesTransition which samples every second and - triggers at random (one out of fifty times on average.) - - \snippet animation/stickman/lifecycle.cpp 4 - - When it triggers, the machine will first enter a "lightningBlink" state which uses a timer to - pause for a brief period of time while the background color of the scene is white. This gives us - a flash effect when the lightning strikes. - - \snippet animation/stickman/lifecycle.cpp 5 - - We start and stop a QTimer object when entering and exiting the state. Then we transition into - the "dead" state when the timer times out. - - \snippet animation/stickman/lifecycle.cpp 0 - - When the machine is in the "dead" state, it will be unresponsive. This is because the "dead" - state has no transitions leading out. - - \image stickman-example3.png - -*/ diff --git a/examples/widgets/doc/src/sub-attaq.qdoc b/examples/widgets/doc/src/sub-attaq.qdoc deleted file mode 100644 index 994e9d6f90..0000000000 --- a/examples/widgets/doc/src/sub-attaq.qdoc +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example animation/sub-attaq - \title Sub-Attaq - \ingroup examples-layout - - \brief This example shows Qt's ability to combine \l{The Animation Framework}{the animation framework} - and \l{The State Machine Framework}{the state machine framework} to create a game. - - \image sub-attaq-demo.png - - The purpose of the game is to destroy all submarines to win the current level. - The boat can be controlled using left and right keys. To fire a bomb you can press - up and down keys. -*/ diff --git a/examples/widgets/doc/src/trafficlight.qdoc b/examples/widgets/doc/src/trafficlight.qdoc deleted file mode 100644 index 50c0944101..0000000000 --- a/examples/widgets/doc/src/trafficlight.qdoc +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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$ -** -****************************************************************************/ - -/*! - \example statemachine/trafficlight - \title Traffic Light Example - - \brief The Traffic Light example shows how to use \l{The State Machine Framework} - to implement the control flow of a traffic light. - - \image trafficlight-example.png - - In this example we write a TrafficLightWidget class. The traffic light has - three lights: Red, yellow and green. The traffic light transitions from - one light to another (red to yellow to green to yellow to red again) at - certain intervals. - - \snippet statemachine/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 - - 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 - - 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 - timer, and as we shall see the timeout is used to transition from one - LightState to another. Here is the statechart for the light state: - - \image trafficlight-example1.png - \omit - \caption This is a caption - \endomit - - \snippet statemachine/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, - green-to-yellow and yellow-to-red. The initial state is red-to-yellow; - when the state's timer times out, the state machine transitions to - yellow-to-green. The same process repeats through the other states. - This is what the statechart looks like: - - \image trafficlight-example2.png - \omit - \caption This is a caption - \endomit - - \snippet statemachine/trafficlight/main.cpp 4 - - The main() function constructs a TrafficLight and shows it. - -*/ diff --git a/examples/widgets/doc/src/twowaybutton.qdoc b/examples/widgets/doc/src/twowaybutton.qdoc deleted file mode 100644 index 2e1c29199d..0000000000 --- a/examples/widgets/doc/src/twowaybutton.qdoc +++ /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 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$ -** -****************************************************************************/ - -/*! - \example statemachine/twowaybutton - \title Two-way Button Example - - \brief The Two-way button example shows how to use \l{The State Machine - Framework} to implement a simple state machine that toggles the current - state when a button is clicked. - - \snippet statemachine/twowaybutton/main.cpp 0 - - The application's main() function begins by constructing the application - object, a button and a state machine. - - \snippet statemachine/twowaybutton/main.cpp 1 - - The state machine has two states; \c on and \c off. When either state is - entered, the text of the button will be set accordingly. - - \snippet statemachine/twowaybutton/main.cpp 2 - - When the state machine is in the \c off state and the button is clicked, - it will transition to the \c on state; when the state machine is in the \c - on state and the button is clicked, it will transition to the \c off - state. - - \snippet statemachine/twowaybutton/main.cpp 3 - - The states are added to the state machine; they become top-level (sibling) - states. - - \snippet statemachine/twowaybutton/main.cpp 4 - - The initial state is \c off; this is the state the state machine will - immediately transition to once the state machine is started. - - \snippet statemachine/twowaybutton/main.cpp 5 - - Finally, the button is resized and made visible, and the application event - loop is entered. - -*/ diff --git a/examples/widgets/graphicsview/CMakeLists.txt b/examples/widgets/graphicsview/CMakeLists.txt index 5ea8d6b2c6..a60ba190ef 100644 --- a/examples/widgets/graphicsview/CMakeLists.txt +++ b/examples/widgets/graphicsview/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory(chip) add_subdirectory(elasticnodes) add_subdirectory(embeddeddialogs) add_subdirectory(collidingmice) -add_subdirectory(padnavigator) add_subdirectory(basicgraphicslayouts) add_subdirectory(diagramscene) add_subdirectory(flowlayout) diff --git a/examples/widgets/graphicsview/graphicsview.pro b/examples/widgets/graphicsview/graphicsview.pro index d591450559..8becd8aa9d 100644 --- a/examples/widgets/graphicsview/graphicsview.pro +++ b/examples/widgets/graphicsview/graphicsview.pro @@ -4,7 +4,6 @@ SUBDIRS = \ elasticnodes \ embeddeddialogs \ collidingmice \ - padnavigator \ basicgraphicslayouts \ diagramscene \ dragdroprobot \ diff --git a/examples/widgets/graphicsview/padnavigator/.prev_CMakeLists.txt b/examples/widgets/graphicsview/padnavigator/.prev_CMakeLists.txt deleted file mode 100644 index e00a7d40a5..0000000000 --- a/examples/widgets/graphicsview/padnavigator/.prev_CMakeLists.txt +++ /dev/null @@ -1,68 +0,0 @@ -# Generated from padnavigator.pro. - -cmake_minimum_required(VERSION 3.14) -project(padnavigator 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/graphicsview/padnavigator") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_executable(padnavigator - flippablepad.cpp flippablepad.h - form.ui - main.cpp - padnavigator.cpp padnavigator.h - roundrectitem.cpp roundrectitem.h - splashitem.cpp splashitem.h -) -target_link_libraries(padnavigator PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(padnavigator_resource_files - "images/artsfftscope.png" - "images/blue_angle_swirl.jpg" - "images/kontact_contacts.png" - "images/kontact_journal.png" - "images/kontact_mail.png" - "images/kontact_notes.png" - "images/kopeteavailable.png" - "images/metacontact_online.png" - "images/minitools.png" -) - -qt6_add_resources(padnavigator "padnavigator" - PREFIX - "/" - FILES - ${padnavigator_resource_files} -) - -if(TARGET Qt::OpenGL) - target_link_libraries(padnavigator PUBLIC - Qt::OpenGL - Qt::OpenGLWidgets - ) -endif() - -install(TARGETS padnavigator - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/graphicsview/padnavigator/CMakeLists.txt b/examples/widgets/graphicsview/padnavigator/CMakeLists.txt deleted file mode 100644 index cb21f80d22..0000000000 --- a/examples/widgets/graphicsview/padnavigator/CMakeLists.txt +++ /dev/null @@ -1,69 +0,0 @@ -# Generated from padnavigator.pro. - -cmake_minimum_required(VERSION 3.14) -project(padnavigator 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/graphicsview/padnavigator") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) -find_package(Qt6 COMPONENTS OpenGL) # special case - -add_executable(padnavigator - flippablepad.cpp flippablepad.h - form.ui - main.cpp - padnavigator.cpp padnavigator.h - roundrectitem.cpp roundrectitem.h - splashitem.cpp splashitem.h -) -target_link_libraries(padnavigator PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - - -# Resources: -set(padnavigator_resource_files - "images/artsfftscope.png" - "images/blue_angle_swirl.jpg" - "images/kontact_contacts.png" - "images/kontact_journal.png" - "images/kontact_mail.png" - "images/kontact_notes.png" - "images/kopeteavailable.png" - "images/metacontact_online.png" - "images/minitools.png" -) - -qt6_add_resources(padnavigator "padnavigator" - PREFIX - "/" - FILES - ${padnavigator_resource_files} -) - -if(TARGET Qt::OpenGL) - target_link_libraries(padnavigator PUBLIC - Qt::OpenGL - Qt::OpenGLWidgets - ) -endif() - -install(TARGETS padnavigator - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/graphicsview/padnavigator/flippablepad.cpp b/examples/widgets/graphicsview/padnavigator/flippablepad.cpp deleted file mode 100644 index 263909225e..0000000000 --- a/examples/widgets/graphicsview/padnavigator/flippablepad.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "flippablepad.h" - -#include - -//! [0] -static QRectF boundsFromSize(const QSize &size) -{ - return QRectF((-size.width() / 2.0) * 150, (-size.height() / 2.0) * 150, - size.width() * 150, size.height() * 150); -} -//! [0] - -//! [1] -static QPointF posForLocation(int column, int row, const QSize &size) -{ - return QPointF(column * 150, row * 150) - - QPointF((size.width() - 1) * 75, (size.height() - 1) * 75); -} -//! [1] - -//! [2] -FlippablePad::FlippablePad(const QSize &size, QGraphicsItem *parent) - : RoundRectItem(boundsFromSize(size), QColor(226, 255, 92, 64), parent) -{ -//! [2] -//! [3] - int numIcons = size.width() * size.height(); - QList pixmaps; - QDirIterator it(":/images", {"*.png"}); - while (it.hasNext() && pixmaps.size() < numIcons) - pixmaps << it.next(); -//! [3] - -//! [4] - const QRectF iconRect(-54, -54, 108, 108); - const QColor iconColor(214, 240, 110, 128); - iconGrid.resize(size.height()); - int n = 0; - - for (int y = 0; y < size.height(); ++y) { - iconGrid[y].resize(size.width()); - for (int x = 0; x < size.width(); ++x) { - RoundRectItem *rect = new RoundRectItem(iconRect, iconColor, this); - rect->setZValue(1); - rect->setPos(posForLocation(x, y, size)); - rect->setPixmap(pixmaps.at(n++ % pixmaps.size())); - iconGrid[y][x] = rect; - } - } -} -//! [4] - -//! [5] -RoundRectItem *FlippablePad::iconAt(int column, int row) const -{ - return iconGrid[row][column]; -} -//! [5] diff --git a/examples/widgets/graphicsview/padnavigator/flippablepad.h b/examples/widgets/graphicsview/padnavigator/flippablepad.h deleted file mode 100644 index a056eae1c5..0000000000 --- a/examples/widgets/graphicsview/padnavigator/flippablepad.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FLIPPABLEPAD_H -#define FLIPPABLEPAD_H - -#include "roundrectitem.h" - -#include - -//! [0] -class FlippablePad : public RoundRectItem -{ -public: - explicit FlippablePad(const QSize &size, QGraphicsItem *parent = nullptr); - - RoundRectItem *iconAt(int column, int row) const; - -private: - QList> iconGrid; -}; -//! [0] - -#endif // FLIPPABLEPAD_H diff --git a/examples/widgets/graphicsview/padnavigator/form.ui b/examples/widgets/graphicsview/padnavigator/form.ui deleted file mode 100644 index fc7d12321e..0000000000 --- a/examples/widgets/graphicsview/padnavigator/form.ui +++ /dev/null @@ -1,208 +0,0 @@ - - Form - - - - 0 - 0 - 378 - 385 - - - - BackSide - - - - - - Settings - - - true - - - true - - - - - - Title: - - - - - - - Pad Navigator Example - - - - - - - Modified: - - - - - - - Extent - - - - - - - - - 42 - - - Qt::Horizontal - - - - - - - 42 - - - - - - - - - - - - - - - Other input - - - true - - - true - - - - - - - Widgets On Graphics View - - - - - QGraphicsProxyWidget - - - - QGraphicsWidget - - - - QObject - - - - - QGraphicsItem - - - - - QGraphicsLayoutItem - - - - - - - QGraphicsGridLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - QGraphicsLinearLayout - - - - QGraphicsLayout - - - - QGraphicsLayoutItem - - - - - - - - - - - - - groupBox - hostName - dateTimeEdit - horizontalSlider - spinBox - groupBox_2 - treeWidget - - - - - horizontalSlider - valueChanged(int) - spinBox - setValue(int) - - - 184 - 125 - - - 275 - 127 - - - - - spinBox - valueChanged(int) - horizontalSlider - setValue(int) - - - 272 - 114 - - - 190 - 126 - - - - - diff --git a/examples/widgets/graphicsview/padnavigator/images/artsfftscope.png b/examples/widgets/graphicsview/padnavigator/images/artsfftscope.png deleted file mode 100644 index 4db003f8d2..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/artsfftscope.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/blue_angle_swirl.jpg b/examples/widgets/graphicsview/padnavigator/images/blue_angle_swirl.jpg deleted file mode 100644 index 5bf0debdbd..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/blue_angle_swirl.jpg and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/kontact_contacts.png b/examples/widgets/graphicsview/padnavigator/images/kontact_contacts.png deleted file mode 100644 index 6fb4cc8f38..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/kontact_contacts.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/kontact_journal.png b/examples/widgets/graphicsview/padnavigator/images/kontact_journal.png deleted file mode 100644 index b1fedb6982..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/kontact_journal.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/kontact_mail.png b/examples/widgets/graphicsview/padnavigator/images/kontact_mail.png deleted file mode 100644 index 672f8fa3ab..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/kontact_mail.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/kontact_notes.png b/examples/widgets/graphicsview/padnavigator/images/kontact_notes.png deleted file mode 100644 index 229bf73ac6..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/kontact_notes.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/kopeteavailable.png b/examples/widgets/graphicsview/padnavigator/images/kopeteavailable.png deleted file mode 100644 index 2eaf41afec..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/kopeteavailable.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/metacontact_online.png b/examples/widgets/graphicsview/padnavigator/images/metacontact_online.png deleted file mode 100644 index 6a398dd10f..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/metacontact_online.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/images/minitools.png b/examples/widgets/graphicsview/padnavigator/images/minitools.png deleted file mode 100644 index 0248c9d50a..0000000000 Binary files a/examples/widgets/graphicsview/padnavigator/images/minitools.png and /dev/null differ diff --git a/examples/widgets/graphicsview/padnavigator/main.cpp b/examples/widgets/graphicsview/padnavigator/main.cpp deleted file mode 100644 index c433ab3aa9..0000000000 --- a/examples/widgets/graphicsview/padnavigator/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "padnavigator.h" - -#include - -//! [0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(padnavigator); - - PadNavigator navigator(QSize(3, 3)); - navigator.show(); - return app.exec(); -} -//! [0] diff --git a/examples/widgets/graphicsview/padnavigator/padnavigator.cpp b/examples/widgets/graphicsview/padnavigator/padnavigator.cpp deleted file mode 100644 index 5088386a26..0000000000 --- a/examples/widgets/graphicsview/padnavigator/padnavigator.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "flippablepad.h" -#include "padnavigator.h" -#include "splashitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_OPENGL -#include -#endif - -//! [0] -PadNavigator::PadNavigator(const QSize &size, QWidget *parent) - : QGraphicsView(parent) -{ -//! [0] -//! [1] - // Splash item - SplashItem *splash = new SplashItem; - splash->setZValue(1); -//! [1] - -//! [2] - // Pad item - FlippablePad *pad = new FlippablePad(size); - QGraphicsRotation *flipRotation = new QGraphicsRotation(pad); - QGraphicsRotation *xRotation = new QGraphicsRotation(pad); - QGraphicsRotation *yRotation = new QGraphicsRotation(pad); - flipRotation->setAxis(Qt::YAxis); - xRotation->setAxis(Qt::YAxis); - yRotation->setAxis(Qt::XAxis); - pad->setTransformations(QList() - << flipRotation - << xRotation << yRotation); -//! [2] - -//! [3] - // Back (proxy widget) item - QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad); - QWidget *widget = new QWidget; - form.setupUi(widget); - form.hostName->setFocus(); - backItem->setWidget(widget); - backItem->setVisible(false); - backItem->setFocus(); - backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache); - const QRectF r = backItem->rect(); - backItem->setTransform(QTransform() - .rotate(180, Qt::YAxis) - .translate(-r.width()/2, -r.height()/2)); -//! [3] - -//! [4] - // Selection item - RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray, pad); - selectionItem->setZValue(0.5); -//! [4] - -//! [5] - // Splash animations - QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y"); - QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity"); - smoothSplashMove->setEasingCurve(QEasingCurve::InQuad); - smoothSplashMove->setDuration(250); - smoothSplashOpacity->setDuration(250); -//! [5] - -//! [6] - // Selection animation - QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x"); - QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y"); - QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle"); - QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle"); - smoothXSelection->setDuration(125); - smoothYSelection->setDuration(125); - smoothXRotation->setDuration(125); - smoothYRotation->setDuration(125); - smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad); - smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad); - smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad); -//! [6] - -//! [7] - // Flip animation setup - QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle"); - QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale"); - QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this); - smoothFlipScale->setDuration(500); - smoothFlipRotation->setDuration(500); - smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipScale->setKeyValueAt(0, qvariant_cast(1.0)); - smoothFlipScale->setKeyValueAt(0.5, qvariant_cast(0.7)); - smoothFlipScale->setKeyValueAt(1, qvariant_cast(1.0)); - flipAnimation->addAnimation(smoothFlipRotation); - flipAnimation->addAnimation(smoothFlipScale); -//! [7] - -//! [8] - // Flip animation delayed property assignment - QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup; - QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill"); - QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible"); - QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible"); - setFillAnimation->setDuration(0); - setBackItemVisibleAnimation->setDuration(0); - setSelectionItemVisibleAnimation->setDuration(0); - setVariablesSequence->addPause(250); - setVariablesSequence->addAnimation(setBackItemVisibleAnimation); - setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation); - setVariablesSequence->addAnimation(setFillAnimation); - flipAnimation->addAnimation(setVariablesSequence); -//! [8] - -//! [9] - // Build the state machine - QStateMachine *stateMachine = new QStateMachine(this); - QState *splashState = new QState(stateMachine); - QState *frontState = new QState(stateMachine); - QHistoryState *historyState = new QHistoryState(frontState); - QState *backState = new QState(stateMachine); -//! [9] -//! [10] - frontState->assignProperty(pad, "fill", false); - frontState->assignProperty(splash, "opacity", 0.0); - frontState->assignProperty(backItem, "visible", false); - frontState->assignProperty(flipRotation, "angle", qvariant_cast(0.0)); - frontState->assignProperty(selectionItem, "visible", true); - backState->assignProperty(pad, "fill", true); - backState->assignProperty(backItem, "visible", true); - backState->assignProperty(xRotation, "angle", qvariant_cast(0.0)); - backState->assignProperty(yRotation, "angle", qvariant_cast(0.0)); - backState->assignProperty(flipRotation, "angle", qvariant_cast(180.0)); - backState->assignProperty(selectionItem, "visible", false); - stateMachine->addDefaultAnimation(smoothXRotation); - stateMachine->addDefaultAnimation(smoothYRotation); - stateMachine->addDefaultAnimation(smoothXSelection); - stateMachine->addDefaultAnimation(smoothYSelection); - stateMachine->setInitialState(splashState); -//! [10] - -//! [11] - // Transitions - QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState); - anyKeyTransition->setTargetState(frontState); - anyKeyTransition->addAnimation(smoothSplashMove); - anyKeyTransition->addAnimation(smoothSplashOpacity); -//! [11] - -//! [12] - QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Enter, backState); - QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Return, backState); - QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Enter, frontState); - QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Return, frontState); - enterTransition->setTargetState(historyState); - returnTransition->setTargetState(historyState); - backEnterTransition->setTargetState(backState); - backReturnTransition->setTargetState(backState); - enterTransition->addAnimation(flipAnimation); - returnTransition->addAnimation(flipAnimation); - backEnterTransition->addAnimation(flipAnimation); - backReturnTransition->addAnimation(flipAnimation); -//! [12] - -//! [13] - // Create substates for each icon; store in temporary grid. - int columns = size.width(); - int rows = size.height(); - QList> stateGrid; - stateGrid.resize(rows); - for (int y = 0; y < rows; ++y) { - stateGrid[y].resize(columns); - for (int x = 0; x < columns; ++x) - stateGrid[y][x] = new QState(frontState); - } - frontState->setInitialState(stateGrid[0][0]); - selectionItem->setPos(pad->iconAt(0, 0)->pos()); -//! [13] - -//! [14] - // Enable key navigation using state transitions - for (int y = 0; y < rows; ++y) { - for (int x = 0; x < columns; ++x) { - QState *state = stateGrid[y][x]; - QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Right, state); - QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Left, state); - QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Down, state); - QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress, - Qt::Key_Up, state); - rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]); - leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]); - downTransition->setTargetState(stateGrid[(y + 1) % rows][x]); - upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]); -//! [14] -//! [15] - RoundRectItem *icon = pad->iconAt(x, y); - state->assignProperty(xRotation, "angle", -icon->x() / 6.0); - state->assignProperty(yRotation, "angle", icon->y() / 6.0); - state->assignProperty(selectionItem, "x", icon->x()); - state->assignProperty(selectionItem, "y", icon->y()); - frontState->assignProperty(icon, "visible", true); - backState->assignProperty(icon, "visible", false); - - QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible"); - setIconVisibleAnimation->setDuration(0); - setVariablesSequence->addAnimation(setIconVisibleAnimation); - } - } -//! [15] - -//! [16] - // Scene - QGraphicsScene *scene = new QGraphicsScene(this); - scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); - scene->setItemIndexMethod(QGraphicsScene::NoIndex); - scene->addItem(pad); - scene->setSceneRect(scene->itemsBoundingRect()); - setScene(scene); -//! [16] - -//! [17] - // Adjust splash item to scene contents - const QRectF sbr = splash->boundingRect(); - splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2); - frontState->assignProperty(splash, "y", splash->y() - 100.0); - scene->addItem(splash); -//! [17] - -//! [18] - // View - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setMinimumSize(50, 50); - setViewportUpdateMode(FullViewportUpdate); - setCacheMode(CacheBackground); - setRenderHints(QPainter::Antialiasing - | QPainter::SmoothPixmapTransform - | QPainter::TextAntialiasing); -#ifndef QT_NO_OPENGL - setViewport(new QOpenGLWidget); -#endif - - stateMachine->start(); -//! [18] -} - -//! [19] -void PadNavigator::resizeEvent(QResizeEvent *event) -{ - QGraphicsView::resizeEvent(event); - fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); -} -//! [19] diff --git a/examples/widgets/graphicsview/padnavigator/padnavigator.h b/examples/widgets/graphicsview/padnavigator/padnavigator.h deleted file mode 100644 index 0fe9ad045d..0000000000 --- a/examples/widgets/graphicsview/padnavigator/padnavigator.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef PADNAVIGATOR_H -#define PADNAVIGATOR_H - -#include -#include "ui_form.h" - -//! [0] -class PadNavigator : public QGraphicsView -{ - Q_OBJECT -public: - explicit PadNavigator(const QSize &size, QWidget *parent = nullptr); - -protected: - void resizeEvent(QResizeEvent *event) override; - -private: - Ui::Form form; -}; -//! [0] - -#endif // PADNAVIGATOR_H diff --git a/examples/widgets/graphicsview/padnavigator/padnavigator.pro b/examples/widgets/graphicsview/padnavigator/padnavigator.pro deleted file mode 100644 index d957be4593..0000000000 --- a/examples/widgets/graphicsview/padnavigator/padnavigator.pro +++ /dev/null @@ -1,27 +0,0 @@ -SOURCES += main.cpp \ - roundrectitem.cpp \ - flippablepad.cpp \ - padnavigator.cpp \ - splashitem.cpp - -HEADERS += \ - roundrectitem.h \ - flippablepad.h \ - padnavigator.h \ - splashitem.h - -RESOURCES += \ - padnavigator.qrc - -FORMS += \ - form.ui - -QT += widgets -requires(qtConfig(treewidget)) -qtHaveModule(opengl): QT += opengl openglwidgets - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/graphicsview/padnavigator -INSTALLS += target - -CONFIG += console diff --git a/examples/widgets/graphicsview/padnavigator/padnavigator.qrc b/examples/widgets/graphicsview/padnavigator/padnavigator.qrc deleted file mode 100644 index b26ab92ae1..0000000000 --- a/examples/widgets/graphicsview/padnavigator/padnavigator.qrc +++ /dev/null @@ -1,13 +0,0 @@ - - - images/blue_angle_swirl.jpg - images/artsfftscope.png - images/kontact_contacts.png - images/kontact_journal.png - images/kontact_mail.png - images/kontact_notes.png - images/kopeteavailable.png - images/metacontact_online.png - images/minitools.png - - diff --git a/examples/widgets/graphicsview/padnavigator/roundrectitem.cpp b/examples/widgets/graphicsview/padnavigator/roundrectitem.cpp deleted file mode 100644 index b4ea489069..0000000000 --- a/examples/widgets/graphicsview/padnavigator/roundrectitem.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "roundrectitem.h" - -#include -#include -#include - -//! [0] -RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color, - QGraphicsItem *parent) - : QGraphicsObject(parent), fillRect(false), bounds(bounds) -{ - gradient.setStart(bounds.topLeft()); - gradient.setFinalStop(bounds.bottomRight()); - gradient.setColorAt(0, color); - gradient.setColorAt(1, color.darker(200)); - setCacheMode(ItemCoordinateCache); -} -//! [0] - -//! [1] -QPixmap RoundRectItem::pixmap() const -{ - return pix; -} -void RoundRectItem::setPixmap(const QPixmap &pixmap) -{ - pix = pixmap; - update(); -} -//! [1] - -//! [2] -QRectF RoundRectItem::boundingRect() const -{ - return bounds.adjusted(0, 0, 2, 2); -} -//! [2] - -//! [3] -void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(Qt::NoPen); - painter->setBrush(QColor(0, 0, 0, 64)); - painter->drawRoundedRect(bounds.translated(2, 2), 25, 25, Qt::RelativeSize); -//! [3] -//! [4] - if (fillRect) - painter->setBrush(QGuiApplication::palette().brush(QPalette::Window)); - else - painter->setBrush(gradient); - painter->setPen(QPen(Qt::black, 1)); - painter->drawRoundedRect(bounds, 25,25, Qt::RelativeSize); -//! [4] -//! [5] - if (!pix.isNull()) { - painter->scale(1.95, 1.95); - painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix); - } -} -//! [5] - -//! [6] -bool RoundRectItem::fill() const -{ - return fillRect; -} -void RoundRectItem::setFill(bool fill) -{ - fillRect = fill; - update(); -} -//! [6] diff --git a/examples/widgets/graphicsview/padnavigator/roundrectitem.h b/examples/widgets/graphicsview/padnavigator/roundrectitem.h deleted file mode 100644 index 91b3e6542e..0000000000 --- a/examples/widgets/graphicsview/padnavigator/roundrectitem.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ROUNDRECTITEM_H -#define ROUNDRECTITEM_H - -#include -#include - -//! [0] -class RoundRectItem : public QGraphicsObject -{ - Q_OBJECT - Q_PROPERTY(bool fill READ fill WRITE setFill) -public: - RoundRectItem(const QRectF &bounds, const QColor &color, - QGraphicsItem *parent = nullptr); - - QPixmap pixmap() const; - void setPixmap(const QPixmap &pixmap); - - QRectF boundingRect() const override; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; - - bool fill() const; - void setFill(bool fill); -//! [0] - -//! [1] -private: - QPixmap pix; - bool fillRect; - QRectF bounds; - QLinearGradient gradient; -}; -//! [1] - -#endif // ROUNDRECTITEM_H diff --git a/examples/widgets/graphicsview/padnavigator/splashitem.cpp b/examples/widgets/graphicsview/padnavigator/splashitem.cpp deleted file mode 100644 index 7c3dfba588..0000000000 --- a/examples/widgets/graphicsview/padnavigator/splashitem.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "splashitem.h" - -#include - -//! [0] -SplashItem::SplashItem(QGraphicsItem *parent) - : QGraphicsObject(parent) -{ - text = tr("Welcome to the Pad Navigator Example. You can use the" - " keyboard arrows to navigate the icons, and press enter" - " to activate an item. Press any key to begin."); - setCacheMode(DeviceCoordinateCache); -} -//! [0] - -//! [1] -QRectF SplashItem::boundingRect() const -{ - return QRectF(0, 0, 400, 175); -} -//! [1] - -//! [2] -void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) -{ - Q_UNUSED(option); - Q_UNUSED(widget); - painter->setPen(QPen(Qt::black, 2)); - painter->setBrush(QColor(245, 245, 255, 220)); - painter->setClipRect(boundingRect()); - painter->drawRoundedRect(3, -100 + 3, 400 - 6, 250 - 6, 25, 25, Qt::RelativeSize); - - QRectF textRect = boundingRect().adjusted(10, 10, -10, -10); - int flags = Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap; - - QFont font; - font.setPixelSize(18); - painter->setPen(Qt::black); - painter->setFont(font); - painter->drawText(textRect, flags, text); -} -//! [2] diff --git a/examples/widgets/graphicsview/padnavigator/splashitem.h b/examples/widgets/graphicsview/padnavigator/splashitem.h deleted file mode 100644 index b8e723db81..0000000000 --- a/examples/widgets/graphicsview/padnavigator/splashitem.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SPLASHITEM_H -#define SPLASHITEM_H - -#include - -//! [0] -class SplashItem : public QGraphicsObject -{ - Q_OBJECT -public: - explicit SplashItem(QGraphicsItem *parent = nullptr); - - QRectF boundingRect() const override; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override; - -private: - QString text; -}; -//! [0] - -#endif // SPLASHITEM_H diff --git a/examples/widgets/statemachine/CMakeLists.txt b/examples/widgets/statemachine/CMakeLists.txt deleted file mode 100644 index 90a7b3e263..0000000000 --- a/examples/widgets/statemachine/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Generated from statemachine.pro. - -add_subdirectory(factorial) -add_subdirectory(pingpong) -if(TARGET Qt::Widgets) - add_subdirectory(eventtransitions) - add_subdirectory(rogue) - add_subdirectory(trafficlight) - add_subdirectory(twowaybutton) -endif() diff --git a/examples/widgets/statemachine/README b/examples/widgets/statemachine/README deleted file mode 100644 index a0ac35a89b..0000000000 --- a/examples/widgets/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/widgets/statemachine/eventtransitions/CMakeLists.txt b/examples/widgets/statemachine/eventtransitions/CMakeLists.txt deleted file mode 100644 index 642e6343db..0000000000 --- a/examples/widgets/statemachine/eventtransitions/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Generated from eventtransitions.pro. - -cmake_minimum_required(VERSION 3.14) -project(eventtransitions 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/statemachine/eventtransitions") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(eventtransitions - main.cpp -) -target_link_libraries(eventtransitions PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS eventtransitions - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/eventtransitions/eventtransitions.pro b/examples/widgets/statemachine/eventtransitions/eventtransitions.pro deleted file mode 100644 index 07c8be73d4..0000000000 --- a/examples/widgets/statemachine/eventtransitions/eventtransitions.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += widgets - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/eventtransitions -INSTALLS += target diff --git a/examples/widgets/statemachine/eventtransitions/main.cpp b/examples/widgets/statemachine/eventtransitions/main.cpp deleted file mode 100644 index fe9518092f..0000000000 --- a/examples/widgets/statemachine/eventtransitions/main.cpp +++ /dev/null @@ -1,130 +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 -#include -#include -#include -#include -#include - -//! [0] -class Window : public QWidget -{ -public: - Window(QWidget *parent = nullptr) - : QWidget(parent) - { - QPushButton *button = new QPushButton(this); - button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(button); - layout->setContentsMargins(80, 80, 80, 80); - setLayout(layout); -//! [0] - -//! [1] - QStateMachine *machine = new QStateMachine(this); - - QState *s1 = new QState(); - s1->assignProperty(button, "text", "Outside"); - - QState *s2 = new QState(); - s2->assignProperty(button, "text", "Inside"); -//! [1] - -//! [2] - QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter); - enterTransition->setTargetState(s2); - s1->addTransition(enterTransition); -//! [2] - -//! [3] - QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave); - leaveTransition->setTargetState(s1); - s2->addTransition(leaveTransition); -//! [3] - -//! [4] - QState *s3 = new QState(); - s3->assignProperty(button, "text", "Pressing..."); - - QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress); - pressTransition->setTargetState(s3); - s2->addTransition(pressTransition); - - QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease); - releaseTransition->setTargetState(s2); - s3->addTransition(releaseTransition); -//! [4] - -//! [5] - machine->addState(s1); - machine->addState(s2); - machine->addState(s3); - - machine->setInitialState(s1); - machine->start(); - } -}; -//! [5] - -//! [6] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - Window window; - window.resize(300, 300); - window.show(); - - return app.exec(); -} -//! [6] diff --git a/examples/widgets/statemachine/factorial/CMakeLists.txt b/examples/widgets/statemachine/factorial/CMakeLists.txt deleted file mode 100644 index 17904e3cd2..0000000000 --- a/examples/widgets/statemachine/factorial/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Generated from factorial.pro. - -cmake_minimum_required(VERSION 3.14) -project(factorial 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/statemachine/factorial") - -find_package(Qt6 COMPONENTS Core) - -add_executable(factorial - main.cpp -) -target_link_libraries(factorial PUBLIC - Qt::Core -) - -install(TARGETS factorial - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/factorial/factorial.pro b/examples/widgets/statemachine/factorial/factorial.pro deleted file mode 100644 index bf285acf4d..0000000000 --- a/examples/widgets/statemachine/factorial/factorial.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT = core -CONFIG += cmdline - -SOURCES += main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/factorial -INSTALLS += target - - diff --git a/examples/widgets/statemachine/factorial/main.cpp b/examples/widgets/statemachine/factorial/main.cpp deleted file mode 100644 index e6cbdcae29..0000000000 --- a/examples/widgets/statemachine/factorial/main.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the 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 - -//! [0] -class Factorial : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x WRITE setX) - Q_PROPERTY(int fac READ fac WRITE setFac) -public: - using QObject::QObject; - - int x() const - { - return m_x; - } - - void setX(int x) - { - if (x == m_x) - return; - m_x = x; - emit xChanged(x); - } - - int fac() const - { - return m_fac; - } - - void setFac(int fac) - { - m_fac = fac; - } - -Q_SIGNALS: - void xChanged(int value); - -private: - int m_x = -1; - int m_fac = 1; -}; -//! [0] - -//! [1] -class FactorialLoopTransition : public QSignalTransition -{ -public: - FactorialLoopTransition(Factorial *fact) - : QSignalTransition(fact, &Factorial::xChanged), m_fact(fact) - {} - - bool eventTest(QEvent *e) override - { - if (!QSignalTransition::eventTest(e)) - return false; - QStateMachine::SignalEvent *se = static_cast(e); - return se->arguments().at(0).toInt() > 1; - } - - void onTransition(QEvent *e) override - { - QStateMachine::SignalEvent *se = static_cast(e); - int x = se->arguments().at(0).toInt(); - int fac = m_fact->property("fac").toInt(); - m_fact->setProperty("fac", x * fac); - m_fact->setProperty("x", x - 1); - } - -private: - Factorial *m_fact; -}; -//! [1] - -//! [2] -class FactorialDoneTransition : public QSignalTransition -{ -public: - FactorialDoneTransition(Factorial *fact) - : QSignalTransition(fact, &Factorial::xChanged), m_fact(fact) - {} - - bool eventTest(QEvent *e) override - { - if (!QSignalTransition::eventTest(e)) - return false; - QStateMachine::SignalEvent *se = static_cast(e); - return se->arguments().at(0).toInt() <= 1; - } - - void onTransition(QEvent *) override - { - qInfo() << m_fact->property("fac").toInt(); - } - -private: - Factorial *m_fact; -}; -//! [2] - -//! [3] -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - Factorial factorial; - QStateMachine machine; -//! [3] - -//! [4] - QState *compute = new QState(&machine); - compute->assignProperty(&factorial, "fac", 1); - compute->assignProperty(&factorial, "x", 6); - compute->addTransition(new FactorialLoopTransition(&factorial)); -//! [4] - -//! [5] - QFinalState *done = new QFinalState(&machine); - FactorialDoneTransition *doneTransition = new FactorialDoneTransition(&factorial); - doneTransition->setTargetState(done); - compute->addTransition(doneTransition); -//! [5] - -//! [6] - machine.setInitialState(compute); - QObject::connect(&machine, &QStateMachine::finished, &app, QCoreApplication::quit); - machine.start(); - - return app.exec(); -} -//! [6] - -#include "main.moc" diff --git a/examples/widgets/statemachine/pingpong/CMakeLists.txt b/examples/widgets/statemachine/pingpong/CMakeLists.txt deleted file mode 100644 index 68cb4acb44..0000000000 --- a/examples/widgets/statemachine/pingpong/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Generated from pingpong.pro. - -cmake_minimum_required(VERSION 3.14) -project(pingpong 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/statemachine/pingpong") - -find_package(Qt6 COMPONENTS Core) - -add_executable(pingpong - main.cpp -) -target_link_libraries(pingpong PUBLIC - Qt::Core -) - -install(TARGETS pingpong - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/pingpong/main.cpp b/examples/widgets/statemachine/pingpong/main.cpp deleted file mode 100644 index c09060c502..0000000000 --- a/examples/widgets/statemachine/pingpong/main.cpp +++ /dev/null @@ -1,149 +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 -#include - -//! [0] -class PingEvent : public QEvent -{ -public: - PingEvent() : QEvent(QEvent::Type(QEvent::User+2)) - {} -}; - -class PongEvent : public QEvent -{ -public: - PongEvent() : QEvent(QEvent::Type(QEvent::User+3)) - {} -}; -//! [0] - -//! [1] -class Pinger : public QState -{ -public: - Pinger(QState *parent) - : QState(parent) {} - -protected: - void onEntry(QEvent *) override - { - machine()->postEvent(new PingEvent()); - fprintf(stdout, "ping?\n"); - } -}; -//! [1] - -//! [3] -class PongTransition : public QAbstractTransition -{ -public: - PongTransition() {} - -protected: - bool eventTest(QEvent *e) override { - return (e->type() == QEvent::User+3); - } - void onTransition(QEvent *) override - { - machine()->postDelayedEvent(new PingEvent(), 500); - fprintf(stdout, "ping?\n"); - } -}; -//! [3] - -//! [2] -class PingTransition : public QAbstractTransition -{ -public: - PingTransition() {} - -protected: - bool eventTest(QEvent *e) override { - return (e->type() == QEvent::User+2); - } - void onTransition(QEvent *) override - { - machine()->postDelayedEvent(new PongEvent(), 500); - fprintf(stdout, "pong!\n"); - } -}; -//! [2] - -//! [4] -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QStateMachine machine; - QState *group = new QState(QState::ParallelStates); - group->setObjectName("group"); -//! [4] - -//! [5] - Pinger *pinger = new Pinger(group); - pinger->setObjectName("pinger"); - pinger->addTransition(new PongTransition()); - - QState *ponger = new QState(group); - ponger->setObjectName("ponger"); - ponger->addTransition(new PingTransition()); -//! [5] - -//! [6] - machine.addState(group); - machine.setInitialState(group); - machine.start(); - - return app.exec(); -} -//! [6] diff --git a/examples/widgets/statemachine/pingpong/pingpong.pro b/examples/widgets/statemachine/pingpong/pingpong.pro deleted file mode 100644 index 18dee0400d..0000000000 --- a/examples/widgets/statemachine/pingpong/pingpong.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT = core -CONFIG += cmdline - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/pingpong -INSTALLS += target - - diff --git a/examples/widgets/statemachine/rogue/CMakeLists.txt b/examples/widgets/statemachine/rogue/CMakeLists.txt deleted file mode 100644 index 156b054311..0000000000 --- a/examples/widgets/statemachine/rogue/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Generated from rogue.pro. - -cmake_minimum_required(VERSION 3.14) -project(rogue 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/statemachine/rogue") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(rogue - main.cpp - movementtransition.h - window.cpp window.h -) -target_link_libraries(rogue PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS rogue - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/rogue/main.cpp b/examples/widgets/statemachine/rogue/main.cpp deleted file mode 100644 index 44ade770ee..0000000000 --- a/examples/widgets/statemachine/rogue/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation 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 - -#include "window.h" - -int main(int argv, char **args) -{ - QApplication app(argv, args); - - Window window; - window.show(); - - return app.exec(); -} - diff --git a/examples/widgets/statemachine/rogue/movementtransition.h b/examples/widgets/statemachine/rogue/movementtransition.h deleted file mode 100644 index 74ffed6608..0000000000 --- a/examples/widgets/statemachine/rogue/movementtransition.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE: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 MOVEMENTTRANSITION_H -#define MOVEMENTTRANSITION_H - -#include - -#include "window.h" - -//![0] -class MovementTransition : public QEventTransition -{ - Q_OBJECT - -public: - MovementTransition(Window *window) : - QEventTransition(window, QEvent::KeyPress) { - this->window = window; - } -//![0] - -//![1] -protected: - bool eventTest(QEvent *event) override { - if (event->type() == QEvent::StateMachineWrapped && - static_cast(event)->event()->type() == QEvent::KeyPress) { - QEvent *wrappedEvent = static_cast(event)->event(); - - QKeyEvent *keyEvent = static_cast(wrappedEvent); - int key = keyEvent->key(); - - return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 || - key == Qt::Key_4 || key == Qt::Key_Down || key == Qt::Key_Up || - key == Qt::Key_Right || key == Qt::Key_Left; - } - return false; - } -//![1] - -//![2] - void onTransition(QEvent *event) override { - QKeyEvent *keyEvent = static_cast( - static_cast(event)->event()); - - int key = keyEvent->key(); - switch (key) { - case Qt::Key_Left: - case Qt::Key_4: - window->movePlayer(Window::Left); - break; - case Qt::Key_Up: - case Qt::Key_8: - window->movePlayer(Window::Up); - break; - case Qt::Key_Right: - case Qt::Key_6: - window->movePlayer(Window::Right); - break; - case Qt::Key_Down: - case Qt::Key_2: - window->movePlayer(Window::Down); - break; - default: - ; - } - } -//![2] - -private: - Window *window; -}; - -#endif - diff --git a/examples/widgets/statemachine/rogue/rogue.pro b/examples/widgets/statemachine/rogue/rogue.pro deleted file mode 100644 index cf9657c7d6..0000000000 --- a/examples/widgets/statemachine/rogue/rogue.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT += widgets - -HEADERS = window.h \ - movementtransition.h -SOURCES = main.cpp \ - window.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/rogue -INSTALLS += target diff --git a/examples/widgets/statemachine/rogue/window.cpp b/examples/widgets/statemachine/rogue/window.cpp deleted file mode 100644 index a5363e2758..0000000000 --- a/examples/widgets/statemachine/rogue/window.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE: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 - -#include "window.h" -#include "movementtransition.h" - -//![0] -Window::Window() -{ - pX = 5; - pY = 5; -//![0] - - QFontDatabase database; - QFont font; - if (database.families().contains("Monospace")) { - font = QFont("Monospace"); - } - else { - const QStringList fontFamilies = database.families(); - for (const QString &family : fontFamilies ) { - if (database.isFixedPitch(family)) { - font = QFont(family); - break; - } - } - } - font.setPointSize(12); - setFont(font); - -//![1] - setupMap(); - buildMachine(); -} -//![1] - -void Window::setStatus(const QString &status) -{ - myStatus = status; - repaint(); -} - -QString Window::status() const -{ - return myStatus; -} - -void Window::paintEvent(QPaintEvent * /* event */) -{ - QFontMetrics metrics(font()); - QPainter painter(this); - int fontHeight = metrics.height(); - int fontWidth = metrics.horizontalAdvance('X'); - int yPos = fontHeight; - int xPos; - - painter.fillRect(rect(), Qt::black); - painter.setPen(Qt::white); - - painter.drawText(QPoint(0, yPos), status()); - - for (int y = 0; y < HEIGHT; ++y) { - yPos += fontHeight; - xPos = 0; - - for (int x = 0; x < WIDTH; ++x) { - if (y == pY && x == pX) { - xPos += fontWidth; - continue; - } - - painter.setPen(Qt::white); - - double x1 = static_cast(pX); - double y1 = static_cast(pY); - double x2 = static_cast(x); - double y2 = static_cast(y); - - if (x2x1) { - x2-=0.5; - } - - if (y2y1) { - y2-=0.5; - } - - double dx = x2 - x1; - double dy = y2 - y1; - - double length = qSqrt(dx*dx+dy*dy); - - dx /= length; - dy /= length; - - double xi = x1; - double yi = y1; - - while (length > 0) { - int cx = static_cast(xi+0.5); - int cy = static_cast(yi+0.5); - - if (x2 == cx && y2 == cy) - break; - - if (!(x1==cx && y1==cy) - && (map[cx][cy] == '#' || (length-10) > 0)) { - painter.setPen(QColor(60,60,60)); - break; - } - - xi += dx; - yi += dy; - --length; - } - - painter.drawText(QPoint(xPos, yPos), map[x][y]); - xPos += fontWidth; - } - } - painter.setPen(Qt::white); - painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@')); -} - -QSize Window::sizeHint() const -{ - QFontMetrics metrics(font()); - - return QSize(metrics.horizontalAdvance('X') * WIDTH, metrics.height() * (HEIGHT + 1)); -} - -//![2] -void Window::buildMachine() -{ - machine = new QStateMachine; - - QState *inputState = new QState(machine); - inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8"); - - MovementTransition *transition = new MovementTransition(this); - inputState->addTransition(transition); -//![2] - -//![3] - QState *quitState = new QState(machine); - quitState->assignProperty(this, "status", "Really quit(y/n)?"); - - QKeyEventTransition *yesTransition = new - QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y); - yesTransition->setTargetState(new QFinalState(machine)); - quitState->addTransition(yesTransition); - - QKeyEventTransition *noTransition = - new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N); - noTransition->setTargetState(inputState); - quitState->addTransition(noTransition); -//![3] - -//![4] - QKeyEventTransition *quitTransition = - new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q); - quitTransition->setTargetState(quitState); - inputState->addTransition(quitTransition); -//![4] - -//![5] - machine->setInitialState(inputState); - - connect(machine, &QStateMachine::finished, - qApp, &QApplication::quit); - - machine->start(); -} -//![5] - -void Window::movePlayer(Direction direction) -{ - switch (direction) { - case Left: - if (map[pX - 1][pY] != '#') - --pX; - break; - case Right: - if (map[pX + 1][pY] != '#') - ++pX; - break; - case Up: - if (map[pX][pY - 1] != '#') - --pY; - break; - case Down: - if (map[pX][pY + 1] != '#') - ++pY; - break; - } - repaint(); -} - -void Window::setupMap() -{ - for (int x = 0; x < WIDTH; ++x) - for (int y = 0; y < HEIGHT; ++y) { - if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || QRandomGenerator::global()->bounded(40) == 0) - map[x][y] = '#'; - else - map[x][y] = '.'; - } -} - diff --git a/examples/widgets/statemachine/rogue/window.h b/examples/widgets/statemachine/rogue/window.h deleted file mode 100644 index af34815ffd..0000000000 --- a/examples/widgets/statemachine/rogue/window.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef WINDOW_H -#define WINDOW_H - -#include - -QT_BEGIN_NAMESPACE -class QState; -class QStateMachine; -class QTransition; -QT_END_NAMESPACE - -#define WIDTH 35 -#define HEIGHT 20 - -//![0] -class Window : public QWidget -{ - Q_OBJECT - Q_PROPERTY(QString status READ status WRITE setStatus) - -public: - enum Direction { Up, Down, Left, Right }; - - Window(); - - void movePlayer(Direction direction); - void setStatus(const QString &status); - QString status() const; - - QSize sizeHint() const override; - -protected: - void paintEvent(QPaintEvent *event) override; -//![0] - -//![1] -private: - void buildMachine(); - void setupMap(); - - QChar map[WIDTH][HEIGHT]; - int pX, pY; - - QStateMachine *machine; - QString myStatus; -}; -//![1] - -#endif - diff --git a/examples/widgets/statemachine/statemachine.pro b/examples/widgets/statemachine/statemachine.pro deleted file mode 100644 index 926e01cfda..0000000000 --- a/examples/widgets/statemachine/statemachine.pro +++ /dev/null @@ -1,12 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = \ - factorial \ - pingpong - -qtHaveModule(widgets) { - SUBDIRS += \ - eventtransitions \ - rogue \ - trafficlight \ - twowaybutton -} diff --git a/examples/widgets/statemachine/trafficlight/CMakeLists.txt b/examples/widgets/statemachine/trafficlight/CMakeLists.txt deleted file mode 100644 index ca2ec2313a..0000000000 --- a/examples/widgets/statemachine/trafficlight/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Generated from trafficlight.pro. - -cmake_minimum_required(VERSION 3.14) -project(trafficlight 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/statemachine/trafficlight") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(trafficlight - main.cpp -) -target_link_libraries(trafficlight PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS trafficlight - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/trafficlight/main.cpp b/examples/widgets/statemachine/trafficlight/main.cpp deleted file mode 100644 index dd8bddcb37..0000000000 --- a/examples/widgets/statemachine/trafficlight/main.cpp +++ /dev/null @@ -1,200 +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 -#include -#include -#include -#include -#include -#include - -//! [0] -class LightWidget : public QWidget -{ - Q_OBJECT - Q_PROPERTY(bool on READ isOn WRITE setOn) -public: - LightWidget(const QColor &color, QWidget *parent = nullptr) - : QWidget(parent), m_color(color), m_on(false) {} - - bool isOn() const - { return m_on; } - void setOn(bool on) - { - if (on == m_on) - return; - m_on = on; - update(); - } - -public slots: - void turnOff() { setOn(false); } - void turnOn() { setOn(true); } - -protected: - void paintEvent(QPaintEvent *) override - { - if (!m_on) - return; - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(m_color); - painter.drawEllipse(0, 0, width(), height()); - } - -private: - QColor m_color; - bool m_on; -}; -//! [0] - -//! [1] -class TrafficLightWidget : public QWidget -{ -public: - TrafficLightWidget(QWidget *parent = nullptr) - : QWidget(parent) - { - QVBoxLayout *vbox = new QVBoxLayout(this); - m_red = new LightWidget(Qt::red); - vbox->addWidget(m_red); - m_yellow = new LightWidget(Qt::yellow); - vbox->addWidget(m_yellow); - m_green = new LightWidget(Qt::green); - vbox->addWidget(m_green); - QPalette pal = palette(); - pal.setColor(QPalette::Window, Qt::black); - setPalette(pal); - setAutoFillBackground(true); - } - - LightWidget *redLight() const - { return m_red; } - LightWidget *yellowLight() const - { return m_yellow; } - LightWidget *greenLight() const - { return m_green; } - -private: - LightWidget *m_red; - LightWidget *m_yellow; - LightWidget *m_green; -}; -//! [1] - -//! [2] -QState *createLightState(LightWidget *light, int duration, QState *parent = nullptr) -{ - QState *lightState = new QState(parent); - QTimer *timer = new QTimer(lightState); - timer->setInterval(duration); - timer->setSingleShot(true); - QState *timing = new QState(lightState); - QObject::connect(timing, &QAbstractState::entered, light, &LightWidget::turnOn); - QObject::connect(timing, &QAbstractState::entered, timer, QOverload<>::of(&QTimer::start)); - QObject::connect(timing, &QAbstractState::exited, light, &LightWidget::turnOff); - QFinalState *done = new QFinalState(lightState); - timing->addTransition(timer, &QTimer::timeout, done); - lightState->setInitialState(timing); - return lightState; -} -//! [2] - -//! [3] -class TrafficLight : public QWidget -{ -public: - TrafficLight(QWidget *parent = nullptr) - : QWidget(parent) - { - QVBoxLayout *vbox = new QVBoxLayout(this); - TrafficLightWidget *widget = new TrafficLightWidget; - vbox->addWidget(widget); - vbox->setContentsMargins(QMargins()); - - QStateMachine *machine = new QStateMachine(this); - QState *redGoingYellow = createLightState(widget->redLight(), 3000); - redGoingYellow->setObjectName("redGoingYellow"); - QState *yellowGoingGreen = createLightState(widget->yellowLight(), 1000); - yellowGoingGreen->setObjectName("yellowGoingGreen"); - redGoingYellow->addTransition(redGoingYellow, &QState::finished, yellowGoingGreen); - QState *greenGoingYellow = createLightState(widget->greenLight(), 3000); - greenGoingYellow->setObjectName("greenGoingYellow"); - yellowGoingGreen->addTransition(yellowGoingGreen, &QState::finished, greenGoingYellow); - QState *yellowGoingRed = createLightState(widget->yellowLight(), 1000); - yellowGoingRed->setObjectName("yellowGoingRed"); - greenGoingYellow->addTransition(greenGoingYellow, &QState::finished, yellowGoingRed); - yellowGoingRed->addTransition(yellowGoingRed, &QState::finished, redGoingYellow); - - machine->addState(redGoingYellow); - machine->addState(yellowGoingGreen); - machine->addState(greenGoingYellow); - machine->addState(yellowGoingRed); - machine->setInitialState(redGoingYellow); - machine->start(); - } -}; -//! [3] - -//! [4] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - TrafficLight widget; - widget.resize(110, 300); - widget.show(); - - return app.exec(); -} -//! [4] - -#include "main.moc" diff --git a/examples/widgets/statemachine/trafficlight/trafficlight.pro b/examples/widgets/statemachine/trafficlight/trafficlight.pro deleted file mode 100644 index 85d9cda504..0000000000 --- a/examples/widgets/statemachine/trafficlight/trafficlight.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/trafficlight -INSTALLS += target - - diff --git a/examples/widgets/statemachine/twowaybutton/CMakeLists.txt b/examples/widgets/statemachine/twowaybutton/CMakeLists.txt deleted file mode 100644 index 91abfc0db0..0000000000 --- a/examples/widgets/statemachine/twowaybutton/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Generated from twowaybutton.pro. - -cmake_minimum_required(VERSION 3.14) -project(twowaybutton 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/statemachine/twowaybutton") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Widgets) - -add_qt_gui_executable(twowaybutton - main.cpp -) -target_link_libraries(twowaybutton PUBLIC - Qt::Core - Qt::Gui - Qt::Widgets -) - -install(TARGETS twowaybutton - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/widgets/statemachine/twowaybutton/main.cpp b/examples/widgets/statemachine/twowaybutton/main.cpp deleted file mode 100644 index 3d4fef3bbe..0000000000 --- a/examples/widgets/statemachine/twowaybutton/main.cpp +++ /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$ -** -****************************************************************************/ - -#include - -//! [0] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - QPushButton button; - QStateMachine machine; -//! [0] - -//! [1] - QState *off = new QState(); - off->assignProperty(&button, "text", "Off"); - off->setObjectName("off"); - - QState *on = new QState(); - on->setObjectName("on"); - on->assignProperty(&button, "text", "On"); -//! [1] - -//! [2] - off->addTransition(&button, &QAbstractButton::clicked, on); - on->addTransition(&button, &QAbstractButton::clicked, off); -//! [2] - -//! [3] - machine.addState(off); - machine.addState(on); -//! [3] - -//! [4] - machine.setInitialState(off); - machine.start(); -//! [4] - -//! [5] - button.resize(100, 50); - button.show(); - return app.exec(); -} -//! [5] diff --git a/examples/widgets/statemachine/twowaybutton/twowaybutton.pro b/examples/widgets/statemachine/twowaybutton/twowaybutton.pro deleted file mode 100644 index 22d19308ae..0000000000 --- a/examples/widgets/statemachine/twowaybutton/twowaybutton.pro +++ /dev/null @@ -1,9 +0,0 @@ -QT += widgets - -SOURCES = main.cpp - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/twowaybutton -INSTALLS += target - - diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro index 4452414668..2dbbefa141 100644 --- a/examples/widgets/widgets.pro +++ b/examples/widgets/widgets.pro @@ -18,7 +18,6 @@ SUBDIRS = \ painting \ richtext \ scroller \ - statemachine \ tools \ touch \ tutorials \ -- cgit v1.2.3