From 2366667fc97eb6a56203b2dd7dac776ff4164abd Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 22 Apr 2009 14:47:24 +1000 Subject: Initial import of kinetic-dui branch from the old kinetic --- .gitignore | 4 + bin/snapshot | 333 +++ bin/syncqt | 4 + configure | 26 +- configure.exe | Bin 860160 -> 1939968 bytes demos/boxes/boxes.pro | 2 - demos/boxes/glextensions.cpp | 37 - demos/boxes/glextensions.h | 85 - demos/boxes/glshaders.cpp | 266 -- demos/boxes/glshaders.h | 108 - demos/boxes/scene.cpp | 102 +- demos/boxes/scene.h | 11 +- demos/declarative/calculator/CalcButton.qml | 40 + demos/declarative/calculator/calculator.js | 87 + demos/declarative/calculator/calculator.qml | 83 + .../declarative/calculator/pics/button-pressed.png | Bin 0 -> 644 bytes .../declarative/calculator/pics/button-pressed.sci | 5 + demos/declarative/calculator/pics/button.png | Bin 0 -> 635 bytes demos/declarative/calculator/pics/button.sci | 5 + demos/declarative/calculator/pics/clear.png | Bin 0 -> 611 bytes .../mediabrowser/content/LikeOMeter.qml | 13 + .../mediabrowser/content/MediaButton.qml | 21 + .../mediabrowser/content/MovieInfoContainer.qml | 60 + .../mediabrowser/content/MoviesPathView.qml | 74 + .../declarative/mediabrowser/content/ScrollBar.qml | 18 + demos/declarative/mediabrowser/content/Star.qml | 25 + .../mediabrowser/content/pics/background.png | Bin 0 -> 60504 bytes .../mediabrowser/content/pics/button-pressed.png | Bin 0 -> 571 bytes .../mediabrowser/content/pics/button.png | Bin 0 -> 564 bytes .../mediabrowser/content/pics/ghns_star.png | Bin 0 -> 891 bytes .../mediabrowser/content/pics/reflection.png | Bin 0 -> 4839 bytes .../mediabrowser/content/pics/shadow-bottom.png | Bin 0 -> 656 bytes .../mediabrowser/content/pics/shadow-corner.png | Bin 0 -> 405 bytes .../content/pics/shadow-right-screen.png | Bin 0 -> 227 bytes .../mediabrowser/content/pics/shadow-right.png | Bin 0 -> 635 bytes .../mediabrowser/dummydata/MoviesModel.qml | 38 + demos/declarative/mediabrowser/mediabrowser.qml | 36 + demos/declarative/webbrowser/README | 5 + demos/declarative/webbrowser/WebBrowser.qml | 175 ++ .../webbrowser/content/RectSoftShadow.qml | 10 + .../webbrowser/content/pics/addressbar-filled.png | Bin 0 -> 996 bytes .../webbrowser/content/pics/addressbar-filled.sci | 6 + .../webbrowser/content/pics/addressbar.png | Bin 0 -> 867 bytes .../webbrowser/content/pics/addressbar.sci | 6 + .../webbrowser/content/pics/back-disabled.png | Bin 0 -> 1035 bytes demos/declarative/webbrowser/content/pics/back.png | Bin 0 -> 1113 bytes .../declarative/webbrowser/content/pics/footer.png | Bin 0 -> 588 bytes .../declarative/webbrowser/content/pics/footer.sci | 6 + .../webbrowser/content/pics/forward-disabled.png | Bin 0 -> 1044 bytes .../webbrowser/content/pics/forward.png | Bin 0 -> 1120 bytes .../declarative/webbrowser/content/pics/header.png | Bin 0 -> 304 bytes .../declarative/webbrowser/content/pics/reload.png | Bin 0 -> 1709 bytes .../webbrowser/content/pics/softshadow-bottom.png | Bin 0 -> 153 bytes .../webbrowser/content/pics/softshadow-left.png | Bin 0 -> 349 bytes .../webbrowser/content/pics/softshadow-left.sci | 5 + .../webbrowser/content/pics/softshadow-right.png | Bin 0 -> 390 bytes .../webbrowser/content/pics/softshadow-right.sci | 5 + .../webbrowser/content/pics/softshadow-top.png | Bin 0 -> 137 bytes doc/src/animation.qdoc | 365 +++ doc/src/declarative/anchor-layout.qdoc | 68 + doc/src/declarative/animation.qdoc | 130 + doc/src/declarative/basictypes.qdoc | 387 +++ doc/src/declarative/binding.qdoc | 110 + doc/src/declarative/components.qdoc | 74 + doc/src/declarative/cppitem.qdoc | 127 + doc/src/declarative/effects.qdoc | 31 + doc/src/declarative/elements.qdoc | 128 + doc/src/declarative/examples.qdoc | 32 + doc/src/declarative/focus.qdoc | 248 ++ doc/src/declarative/index.qdoc | 51 + doc/src/declarative/measuring-performance.qdoc | 81 + doc/src/declarative/modules.qdoc | 135 + doc/src/declarative/pics/ListViewHighlight.png | Bin 0 -> 3582 bytes doc/src/declarative/pics/ListViewHorizontal.png | Bin 0 -> 2519 bytes doc/src/declarative/pics/ListViewVertical.png | Bin 0 -> 2424 bytes doc/src/declarative/pics/anchors.svg | 92 + doc/src/declarative/pics/animatedimageitem.gif | Bin 0 -> 9997 bytes doc/src/declarative/pics/blur_example.png | Bin 0 -> 64019 bytes doc/src/declarative/pics/declarative-qmlfocus1.png | Bin 0 -> 22047 bytes doc/src/declarative/pics/declarative-qmlfocus2.png | Bin 0 -> 24225 bytes doc/src/declarative/pics/declarative-qmlfocus3.png | Bin 0 -> 26300 bytes doc/src/declarative/pics/declarative-qmlfocus4.png | Bin 0 -> 21401 bytes doc/src/declarative/pics/edge1.png | Bin 0 -> 3423 bytes doc/src/declarative/pics/edge2.png | Bin 0 -> 3436 bytes doc/src/declarative/pics/edge3.png | Bin 0 -> 3854 bytes doc/src/declarative/pics/edge4.png | Bin 0 -> 5152 bytes doc/src/declarative/pics/edges.png | Bin 0 -> 15226 bytes doc/src/declarative/pics/edges.svg | 185 ++ doc/src/declarative/pics/edges_examples.svg | 109 + doc/src/declarative/pics/edges_qml.png | Bin 0 -> 21731 bytes doc/src/declarative/pics/edges_qml.svg | 188 ++ doc/src/declarative/pics/flickable.gif | Bin 0 -> 185221 bytes doc/src/declarative/pics/flipable.gif | Bin 0 -> 80659 bytes doc/src/declarative/pics/gridLayout_example.png | Bin 0 -> 437 bytes doc/src/declarative/pics/gridview.png | Bin 0 -> 1369 bytes doc/src/declarative/pics/highlight.gif | Bin 0 -> 18259 bytes .../declarative/pics/horizontalLayout_example.png | Bin 0 -> 292 bytes doc/src/declarative/pics/layout-add.gif | Bin 0 -> 7821 bytes doc/src/declarative/pics/layout-move.gif | Bin 0 -> 6154 bytes doc/src/declarative/pics/layout-remove.gif | Bin 0 -> 5610 bytes doc/src/declarative/pics/margins_qml.png | Bin 0 -> 18476 bytes doc/src/declarative/pics/margins_qml.svg | 196 ++ doc/src/declarative/pics/particles.gif | Bin 0 -> 163068 bytes doc/src/declarative/pics/pathview.gif | Bin 0 -> 90512 bytes doc/src/declarative/pics/propanim.gif | Bin 0 -> 74909 bytes doc/src/declarative/pics/qtlogo.png | Bin 0 -> 2738 bytes doc/src/declarative/pics/reflection_example.png | Bin 0 -> 30919 bytes doc/src/declarative/pics/scalegrid.svg | 183 ++ doc/src/declarative/pics/shadow_example.png | Bin 0 -> 4775 bytes doc/src/declarative/pics/spacing_a.png | Bin 0 -> 495 bytes doc/src/declarative/pics/spacing_b.png | Bin 0 -> 462 bytes doc/src/declarative/pics/trivialListView.png | Bin 0 -> 2387 bytes .../declarative/pics/verticalLayout_example.png | Bin 0 -> 385 bytes .../declarative/pics/verticalLayout_transition.gif | Bin 0 -> 12641 bytes doc/src/declarative/pics/webview.png | Bin 0 -> 126662 bytes doc/src/declarative/qmlforcpp.qdoc | 999 +++++++ doc/src/declarative/qtprogrammers.qdoc | 121 + doc/src/declarative/scenegraph.qdoc | 13 + doc/src/declarative/tutorial.qdoc | 19 + doc/src/declarative/tutorial1.qdoc | 55 + doc/src/declarative/tutorial2.qdoc | 94 + doc/src/declarative/tutorial3.qdoc | 83 + .../diagrams/programs/easingcurve/easingcurve.pro | 13 + doc/src/diagrams/programs/easingcurve/main.cpp | 90 + doc/src/duiviewer.qdoc | 80 + doc/src/examples.qdoc | 6 + doc/src/examples/trafficlight.qdoc | 58 + doc/src/external-resources.qdoc | 10 + doc/src/groups.qdoc | 23 + doc/src/images/declarative-anchors_example.png | Bin 0 -> 3654 bytes doc/src/images/declarative-anchors_example2.png | Bin 0 -> 3819 bytes doc/src/images/declarative-image_tile.png | Bin 0 -> 396 bytes doc/src/images/declarative-item_opacity1.png | Bin 0 -> 464 bytes doc/src/images/declarative-item_opacity2.png | Bin 0 -> 464 bytes doc/src/images/declarative-item_stacking1.png | Bin 0 -> 460 bytes doc/src/images/declarative-item_stacking2.png | Bin 0 -> 461 bytes doc/src/images/declarative-item_stacking3.png | Bin 0 -> 464 bytes doc/src/images/declarative-item_stacking4.png | Bin 0 -> 463 bytes doc/src/images/declarative-qtlogo1.png | Bin 0 -> 3436 bytes doc/src/images/declarative-qtlogo2.png | Bin 0 -> 11023 bytes doc/src/images/declarative-qtlogo3.png | Bin 0 -> 5848 bytes doc/src/images/declarative-qtlogo4.png | Bin 0 -> 11241 bytes doc/src/images/declarative-rect.png | Bin 0 -> 674 bytes doc/src/images/declarative-rect_gradient.png | Bin 0 -> 873 bytes doc/src/images/declarative-rect_tint.png | Bin 0 -> 363 bytes doc/src/images/declarative-rotation.png | Bin 0 -> 645 bytes doc/src/images/declarative-scale.png | Bin 0 -> 336 bytes doc/src/images/declarative-scalegrid.png | Bin 0 -> 4228 bytes doc/src/images/declarative-text.png | Bin 0 -> 3289 bytes doc/src/images/declarative-textedit.gif | Bin 0 -> 15286 bytes doc/src/images/declarative-textformat.png | Bin 0 -> 11498 bytes doc/src/images/declarative-textstyle.png | Bin 0 -> 6825 bytes doc/src/images/declarative-transformorigin.png | Bin 0 -> 17468 bytes doc/src/images/declarative-tutorial1.png | Bin 0 -> 3416 bytes doc/src/images/declarative-tutorial2.png | Bin 0 -> 3145 bytes doc/src/images/declarative-tutorial3_animation.gif | Bin 0 -> 42486 bytes doc/src/images/qeasingcurve-cosinecurve.png | Bin 0 -> 2544 bytes doc/src/images/qeasingcurve-inback.png | Bin 0 -> 2225 bytes doc/src/images/qeasingcurve-inbounce.png | Bin 0 -> 2378 bytes doc/src/images/qeasingcurve-incirc.png | Bin 0 -> 2138 bytes doc/src/images/qeasingcurve-incubic.png | Bin 0 -> 2230 bytes doc/src/images/qeasingcurve-incurve.png | Bin 0 -> 2325 bytes doc/src/images/qeasingcurve-inelastic.png | Bin 0 -> 2314 bytes doc/src/images/qeasingcurve-inexpo.png | Bin 0 -> 2183 bytes doc/src/images/qeasingcurve-inoutback.png | Bin 0 -> 2460 bytes doc/src/images/qeasingcurve-inoutbounce.png | Bin 0 -> 2522 bytes doc/src/images/qeasingcurve-inoutcirc.png | Bin 0 -> 2352 bytes doc/src/images/qeasingcurve-inoutcubic.png | Bin 0 -> 2410 bytes doc/src/images/qeasingcurve-inoutelastic.png | Bin 0 -> 2485 bytes doc/src/images/qeasingcurve-inoutexpo.png | Bin 0 -> 2383 bytes doc/src/images/qeasingcurve-inoutquad.png | Bin 0 -> 2392 bytes doc/src/images/qeasingcurve-inoutquart.png | Bin 0 -> 2331 bytes doc/src/images/qeasingcurve-inoutquint.png | Bin 0 -> 2244 bytes doc/src/images/qeasingcurve-inoutsine.png | Bin 0 -> 2405 bytes doc/src/images/qeasingcurve-inquad.png | Bin 0 -> 2283 bytes doc/src/images/qeasingcurve-inquart.png | Bin 0 -> 2261 bytes doc/src/images/qeasingcurve-inquint.png | Bin 0 -> 2178 bytes doc/src/images/qeasingcurve-insine.png | Bin 0 -> 2167 bytes doc/src/images/qeasingcurve-linear.png | Bin 0 -> 2165 bytes doc/src/images/qeasingcurve-outback.png | Bin 0 -> 2371 bytes doc/src/images/qeasingcurve-outbounce.png | Bin 0 -> 2481 bytes doc/src/images/qeasingcurve-outcirc.png | Bin 0 -> 2269 bytes doc/src/images/qeasingcurve-outcubic.png | Bin 0 -> 2336 bytes doc/src/images/qeasingcurve-outcurve.png | Bin 0 -> 2389 bytes doc/src/images/qeasingcurve-outelastic.png | Bin 0 -> 2402 bytes doc/src/images/qeasingcurve-outexpo.png | Bin 0 -> 2299 bytes doc/src/images/qeasingcurve-outinback.png | Bin 0 -> 2400 bytes doc/src/images/qeasingcurve-outinbounce.png | Bin 0 -> 2568 bytes doc/src/images/qeasingcurve-outincirc.png | Bin 0 -> 2339 bytes doc/src/images/qeasingcurve-outincubic.png | Bin 0 -> 2393 bytes doc/src/images/qeasingcurve-outinelastic.png | Bin 0 -> 2517 bytes doc/src/images/qeasingcurve-outinexpo.png | Bin 0 -> 2377 bytes doc/src/images/qeasingcurve-outinquad.png | Bin 0 -> 2380 bytes doc/src/images/qeasingcurve-outinquart.png | Bin 0 -> 2319 bytes doc/src/images/qeasingcurve-outinquint.png | Bin 0 -> 2248 bytes doc/src/images/qeasingcurve-outinsine.png | Bin 0 -> 2388 bytes doc/src/images/qeasingcurve-outquad.png | Bin 0 -> 2324 bytes doc/src/images/qeasingcurve-outquart.png | Bin 0 -> 2304 bytes doc/src/images/qeasingcurve-outquint.png | Bin 0 -> 2242 bytes doc/src/images/qeasingcurve-outsine.png | Bin 0 -> 2364 bytes doc/src/images/qeasingcurve-sinecurve.png | Bin 0 -> 2470 bytes doc/src/images/statemachine-button-history.png | Bin 0 -> 91677 bytes doc/src/images/statemachine-button-nested.png | Bin 0 -> 73774 bytes doc/src/images/statemachine-button.png | Bin 0 -> 32767 bytes doc/src/images/statemachine-finished.png | Bin 0 -> 37907 bytes doc/src/images/statemachine-nonparallel.png | Bin 0 -> 68482 bytes doc/src/images/statemachine-parallel.png | Bin 0 -> 99587 bytes doc/src/images/trafficlight-example.png | Bin 0 -> 5325 bytes doc/src/index.qdoc | 1 + .../code/src_corelib_tools_qeasingcurve.cpp | 4 + doc/src/statemachine.qdoc | 272 ++ examples/animation/animatedtiles/animatedtiles.pro | 2 + examples/animation/animatedtiles/animatedtiles.qrc | 11 + .../animatedtiles/images/Time-For-Lunch-2.jpg | Bin 0 -> 32471 bytes .../animation/animatedtiles/images/centered.png | Bin 0 -> 892 bytes .../animation/animatedtiles/images/ellipse.png | Bin 0 -> 10767 bytes .../animation/animatedtiles/images/figure8.png | Bin 0 -> 14050 bytes .../animation/animatedtiles/images/kinetic.png | Bin 0 -> 6776 bytes examples/animation/animatedtiles/images/random.png | Bin 0 -> 14969 bytes examples/animation/animatedtiles/images/tile.png | Bin 0 -> 16337 bytes examples/animation/animatedtiles/main.cpp | 242 ++ examples/animation/animation.pro | 21 + .../appchooser/accessories-dictionary.png | Bin 0 -> 5396 bytes examples/animation/appchooser/akregator.png | Bin 0 -> 4873 bytes examples/animation/appchooser/appchooser.pro | 9 + examples/animation/appchooser/appchooser.qrc | 8 + examples/animation/appchooser/digikam.png | Bin 0 -> 3334 bytes examples/animation/appchooser/k3b.png | Bin 0 -> 8220 bytes examples/animation/appchooser/main.cpp | 124 + examples/animation/easing/animation.h | 75 + examples/animation/easing/easing.pro | 16 + examples/animation/easing/form.ui | 201 ++ examples/animation/easing/images/qt-logo.png | Bin 0 -> 5149 bytes examples/animation/easing/main.cpp | 22 + examples/animation/easing/resources.qrc | 5 + examples/animation/easing/window.cpp | 133 + examples/animation/easing/window.h | 49 + examples/animation/example/example.pro | 12 + examples/animation/example/main.cpp | 23 + examples/animation/example/mainwindow.cpp | 220 ++ examples/animation/example/mainwindow.h | 45 + examples/animation/moveblocks/main.cpp | 274 ++ examples/animation/moveblocks/moveblocks.pro | 8 + examples/animation/padnavigator-ng/backside.ui | 208 ++ .../padnavigator-ng/images/artsfftscope.png | Bin 0 -> 1294 bytes .../padnavigator-ng/images/blue_angle_swirl.jpg | Bin 0 -> 11826 bytes .../padnavigator-ng/images/kontact_contacts.png | Bin 0 -> 4382 bytes .../padnavigator-ng/images/kontact_journal.png | Bin 0 -> 3261 bytes .../padnavigator-ng/images/kontact_mail.png | Bin 0 -> 3202 bytes .../padnavigator-ng/images/kontact_notes.png | Bin 0 -> 3893 bytes .../padnavigator-ng/images/kopeteavailable.png | Bin 0 -> 2380 bytes .../padnavigator-ng/images/metacontact_online.png | Bin 0 -> 2545 bytes .../animation/padnavigator-ng/images/minitools.png | Bin 0 -> 2087 bytes examples/animation/padnavigator-ng/main.cpp | 24 + .../animation/padnavigator-ng/padnavigator.pro | 24 + .../animation/padnavigator-ng/padnavigator.qrc | 14 + examples/animation/padnavigator-ng/panel.cpp | 216 ++ examples/animation/padnavigator-ng/panel.h | 59 + .../animation/padnavigator-ng/roundrectitem.cpp | 106 + examples/animation/padnavigator-ng/roundrectitem.h | 47 + examples/animation/padnavigator-ng/splashitem.cpp | 55 + examples/animation/padnavigator-ng/splashitem.h | 31 + examples/animation/photobrowser/main.cpp | 52 + examples/animation/photobrowser/menu.cpp | 125 + examples/animation/photobrowser/menu.h | 50 + examples/animation/photobrowser/photobrowser.pro | 17 + examples/animation/photobrowser/river.cpp | 561 ++++ examples/animation/photobrowser/river.h | 81 + examples/animation/photobrowser/riveritem.cpp | 95 + examples/animation/photobrowser/riveritem.h | 36 + examples/animation/piemenu/main.cpp | 26 + examples/animation/piemenu/piemenu.pro | 8 + examples/animation/piemenu/qgraphicspiemenu.cpp | 220 ++ examples/animation/piemenu/qgraphicspiemenu.h | 74 + examples/animation/piemenu/qgraphicspiemenu_p.h | 48 + .../animation/piemenu/qgraphicspiemenusection_p.h | 58 + examples/animation/piemenu/scene.cpp | 43 + examples/animation/piemenu/scene.h | 30 + .../animation/research/memberfunctions/main.cpp | 48 + .../research/memberfunctions/memberfunctions.pro | 16 + .../research/memberfunctions/qvalueanimation.cpp | 73 + .../research/memberfunctions/qvalueanimation.h | 89 + .../research/memberfunctions/qvalueanimation_p.h | 47 + .../animation/research/propertytransform/main.cpp | 47 + .../propertytransform/propertytransform.pro | 14 + .../propertytransform/qpropertytransform.h | 78 + examples/animation/research/sound/main.cpp | 74 + examples/animation/research/sound/media/sax.mp3 | Bin 0 -> 417844 bytes examples/animation/research/sound/sound.pro | 14 + examples/animation/research/sound/sound.qrc | 5 + .../animation/states/accessories-dictionary.png | Bin 0 -> 5396 bytes examples/animation/states/akregator.png | Bin 0 -> 4873 bytes examples/animation/states/digikam.png | Bin 0 -> 3334 bytes examples/animation/states/help-browser.png | Bin 0 -> 6984 bytes examples/animation/states/k3b.png | Bin 0 -> 8220 bytes examples/animation/states/kchart.png | Bin 0 -> 4887 bytes examples/animation/states/main.cpp | 259 ++ examples/animation/states/states.pro | 8 + examples/animation/states/states.qrc | 10 + examples/animation/stickman/animation.cpp | 152 ++ examples/animation/stickman/animation.h | 40 + examples/animation/stickman/animations/chilling | Bin 0 -> 6508 bytes examples/animation/stickman/animations/dancing | Bin 0 -> 2348 bytes examples/animation/stickman/animations/dead | Bin 0 -> 268 bytes examples/animation/stickman/animations/jumping | Bin 0 -> 1308 bytes examples/animation/stickman/graphicsview.cpp | 15 + examples/animation/stickman/graphicsview.h | 19 + examples/animation/stickman/lifecycle.cpp | 176 ++ examples/animation/stickman/lifecycle.h | 40 + examples/animation/stickman/main.cpp | 58 + examples/animation/stickman/node.cpp | 42 + examples/animation/stickman/node.h | 26 + examples/animation/stickman/stickman.cpp | 299 +++ examples/animation/stickman/stickman.h | 59 + examples/animation/stickman/stickman.pro | 12 + examples/animation/sub-attaq/animationmanager.cpp | 97 + examples/animation/sub-attaq/animationmanager.h | 68 + examples/animation/sub-attaq/boat.cpp | 293 ++ examples/animation/sub-attaq/boat.h | 100 + examples/animation/sub-attaq/boat_p.h | 258 ++ examples/animation/sub-attaq/bomb.cpp | 132 + examples/animation/sub-attaq/bomb.h | 81 + .../sub-attaq/custompropertyanimation.cpp | 114 + .../animation/sub-attaq/custompropertyanimation.h | 117 + .../sub-attaq/custompropertyanimation_p.h | 64 + examples/animation/sub-attaq/data.xml | 15 + examples/animation/sub-attaq/graphicsscene.cpp | 368 +++ examples/animation/sub-attaq/graphicsscene.h | 129 + examples/animation/sub-attaq/main.cpp | 57 + examples/animation/sub-attaq/mainwindow.cpp | 92 + examples/animation/sub-attaq/mainwindow.h | 63 + .../animation/sub-attaq/pics/big/background.png | Bin 0 -> 48858 bytes examples/animation/sub-attaq/pics/big/boat.png | Bin 0 -> 5198 bytes examples/animation/sub-attaq/pics/big/bomb.png | Bin 0 -> 760 bytes .../sub-attaq/pics/big/explosion/boat/step1.png | Bin 0 -> 5760 bytes .../sub-attaq/pics/big/explosion/boat/step2.png | Bin 0 -> 9976 bytes .../sub-attaq/pics/big/explosion/boat/step3.png | Bin 0 -> 12411 bytes .../sub-attaq/pics/big/explosion/boat/step4.png | Bin 0 -> 15438 bytes .../pics/big/explosion/submarine/step1.png | Bin 0 -> 3354 bytes .../pics/big/explosion/submarine/step2.png | Bin 0 -> 6205 bytes .../pics/big/explosion/submarine/step3.png | Bin 0 -> 6678 bytes .../pics/big/explosion/submarine/step4.png | Bin 0 -> 6666 bytes .../animation/sub-attaq/pics/big/submarine.png | Bin 0 -> 3202 bytes examples/animation/sub-attaq/pics/big/surface.png | Bin 0 -> 575 bytes examples/animation/sub-attaq/pics/big/torpedo.png | Bin 0 -> 951 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 + examples/animation/sub-attaq/pics/scalable/see.svg | 44 + examples/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 0 -> 34634 bytes examples/animation/sub-attaq/pics/small/boat.png | Bin 0 -> 2394 bytes examples/animation/sub-attaq/pics/small/bomb.png | Bin 0 -> 760 bytes .../animation/sub-attaq/pics/small/submarine.png | Bin 0 -> 1338 bytes .../animation/sub-attaq/pics/small/surface.png | Bin 0 -> 502 bytes .../animation/sub-attaq/pics/small/torpedo.png | Bin 0 -> 951 bytes .../animation/sub-attaq/pics/welcome/logo-a.png | Bin 0 -> 5972 bytes .../animation/sub-attaq/pics/welcome/logo-a2.png | Bin 0 -> 5969 bytes .../animation/sub-attaq/pics/welcome/logo-b.png | Bin 0 -> 6869 bytes .../animation/sub-attaq/pics/welcome/logo-dash.png | Bin 0 -> 2255 bytes .../animation/sub-attaq/pics/welcome/logo-excl.png | Bin 0 -> 2740 bytes .../animation/sub-attaq/pics/welcome/logo-q.png | Bin 0 -> 7016 bytes .../animation/sub-attaq/pics/welcome/logo-s.png | Bin 0 -> 5817 bytes .../animation/sub-attaq/pics/welcome/logo-t.png | Bin 0 -> 3717 bytes .../animation/sub-attaq/pics/welcome/logo-t2.png | Bin 0 -> 3688 bytes .../animation/sub-attaq/pics/welcome/logo-u.png | Bin 0 -> 5374 bytes examples/animation/sub-attaq/pixmapitem.cpp | 59 + examples/animation/sub-attaq/pixmapitem.h | 63 + examples/animation/sub-attaq/states.cpp | 289 ++ examples/animation/sub-attaq/states.h | 158 ++ examples/animation/sub-attaq/sub-attaq.pro | 36 + examples/animation/sub-attaq/subattaq.qrc | 38 + examples/animation/sub-attaq/submarine.cpp | 219 ++ examples/animation/sub-attaq/submarine.h | 97 + examples/animation/sub-attaq/submarine_p.h | 136 + examples/animation/sub-attaq/torpedo.cpp | 126 + examples/animation/sub-attaq/torpedo.h | 81 + examples/declarative/animation/animation.qml | 28 + examples/declarative/behaviours/MyRect.qml | 4 + examples/declarative/behaviours/test.qml | 37 + examples/declarative/connections/connections.qml | 9 + examples/declarative/contacts/contacts.pro | 22 + examples/declarative/contacts/contacts.qml | 44 + .../contacts/dummydata/contactModel.qml | 103 + examples/declarative/contacts/main.cpp | 80 + examples/declarative/declarative.pro | 4 + examples/declarative/dial/DialLibrary/Dial.qml | 13 + .../declarative/dial/DialLibrary/background.svg | 385 +++ examples/declarative/dial/DialLibrary/needle.svg | 26 + .../declarative/dial/DialLibrary/needle_shadow.svg | 30 + examples/declarative/dial/DialLibrary/overlay.svg | 47 + examples/declarative/dial/dial.qml | 14 + examples/declarative/easing/easing.qml | 67 + examples/declarative/follow/follow.qml | 35 + examples/declarative/follow/pong.qml | 55 + .../declarative/listview/content/MediaButton.qml | 21 + .../listview/content/pics/button-pressed.png | Bin 0 -> 571 bytes .../declarative/listview/content/pics/button.png | Bin 0 -> 564 bytes .../listview/content/pics/fruit-salad.jpg | Bin 0 -> 17952 bytes .../listview/content/pics/hamburger.jpg | Bin 0 -> 8572 bytes .../declarative/listview/content/pics/lemonade.jpg | Bin 0 -> 6645 bytes .../declarative/listview/content/pics/pancakes.jpg | Bin 0 -> 9163 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 0 -> 8639 bytes .../declarative/listview/dummydata/MyPetsModel.qml | 51 + .../declarative/listview/dummydata/Recipies.qml | 112 + examples/declarative/listview/highlight.qml | 56 + examples/declarative/listview/listview.qml | 81 + examples/declarative/listview/recipes.qml | 83 + examples/declarative/minehunt/Description.qml | 10 + examples/declarative/minehunt/Explosion.qml | 6 + examples/declarative/minehunt/main.cpp | 312 +++ examples/declarative/minehunt/minehunt.pro | 8 + examples/declarative/minehunt/minehunt.qml | 73 + .../minehunt/pics/No-Ones-Laughing-3.jpg | Bin 0 -> 30730 bytes examples/declarative/minehunt/pics/bomb-color.png | Bin 0 -> 284 bytes examples/declarative/minehunt/pics/bomb.png | Bin 0 -> 535 bytes .../declarative/minehunt/pics/cachepix-black.png | Bin 0 -> 1658 bytes .../declarative/minehunt/pics/cachepix-black.sci | 5 + .../declarative/minehunt/pics/cachepix-boxless.png | Bin 0 -> 1819 bytes .../declarative/minehunt/pics/cachepix-boxless.sci | 5 + examples/declarative/minehunt/pics/flag-color.png | Bin 0 -> 219 bytes examples/declarative/minehunt/pics/flag.png | Bin 0 -> 196 bytes examples/declarative/minehunt/pics/frown.png | Bin 0 -> 1036 bytes examples/declarative/minehunt/pics/glee.png | Bin 0 -> 1082 bytes examples/declarative/minehunt/pics/smile.png | Bin 0 -> 1028 bytes examples/declarative/minehunt/pics/star.png | Bin 0 -> 2677 bytes examples/declarative/mouseregion/mouse.qml | 24 + examples/declarative/namespaces/BlueStuff/Rect.qml | 1 + examples/declarative/namespaces/Local.qml | 1 + examples/declarative/namespaces/components.qml | 17 + .../declarative/namespaces/lib/Chronos/Clock.qml | 15 + .../declarative/namespaces/lib/Chronos/Hand.qml | 9 + .../namespaces/lib/Chronos/pics/clockface.png | Bin 0 -> 46895 bytes .../declarative/namespaces/lib/Path/PathLabel.qml | 1 + .../declarative/namespaces/lib/RedStuff/Rect.qml | 1 + .../declarative/namespaces/lib/Wrong/Wrong.qml | 3 + examples/declarative/namespaces/library.qml | 12 + examples/declarative/namespaces/path.qml | 18 + examples/declarative/namespaces/simple.qml | 5 + examples/declarative/namespaces/wrong1.qml | 4 + examples/declarative/scrollbar/ScrollBar.qml | 26 + examples/declarative/scrollbar/display.qml | 28 + .../declarative/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 604121 bytes examples/declarative/slideswitch/Switch.qml | 52 + examples/declarative/slideswitch/background.svg | 23 + examples/declarative/slideswitch/display.qml | 3 + examples/declarative/slideswitch/knob.svg | 867 ++++++ examples/declarative/states/states.qml | 40 + examples/declarative/states/transitions.qml | 68 + examples/declarative/support/contact.cpp | 83 + examples/declarative/support/contact.h | 141 + examples/declarative/support/contactmodel.cpp | 159 ++ examples/declarative/support/contactmodel.h | 55 + examples/declarative/support/support.pro | 12 + .../1_Drawing_an_animation.qml | 22 + .../1_Drawing_and_Animation/RemoveButton1.qml | 4 + .../1_Drawing_and_Animation/RemoveButton2.qml | 10 + .../1_Drawing_and_Animation/RemoveButton3.qml | 23 + .../1_Drawing_and_Animation/RemoveButton4.qml | 65 + .../1_Drawing_and_Animation/RemoveButton5.qml | 70 + .../tutorials/contacts/2_Reuse/2_Reuse.qml | 34 + .../tutorials/contacts/2_Reuse/Contact3.qml | 27 + .../tutorials/contacts/2_Reuse/Contact4.qml | 27 + .../tutorials/contacts/2_Reuse/ContactField1.qml | 17 + .../tutorials/contacts/2_Reuse/ContactField2.qml | 19 + .../tutorials/contacts/2_Reuse/ContactField3.qml | 35 + .../tutorials/contacts/2_Reuse/ContactField4.qml | 35 + .../tutorials/contacts/2_Reuse/FieldText3.qml | 93 + .../tutorials/contacts/2_Reuse/FieldText4.qml | 98 + .../tutorials/contacts/2_Reuse/RemoveButton1.qml | 70 + .../tutorials/contacts/2_Reuse/RemoveButton2.qml | 76 + .../tutorials/contacts/2_Reuse/RemoveButton3.qml | 76 + .../tutorials/contacts/2_Reuse/RemoveButton4.qml | 80 + .../contacts/3_Collections/3_Collections.qml | 8 + .../tutorials/contacts/3_Collections/Button.qml | 38 + .../tutorials/contacts/3_Collections/Contact.qml | 28 + .../contacts/3_Collections/ContactField.qml | 35 + .../contacts/3_Collections/ContactView1.qml | 22 + .../contacts/3_Collections/ContactView2.qml | 62 + .../contacts/3_Collections/ContactView3.qml | 67 + .../tutorials/contacts/3_Collections/FieldText.qml | 98 + .../contacts/3_Collections/RemoveButton.qml | 80 + .../tutorials/contacts/shared/contacts.sqlite | Bin 0 -> 12288 bytes .../tutorials/contacts/shared/pics/cancel.png | Bin 0 -> 1038 bytes .../tutorials/contacts/shared/pics/email.png | Bin 0 -> 977 bytes .../tutorials/contacts/shared/pics/new.png | Bin 0 -> 688 bytes .../tutorials/contacts/shared/pics/ok.png | Bin 0 -> 655 bytes .../tutorials/contacts/shared/pics/phone.png | Bin 0 -> 624 bytes .../tutorials/contacts/shared/pics/search.png | Bin 0 -> 635 bytes .../tutorials/contacts/shared/pics/trash.png | Bin 0 -> 989 bytes .../declarative/tutorials/contacts/t8/Button.qml | 33 + .../declarative/tutorials/contacts/t8/Contact.qml | 80 + .../declarative/tutorials/contacts/t8/Field.qml | 54 + .../tutorials/contacts/t8/FieldRemover.qml | 57 + .../tutorials/contacts/t8/FieldText.qml | 89 + .../tutorials/contacts/t8/SearchBar.qml | 16 + .../declarative/tutorials/contacts/t8/contacts.qml | 133 + examples/declarative/tutorials/t1/tutorial1.qml | 3 + examples/declarative/tutorials/t2/Cell.qml | 7 + examples/declarative/tutorials/t2/tutorial2.qml | 11 + examples/declarative/tutorials/t3/Cell.qml | 7 + examples/declarative/tutorials/t3/tutorial3.qml | 27 + examples/declarative/velocity/Day.qml | 41 + examples/declarative/velocity/cork.jpg | Bin 0 -> 88766 bytes examples/declarative/velocity/sticky.png | Bin 0 -> 15319 bytes examples/declarative/velocity/tack.png | Bin 0 -> 7282 bytes examples/declarative/velocity/velocity.qml | 81 + examples/declarative/webview/autosize.qml | 42 + .../declarative/webview/content/SpinSquare.qml | 12 + examples/declarative/webview/inline-html.qml | 13 + examples/declarative/webview/inline-xhtml.qml | 14 + examples/declarative/webview/qml-in-html.qml | 20 + examples/declarative/webview/transparent.qml | 6 + examples/declarative/xmldata/daringfireball.qml | 25 + examples/declarative/xmldata/yahoonews.qml | 38 + examples/examples.pro | 3 + examples/opengl/hellogl_es2/glwidget.cpp | 391 +-- examples/opengl/hellogl_es2/glwidget.h | 31 +- examples/statemachine/README | 36 + .../statemachine/citizenquartz/citizenquartz.pro | 20 + .../statemachine/citizenquartz/citizenquartz.qrc | 5 + examples/statemachine/citizenquartz/clock.cpp | 382 +++ examples/statemachine/citizenquartz/clock.h | 60 + .../statemachine/citizenquartz/clockbutton.cpp | 39 + examples/statemachine/citizenquartz/clockbutton.h | 25 + .../statemachine/citizenquartz/clockdisplay.cpp | 140 + examples/statemachine/citizenquartz/clockdisplay.h | 75 + .../statemachine/citizenquartz/images/alarm.png | Bin 0 -> 434 bytes examples/statemachine/citizenquartz/main.cpp | 23 + .../citizenquartz/propertyaddstate.cpp | 46 + .../statemachine/citizenquartz/propertyaddstate.h | 33 + .../statemachine/citizenquartz/sound/alarm.wav | Bin 0 -> 3238264 bytes examples/statemachine/citizenquartz/timeperiod.h | 84 + .../statemachine/clockticking/clockticking.pro | 10 + examples/statemachine/clockticking/main.cpp | 101 + examples/statemachine/composition/composition.pro | 7 + examples/statemachine/composition/main.cpp | 74 + .../eventtransitions/eventtransitions.pro | 7 + examples/statemachine/eventtransitions/main.cpp | 72 + examples/statemachine/factorial/factorial.pro | 10 + examples/statemachine/factorial/main.cpp | 140 + examples/statemachine/helloworld/helloworld.pro | 10 + examples/statemachine/helloworld/main.cpp | 48 + examples/statemachine/pauseandresume/main.cpp | 72 + .../statemachine/pauseandresume/pauseandresume.pro | 7 + examples/statemachine/pingpong/main.cpp | 112 + examples/statemachine/pingpong/pingpong.pro | 10 + examples/statemachine/statemachine.pro | 17 + examples/statemachine/trafficlight/main.cpp | 158 ++ .../statemachine/trafficlight/trafficlight.pro | 12 + examples/statemachine/twowaybutton/main.cpp | 48 + .../statemachine/twowaybutton/twowaybutton.pro | 7 + mkspecs/features/qt.prf | 4 +- mkspecs/linux-g++-x11egl/qmake.conf | 23 + mkspecs/linux-g++-x11egl/qplatformdefs.h | 134 + mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf | 20 + mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h | 42 + mkspecs/win32-icc/qmake.conf | 2 +- src/3rdparty/easing/easing.cpp | 669 +++++ src/3rdparty/easing/legal.qdoc | 35 + src/corelib/animation/animation.pri | 25 + src/corelib/animation/qabstractanimation.cpp | 757 ++++++ src/corelib/animation/qabstractanimation.h | 141 + src/corelib/animation/qabstractanimation_p.h | 141 + src/corelib/animation/qanimationgroup.cpp | 274 ++ src/corelib/animation/qanimationgroup.h | 92 + src/corelib/animation/qanimationgroup_p.h | 79 + src/corelib/animation/qparallelanimationgroup.cpp | 298 +++ src/corelib/animation/qparallelanimationgroup.h | 90 + src/corelib/animation/qparallelanimationgroup_p.h | 85 + src/corelib/animation/qpauseanimation.cpp | 139 + src/corelib/animation/qpauseanimation.h | 88 + src/corelib/animation/qpropertyanimation.cpp | 256 ++ src/corelib/animation/qpropertyanimation.h | 94 + src/corelib/animation/qpropertyanimation_p.h | 89 + .../animation/qsequentialanimationgroup.cpp | 572 ++++ src/corelib/animation/qsequentialanimationgroup.h | 100 + .../animation/qsequentialanimationgroup_p.h | 111 + src/corelib/animation/qvariantanimation.cpp | 599 +++++ src/corelib/animation/qvariantanimation.h | 136 + src/corelib/animation/qvariantanimation_p.h | 143 + src/corelib/arch/qatomic_bootstrap.h | 14 + src/corelib/corelib.pro | 2 + src/corelib/global/qglobal.h | 29 + src/corelib/kernel/kernel.pri | 18 +- src/corelib/kernel/qabstractitemmodel.cpp | 31 + src/corelib/kernel/qabstractitemmodel.h | 3 + src/corelib/kernel/qabstractitemmodel_p.h | 5 +- src/corelib/kernel/qcoreevent.h | 9 +- src/corelib/kernel/qmetaobject.cpp | 89 +- src/corelib/kernel/qmetaobject.h | 3 + src/corelib/kernel/qmetaobjectbuilder.cpp | 2438 +++++++++++++++++ src/corelib/kernel/qmetaobjectbuilder_p.h | 269 ++ src/corelib/kernel/qobject.cpp | 9 +- src/corelib/kernel/qobject.h | 11 + src/corelib/kernel/qobject_p.h | 8 + src/corelib/kernel/qobjectdefs.h | 4 + src/corelib/kernel/qvariant_p.h | 34 +- src/corelib/statemachine/qabstractstate.cpp | 155 ++ src/corelib/statemachine/qabstractstate.h | 57 + src/corelib/statemachine/qabstractstate_p.h | 64 + src/corelib/statemachine/qabstracttransition.cpp | 281 ++ src/corelib/statemachine/qabstracttransition.h | 69 + src/corelib/statemachine/qabstracttransition_p.h | 65 + src/corelib/statemachine/qactionstate.cpp | 385 +++ src/corelib/statemachine/qactionstate.h | 85 + src/corelib/statemachine/qactionstate_p.h | 55 + src/corelib/statemachine/qanimationstate.cpp | 574 ++++ src/corelib/statemachine/qanimationstate.h | 63 + src/corelib/statemachine/qboundevent_p.h | 52 + src/corelib/statemachine/qeventtransition.cpp | 263 ++ src/corelib/statemachine/qeventtransition.h | 68 + src/corelib/statemachine/qeventtransition_p.h | 48 + src/corelib/statemachine/qfinalstate.cpp | 103 + src/corelib/statemachine/qfinalstate.h | 50 + src/corelib/statemachine/qhistorystate.cpp | 145 + src/corelib/statemachine/qhistorystate.h | 56 + src/corelib/statemachine/qhistorystate_p.h | 53 + src/corelib/statemachine/qsignalevent.h | 45 + src/corelib/statemachine/qsignaleventgenerator_p.h | 55 + src/corelib/statemachine/qsignaltransition.cpp | 228 ++ src/corelib/statemachine/qsignaltransition.h | 63 + src/corelib/statemachine/qsignaltransition_p.h | 48 + src/corelib/statemachine/qstate.cpp | 469 ++++ src/corelib/statemachine/qstate.h | 94 + src/corelib/statemachine/qstate_p.h | 54 + src/corelib/statemachine/qstateaction.cpp | 469 ++++ src/corelib/statemachine/qstateaction.h | 121 + src/corelib/statemachine/qstateaction_p.h | 92 + src/corelib/statemachine/qstatefinishedevent.h | 40 + .../statemachine/qstatefinishedtransition.cpp | 152 ++ .../statemachine/qstatefinishedtransition.h | 58 + src/corelib/statemachine/qstatemachine.cpp | 1847 +++++++++++++ src/corelib/statemachine/qstatemachine.h | 116 + src/corelib/statemachine/qstatemachine_p.h | 175 ++ src/corelib/statemachine/qtransition.cpp | 230 ++ src/corelib/statemachine/qtransition.h | 68 + src/corelib/statemachine/qtransition_p.h | 50 + src/corelib/statemachine/statemachine.pri | 47 + src/corelib/tools/qeasingcurve.cpp | 844 ++++++ src/corelib/tools/qeasingcurve.h | 114 + src/corelib/tools/qtimeline.cpp | 114 +- src/corelib/tools/qtimeline.h | 7 + src/corelib/tools/tools.pri | 2 + src/declarative/3rdparty/3rdparty.pri | 2 + src/declarative/3rdparty/easing.cpp | 726 +++++ src/declarative/3rdparty/legal.qdoc | 35 + src/declarative/3rdparty/qlistmodelinterface.h | 122 + src/declarative/canvas/canvas.pri | 19 + src/declarative/canvas/qsimplecanvas.cpp | 981 +++++++ src/declarative/canvas/qsimplecanvas.h | 187 ++ .../canvas/qsimplecanvas_graphicsview.cpp | 180 ++ src/declarative/canvas/qsimplecanvas_opengl.cpp | 456 ++++ src/declarative/canvas/qsimplecanvas_opengl1.cpp | 401 +++ src/declarative/canvas/qsimplecanvas_p.h | 196 ++ src/declarative/canvas/qsimplecanvas_software.cpp | 190 ++ src/declarative/canvas/qsimplecanvasfilter.cpp | 323 +++ src/declarative/canvas/qsimplecanvasfilter.h | 113 + src/declarative/canvas/qsimplecanvasfilter_p.h | 70 + src/declarative/canvas/qsimplecanvasitem.cpp | 1841 +++++++++++++ src/declarative/canvas/qsimplecanvasitem.h | 300 +++ src/declarative/canvas/qsimplecanvasitem_p.h | 242 ++ src/declarative/canvas/qsimplecanvasserver.cpp | 107 + src/declarative/canvas/qsimplecanvasserver_p.h | 71 + src/declarative/declarative.pro | 25 + src/declarative/extra/extra.pri | 24 + src/declarative/extra/qfxintegermodel.cpp | 126 + src/declarative/extra/qfxintegermodel.h | 86 + src/declarative/extra/qmlnumberformatter.cpp | 214 ++ src/declarative/extra/qmlnumberformatter.h | 92 + src/declarative/extra/qmlsqlconnection.cpp | 441 +++ src/declarative/extra/qmlsqlconnection.h | 117 + src/declarative/extra/qmlsqlquery.cpp | 696 +++++ src/declarative/extra/qmlsqlquery.h | 143 + src/declarative/extra/qmlxmllistmodel.cpp | 357 +++ src/declarative/extra/qmlxmllistmodel.h | 139 + src/declarative/extra/qnumberformat.cpp | 224 ++ src/declarative/extra/qnumberformat.h | 172 ++ src/declarative/fx/fx.pri | 94 + src/declarative/fx/qfxanchors.cpp | 857 ++++++ src/declarative/fx/qfxanchors.h | 194 ++ src/declarative/fx/qfxanchors_p.h | 105 + src/declarative/fx/qfxanimatedimageitem.cpp | 211 ++ src/declarative/fx/qfxanimatedimageitem.h | 100 + src/declarative/fx/qfxanimatedimageitem_p.h | 77 + src/declarative/fx/qfxblendedimage.cpp | 249 ++ src/declarative/fx/qfxblendedimage.h | 105 + src/declarative/fx/qfxblurfilter.cpp | 462 ++++ src/declarative/fx/qfxblurfilter.h | 82 + src/declarative/fx/qfxcomponentinstance.cpp | 132 + src/declarative/fx/qfxcomponentinstance.h | 89 + src/declarative/fx/qfxcomponentinstance_p.h | 76 + src/declarative/fx/qfxcontentwrapper.cpp | 129 + src/declarative/fx/qfxcontentwrapper.h | 90 + src/declarative/fx/qfxcontentwrapper_p.h | 71 + src/declarative/fx/qfxflickable.cpp | 1113 ++++++++ src/declarative/fx/qfxflickable.h | 195 ++ src/declarative/fx/qfxflickable_p.h | 166 ++ src/declarative/fx/qfxfocuspanel.cpp | 104 + src/declarative/fx/qfxfocuspanel.h | 81 + src/declarative/fx/qfxfocusrealm.cpp | 72 + src/declarative/fx/qfxfocusrealm.h | 67 + src/declarative/fx/qfxgridview.cpp | 1469 ++++++++++ src/declarative/fx/qfxgridview.h | 148 ++ src/declarative/fx/qfxhighlightfilter.cpp | 315 +++ src/declarative/fx/qfxhighlightfilter.h | 98 + src/declarative/fx/qfximage.cpp | 935 +++++++ src/declarative/fx/qfximage.h | 124 + src/declarative/fx/qfximage_p.h | 117 + src/declarative/fx/qfximageitem.cpp | 343 +++ src/declarative/fx/qfximageitem.h | 100 + src/declarative/fx/qfximageitem_p.h | 95 + src/declarative/fx/qfxitem.cpp | 1751 ++++++++++++ src/declarative/fx/qfxitem.h | 285 ++ src/declarative/fx/qfxitem_p.h | 182 ++ src/declarative/fx/qfxkeyactions.cpp | 930 +++++++ src/declarative/fx/qfxkeyactions.h | 319 +++ src/declarative/fx/qfxkeyproxy.cpp | 116 + src/declarative/fx/qfxkeyproxy.h | 78 + src/declarative/fx/qfxlayouts.cpp | 1027 +++++++ src/declarative/fx/qfxlayouts.h | 171 ++ src/declarative/fx/qfxlayouts_p.h | 100 + src/declarative/fx/qfxlistview.cpp | 1680 ++++++++++++ src/declarative/fx/qfxlistview.h | 157 ++ src/declarative/fx/qfxmouseregion.cpp | 589 ++++ src/declarative/fx/qfxmouseregion.h | 162 ++ src/declarative/fx/qfxmouseregion_p.h | 101 + src/declarative/fx/qfxpainted.cpp | 193 ++ src/declarative/fx/qfxpainted.h | 84 + src/declarative/fx/qfxpainted_p.h | 84 + src/declarative/fx/qfxparticles.cpp | 1063 ++++++++ src/declarative/fx/qfxparticles.h | 240 ++ src/declarative/fx/qfxpath.cpp | 745 ++++++ src/declarative/fx/qfxpath.h | 257 ++ src/declarative/fx/qfxpath_p.h | 79 + src/declarative/fx/qfxpathview.cpp | 841 ++++++ src/declarative/fx/qfxpathview.h | 132 + src/declarative/fx/qfxpathview_p.h | 132 + src/declarative/fx/qfxpixmap.cpp | 284 ++ src/declarative/fx/qfxpixmap.h | 92 + src/declarative/fx/qfxrect.cpp | 851 ++++++ src/declarative/fx/qfxrect.h | 140 + src/declarative/fx/qfxrect_p.h | 107 + src/declarative/fx/qfxreflectionfilter.cpp | 358 +++ src/declarative/fx/qfxreflectionfilter.h | 96 + src/declarative/fx/qfxrepeater.cpp | 354 +++ src/declarative/fx/qfxrepeater.h | 88 + src/declarative/fx/qfxrepeater_p.h | 81 + src/declarative/fx/qfxscalegrid.cpp | 216 ++ src/declarative/fx/qfxscalegrid.h | 120 + src/declarative/fx/qfxshadowfilter.cpp | 202 ++ src/declarative/fx/qfxshadowfilter.h | 86 + src/declarative/fx/qfxtext.cpp | 958 +++++++ src/declarative/fx/qfxtext.h | 153 ++ src/declarative/fx/qfxtext_p.h | 132 + src/declarative/fx/qfxtextedit.cpp | 804 ++++++ src/declarative/fx/qfxtextedit.h | 187 ++ src/declarative/fx/qfxtextedit_p.h | 102 + src/declarative/fx/qfxtransform.cpp | 661 +++++ src/declarative/fx/qfxtransform.h | 274 ++ src/declarative/fx/qfxvisualitemmodel.cpp | 690 +++++ src/declarative/fx/qfxvisualitemmodel.h | 120 + src/declarative/fx/qfxwebview.cpp | 1079 ++++++++ src/declarative/fx/qfxwebview.h | 217 ++ src/declarative/fx/qfxwidgetcontainer.cpp | 108 + src/declarative/fx/qfxwidgetcontainer.h | 79 + src/declarative/opengl/glbasicshaders.cpp | 707 +++++ src/declarative/opengl/glbasicshaders.h | 244 ++ src/declarative/opengl/glheaders.h | 49 + src/declarative/opengl/glsave.cpp | 1 + src/declarative/opengl/glsave.h | 111 + src/declarative/opengl/gltexture.cpp | 321 +++ src/declarative/opengl/gltexture.h | 116 + src/declarative/opengl/opengl.pri | 20 + src/declarative/qml/qml.h | 98 + src/declarative/qml/qml.pri | 63 + src/declarative/qml/qmlbindablevalue.cpp | 210 ++ src/declarative/qml/qmlbindablevalue.h | 94 + src/declarative/qml/qmlboundsignal.cpp | 158 ++ src/declarative/qml/qmlboundsignal_p.h | 104 + src/declarative/qml/qmlclassfactory.cpp | 47 + src/declarative/qml/qmlclassfactory_p.h | 63 + src/declarative/qml/qmlcompiledcomponent.cpp | 170 ++ src/declarative/qml/qmlcompiledcomponent_p.h | 80 + src/declarative/qml/qmlcompiler.cpp | 1662 ++++++++++++ src/declarative/qml/qmlcompiler_p.h | 183 ++ src/declarative/qml/qmlcomponent.cpp | 405 +++ src/declarative/qml/qmlcomponent.h | 102 + src/declarative/qml/qmlcomponent_p.h | 85 + src/declarative/qml/qmlcompositetypemanager.cpp | 359 +++ src/declarative/qml/qmlcompositetypemanager_p.h | 144 + src/declarative/qml/qmlcontext.cpp | 405 +++ src/declarative/qml/qmlcontext.h | 104 + src/declarative/qml/qmlcontext_p.h | 87 + src/declarative/qml/qmlcustomparser.cpp | 96 + src/declarative/qml/qmlcustomparser.h | 82 + src/declarative/qml/qmldom.cpp | 1372 ++++++++++ src/declarative/qml/qmldom.h | 263 ++ src/declarative/qml/qmldom_p.h | 116 + src/declarative/qml/qmlengine.cpp | 1295 +++++++++ src/declarative/qml/qmlengine.h | 107 + src/declarative/qml/qmlengine_p.h | 215 ++ src/declarative/qml/qmlexpression.h | 115 + src/declarative/qml/qmlinfo.cpp | 97 + src/declarative/qml/qmlinfo.h | 69 + src/declarative/qml/qmlinstruction.cpp | 214 ++ src/declarative/qml/qmlinstruction_p.h | 299 +++ src/declarative/qml/qmllist.h | 125 + src/declarative/qml/qmlmetaproperty.cpp | 847 ++++++ src/declarative/qml/qmlmetaproperty.h | 137 + src/declarative/qml/qmlmetaproperty_p.h | 75 + src/declarative/qml/qmlmetatype.cpp | 1164 ++++++++ src/declarative/qml/qmlmetatype.h | 258 ++ src/declarative/qml/qmlparser.cpp | 167 ++ src/declarative/qml/qmlparser_p.h | 209 ++ src/declarative/qml/qmlparserstatus.cpp | 75 + src/declarative/qml/qmlparserstatus.h | 69 + src/declarative/qml/qmlprivate.cpp | 48 + src/declarative/qml/qmlprivate.h | 365 +++ src/declarative/qml/qmlpropertyvaluesource.cpp | 75 + src/declarative/qml/qmlpropertyvaluesource.h | 79 + src/declarative/qml/qmlproxymetaobject.cpp | 113 + src/declarative/qml/qmlproxymetaobject_p.h | 85 + src/declarative/qml/qmlrefcount.cpp | 66 + src/declarative/qml/qmlrefcount_p.h | 69 + src/declarative/qml/qmlstringconverters.cpp | 212 ++ src/declarative/qml/qmlstringconverters_p.h | 68 + src/declarative/qml/qmlvme.cpp | 1345 ++++++++++ src/declarative/qml/qmlvme_p.h | 75 + src/declarative/qml/qmlvmemetaobject.cpp | 140 + src/declarative/qml/qmlvmemetaobject_p.h | 71 + src/declarative/qml/qmlxmlparser.cpp | 384 +++ src/declarative/qml/qmlxmlparser_p.h | 88 + src/declarative/qml/script/generator/generator.pro | 11 + src/declarative/qml/script/generator/main.cpp | 135 + src/declarative/qml/script/instructions.h | 32 + src/declarative/qml/script/keywords.cpp | 89 + src/declarative/qml/script/lexer.cpp | 139 + src/declarative/qml/script/lexer.h | 54 + src/declarative/qml/script/qmlbasicscript.cpp | 923 +++++++ src/declarative/qml/script/qmlbasicscript.h | 76 + src/declarative/qml/script/qmlbasicscript_p.h | 52 + src/declarative/qml/script/script.pri | 11 + src/declarative/qml/script/tokens.cpp | 44 + src/declarative/qml/script/tokens.h | 36 + src/declarative/test/qfxtestengine.cpp | 457 ++++ src/declarative/test/qfxtestengine.h | 85 + src/declarative/test/qfxtestobjects.cpp | 348 +++ src/declarative/test/qfxtestobjects.h | 212 ++ src/declarative/test/qfxtestview.cpp | 79 + src/declarative/test/qfxtestview.h | 74 + src/declarative/test/test.pri | 9 + src/declarative/timeline/gfxeasing.cpp | 846 ++++++ src/declarative/timeline/gfxeasing.h | 107 + src/declarative/timeline/gfxtimeline.cpp | 946 +++++++ src/declarative/timeline/gfxtimeline.h | 190 ++ src/declarative/timeline/gfxvalueproxy.h | 83 + src/declarative/timeline/timeline.pri | 9 + src/declarative/util/qbindablemap.cpp | 179 ++ src/declarative/util/qbindablemap.h | 87 + src/declarative/util/qfxglobal.h | 124 + src/declarative/util/qfxperf.cpp | 75 + src/declarative/util/qfxperf.h | 87 + src/declarative/util/qfxview.cpp | 310 +++ src/declarative/util/qfxview.h | 107 + src/declarative/util/qmlanimation.cpp | 2292 ++++++++++++++++ src/declarative/util/qmlanimation.h | 453 ++++ src/declarative/util/qmlanimation_p.h | 374 +++ src/declarative/util/qmlbehaviour.cpp | 248 ++ src/declarative/util/qmlbehaviour.h | 99 + src/declarative/util/qmlbind.cpp | 203 ++ src/declarative/util/qmlbind.h | 89 + src/declarative/util/qmlconnection.cpp | 290 ++ src/declarative/util/qmlconnection.h | 91 + src/declarative/util/qmldatetimeformatter.cpp | 368 +++ src/declarative/util/qmldatetimeformatter.h | 116 + src/declarative/util/qmlfollow.cpp | 309 +++ src/declarative/util/qmlfollow.h | 94 + src/declarative/util/qmlfont.cpp | 147 + src/declarative/util/qmlfont.h | 92 + src/declarative/util/qmllistaccessor.cpp | 243 ++ src/declarative/util/qmllistaccessor.h | 82 + src/declarative/util/qmllistmodel.cpp | 721 +++++ src/declarative/util/qmllistmodel.h | 96 + src/declarative/util/qmlnullablevalue_p.h | 67 + src/declarative/util/qmlopenmetaobject.cpp | 188 ++ src/declarative/util/qmlopenmetaobject.h | 96 + src/declarative/util/qmlpackage.cpp | 148 ++ src/declarative/util/qmlpackage.h | 86 + src/declarative/util/qmlscript.cpp | 219 ++ src/declarative/util/qmlscript.h | 80 + src/declarative/util/qmlsetproperties.cpp | 247 ++ src/declarative/util/qmlsetproperties.h | 83 + src/declarative/util/qmlstate.cpp | 469 ++++ src/declarative/util/qmlstate.h | 175 ++ src/declarative/util/qmlstate_p.h | 77 + src/declarative/util/qmlstategroup.cpp | 306 +++ src/declarative/util/qmlstategroup.h | 95 + src/declarative/util/qmlstateoperations.cpp | 416 +++ src/declarative/util/qmlstateoperations.h | 132 + src/declarative/util/qmltransition.cpp | 283 ++ src/declarative/util/qmltransition.h | 98 + src/declarative/util/qperformancelog.cpp | 177 ++ src/declarative/util/qperformancelog.h | 176 ++ src/declarative/util/util.pri | 49 + src/declarative/widgets/graphicslayouts.cpp | 325 +++ src/declarative/widgets/graphicslayouts.h | 190 ++ src/declarative/widgets/graphicswidgets.cpp | 173 ++ src/declarative/widgets/graphicswidgets.h | 60 + src/declarative/widgets/widgets.pri | 10 + src/gui/animation/animation.pri | 8 + src/gui/animation/qitemanimation.cpp | 361 +++ src/gui/animation/qitemanimation.h | 111 + src/gui/animation/qitemanimation_p.h | 83 + src/gui/graphicsview/qgraphicsitem.cpp | 252 +- src/gui/graphicsview/qgraphicsitem.h | 19 +- src/gui/graphicsview/qgraphicsitem_p.h | 12 +- src/gui/graphicsview/qgraphicslayout.h | 2 + src/gui/graphicsview/qgraphicslayoutitem.h | 2 + src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 + src/gui/graphicsview/qgraphicsproxywidget.h | 2 + src/gui/graphicsview/qgraphicswidget.cpp | 4 +- src/gui/graphicsview/qgraphicswidget.h | 7 + src/gui/gui.pro | 2 + src/gui/kernel/qaction.h | 30 +- src/gui/kernel/qapplication.cpp | 6 + src/gui/kernel/qevent.cpp | 41 +- src/gui/kernel/qevent.h | 5 + src/gui/kernel/qevent_p.h | 6 + src/gui/painting/qdrawhelper.cpp | 12 +- src/gui/statemachine/qbasickeyeventtransition.cpp | 174 ++ src/gui/statemachine/qbasickeyeventtransition_p.h | 67 + .../statemachine/qbasicmouseeventtransition.cpp | 159 ++ .../statemachine/qbasicmouseeventtransition_p.h | 70 + src/gui/statemachine/qguistatemachine.cpp | 514 ++++ src/gui/statemachine/qkeyeventtransition.cpp | 156 ++ src/gui/statemachine/qkeyeventtransition.h | 60 + src/gui/statemachine/qmouseeventtransition.cpp | 162 ++ src/gui/statemachine/qmouseeventtransition.h | 62 + src/gui/statemachine/statemachine.pri | 16 + src/opengl/gl2paintengineex/qglshader_p.h | 2 + src/opengl/opengl.pro | 4 + src/opengl/qglextensions.cpp | 174 +- src/opengl/qglextensions_p.h | 134 +- src/opengl/qglpixmapfilter.cpp | 172 +- src/opengl/qglpixmapfilter_p.h | 29 - src/opengl/qglshaderprogram.cpp | 2798 ++++++++++++++++++++ src/opengl/qglshaderprogram.h | 266 ++ src/script/qscriptengine_p.cpp | 5 + src/script/qscriptenginefwd_p.h | 1 + src/script/qscriptextqobject.cpp | 33 +- src/src.pro | 4 + src/tools/moc/generator.cpp | 16 +- src/tools/moc/keywords.cpp | 162 +- src/tools/moc/moc.cpp | 11 +- src/tools/moc/moc.h | 7 +- src/tools/moc/token.h | 1 + src/tools/moc/util/generate_keywords.cpp | 1 + tests/auto/auto.pro | 10 + tests/auto/declarative/.gitignore | 3 + .../datetimeformatter/datetimeformatter.pro | 3 + .../datetimeformatter/tst_datetimeformatter.cpp | 83 + tests/auto/declarative/declarative.pro | 22 + .../auto/declarative/layouts/data/grid-margin.xml | 9 + .../layouts/data/grid-spacing-margin.xml | 9 + .../auto/declarative/layouts/data/grid-spacing.xml | 9 + tests/auto/declarative/layouts/data/grid.xml | 9 + .../declarative/layouts/data/horizontal-margin.xml | 7 + .../layouts/data/horizontal-spacing-margin.xml | 7 + .../layouts/data/horizontal-spacing.xml | 7 + tests/auto/declarative/layouts/data/horizontal.xml | 7 + .../declarative/layouts/data/vertical-margin.xml | 7 + .../layouts/data/vertical-spacing-margin.xml | 7 + .../declarative/layouts/data/vertical-spacing.xml | 7 + tests/auto/declarative/layouts/data/vertical.xml | 7 + tests/auto/declarative/layouts/layouts.pro | 6 + tests/auto/declarative/layouts/tst_layouts.cpp | 392 +++ tests/auto/declarative/listview/data/listview.xml | 14 + tests/auto/declarative/listview/listview.pro | 6 + tests/auto/declarative/listview/tst_listview.cpp | 484 ++++ .../auto/declarative/namespaces/data/Red/Rect.qml | 2 + tests/auto/declarative/namespaces/namespaces.pro | 6 + .../auto/declarative/namespaces/tst_namespaces.cpp | 94 + .../numberformatter/numberformatter.pro | 3 + .../numberformatter/tst_numberformatter.cpp | 216 ++ tests/auto/declarative/pathview/data/pathview.xml | 20 + tests/auto/declarative/pathview/pathview.pro | 6 + tests/auto/declarative/pathview/tst_pathview.cpp | 259 ++ .../auto/declarative/qbindablemap/qbindablemap.pro | 3 + .../declarative/qbindablemap/tst_qbindablemap.cpp | 72 + tests/auto/declarative/qfxtext/qfxtext.pro | 3 + tests/auto/declarative/qfxtext/tst_qfxtext.cpp | 412 +++ tests/auto/declarative/qfxtextedit/qfxtextedit.pro | 3 + .../declarative/qfxtextedit/tst_qfxtextedit.cpp | 326 +++ .../declarative/qmlbindengine/qmlbindengine.pro | 3 + .../qmlbindengine/tst_qmlbindengine.cpp | 123 + tests/auto/declarative/qmllist/qmllist.pro | 3 + tests/auto/declarative/qmllist/tst_qmllist.cpp | 38 + .../qmllistaccessor/qmllistaccessor.pro | 3 + .../qmllistaccessor/tst_qmllistaccessor.cpp | 61 + .../qmlmetaproperty/qmlmetaproperty.pro | 3 + .../qmlmetaproperty/tst_qmlmetaproperty.cpp | 104 + tests/auto/declarative/qmlparser/qmlparser.pro | 3 + tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 444 ++++ tests/auto/declarative/repeater/data/repeater.xml | 7 + tests/auto/declarative/repeater/repeater.pro | 6 + tests/auto/declarative/repeater/tst_repeater.cpp | 91 + .../declarative/simplecanvasitem/data/test.xml | 12 + .../simplecanvasitem/simplecanvasitem.pro | 6 + .../simplecanvasitem/tst_simplecanvasitem.cpp | 79 + .../declarative/visual/ListView/basic1/basic1.xml | 19 + .../visual/ListView/basic1/data/opengl/image0.png | Bin 0 -> 3759 bytes .../ListView/basic1/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/ListView/basic1/test | 1 + .../declarative/visual/ListView/basic2/basic2.xml | 20 + .../visual/ListView/basic2/data/opengl/image0.png | Bin 0 -> 3759 bytes .../ListView/basic2/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/ListView/basic2/test | 1 + .../declarative/visual/ListView/basic3/basic3.xml | 18 + .../visual/ListView/basic3/data/opengl/image0.png | Bin 0 -> 3759 bytes .../ListView/basic3/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/ListView/basic3/test | 1 + .../declarative/visual/ListView/basic4/basic4.xml | 19 + .../visual/ListView/basic4/data/opengl/image0.png | Bin 0 -> 3759 bytes .../ListView/basic4/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/ListView/basic4/test | 1 + .../visual/bindinganimation/bindinganimation.xml | 19 + .../visual/bindinganimation/data/opengl/image0.png | Bin 0 -> 817 bytes .../bindinganimation/data/opengl/manifest-play.xml | 104 + .../bindinganimation/data/opengl/manifest.xml | 104 + .../auto/declarative/visual/bindinganimation/test | 1 + .../visual/colorAnimation/colorAnimation.xml | 18 + .../declarative/visual/colorAnimation/image0.png | Bin 0 -> 947 bytes .../visual/colorAnimation/manifest-play.xml | 73 + .../declarative/visual/colorAnimation/manifest.xml | 73 + tests/auto/declarative/visual/easing/easing.xml | 70 + tests/auto/declarative/visual/easing/image0.png | Bin 0 -> 17530 bytes .../declarative/visual/easing/manifest-play.xml | 23 + tests/auto/declarative/visual/easing/manifest.xml | 23 + .../auto/declarative/visual/easing/pics/qtlogo.png | Bin 0 -> 2738 bytes tests/auto/declarative/visual/flickable/Day.qml | 8 + tests/auto/declarative/visual/flickable/cork.jpg | Bin 0 -> 88766 bytes .../declarative/visual/flickable/flickable.xml | 43 + tests/auto/declarative/visual/flickable/image0.png | Bin 0 -> 360547 bytes .../declarative/visual/flickable/manifest-fail.xml | 30 + .../auto/declarative/visual/flickable/manifest.xml | 190 ++ .../auto/declarative/visual/flipable/flipable.xml | 138 + tests/auto/declarative/visual/flipable/image0.png | Bin 0 -> 6184 bytes .../declarative/visual/flipable/manifest-play.xml | 24 + .../auto/declarative/visual/flipable/manifest.xml | 24 + .../declarative/visual/flipable/pics/arrow.png | Bin 0 -> 546 bytes .../auto/declarative/visual/flipable/pics/face.png | Bin 0 -> 10112 bytes .../declarative/visual/flipable/pics/photo0.png | Bin 0 -> 10412 bytes .../declarative/visual/flipable/pics/photo1.png | Bin 0 -> 11068 bytes .../declarative/visual/flipable/pics/photo10.png | Bin 0 -> 12539 bytes .../declarative/visual/flipable/pics/photo2.png | Bin 0 -> 11490 bytes .../declarative/visual/flipable/pics/photo3.png | Bin 0 -> 11308 bytes .../declarative/visual/flipable/pics/photo4.png | Bin 0 -> 11322 bytes .../declarative/visual/flipable/pics/photo5.png | Bin 0 -> 11497 bytes .../declarative/visual/flipable/pics/photo6.png | Bin 0 -> 11707 bytes .../declarative/visual/flipable/pics/photo7.png | Bin 0 -> 11101 bytes .../declarative/visual/flipable/pics/photo8.png | Bin 0 -> 11558 bytes .../declarative/visual/flipable/pics/photo9.png | Bin 0 -> 10943 bytes .../declarative/visual/pauseAnimation/image0.png | Bin 0 -> 3209 bytes .../visual/pauseAnimation/manifest-play.xml | 138 + .../declarative/visual/pauseAnimation/manifest.xml | 138 + .../visual/pauseAnimation/pauseAnimation.xml | 13 + .../visual/pauseAnimation/pics/qtlogo.png | Bin 0 -> 2738 bytes .../visual/qfxtext/elide/data/opengl/image0.png | Bin 0 -> 980 bytes .../visual/qfxtext/elide/data/opengl/manifest.xml | 4 + .../declarative/visual/qfxtext/elide/elide.xml | 6 + tests/auto/declarative/visual/qfxtext/elide/test | 1 + .../declarative/visual/repeater/basic1/basic1.xml | 21 + .../visual/repeater/basic1/data/opengl/image0.png | Bin 0 -> 3493 bytes .../repeater/basic1/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/repeater/basic1/test | 1 + .../declarative/visual/repeater/basic2/basic2.xml | 22 + .../visual/repeater/basic2/data/opengl/image0.png | Bin 0 -> 3493 bytes .../repeater/basic2/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/repeater/basic2/test | 1 + .../declarative/visual/repeater/basic3/basic3.xml | 19 + .../visual/repeater/basic3/data/opengl/image0.png | Bin 0 -> 3493 bytes .../repeater/basic3/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/repeater/basic3/test | 1 + .../declarative/visual/repeater/basic4/basic4.xml | 18 + .../visual/repeater/basic4/data/opengl/image0.png | Bin 0 -> 3493 bytes .../repeater/basic4/data/opengl/manifest.xml | 4 + tests/auto/declarative/visual/repeater/basic4/test | 1 + tests/auto/declarative/visual/runtests.sh | 2 + tests/auto/declarative/visual/tests | 11 + tests/auto/declarative/visual/tst_visual.cpp | 72 + tests/auto/declarative/visual/visual.pro | 5 + .../visual/webview/autosize/data/opengl/image0.png | Bin 0 -> 5396 bytes .../webview/autosize/data/opengl/manifest.xml | 4 + .../auto/declarative/visual/webview/autosize/test | 1 + tests/auto/dynamicobject/dynamicobject.pro | 6 + tests/auto/dynamicobject/qdynamicmetaobject.cpp | 254 ++ tests/auto/dynamicobject/qdynamicmetaobject.h | 47 + tests/auto/dynamicobject/qmetaobjectbuilder.cpp | 2347 ++++++++++++++++ tests/auto/dynamicobject/qmetaobjectbuilder.h | 258 ++ tests/auto/dynamicobject/tst_qobject.cpp | 325 +++ tests/auto/qanimationgroup/qanimationgroup.pro | 5 + tests/auto/qanimationgroup/tst_qanimationgroup.cpp | 347 +++ tests/auto/qanimationstate/qanimationstate.pro | 5 + tests/auto/qanimationstate/tst_qanimationstate.cpp | 625 +++++ tests/auto/qeasingcurve/qeasingcurve.pro | 3 + tests/auto/qeasingcurve/tst_qeasingcurve.cpp | 488 ++++ .../qparallelanimationgroup.pro | 5 + .../tst_qparallelanimationgroup.cpp | 834 ++++++ .../auto/qpropertyanimation/qpropertyanimation.pro | 5 + .../qpropertyanimation/tst_qpropertyanimation.cpp | 831 ++++++ tests/auto/qscriptqobject/tst_qscriptqobject.cpp | 66 +- .../qsequentialanimationgroup.pro | 5 + .../tst_qsequentialanimationgroup.cpp | 1649 ++++++++++++ tests/auto/qstate/qstate.pro | 5 + tests/auto/qstate/tst_qstate.cpp | 372 +++ tests/auto/qstatemachine/qstatemachine.pro | 4 + tests/auto/qstatemachine/tst_qstatemachine.cpp | 2177 +++++++++++++++ tests/benchmarks/benchmarks.pro | 11 +- tests/benchmarks/qanimation/dummyanimation.cpp | 20 + tests/benchmarks/qanimation/dummyanimation.h | 19 + tests/benchmarks/qanimation/dummyobject.cpp | 25 + tests/benchmarks/qanimation/dummyobject.h | 23 + tests/benchmarks/qanimation/main.cpp | 173 ++ tests/benchmarks/qanimation/qanimation.pro | 18 + tests/benchmarks/qanimation/rectanimation.cpp | 58 + tests/benchmarks/qanimation/rectanimation.h | 30 + tests/benchmarks/qfxview/main.cpp | 182 ++ tests/benchmarks/qfxview/qfxview.pro | 16 + .../qfxview/testdata/tatwheel/editor/data.xml | 44 + .../qfxview/testdata/tatwheel/pics/background.png | Bin 0 -> 26508 bytes .../qfxview/testdata/tatwheel/pics/background3.png | Bin 0 -> 37671 bytes .../qfxview/testdata/tatwheel/pics/battery.png | Bin 0 -> 770 bytes .../testdata/tatwheel/pics/calendar-blur.png | Bin 0 -> 51439 bytes .../qfxview/testdata/tatwheel/pics/calendar.png | Bin 0 -> 10153 bytes .../testdata/tatwheel/pics/callhistory-blur.png | Bin 0 -> 57023 bytes .../qfxview/testdata/tatwheel/pics/callhistory.png | Bin 0 -> 13227 bytes .../qfxview/testdata/tatwheel/pics/camera-blur.png | Bin 0 -> 50955 bytes .../qfxview/testdata/tatwheel/pics/camera.png | Bin 0 -> 16126 bytes .../testdata/tatwheel/pics/contacts-blur.png | Bin 0 -> 51041 bytes .../qfxview/testdata/tatwheel/pics/contacts.png | Bin 0 -> 12177 bytes .../testdata/tatwheel/pics/file-manager-blur.png | Bin 0 -> 45164 bytes .../testdata/tatwheel/pics/file-manager.png | Bin 0 -> 8858 bytes .../qfxview/testdata/tatwheel/pics/fire.png | Bin 0 -> 1124 bytes .../qfxview/testdata/tatwheel/pics/flask-blue.png | Bin 0 -> 764 bytes .../testdata/tatwheel/pics/flask-container.png | Bin 0 -> 536 bytes .../qfxview/testdata/tatwheel/pics/flask-front.png | Bin 0 -> 962 bytes .../qfxview/testdata/tatwheel/pics/flask-pink.png | Bin 0 -> 747 bytes .../testdata/tatwheel/pics/flask-yellow.png | Bin 0 -> 775 bytes .../qfxview/testdata/tatwheel/pics/ice.png | Bin 0 -> 1112 bytes .../testdata/tatwheel/pics/icon-reflection.png | Bin 0 -> 7123 bytes .../testdata/tatwheel/pics/internet-blur.png | Bin 0 -> 57126 bytes .../qfxview/testdata/tatwheel/pics/internet.png | Bin 0 -> 24320 bytes .../testdata/tatwheel/pics/menu-background1.png | Bin 0 -> 2831 bytes .../testdata/tatwheel/pics/menu-border1.png | Bin 0 -> 926 bytes .../testdata/tatwheel/pics/menu-border3.png | Bin 0 -> 10153 bytes .../testdata/tatwheel/pics/menu-highlight.png | Bin 0 -> 3421 bytes .../qfxview/testdata/tatwheel/pics/menubar.png | Bin 0 -> 741 bytes .../testdata/tatwheel/pics/messages-blur.png | Bin 0 -> 44556 bytes .../qfxview/testdata/tatwheel/pics/messages.png | Bin 0 -> 11426 bytes .../qfxview/testdata/tatwheel/pics/moon.png | Bin 0 -> 1027 bytes .../qfxview/testdata/tatwheel/pics/sad.png | Bin 0 -> 1053 bytes .../testdata/tatwheel/pics/settings-blur.png | Bin 0 -> 50199 bytes .../qfxview/testdata/tatwheel/pics/settings.png | Bin 0 -> 8697 bytes .../qfxview/testdata/tatwheel/pics/signal.png | Bin 0 -> 739 bytes .../qfxview/testdata/tatwheel/pics/smile.png | Bin 0 -> 1051 bytes .../qfxview/testdata/tatwheel/pics/star.png | Bin 0 -> 262 bytes .../qfxview/testdata/tatwheel/pics/sun.png | Bin 0 -> 1021 bytes .../qfxview/testdata/tatwheel/pics/titlebar.png | Bin 0 -> 1041 bytes .../qfxview/testdata/tatwheel/pics/wifi.png | Bin 0 -> 782 bytes .../qfxview/testdata/tatwheel/tat-wheel.xml | 68 + tests/benchmarks/qmlxmlparser/main.cpp | 96 + tests/benchmarks/qmlxmlparser/qmlxmlparser.pro | 14 + .../benchmarks/qmlxmlparser/testdata/concept2.xml | 421 +++ tests/benchmarks/qvariant/qvariant.pro | 1 - tests/benchmarks/qvariant/tst_qvariant.cpp | 115 +- tools/configure/configureapp.cpp | 12 + tools/duiviewer/duiviewer.pro | 12 + tools/duiviewer/main.cpp | 135 + tools/duiviewer/qfxviewer.cpp | 361 +++ tools/duiviewer/qfxviewer.h | 71 + tools/qdoc3/codemarker.cpp | 109 +- tools/qdoc3/codemarker.h | 12 +- tools/qdoc3/command.cpp | 44 +- tools/qdoc3/cppcodemarker.cpp | 224 +- tools/qdoc3/cppcodemarker.h | 5 + tools/qdoc3/cppcodeparser.cpp | 260 +- tools/qdoc3/cppcodeparser.h | 12 + tools/qdoc3/doc.cpp | 14 +- tools/qdoc3/generator.cpp | 190 +- tools/qdoc3/generator.h | 5 +- tools/qdoc3/helpprojectwriter.cpp | 30 +- tools/qdoc3/htmlgenerator.cpp | 691 ++++- tools/qdoc3/htmlgenerator.h | 29 +- tools/qdoc3/jambiapiparser.cpp | 5 +- tools/qdoc3/node.cpp | 106 +- tools/qdoc3/node.h | 126 +- tools/qdoc3/pagegenerator.cpp | 59 +- tools/qdoc3/test/classic.css | 42 + tools/qdoc3/test/qt-build-docs.qdocconf | 3 +- tools/qdoc3/test/qt.qdocconf | 3 +- tools/qdoc3/tree.cpp | 50 +- tools/qdoc3/webxmlgenerator.cpp | 4 +- tools/tools.pro | 1 + 1210 files changed, 138839 insertions(+), 1789 deletions(-) create mode 100644 bin/snapshot delete mode 100644 demos/boxes/glshaders.cpp delete mode 100644 demos/boxes/glshaders.h create mode 100644 demos/declarative/calculator/CalcButton.qml create mode 100644 demos/declarative/calculator/calculator.js create mode 100644 demos/declarative/calculator/calculator.qml create mode 100644 demos/declarative/calculator/pics/button-pressed.png create mode 100644 demos/declarative/calculator/pics/button-pressed.sci create mode 100644 demos/declarative/calculator/pics/button.png create mode 100644 demos/declarative/calculator/pics/button.sci create mode 100644 demos/declarative/calculator/pics/clear.png create mode 100644 demos/declarative/mediabrowser/content/LikeOMeter.qml create mode 100644 demos/declarative/mediabrowser/content/MediaButton.qml create mode 100644 demos/declarative/mediabrowser/content/MovieInfoContainer.qml create mode 100644 demos/declarative/mediabrowser/content/MoviesPathView.qml create mode 100644 demos/declarative/mediabrowser/content/ScrollBar.qml create mode 100644 demos/declarative/mediabrowser/content/Star.qml create mode 100644 demos/declarative/mediabrowser/content/pics/background.png create mode 100644 demos/declarative/mediabrowser/content/pics/button-pressed.png create mode 100644 demos/declarative/mediabrowser/content/pics/button.png create mode 100644 demos/declarative/mediabrowser/content/pics/ghns_star.png create mode 100644 demos/declarative/mediabrowser/content/pics/reflection.png create mode 100644 demos/declarative/mediabrowser/content/pics/shadow-bottom.png create mode 100644 demos/declarative/mediabrowser/content/pics/shadow-corner.png create mode 100644 demos/declarative/mediabrowser/content/pics/shadow-right-screen.png create mode 100644 demos/declarative/mediabrowser/content/pics/shadow-right.png create mode 100644 demos/declarative/mediabrowser/dummydata/MoviesModel.qml create mode 100644 demos/declarative/mediabrowser/mediabrowser.qml create mode 100644 demos/declarative/webbrowser/README create mode 100644 demos/declarative/webbrowser/WebBrowser.qml create mode 100644 demos/declarative/webbrowser/content/RectSoftShadow.qml create mode 100644 demos/declarative/webbrowser/content/pics/addressbar-filled.png create mode 100644 demos/declarative/webbrowser/content/pics/addressbar-filled.sci create mode 100644 demos/declarative/webbrowser/content/pics/addressbar.png create mode 100644 demos/declarative/webbrowser/content/pics/addressbar.sci create mode 100644 demos/declarative/webbrowser/content/pics/back-disabled.png create mode 100644 demos/declarative/webbrowser/content/pics/back.png create mode 100644 demos/declarative/webbrowser/content/pics/footer.png create mode 100644 demos/declarative/webbrowser/content/pics/footer.sci create mode 100644 demos/declarative/webbrowser/content/pics/forward-disabled.png create mode 100644 demos/declarative/webbrowser/content/pics/forward.png create mode 100644 demos/declarative/webbrowser/content/pics/header.png create mode 100644 demos/declarative/webbrowser/content/pics/reload.png create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-bottom.png create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-left.png create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-left.sci create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-right.png create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-right.sci create mode 100644 demos/declarative/webbrowser/content/pics/softshadow-top.png create mode 100644 doc/src/animation.qdoc create mode 100644 doc/src/declarative/anchor-layout.qdoc create mode 100644 doc/src/declarative/animation.qdoc create mode 100644 doc/src/declarative/basictypes.qdoc create mode 100644 doc/src/declarative/binding.qdoc create mode 100644 doc/src/declarative/components.qdoc create mode 100644 doc/src/declarative/cppitem.qdoc create mode 100644 doc/src/declarative/effects.qdoc create mode 100644 doc/src/declarative/elements.qdoc create mode 100644 doc/src/declarative/examples.qdoc create mode 100644 doc/src/declarative/focus.qdoc create mode 100644 doc/src/declarative/index.qdoc create mode 100644 doc/src/declarative/measuring-performance.qdoc create mode 100644 doc/src/declarative/modules.qdoc create mode 100644 doc/src/declarative/pics/ListViewHighlight.png create mode 100644 doc/src/declarative/pics/ListViewHorizontal.png create mode 100644 doc/src/declarative/pics/ListViewVertical.png create mode 100644 doc/src/declarative/pics/anchors.svg create mode 100644 doc/src/declarative/pics/animatedimageitem.gif create mode 100644 doc/src/declarative/pics/blur_example.png create mode 100644 doc/src/declarative/pics/declarative-qmlfocus1.png create mode 100644 doc/src/declarative/pics/declarative-qmlfocus2.png create mode 100644 doc/src/declarative/pics/declarative-qmlfocus3.png create mode 100644 doc/src/declarative/pics/declarative-qmlfocus4.png create mode 100644 doc/src/declarative/pics/edge1.png create mode 100644 doc/src/declarative/pics/edge2.png create mode 100644 doc/src/declarative/pics/edge3.png create mode 100644 doc/src/declarative/pics/edge4.png create mode 100644 doc/src/declarative/pics/edges.png create mode 100644 doc/src/declarative/pics/edges.svg create mode 100644 doc/src/declarative/pics/edges_examples.svg create mode 100644 doc/src/declarative/pics/edges_qml.png create mode 100644 doc/src/declarative/pics/edges_qml.svg create mode 100644 doc/src/declarative/pics/flickable.gif create mode 100644 doc/src/declarative/pics/flipable.gif create mode 100644 doc/src/declarative/pics/gridLayout_example.png create mode 100644 doc/src/declarative/pics/gridview.png create mode 100644 doc/src/declarative/pics/highlight.gif create mode 100644 doc/src/declarative/pics/horizontalLayout_example.png create mode 100644 doc/src/declarative/pics/layout-add.gif create mode 100644 doc/src/declarative/pics/layout-move.gif create mode 100644 doc/src/declarative/pics/layout-remove.gif create mode 100644 doc/src/declarative/pics/margins_qml.png create mode 100644 doc/src/declarative/pics/margins_qml.svg create mode 100644 doc/src/declarative/pics/particles.gif create mode 100644 doc/src/declarative/pics/pathview.gif create mode 100644 doc/src/declarative/pics/propanim.gif create mode 100644 doc/src/declarative/pics/qtlogo.png create mode 100644 doc/src/declarative/pics/reflection_example.png create mode 100644 doc/src/declarative/pics/scalegrid.svg create mode 100644 doc/src/declarative/pics/shadow_example.png create mode 100644 doc/src/declarative/pics/spacing_a.png create mode 100644 doc/src/declarative/pics/spacing_b.png create mode 100644 doc/src/declarative/pics/trivialListView.png create mode 100644 doc/src/declarative/pics/verticalLayout_example.png create mode 100644 doc/src/declarative/pics/verticalLayout_transition.gif create mode 100644 doc/src/declarative/pics/webview.png create mode 100644 doc/src/declarative/qmlforcpp.qdoc create mode 100644 doc/src/declarative/qtprogrammers.qdoc create mode 100644 doc/src/declarative/scenegraph.qdoc create mode 100644 doc/src/declarative/tutorial.qdoc create mode 100644 doc/src/declarative/tutorial1.qdoc create mode 100644 doc/src/declarative/tutorial2.qdoc create mode 100644 doc/src/declarative/tutorial3.qdoc create mode 100644 doc/src/diagrams/programs/easingcurve/easingcurve.pro create mode 100644 doc/src/diagrams/programs/easingcurve/main.cpp create mode 100644 doc/src/duiviewer.qdoc create mode 100644 doc/src/examples/trafficlight.qdoc create mode 100644 doc/src/images/declarative-anchors_example.png create mode 100644 doc/src/images/declarative-anchors_example2.png create mode 100644 doc/src/images/declarative-image_tile.png create mode 100644 doc/src/images/declarative-item_opacity1.png create mode 100644 doc/src/images/declarative-item_opacity2.png create mode 100644 doc/src/images/declarative-item_stacking1.png create mode 100644 doc/src/images/declarative-item_stacking2.png create mode 100644 doc/src/images/declarative-item_stacking3.png create mode 100644 doc/src/images/declarative-item_stacking4.png create mode 100644 doc/src/images/declarative-qtlogo1.png create mode 100644 doc/src/images/declarative-qtlogo2.png create mode 100644 doc/src/images/declarative-qtlogo3.png create mode 100644 doc/src/images/declarative-qtlogo4.png create mode 100644 doc/src/images/declarative-rect.png create mode 100644 doc/src/images/declarative-rect_gradient.png create mode 100644 doc/src/images/declarative-rect_tint.png create mode 100644 doc/src/images/declarative-rotation.png create mode 100644 doc/src/images/declarative-scale.png create mode 100644 doc/src/images/declarative-scalegrid.png create mode 100644 doc/src/images/declarative-text.png create mode 100644 doc/src/images/declarative-textedit.gif create mode 100644 doc/src/images/declarative-textformat.png create mode 100644 doc/src/images/declarative-textstyle.png create mode 100644 doc/src/images/declarative-transformorigin.png create mode 100644 doc/src/images/declarative-tutorial1.png create mode 100644 doc/src/images/declarative-tutorial2.png create mode 100644 doc/src/images/declarative-tutorial3_animation.gif create mode 100644 doc/src/images/qeasingcurve-cosinecurve.png create mode 100644 doc/src/images/qeasingcurve-inback.png create mode 100644 doc/src/images/qeasingcurve-inbounce.png create mode 100644 doc/src/images/qeasingcurve-incirc.png create mode 100644 doc/src/images/qeasingcurve-incubic.png create mode 100644 doc/src/images/qeasingcurve-incurve.png create mode 100644 doc/src/images/qeasingcurve-inelastic.png create mode 100644 doc/src/images/qeasingcurve-inexpo.png create mode 100644 doc/src/images/qeasingcurve-inoutback.png create mode 100644 doc/src/images/qeasingcurve-inoutbounce.png create mode 100644 doc/src/images/qeasingcurve-inoutcirc.png create mode 100644 doc/src/images/qeasingcurve-inoutcubic.png create mode 100644 doc/src/images/qeasingcurve-inoutelastic.png create mode 100644 doc/src/images/qeasingcurve-inoutexpo.png create mode 100644 doc/src/images/qeasingcurve-inoutquad.png create mode 100644 doc/src/images/qeasingcurve-inoutquart.png create mode 100644 doc/src/images/qeasingcurve-inoutquint.png create mode 100644 doc/src/images/qeasingcurve-inoutsine.png create mode 100644 doc/src/images/qeasingcurve-inquad.png create mode 100644 doc/src/images/qeasingcurve-inquart.png create mode 100644 doc/src/images/qeasingcurve-inquint.png create mode 100644 doc/src/images/qeasingcurve-insine.png create mode 100644 doc/src/images/qeasingcurve-linear.png create mode 100644 doc/src/images/qeasingcurve-outback.png create mode 100644 doc/src/images/qeasingcurve-outbounce.png create mode 100644 doc/src/images/qeasingcurve-outcirc.png create mode 100644 doc/src/images/qeasingcurve-outcubic.png create mode 100644 doc/src/images/qeasingcurve-outcurve.png create mode 100644 doc/src/images/qeasingcurve-outelastic.png create mode 100644 doc/src/images/qeasingcurve-outexpo.png create mode 100644 doc/src/images/qeasingcurve-outinback.png create mode 100644 doc/src/images/qeasingcurve-outinbounce.png create mode 100644 doc/src/images/qeasingcurve-outincirc.png create mode 100644 doc/src/images/qeasingcurve-outincubic.png create mode 100644 doc/src/images/qeasingcurve-outinelastic.png create mode 100644 doc/src/images/qeasingcurve-outinexpo.png create mode 100644 doc/src/images/qeasingcurve-outinquad.png create mode 100644 doc/src/images/qeasingcurve-outinquart.png create mode 100644 doc/src/images/qeasingcurve-outinquint.png create mode 100644 doc/src/images/qeasingcurve-outinsine.png create mode 100644 doc/src/images/qeasingcurve-outquad.png create mode 100644 doc/src/images/qeasingcurve-outquart.png create mode 100644 doc/src/images/qeasingcurve-outquint.png create mode 100644 doc/src/images/qeasingcurve-outsine.png create mode 100644 doc/src/images/qeasingcurve-sinecurve.png create mode 100644 doc/src/images/statemachine-button-history.png create mode 100644 doc/src/images/statemachine-button-nested.png create mode 100644 doc/src/images/statemachine-button.png create mode 100644 doc/src/images/statemachine-finished.png create mode 100644 doc/src/images/statemachine-nonparallel.png create mode 100644 doc/src/images/statemachine-parallel.png create mode 100644 doc/src/images/trafficlight-example.png create mode 100644 doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp create mode 100644 doc/src/statemachine.qdoc create mode 100644 examples/animation/animatedtiles/animatedtiles.pro create mode 100644 examples/animation/animatedtiles/animatedtiles.qrc create mode 100644 examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg create mode 100644 examples/animation/animatedtiles/images/centered.png create mode 100644 examples/animation/animatedtiles/images/ellipse.png create mode 100644 examples/animation/animatedtiles/images/figure8.png create mode 100644 examples/animation/animatedtiles/images/kinetic.png create mode 100644 examples/animation/animatedtiles/images/random.png create mode 100644 examples/animation/animatedtiles/images/tile.png create mode 100644 examples/animation/animatedtiles/main.cpp create mode 100644 examples/animation/animation.pro create mode 100644 examples/animation/appchooser/accessories-dictionary.png create mode 100644 examples/animation/appchooser/akregator.png create mode 100644 examples/animation/appchooser/appchooser.pro create mode 100644 examples/animation/appchooser/appchooser.qrc create mode 100644 examples/animation/appchooser/digikam.png create mode 100644 examples/animation/appchooser/k3b.png create mode 100644 examples/animation/appchooser/main.cpp create mode 100644 examples/animation/easing/animation.h create mode 100644 examples/animation/easing/easing.pro create mode 100644 examples/animation/easing/form.ui create mode 100644 examples/animation/easing/images/qt-logo.png create mode 100644 examples/animation/easing/main.cpp create mode 100644 examples/animation/easing/resources.qrc create mode 100644 examples/animation/easing/window.cpp create mode 100644 examples/animation/easing/window.h create mode 100644 examples/animation/example/example.pro create mode 100644 examples/animation/example/main.cpp create mode 100644 examples/animation/example/mainwindow.cpp create mode 100644 examples/animation/example/mainwindow.h create mode 100644 examples/animation/moveblocks/main.cpp create mode 100644 examples/animation/moveblocks/moveblocks.pro create mode 100644 examples/animation/padnavigator-ng/backside.ui create mode 100644 examples/animation/padnavigator-ng/images/artsfftscope.png create mode 100644 examples/animation/padnavigator-ng/images/blue_angle_swirl.jpg create mode 100644 examples/animation/padnavigator-ng/images/kontact_contacts.png create mode 100644 examples/animation/padnavigator-ng/images/kontact_journal.png create mode 100644 examples/animation/padnavigator-ng/images/kontact_mail.png create mode 100644 examples/animation/padnavigator-ng/images/kontact_notes.png create mode 100644 examples/animation/padnavigator-ng/images/kopeteavailable.png create mode 100644 examples/animation/padnavigator-ng/images/metacontact_online.png create mode 100644 examples/animation/padnavigator-ng/images/minitools.png create mode 100644 examples/animation/padnavigator-ng/main.cpp create mode 100644 examples/animation/padnavigator-ng/padnavigator.pro create mode 100644 examples/animation/padnavigator-ng/padnavigator.qrc create mode 100644 examples/animation/padnavigator-ng/panel.cpp create mode 100644 examples/animation/padnavigator-ng/panel.h create mode 100644 examples/animation/padnavigator-ng/roundrectitem.cpp create mode 100644 examples/animation/padnavigator-ng/roundrectitem.h create mode 100644 examples/animation/padnavigator-ng/splashitem.cpp create mode 100644 examples/animation/padnavigator-ng/splashitem.h create mode 100644 examples/animation/photobrowser/main.cpp create mode 100644 examples/animation/photobrowser/menu.cpp create mode 100644 examples/animation/photobrowser/menu.h create mode 100644 examples/animation/photobrowser/photobrowser.pro create mode 100644 examples/animation/photobrowser/river.cpp create mode 100644 examples/animation/photobrowser/river.h create mode 100644 examples/animation/photobrowser/riveritem.cpp create mode 100644 examples/animation/photobrowser/riveritem.h create mode 100644 examples/animation/piemenu/main.cpp create mode 100644 examples/animation/piemenu/piemenu.pro create mode 100644 examples/animation/piemenu/qgraphicspiemenu.cpp create mode 100644 examples/animation/piemenu/qgraphicspiemenu.h create mode 100644 examples/animation/piemenu/qgraphicspiemenu_p.h create mode 100644 examples/animation/piemenu/qgraphicspiemenusection_p.h create mode 100644 examples/animation/piemenu/scene.cpp create mode 100644 examples/animation/piemenu/scene.h create mode 100644 examples/animation/research/memberfunctions/main.cpp create mode 100644 examples/animation/research/memberfunctions/memberfunctions.pro create mode 100644 examples/animation/research/memberfunctions/qvalueanimation.cpp create mode 100644 examples/animation/research/memberfunctions/qvalueanimation.h create mode 100644 examples/animation/research/memberfunctions/qvalueanimation_p.h create mode 100644 examples/animation/research/propertytransform/main.cpp create mode 100644 examples/animation/research/propertytransform/propertytransform.pro create mode 100644 examples/animation/research/propertytransform/qpropertytransform.h create mode 100644 examples/animation/research/sound/main.cpp create mode 100644 examples/animation/research/sound/media/sax.mp3 create mode 100644 examples/animation/research/sound/sound.pro create mode 100644 examples/animation/research/sound/sound.qrc create mode 100644 examples/animation/states/accessories-dictionary.png create mode 100644 examples/animation/states/akregator.png create mode 100644 examples/animation/states/digikam.png create mode 100644 examples/animation/states/help-browser.png create mode 100644 examples/animation/states/k3b.png create mode 100644 examples/animation/states/kchart.png create mode 100644 examples/animation/states/main.cpp create mode 100644 examples/animation/states/states.pro create mode 100644 examples/animation/states/states.qrc create mode 100644 examples/animation/stickman/animation.cpp create mode 100644 examples/animation/stickman/animation.h create mode 100644 examples/animation/stickman/animations/chilling create mode 100644 examples/animation/stickman/animations/dancing create mode 100644 examples/animation/stickman/animations/dead create mode 100644 examples/animation/stickman/animations/jumping create mode 100644 examples/animation/stickman/graphicsview.cpp create mode 100644 examples/animation/stickman/graphicsview.h create mode 100644 examples/animation/stickman/lifecycle.cpp create mode 100644 examples/animation/stickman/lifecycle.h create mode 100644 examples/animation/stickman/main.cpp create mode 100644 examples/animation/stickman/node.cpp create mode 100644 examples/animation/stickman/node.h create mode 100644 examples/animation/stickman/stickman.cpp create mode 100644 examples/animation/stickman/stickman.h create mode 100644 examples/animation/stickman/stickman.pro create mode 100644 examples/animation/sub-attaq/animationmanager.cpp create mode 100644 examples/animation/sub-attaq/animationmanager.h create mode 100644 examples/animation/sub-attaq/boat.cpp create mode 100644 examples/animation/sub-attaq/boat.h create mode 100644 examples/animation/sub-attaq/boat_p.h create mode 100644 examples/animation/sub-attaq/bomb.cpp create mode 100644 examples/animation/sub-attaq/bomb.h create mode 100644 examples/animation/sub-attaq/custompropertyanimation.cpp create mode 100644 examples/animation/sub-attaq/custompropertyanimation.h create mode 100644 examples/animation/sub-attaq/custompropertyanimation_p.h create mode 100644 examples/animation/sub-attaq/data.xml create mode 100644 examples/animation/sub-attaq/graphicsscene.cpp create mode 100644 examples/animation/sub-attaq/graphicsscene.h create mode 100644 examples/animation/sub-attaq/main.cpp create mode 100644 examples/animation/sub-attaq/mainwindow.cpp create mode 100644 examples/animation/sub-attaq/mainwindow.h create mode 100644 examples/animation/sub-attaq/pics/big/background.png create mode 100644 examples/animation/sub-attaq/pics/big/boat.png create mode 100644 examples/animation/sub-attaq/pics/big/bomb.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step1.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step2.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step3.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/boat/step4.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png create mode 100644 examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png create mode 100644 examples/animation/sub-attaq/pics/big/submarine.png create mode 100644 examples/animation/sub-attaq/pics/big/surface.png create mode 100644 examples/animation/sub-attaq/pics/big/torpedo.png create mode 100644 examples/animation/sub-attaq/pics/scalable/background-n810.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/background.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/boat.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/bomb.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/sand.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/see.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/sky.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/sub-attaq.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/submarine.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/surface.svg create mode 100644 examples/animation/sub-attaq/pics/scalable/torpedo.svg create mode 100644 examples/animation/sub-attaq/pics/small/background.png create mode 100644 examples/animation/sub-attaq/pics/small/boat.png create mode 100644 examples/animation/sub-attaq/pics/small/bomb.png create mode 100644 examples/animation/sub-attaq/pics/small/submarine.png create mode 100644 examples/animation/sub-attaq/pics/small/surface.png create mode 100644 examples/animation/sub-attaq/pics/small/torpedo.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-a.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-a2.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-b.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-dash.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-excl.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-q.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-s.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-t.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-t2.png create mode 100644 examples/animation/sub-attaq/pics/welcome/logo-u.png create mode 100644 examples/animation/sub-attaq/pixmapitem.cpp create mode 100644 examples/animation/sub-attaq/pixmapitem.h create mode 100644 examples/animation/sub-attaq/states.cpp create mode 100644 examples/animation/sub-attaq/states.h create mode 100644 examples/animation/sub-attaq/sub-attaq.pro create mode 100644 examples/animation/sub-attaq/subattaq.qrc create mode 100644 examples/animation/sub-attaq/submarine.cpp create mode 100644 examples/animation/sub-attaq/submarine.h create mode 100644 examples/animation/sub-attaq/submarine_p.h create mode 100644 examples/animation/sub-attaq/torpedo.cpp create mode 100644 examples/animation/sub-attaq/torpedo.h create mode 100644 examples/declarative/animation/animation.qml create mode 100644 examples/declarative/behaviours/MyRect.qml create mode 100644 examples/declarative/behaviours/test.qml create mode 100644 examples/declarative/connections/connections.qml create mode 100644 examples/declarative/contacts/contacts.pro create mode 100644 examples/declarative/contacts/contacts.qml create mode 100644 examples/declarative/contacts/dummydata/contactModel.qml create mode 100644 examples/declarative/contacts/main.cpp create mode 100644 examples/declarative/declarative.pro create mode 100644 examples/declarative/dial/DialLibrary/Dial.qml create mode 100644 examples/declarative/dial/DialLibrary/background.svg create mode 100644 examples/declarative/dial/DialLibrary/needle.svg create mode 100644 examples/declarative/dial/DialLibrary/needle_shadow.svg create mode 100644 examples/declarative/dial/DialLibrary/overlay.svg create mode 100644 examples/declarative/dial/dial.qml create mode 100644 examples/declarative/easing/easing.qml create mode 100644 examples/declarative/follow/follow.qml create mode 100644 examples/declarative/follow/pong.qml create mode 100644 examples/declarative/listview/content/MediaButton.qml create mode 100644 examples/declarative/listview/content/pics/button-pressed.png create mode 100644 examples/declarative/listview/content/pics/button.png create mode 100644 examples/declarative/listview/content/pics/fruit-salad.jpg create mode 100644 examples/declarative/listview/content/pics/hamburger.jpg create mode 100644 examples/declarative/listview/content/pics/lemonade.jpg create mode 100644 examples/declarative/listview/content/pics/pancakes.jpg create mode 100644 examples/declarative/listview/content/pics/vegetable-soup.jpg create mode 100644 examples/declarative/listview/dummydata/MyPetsModel.qml create mode 100644 examples/declarative/listview/dummydata/Recipies.qml create mode 100644 examples/declarative/listview/highlight.qml create mode 100644 examples/declarative/listview/listview.qml create mode 100644 examples/declarative/listview/recipes.qml create mode 100644 examples/declarative/minehunt/Description.qml create mode 100644 examples/declarative/minehunt/Explosion.qml create mode 100644 examples/declarative/minehunt/main.cpp create mode 100644 examples/declarative/minehunt/minehunt.pro create mode 100644 examples/declarative/minehunt/minehunt.qml create mode 100644 examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg create mode 100644 examples/declarative/minehunt/pics/bomb-color.png create mode 100644 examples/declarative/minehunt/pics/bomb.png create mode 100644 examples/declarative/minehunt/pics/cachepix-black.png create mode 100644 examples/declarative/minehunt/pics/cachepix-black.sci create mode 100644 examples/declarative/minehunt/pics/cachepix-boxless.png create mode 100644 examples/declarative/minehunt/pics/cachepix-boxless.sci create mode 100644 examples/declarative/minehunt/pics/flag-color.png create mode 100644 examples/declarative/minehunt/pics/flag.png create mode 100644 examples/declarative/minehunt/pics/frown.png create mode 100644 examples/declarative/minehunt/pics/glee.png create mode 100644 examples/declarative/minehunt/pics/smile.png create mode 100644 examples/declarative/minehunt/pics/star.png create mode 100644 examples/declarative/mouseregion/mouse.qml create mode 100644 examples/declarative/namespaces/BlueStuff/Rect.qml create mode 100644 examples/declarative/namespaces/Local.qml create mode 100644 examples/declarative/namespaces/components.qml create mode 100644 examples/declarative/namespaces/lib/Chronos/Clock.qml create mode 100644 examples/declarative/namespaces/lib/Chronos/Hand.qml create mode 100644 examples/declarative/namespaces/lib/Chronos/pics/clockface.png create mode 100644 examples/declarative/namespaces/lib/Path/PathLabel.qml create mode 100644 examples/declarative/namespaces/lib/RedStuff/Rect.qml create mode 100644 examples/declarative/namespaces/lib/Wrong/Wrong.qml create mode 100644 examples/declarative/namespaces/library.qml create mode 100644 examples/declarative/namespaces/path.qml create mode 100644 examples/declarative/namespaces/simple.qml create mode 100644 examples/declarative/namespaces/wrong1.qml create mode 100644 examples/declarative/scrollbar/ScrollBar.qml create mode 100644 examples/declarative/scrollbar/display.qml create mode 100644 examples/declarative/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/declarative/slideswitch/Switch.qml create mode 100644 examples/declarative/slideswitch/background.svg create mode 100644 examples/declarative/slideswitch/display.qml create mode 100644 examples/declarative/slideswitch/knob.svg create mode 100644 examples/declarative/states/states.qml create mode 100644 examples/declarative/states/transitions.qml create mode 100644 examples/declarative/support/contact.cpp create mode 100644 examples/declarative/support/contact.h create mode 100644 examples/declarative/support/contactmodel.cpp create mode 100644 examples/declarative/support/contactmodel.h create mode 100644 examples/declarative/support/support.pro create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_an_animation.qml create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton1.qml create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton2.qml create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton3.qml create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton4.qml create mode 100644 examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton5.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/Contact3.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/Contact4.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/ContactField1.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/ContactField2.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/ContactField3.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/ContactField4.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/FieldText3.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/FieldText4.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/RemoveButton1.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/RemoveButton2.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/RemoveButton3.qml create mode 100644 examples/declarative/tutorials/contacts/2_Reuse/RemoveButton4.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/Button.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/Contact.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/ContactField.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/ContactView1.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/ContactView2.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/ContactView3.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/FieldText.qml create mode 100644 examples/declarative/tutorials/contacts/3_Collections/RemoveButton.qml create mode 100644 examples/declarative/tutorials/contacts/shared/contacts.sqlite create mode 100644 examples/declarative/tutorials/contacts/shared/pics/cancel.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/email.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/new.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/ok.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/phone.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/search.png create mode 100644 examples/declarative/tutorials/contacts/shared/pics/trash.png create mode 100644 examples/declarative/tutorials/contacts/t8/Button.qml create mode 100644 examples/declarative/tutorials/contacts/t8/Contact.qml create mode 100644 examples/declarative/tutorials/contacts/t8/Field.qml create mode 100644 examples/declarative/tutorials/contacts/t8/FieldRemover.qml create mode 100644 examples/declarative/tutorials/contacts/t8/FieldText.qml create mode 100644 examples/declarative/tutorials/contacts/t8/SearchBar.qml create mode 100644 examples/declarative/tutorials/contacts/t8/contacts.qml create mode 100644 examples/declarative/tutorials/t1/tutorial1.qml create mode 100644 examples/declarative/tutorials/t2/Cell.qml create mode 100644 examples/declarative/tutorials/t2/tutorial2.qml create mode 100644 examples/declarative/tutorials/t3/Cell.qml create mode 100644 examples/declarative/tutorials/t3/tutorial3.qml create mode 100644 examples/declarative/velocity/Day.qml create mode 100644 examples/declarative/velocity/cork.jpg create mode 100644 examples/declarative/velocity/sticky.png create mode 100644 examples/declarative/velocity/tack.png create mode 100644 examples/declarative/velocity/velocity.qml create mode 100644 examples/declarative/webview/autosize.qml create mode 100644 examples/declarative/webview/content/SpinSquare.qml create mode 100644 examples/declarative/webview/inline-html.qml create mode 100644 examples/declarative/webview/inline-xhtml.qml create mode 100644 examples/declarative/webview/qml-in-html.qml create mode 100644 examples/declarative/webview/transparent.qml create mode 100644 examples/declarative/xmldata/daringfireball.qml create mode 100644 examples/declarative/xmldata/yahoonews.qml create mode 100644 examples/statemachine/README create mode 100644 examples/statemachine/citizenquartz/citizenquartz.pro create mode 100644 examples/statemachine/citizenquartz/citizenquartz.qrc create mode 100644 examples/statemachine/citizenquartz/clock.cpp create mode 100644 examples/statemachine/citizenquartz/clock.h create mode 100644 examples/statemachine/citizenquartz/clockbutton.cpp create mode 100644 examples/statemachine/citizenquartz/clockbutton.h create mode 100644 examples/statemachine/citizenquartz/clockdisplay.cpp create mode 100644 examples/statemachine/citizenquartz/clockdisplay.h create mode 100644 examples/statemachine/citizenquartz/images/alarm.png create mode 100644 examples/statemachine/citizenquartz/main.cpp create mode 100644 examples/statemachine/citizenquartz/propertyaddstate.cpp create mode 100644 examples/statemachine/citizenquartz/propertyaddstate.h create mode 100644 examples/statemachine/citizenquartz/sound/alarm.wav create mode 100644 examples/statemachine/citizenquartz/timeperiod.h create mode 100644 examples/statemachine/clockticking/clockticking.pro create mode 100644 examples/statemachine/clockticking/main.cpp create mode 100644 examples/statemachine/composition/composition.pro create mode 100644 examples/statemachine/composition/main.cpp create mode 100644 examples/statemachine/eventtransitions/eventtransitions.pro create mode 100644 examples/statemachine/eventtransitions/main.cpp create mode 100644 examples/statemachine/factorial/factorial.pro create mode 100644 examples/statemachine/factorial/main.cpp create mode 100644 examples/statemachine/helloworld/helloworld.pro create mode 100644 examples/statemachine/helloworld/main.cpp create mode 100644 examples/statemachine/pauseandresume/main.cpp create mode 100644 examples/statemachine/pauseandresume/pauseandresume.pro create mode 100644 examples/statemachine/pingpong/main.cpp create mode 100644 examples/statemachine/pingpong/pingpong.pro create mode 100644 examples/statemachine/statemachine.pro create mode 100644 examples/statemachine/trafficlight/main.cpp create mode 100644 examples/statemachine/trafficlight/trafficlight.pro create mode 100644 examples/statemachine/twowaybutton/main.cpp create mode 100644 examples/statemachine/twowaybutton/twowaybutton.pro create mode 100644 mkspecs/linux-g++-x11egl/qmake.conf create mode 100644 mkspecs/linux-g++-x11egl/qplatformdefs.h create mode 100644 mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf create mode 100644 mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h create mode 100644 src/3rdparty/easing/easing.cpp create mode 100644 src/3rdparty/easing/legal.qdoc create mode 100644 src/corelib/animation/animation.pri create mode 100644 src/corelib/animation/qabstractanimation.cpp create mode 100644 src/corelib/animation/qabstractanimation.h create mode 100644 src/corelib/animation/qabstractanimation_p.h create mode 100644 src/corelib/animation/qanimationgroup.cpp create mode 100644 src/corelib/animation/qanimationgroup.h create mode 100644 src/corelib/animation/qanimationgroup_p.h create mode 100644 src/corelib/animation/qparallelanimationgroup.cpp create mode 100644 src/corelib/animation/qparallelanimationgroup.h create mode 100644 src/corelib/animation/qparallelanimationgroup_p.h create mode 100644 src/corelib/animation/qpauseanimation.cpp create mode 100644 src/corelib/animation/qpauseanimation.h create mode 100644 src/corelib/animation/qpropertyanimation.cpp create mode 100644 src/corelib/animation/qpropertyanimation.h create mode 100644 src/corelib/animation/qpropertyanimation_p.h create mode 100644 src/corelib/animation/qsequentialanimationgroup.cpp create mode 100644 src/corelib/animation/qsequentialanimationgroup.h create mode 100644 src/corelib/animation/qsequentialanimationgroup_p.h create mode 100644 src/corelib/animation/qvariantanimation.cpp create mode 100644 src/corelib/animation/qvariantanimation.h create mode 100644 src/corelib/animation/qvariantanimation_p.h create mode 100644 src/corelib/kernel/qmetaobjectbuilder.cpp create mode 100644 src/corelib/kernel/qmetaobjectbuilder_p.h create mode 100644 src/corelib/statemachine/qabstractstate.cpp create mode 100644 src/corelib/statemachine/qabstractstate.h create mode 100644 src/corelib/statemachine/qabstractstate_p.h create mode 100644 src/corelib/statemachine/qabstracttransition.cpp create mode 100644 src/corelib/statemachine/qabstracttransition.h create mode 100644 src/corelib/statemachine/qabstracttransition_p.h create mode 100644 src/corelib/statemachine/qactionstate.cpp create mode 100644 src/corelib/statemachine/qactionstate.h create mode 100644 src/corelib/statemachine/qactionstate_p.h create mode 100644 src/corelib/statemachine/qanimationstate.cpp create mode 100644 src/corelib/statemachine/qanimationstate.h create mode 100644 src/corelib/statemachine/qboundevent_p.h create mode 100644 src/corelib/statemachine/qeventtransition.cpp create mode 100644 src/corelib/statemachine/qeventtransition.h create mode 100644 src/corelib/statemachine/qeventtransition_p.h create mode 100644 src/corelib/statemachine/qfinalstate.cpp create mode 100644 src/corelib/statemachine/qfinalstate.h create mode 100644 src/corelib/statemachine/qhistorystate.cpp create mode 100644 src/corelib/statemachine/qhistorystate.h create mode 100644 src/corelib/statemachine/qhistorystate_p.h create mode 100644 src/corelib/statemachine/qsignalevent.h create mode 100644 src/corelib/statemachine/qsignaleventgenerator_p.h create mode 100644 src/corelib/statemachine/qsignaltransition.cpp create mode 100644 src/corelib/statemachine/qsignaltransition.h create mode 100644 src/corelib/statemachine/qsignaltransition_p.h create mode 100644 src/corelib/statemachine/qstate.cpp create mode 100644 src/corelib/statemachine/qstate.h create mode 100644 src/corelib/statemachine/qstate_p.h create mode 100644 src/corelib/statemachine/qstateaction.cpp create mode 100644 src/corelib/statemachine/qstateaction.h create mode 100644 src/corelib/statemachine/qstateaction_p.h create mode 100644 src/corelib/statemachine/qstatefinishedevent.h create mode 100644 src/corelib/statemachine/qstatefinishedtransition.cpp create mode 100644 src/corelib/statemachine/qstatefinishedtransition.h create mode 100644 src/corelib/statemachine/qstatemachine.cpp create mode 100644 src/corelib/statemachine/qstatemachine.h create mode 100644 src/corelib/statemachine/qstatemachine_p.h create mode 100644 src/corelib/statemachine/qtransition.cpp create mode 100644 src/corelib/statemachine/qtransition.h create mode 100644 src/corelib/statemachine/qtransition_p.h create mode 100644 src/corelib/statemachine/statemachine.pri create mode 100644 src/corelib/tools/qeasingcurve.cpp create mode 100644 src/corelib/tools/qeasingcurve.h create mode 100644 src/declarative/3rdparty/3rdparty.pri create mode 100644 src/declarative/3rdparty/easing.cpp create mode 100644 src/declarative/3rdparty/legal.qdoc create mode 100644 src/declarative/3rdparty/qlistmodelinterface.h create mode 100644 src/declarative/canvas/canvas.pri create mode 100644 src/declarative/canvas/qsimplecanvas.cpp create mode 100644 src/declarative/canvas/qsimplecanvas.h create mode 100644 src/declarative/canvas/qsimplecanvas_graphicsview.cpp create mode 100644 src/declarative/canvas/qsimplecanvas_opengl.cpp create mode 100644 src/declarative/canvas/qsimplecanvas_opengl1.cpp create mode 100644 src/declarative/canvas/qsimplecanvas_p.h create mode 100644 src/declarative/canvas/qsimplecanvas_software.cpp create mode 100644 src/declarative/canvas/qsimplecanvasfilter.cpp create mode 100644 src/declarative/canvas/qsimplecanvasfilter.h create mode 100644 src/declarative/canvas/qsimplecanvasfilter_p.h create mode 100644 src/declarative/canvas/qsimplecanvasitem.cpp create mode 100644 src/declarative/canvas/qsimplecanvasitem.h create mode 100644 src/declarative/canvas/qsimplecanvasitem_p.h create mode 100644 src/declarative/canvas/qsimplecanvasserver.cpp create mode 100644 src/declarative/canvas/qsimplecanvasserver_p.h create mode 100644 src/declarative/declarative.pro create mode 100644 src/declarative/extra/extra.pri create mode 100644 src/declarative/extra/qfxintegermodel.cpp create mode 100644 src/declarative/extra/qfxintegermodel.h create mode 100644 src/declarative/extra/qmlnumberformatter.cpp create mode 100644 src/declarative/extra/qmlnumberformatter.h create mode 100644 src/declarative/extra/qmlsqlconnection.cpp create mode 100644 src/declarative/extra/qmlsqlconnection.h create mode 100644 src/declarative/extra/qmlsqlquery.cpp create mode 100644 src/declarative/extra/qmlsqlquery.h create mode 100644 src/declarative/extra/qmlxmllistmodel.cpp create mode 100644 src/declarative/extra/qmlxmllistmodel.h create mode 100644 src/declarative/extra/qnumberformat.cpp create mode 100644 src/declarative/extra/qnumberformat.h create mode 100644 src/declarative/fx/fx.pri create mode 100644 src/declarative/fx/qfxanchors.cpp create mode 100644 src/declarative/fx/qfxanchors.h create mode 100644 src/declarative/fx/qfxanchors_p.h create mode 100644 src/declarative/fx/qfxanimatedimageitem.cpp create mode 100644 src/declarative/fx/qfxanimatedimageitem.h create mode 100644 src/declarative/fx/qfxanimatedimageitem_p.h create mode 100644 src/declarative/fx/qfxblendedimage.cpp create mode 100644 src/declarative/fx/qfxblendedimage.h create mode 100644 src/declarative/fx/qfxblurfilter.cpp create mode 100644 src/declarative/fx/qfxblurfilter.h create mode 100644 src/declarative/fx/qfxcomponentinstance.cpp create mode 100644 src/declarative/fx/qfxcomponentinstance.h create mode 100644 src/declarative/fx/qfxcomponentinstance_p.h create mode 100644 src/declarative/fx/qfxcontentwrapper.cpp create mode 100644 src/declarative/fx/qfxcontentwrapper.h create mode 100644 src/declarative/fx/qfxcontentwrapper_p.h create mode 100644 src/declarative/fx/qfxflickable.cpp create mode 100644 src/declarative/fx/qfxflickable.h create mode 100644 src/declarative/fx/qfxflickable_p.h create mode 100644 src/declarative/fx/qfxfocuspanel.cpp create mode 100644 src/declarative/fx/qfxfocuspanel.h create mode 100644 src/declarative/fx/qfxfocusrealm.cpp create mode 100644 src/declarative/fx/qfxfocusrealm.h create mode 100644 src/declarative/fx/qfxgridview.cpp create mode 100644 src/declarative/fx/qfxgridview.h create mode 100644 src/declarative/fx/qfxhighlightfilter.cpp create mode 100644 src/declarative/fx/qfxhighlightfilter.h create mode 100644 src/declarative/fx/qfximage.cpp create mode 100644 src/declarative/fx/qfximage.h create mode 100644 src/declarative/fx/qfximage_p.h create mode 100644 src/declarative/fx/qfximageitem.cpp create mode 100644 src/declarative/fx/qfximageitem.h create mode 100644 src/declarative/fx/qfximageitem_p.h create mode 100644 src/declarative/fx/qfxitem.cpp create mode 100644 src/declarative/fx/qfxitem.h create mode 100644 src/declarative/fx/qfxitem_p.h create mode 100644 src/declarative/fx/qfxkeyactions.cpp create mode 100644 src/declarative/fx/qfxkeyactions.h create mode 100644 src/declarative/fx/qfxkeyproxy.cpp create mode 100644 src/declarative/fx/qfxkeyproxy.h create mode 100644 src/declarative/fx/qfxlayouts.cpp create mode 100644 src/declarative/fx/qfxlayouts.h create mode 100644 src/declarative/fx/qfxlayouts_p.h create mode 100644 src/declarative/fx/qfxlistview.cpp create mode 100644 src/declarative/fx/qfxlistview.h create mode 100644 src/declarative/fx/qfxmouseregion.cpp create mode 100644 src/declarative/fx/qfxmouseregion.h create mode 100644 src/declarative/fx/qfxmouseregion_p.h create mode 100644 src/declarative/fx/qfxpainted.cpp create mode 100644 src/declarative/fx/qfxpainted.h create mode 100644 src/declarative/fx/qfxpainted_p.h create mode 100644 src/declarative/fx/qfxparticles.cpp create mode 100644 src/declarative/fx/qfxparticles.h create mode 100644 src/declarative/fx/qfxpath.cpp create mode 100644 src/declarative/fx/qfxpath.h create mode 100644 src/declarative/fx/qfxpath_p.h create mode 100644 src/declarative/fx/qfxpathview.cpp create mode 100644 src/declarative/fx/qfxpathview.h create mode 100644 src/declarative/fx/qfxpathview_p.h create mode 100644 src/declarative/fx/qfxpixmap.cpp create mode 100644 src/declarative/fx/qfxpixmap.h create mode 100644 src/declarative/fx/qfxrect.cpp create mode 100644 src/declarative/fx/qfxrect.h create mode 100644 src/declarative/fx/qfxrect_p.h create mode 100644 src/declarative/fx/qfxreflectionfilter.cpp create mode 100644 src/declarative/fx/qfxreflectionfilter.h create mode 100644 src/declarative/fx/qfxrepeater.cpp create mode 100644 src/declarative/fx/qfxrepeater.h create mode 100644 src/declarative/fx/qfxrepeater_p.h create mode 100644 src/declarative/fx/qfxscalegrid.cpp create mode 100644 src/declarative/fx/qfxscalegrid.h create mode 100644 src/declarative/fx/qfxshadowfilter.cpp create mode 100644 src/declarative/fx/qfxshadowfilter.h create mode 100644 src/declarative/fx/qfxtext.cpp create mode 100644 src/declarative/fx/qfxtext.h create mode 100644 src/declarative/fx/qfxtext_p.h create mode 100644 src/declarative/fx/qfxtextedit.cpp create mode 100644 src/declarative/fx/qfxtextedit.h create mode 100644 src/declarative/fx/qfxtextedit_p.h create mode 100644 src/declarative/fx/qfxtransform.cpp create mode 100644 src/declarative/fx/qfxtransform.h create mode 100644 src/declarative/fx/qfxvisualitemmodel.cpp create mode 100644 src/declarative/fx/qfxvisualitemmodel.h create mode 100644 src/declarative/fx/qfxwebview.cpp create mode 100644 src/declarative/fx/qfxwebview.h create mode 100644 src/declarative/fx/qfxwidgetcontainer.cpp create mode 100644 src/declarative/fx/qfxwidgetcontainer.h create mode 100644 src/declarative/opengl/glbasicshaders.cpp create mode 100644 src/declarative/opengl/glbasicshaders.h create mode 100644 src/declarative/opengl/glheaders.h create mode 100644 src/declarative/opengl/glsave.cpp create mode 100644 src/declarative/opengl/glsave.h create mode 100644 src/declarative/opengl/gltexture.cpp create mode 100644 src/declarative/opengl/gltexture.h create mode 100644 src/declarative/opengl/opengl.pri create mode 100644 src/declarative/qml/qml.h create mode 100644 src/declarative/qml/qml.pri create mode 100644 src/declarative/qml/qmlbindablevalue.cpp create mode 100644 src/declarative/qml/qmlbindablevalue.h create mode 100644 src/declarative/qml/qmlboundsignal.cpp create mode 100644 src/declarative/qml/qmlboundsignal_p.h create mode 100644 src/declarative/qml/qmlclassfactory.cpp create mode 100644 src/declarative/qml/qmlclassfactory_p.h create mode 100644 src/declarative/qml/qmlcompiledcomponent.cpp create mode 100644 src/declarative/qml/qmlcompiledcomponent_p.h create mode 100644 src/declarative/qml/qmlcompiler.cpp create mode 100644 src/declarative/qml/qmlcompiler_p.h create mode 100644 src/declarative/qml/qmlcomponent.cpp create mode 100644 src/declarative/qml/qmlcomponent.h create mode 100644 src/declarative/qml/qmlcomponent_p.h create mode 100644 src/declarative/qml/qmlcompositetypemanager.cpp create mode 100644 src/declarative/qml/qmlcompositetypemanager_p.h create mode 100644 src/declarative/qml/qmlcontext.cpp create mode 100644 src/declarative/qml/qmlcontext.h create mode 100644 src/declarative/qml/qmlcontext_p.h create mode 100644 src/declarative/qml/qmlcustomparser.cpp create mode 100644 src/declarative/qml/qmlcustomparser.h create mode 100644 src/declarative/qml/qmldom.cpp create mode 100644 src/declarative/qml/qmldom.h create mode 100644 src/declarative/qml/qmldom_p.h create mode 100644 src/declarative/qml/qmlengine.cpp create mode 100644 src/declarative/qml/qmlengine.h create mode 100644 src/declarative/qml/qmlengine_p.h create mode 100644 src/declarative/qml/qmlexpression.h create mode 100644 src/declarative/qml/qmlinfo.cpp create mode 100644 src/declarative/qml/qmlinfo.h create mode 100644 src/declarative/qml/qmlinstruction.cpp create mode 100644 src/declarative/qml/qmlinstruction_p.h create mode 100644 src/declarative/qml/qmllist.h create mode 100644 src/declarative/qml/qmlmetaproperty.cpp create mode 100644 src/declarative/qml/qmlmetaproperty.h create mode 100644 src/declarative/qml/qmlmetaproperty_p.h create mode 100644 src/declarative/qml/qmlmetatype.cpp create mode 100644 src/declarative/qml/qmlmetatype.h create mode 100644 src/declarative/qml/qmlparser.cpp create mode 100644 src/declarative/qml/qmlparser_p.h create mode 100644 src/declarative/qml/qmlparserstatus.cpp create mode 100644 src/declarative/qml/qmlparserstatus.h create mode 100644 src/declarative/qml/qmlprivate.cpp create mode 100644 src/declarative/qml/qmlprivate.h create mode 100644 src/declarative/qml/qmlpropertyvaluesource.cpp create mode 100644 src/declarative/qml/qmlpropertyvaluesource.h create mode 100644 src/declarative/qml/qmlproxymetaobject.cpp create mode 100644 src/declarative/qml/qmlproxymetaobject_p.h create mode 100644 src/declarative/qml/qmlrefcount.cpp create mode 100644 src/declarative/qml/qmlrefcount_p.h create mode 100644 src/declarative/qml/qmlstringconverters.cpp create mode 100644 src/declarative/qml/qmlstringconverters_p.h create mode 100644 src/declarative/qml/qmlvme.cpp create mode 100644 src/declarative/qml/qmlvme_p.h create mode 100644 src/declarative/qml/qmlvmemetaobject.cpp create mode 100644 src/declarative/qml/qmlvmemetaobject_p.h create mode 100644 src/declarative/qml/qmlxmlparser.cpp create mode 100644 src/declarative/qml/qmlxmlparser_p.h create mode 100644 src/declarative/qml/script/generator/generator.pro create mode 100644 src/declarative/qml/script/generator/main.cpp create mode 100644 src/declarative/qml/script/instructions.h create mode 100644 src/declarative/qml/script/keywords.cpp create mode 100644 src/declarative/qml/script/lexer.cpp create mode 100644 src/declarative/qml/script/lexer.h create mode 100644 src/declarative/qml/script/qmlbasicscript.cpp create mode 100644 src/declarative/qml/script/qmlbasicscript.h create mode 100644 src/declarative/qml/script/qmlbasicscript_p.h create mode 100644 src/declarative/qml/script/script.pri create mode 100644 src/declarative/qml/script/tokens.cpp create mode 100644 src/declarative/qml/script/tokens.h create mode 100644 src/declarative/test/qfxtestengine.cpp create mode 100644 src/declarative/test/qfxtestengine.h create mode 100644 src/declarative/test/qfxtestobjects.cpp create mode 100644 src/declarative/test/qfxtestobjects.h create mode 100644 src/declarative/test/qfxtestview.cpp create mode 100644 src/declarative/test/qfxtestview.h create mode 100644 src/declarative/test/test.pri create mode 100644 src/declarative/timeline/gfxeasing.cpp create mode 100644 src/declarative/timeline/gfxeasing.h create mode 100644 src/declarative/timeline/gfxtimeline.cpp create mode 100644 src/declarative/timeline/gfxtimeline.h create mode 100644 src/declarative/timeline/gfxvalueproxy.h create mode 100644 src/declarative/timeline/timeline.pri create mode 100644 src/declarative/util/qbindablemap.cpp create mode 100644 src/declarative/util/qbindablemap.h create mode 100644 src/declarative/util/qfxglobal.h create mode 100644 src/declarative/util/qfxperf.cpp create mode 100644 src/declarative/util/qfxperf.h create mode 100644 src/declarative/util/qfxview.cpp create mode 100644 src/declarative/util/qfxview.h create mode 100644 src/declarative/util/qmlanimation.cpp create mode 100644 src/declarative/util/qmlanimation.h create mode 100644 src/declarative/util/qmlanimation_p.h create mode 100644 src/declarative/util/qmlbehaviour.cpp create mode 100644 src/declarative/util/qmlbehaviour.h create mode 100644 src/declarative/util/qmlbind.cpp create mode 100644 src/declarative/util/qmlbind.h create mode 100644 src/declarative/util/qmlconnection.cpp create mode 100644 src/declarative/util/qmlconnection.h create mode 100644 src/declarative/util/qmldatetimeformatter.cpp create mode 100644 src/declarative/util/qmldatetimeformatter.h create mode 100644 src/declarative/util/qmlfollow.cpp create mode 100644 src/declarative/util/qmlfollow.h create mode 100644 src/declarative/util/qmlfont.cpp create mode 100644 src/declarative/util/qmlfont.h create mode 100644 src/declarative/util/qmllistaccessor.cpp create mode 100644 src/declarative/util/qmllistaccessor.h create mode 100644 src/declarative/util/qmllistmodel.cpp create mode 100644 src/declarative/util/qmllistmodel.h create mode 100644 src/declarative/util/qmlnullablevalue_p.h create mode 100644 src/declarative/util/qmlopenmetaobject.cpp create mode 100644 src/declarative/util/qmlopenmetaobject.h create mode 100644 src/declarative/util/qmlpackage.cpp create mode 100644 src/declarative/util/qmlpackage.h create mode 100644 src/declarative/util/qmlscript.cpp create mode 100644 src/declarative/util/qmlscript.h create mode 100644 src/declarative/util/qmlsetproperties.cpp create mode 100644 src/declarative/util/qmlsetproperties.h create mode 100644 src/declarative/util/qmlstate.cpp create mode 100644 src/declarative/util/qmlstate.h create mode 100644 src/declarative/util/qmlstate_p.h create mode 100644 src/declarative/util/qmlstategroup.cpp create mode 100644 src/declarative/util/qmlstategroup.h create mode 100644 src/declarative/util/qmlstateoperations.cpp create mode 100644 src/declarative/util/qmlstateoperations.h create mode 100644 src/declarative/util/qmltransition.cpp create mode 100644 src/declarative/util/qmltransition.h create mode 100644 src/declarative/util/qperformancelog.cpp create mode 100644 src/declarative/util/qperformancelog.h create mode 100644 src/declarative/util/util.pri create mode 100644 src/declarative/widgets/graphicslayouts.cpp create mode 100644 src/declarative/widgets/graphicslayouts.h create mode 100644 src/declarative/widgets/graphicswidgets.cpp create mode 100644 src/declarative/widgets/graphicswidgets.h create mode 100644 src/declarative/widgets/widgets.pri create mode 100644 src/gui/animation/animation.pri create mode 100644 src/gui/animation/qitemanimation.cpp create mode 100644 src/gui/animation/qitemanimation.h create mode 100644 src/gui/animation/qitemanimation_p.h create mode 100644 src/gui/statemachine/qbasickeyeventtransition.cpp create mode 100644 src/gui/statemachine/qbasickeyeventtransition_p.h create mode 100644 src/gui/statemachine/qbasicmouseeventtransition.cpp create mode 100644 src/gui/statemachine/qbasicmouseeventtransition_p.h create mode 100644 src/gui/statemachine/qguistatemachine.cpp create mode 100644 src/gui/statemachine/qkeyeventtransition.cpp create mode 100644 src/gui/statemachine/qkeyeventtransition.h create mode 100644 src/gui/statemachine/qmouseeventtransition.cpp create mode 100644 src/gui/statemachine/qmouseeventtransition.h create mode 100644 src/gui/statemachine/statemachine.pri create mode 100644 src/opengl/qglshaderprogram.cpp create mode 100644 src/opengl/qglshaderprogram.h create mode 100644 tests/auto/declarative/.gitignore create mode 100644 tests/auto/declarative/datetimeformatter/datetimeformatter.pro create mode 100644 tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp create mode 100644 tests/auto/declarative/declarative.pro create mode 100644 tests/auto/declarative/layouts/data/grid-margin.xml create mode 100644 tests/auto/declarative/layouts/data/grid-spacing-margin.xml create mode 100644 tests/auto/declarative/layouts/data/grid-spacing.xml create mode 100644 tests/auto/declarative/layouts/data/grid.xml create mode 100644 tests/auto/declarative/layouts/data/horizontal-margin.xml create mode 100644 tests/auto/declarative/layouts/data/horizontal-spacing-margin.xml create mode 100644 tests/auto/declarative/layouts/data/horizontal-spacing.xml create mode 100644 tests/auto/declarative/layouts/data/horizontal.xml create mode 100644 tests/auto/declarative/layouts/data/vertical-margin.xml create mode 100644 tests/auto/declarative/layouts/data/vertical-spacing-margin.xml create mode 100644 tests/auto/declarative/layouts/data/vertical-spacing.xml create mode 100644 tests/auto/declarative/layouts/data/vertical.xml create mode 100644 tests/auto/declarative/layouts/layouts.pro create mode 100644 tests/auto/declarative/layouts/tst_layouts.cpp create mode 100644 tests/auto/declarative/listview/data/listview.xml create mode 100644 tests/auto/declarative/listview/listview.pro create mode 100644 tests/auto/declarative/listview/tst_listview.cpp create mode 100644 tests/auto/declarative/namespaces/data/Red/Rect.qml create mode 100644 tests/auto/declarative/namespaces/namespaces.pro create mode 100644 tests/auto/declarative/namespaces/tst_namespaces.cpp create mode 100644 tests/auto/declarative/numberformatter/numberformatter.pro create mode 100644 tests/auto/declarative/numberformatter/tst_numberformatter.cpp create mode 100644 tests/auto/declarative/pathview/data/pathview.xml create mode 100644 tests/auto/declarative/pathview/pathview.pro create mode 100644 tests/auto/declarative/pathview/tst_pathview.cpp create mode 100644 tests/auto/declarative/qbindablemap/qbindablemap.pro create mode 100644 tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp create mode 100644 tests/auto/declarative/qfxtext/qfxtext.pro create mode 100644 tests/auto/declarative/qfxtext/tst_qfxtext.cpp create mode 100644 tests/auto/declarative/qfxtextedit/qfxtextedit.pro create mode 100644 tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp create mode 100644 tests/auto/declarative/qmlbindengine/qmlbindengine.pro create mode 100644 tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp create mode 100644 tests/auto/declarative/qmllist/qmllist.pro create mode 100644 tests/auto/declarative/qmllist/tst_qmllist.cpp create mode 100644 tests/auto/declarative/qmllistaccessor/qmllistaccessor.pro create mode 100644 tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp create mode 100644 tests/auto/declarative/qmlmetaproperty/qmlmetaproperty.pro create mode 100644 tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp create mode 100644 tests/auto/declarative/qmlparser/qmlparser.pro create mode 100644 tests/auto/declarative/qmlparser/tst_qmlparser.cpp create mode 100644 tests/auto/declarative/repeater/data/repeater.xml create mode 100644 tests/auto/declarative/repeater/repeater.pro create mode 100644 tests/auto/declarative/repeater/tst_repeater.cpp create mode 100644 tests/auto/declarative/simplecanvasitem/data/test.xml create mode 100644 tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro create mode 100644 tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp create mode 100644 tests/auto/declarative/visual/ListView/basic1/basic1.xml create mode 100644 tests/auto/declarative/visual/ListView/basic1/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/ListView/basic1/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/ListView/basic1/test create mode 100644 tests/auto/declarative/visual/ListView/basic2/basic2.xml create mode 100644 tests/auto/declarative/visual/ListView/basic2/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/ListView/basic2/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/ListView/basic2/test create mode 100644 tests/auto/declarative/visual/ListView/basic3/basic3.xml create mode 100644 tests/auto/declarative/visual/ListView/basic3/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/ListView/basic3/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/ListView/basic3/test create mode 100644 tests/auto/declarative/visual/ListView/basic4/basic4.xml create mode 100644 tests/auto/declarative/visual/ListView/basic4/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/ListView/basic4/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/ListView/basic4/test create mode 100644 tests/auto/declarative/visual/bindinganimation/bindinganimation.xml create mode 100644 tests/auto/declarative/visual/bindinganimation/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/bindinganimation/data/opengl/manifest-play.xml create mode 100644 tests/auto/declarative/visual/bindinganimation/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/bindinganimation/test create mode 100644 tests/auto/declarative/visual/colorAnimation/colorAnimation.xml create mode 100644 tests/auto/declarative/visual/colorAnimation/image0.png create mode 100644 tests/auto/declarative/visual/colorAnimation/manifest-play.xml create mode 100644 tests/auto/declarative/visual/colorAnimation/manifest.xml create mode 100644 tests/auto/declarative/visual/easing/easing.xml create mode 100644 tests/auto/declarative/visual/easing/image0.png create mode 100644 tests/auto/declarative/visual/easing/manifest-play.xml create mode 100644 tests/auto/declarative/visual/easing/manifest.xml create mode 100644 tests/auto/declarative/visual/easing/pics/qtlogo.png create mode 100644 tests/auto/declarative/visual/flickable/Day.qml create mode 100644 tests/auto/declarative/visual/flickable/cork.jpg create mode 100644 tests/auto/declarative/visual/flickable/flickable.xml create mode 100644 tests/auto/declarative/visual/flickable/image0.png create mode 100644 tests/auto/declarative/visual/flickable/manifest-fail.xml create mode 100644 tests/auto/declarative/visual/flickable/manifest.xml create mode 100644 tests/auto/declarative/visual/flipable/flipable.xml create mode 100644 tests/auto/declarative/visual/flipable/image0.png create mode 100644 tests/auto/declarative/visual/flipable/manifest-play.xml create mode 100644 tests/auto/declarative/visual/flipable/manifest.xml create mode 100644 tests/auto/declarative/visual/flipable/pics/arrow.png create mode 100644 tests/auto/declarative/visual/flipable/pics/face.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo0.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo1.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo10.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo2.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo3.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo4.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo5.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo6.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo7.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo8.png create mode 100644 tests/auto/declarative/visual/flipable/pics/photo9.png create mode 100644 tests/auto/declarative/visual/pauseAnimation/image0.png create mode 100644 tests/auto/declarative/visual/pauseAnimation/manifest-play.xml create mode 100644 tests/auto/declarative/visual/pauseAnimation/manifest.xml create mode 100644 tests/auto/declarative/visual/pauseAnimation/pauseAnimation.xml create mode 100644 tests/auto/declarative/visual/pauseAnimation/pics/qtlogo.png create mode 100644 tests/auto/declarative/visual/qfxtext/elide/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/qfxtext/elide/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/qfxtext/elide/elide.xml create mode 100644 tests/auto/declarative/visual/qfxtext/elide/test create mode 100644 tests/auto/declarative/visual/repeater/basic1/basic1.xml create mode 100644 tests/auto/declarative/visual/repeater/basic1/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/repeater/basic1/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/repeater/basic1/test create mode 100644 tests/auto/declarative/visual/repeater/basic2/basic2.xml create mode 100644 tests/auto/declarative/visual/repeater/basic2/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/repeater/basic2/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/repeater/basic2/test create mode 100644 tests/auto/declarative/visual/repeater/basic3/basic3.xml create mode 100644 tests/auto/declarative/visual/repeater/basic3/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/repeater/basic3/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/repeater/basic3/test create mode 100644 tests/auto/declarative/visual/repeater/basic4/basic4.xml create mode 100644 tests/auto/declarative/visual/repeater/basic4/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/repeater/basic4/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/repeater/basic4/test create mode 100755 tests/auto/declarative/visual/runtests.sh create mode 100644 tests/auto/declarative/visual/tests create mode 100644 tests/auto/declarative/visual/tst_visual.cpp create mode 100644 tests/auto/declarative/visual/visual.pro create mode 100644 tests/auto/declarative/visual/webview/autosize/data/opengl/image0.png create mode 100644 tests/auto/declarative/visual/webview/autosize/data/opengl/manifest.xml create mode 100644 tests/auto/declarative/visual/webview/autosize/test create mode 100644 tests/auto/dynamicobject/dynamicobject.pro create mode 100644 tests/auto/dynamicobject/qdynamicmetaobject.cpp create mode 100644 tests/auto/dynamicobject/qdynamicmetaobject.h create mode 100644 tests/auto/dynamicobject/qmetaobjectbuilder.cpp create mode 100644 tests/auto/dynamicobject/qmetaobjectbuilder.h create mode 100644 tests/auto/dynamicobject/tst_qobject.cpp create mode 100644 tests/auto/qanimationgroup/qanimationgroup.pro create mode 100644 tests/auto/qanimationgroup/tst_qanimationgroup.cpp create mode 100644 tests/auto/qanimationstate/qanimationstate.pro create mode 100644 tests/auto/qanimationstate/tst_qanimationstate.cpp create mode 100644 tests/auto/qeasingcurve/qeasingcurve.pro create mode 100644 tests/auto/qeasingcurve/tst_qeasingcurve.cpp create mode 100644 tests/auto/qparallelanimationgroup/qparallelanimationgroup.pro create mode 100644 tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp create mode 100644 tests/auto/qpropertyanimation/qpropertyanimation.pro create mode 100644 tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp create mode 100644 tests/auto/qsequentialanimationgroup/qsequentialanimationgroup.pro create mode 100644 tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp create mode 100644 tests/auto/qstate/qstate.pro create mode 100644 tests/auto/qstate/tst_qstate.cpp create mode 100644 tests/auto/qstatemachine/qstatemachine.pro create mode 100644 tests/auto/qstatemachine/tst_qstatemachine.cpp create mode 100644 tests/benchmarks/qanimation/dummyanimation.cpp create mode 100644 tests/benchmarks/qanimation/dummyanimation.h create mode 100644 tests/benchmarks/qanimation/dummyobject.cpp create mode 100644 tests/benchmarks/qanimation/dummyobject.h create mode 100644 tests/benchmarks/qanimation/main.cpp create mode 100644 tests/benchmarks/qanimation/qanimation.pro create mode 100644 tests/benchmarks/qanimation/rectanimation.cpp create mode 100644 tests/benchmarks/qanimation/rectanimation.h create mode 100644 tests/benchmarks/qfxview/main.cpp create mode 100644 tests/benchmarks/qfxview/qfxview.pro create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/editor/data.xml create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/background.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/background3.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/battery.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/calendar.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/callhistory.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/camera-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/camera.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/contacts.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/file-manager.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/fire.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-blue.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-container.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-front.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-pink.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/flask-yellow.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/ice.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/icon-reflection.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/internet-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/internet.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-background1.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border1.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-border3.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/menu-highlight.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/menubar.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/messages-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/messages.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/moon.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/sad.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/settings-blur.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/settings.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/signal.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/smile.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/star.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/sun.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/titlebar.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/pics/wifi.png create mode 100644 tests/benchmarks/qfxview/testdata/tatwheel/tat-wheel.xml create mode 100644 tests/benchmarks/qmlxmlparser/main.cpp create mode 100644 tests/benchmarks/qmlxmlparser/qmlxmlparser.pro create mode 100644 tests/benchmarks/qmlxmlparser/testdata/concept2.xml create mode 100644 tools/duiviewer/duiviewer.pro create mode 100644 tools/duiviewer/main.cpp create mode 100644 tools/duiviewer/qfxviewer.cpp create mode 100644 tools/duiviewer/qfxviewer.h diff --git a/.gitignore b/.gitignore index 0de9563..9f4144a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,8 +12,11 @@ config.tests/*/*/* !config.tests/*/*/*[.]* config.tests/*/*/*[.]app +callgrind.out.* +pcviewer.cfg *~ *.a +*.la *.core *.moc *.o @@ -44,6 +47,7 @@ bin/Qt*.dll bin/assistant* bin/designer* bin/dumpcpp* +bin/duiviewer* bin/idc* bin/linguist* bin/lrelease* diff --git a/bin/snapshot b/bin/snapshot new file mode 100644 index 0000000..8cf3be2 --- /dev/null +++ b/bin/snapshot @@ -0,0 +1,333 @@ +#!/usr/bin/perl -w +###################################################################### +# +# +###################################################################### + +# use packages ------------------------------------------------------- +use File::Basename; +use File::Path; +use Cwd; +use Config; +use strict; + +my $targetPath = ""; +my $qtdir = $ENV{"QTDIR"}; + +my @files = ( + "3rdparty/easing/easing.cpp", + "corelib/tools/qeasingcurve.h", + "corelib/tools/qeasingcurve.cpp", + "corelib/animation/animation.pri", + "corelib/animation/qabstractanimation.cpp", + "corelib/animation/qabstractanimation.h", + "corelib/animation/qabstractanimation_p.h", + "corelib/animation/qvariantanimation.cpp", + "corelib/animation/qvariantanimation.h", + "corelib/animation/qanimationgroup.cpp", + "corelib/animation/qvariantanimation_p.h", + "corelib/animation/qanimationgroup.h", + "corelib/animation/qanimationgroup_p.h", + "corelib/animation/qparallelanimationgroup.cpp", + "corelib/animation/qparallelanimationgroup.h", + "corelib/animation/qparallelanimationgroup_p.h", + "corelib/animation/qpauseanimation.cpp", + "corelib/animation/qpauseanimation.h", + "corelib/animation/qpropertyanimation.cpp", + "corelib/animation/qpropertyanimation.h", + "corelib/animation/qpropertyanimation_p.h", + "corelib/animation/qsequentialanimationgroup.cpp", + "corelib/animation/qsequentialanimationgroup.h", + "corelib/animation/qsequentialanimationgroup_p.h", + "corelib/statemachine/statemachine.pri", + "corelib/statemachine/qabstractstate.cpp", + "corelib/statemachine/qabstractstate.h", + "corelib/statemachine/qabstractstate_p.h", + "corelib/statemachine/qabstracttransition.cpp", + "corelib/statemachine/qabstracttransition.h", + "corelib/statemachine/qabstracttransition_p.h", + "corelib/statemachine/qactionstate.h", + "corelib/statemachine/qactionstate_p.h", + "corelib/statemachine/qactionstate.cpp", + "corelib/statemachine/qanimationstate.cpp", + "corelib/statemachine/qanimationstate.h", + "corelib/statemachine/qboundevent_p.h", + "corelib/statemachine/qeventtransition.cpp", + "corelib/statemachine/qeventtransition.h", + "corelib/statemachine/qeventtransition_p.h", + "corelib/statemachine/qfinalstate.cpp", + "corelib/statemachine/qfinalstate.h", + "corelib/statemachine/qhistorystate.cpp", + "corelib/statemachine/qhistorystate.h", + "corelib/statemachine/qhistorystate_p.h", + "corelib/statemachine/qsignalevent.h", + "corelib/statemachine/qsignaleventgenerator_p.h", + "corelib/statemachine/qsignaltransition.cpp", + "corelib/statemachine/qsignaltransition.h", + "corelib/statemachine/qsignaltransition_p.h", + "corelib/statemachine/qstate.cpp", + "corelib/statemachine/qstate.h", + "corelib/statemachine/qstateaction.cpp", + "corelib/statemachine/qstateaction.h", + "corelib/statemachine/qstateaction_p.h", + "corelib/statemachine/qstatefinishedevent.h", + "corelib/statemachine/qstatefinishedtransition.cpp", + "corelib/statemachine/qstatefinishedtransition.h", + "corelib/statemachine/qstatemachine.cpp", + "corelib/statemachine/qstatemachine.h", + "corelib/statemachine/qstatemachine_p.h", + "corelib/statemachine/qstate_p.h", + "corelib/statemachine/qtransition.cpp", + "corelib/statemachine/qtransition.h", + "corelib/statemachine/qtransition_p.h", + "gui/statemachine/qkeyeventtransition.h", + "gui/statemachine/qkeyeventtransition.cpp", + "gui/statemachine/qbasickeyeventtransition.cpp", + "gui/statemachine/qbasickeyeventtransition_p.h", + "gui/statemachine/qbasicmouseeventtransition.cpp", + "gui/statemachine/qbasicmouseeventtransition_p.h", + "gui/statemachine/qguistatemachine.cpp", + "gui/statemachine/qkeyeventtransition.cpp", + "gui/statemachine/qkeyeventtransition.h", + "gui/statemachine/qmouseeventtransition.cpp", + "gui/statemachine/qmouseeventtransition.h", + "gui/statemachine/statemachine.pri", # needs special handling + ); + + +while ( @ARGV ) { + my $arg = shift @ARGV; + if ("$arg" eq "-to") { + $targetPath = shift @ARGV; + } +} + +if ($targetPath eq "") { + die("missing -to option"); +} + +my $projectXML = "$targetPath\\files.xml"; +open(OXML, "> " . $projectXML) || die "Could not open $projectXML for writing (no write permission?)"; + +print "COPYING SOURCES...\n"; +foreach my $files(@files) { + copyFile("$qtdir/src/$files","$targetPath/src"); +} +copyFile("$qtdir/doc/src/animation.qdoc","$targetPath/doc"); +copyFile("$qtdir/doc/src/statemachine.qdoc","$targetPath/doc"); +copyFile("$qtdir/src/3rdparty/easing/legal.qdoc","$targetPath/doc"); + +copyFile("$qtdir/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp","$targetPath/doc/src/snippets/code"); + + +my %animation_examples = ( + easing => [ "easing.pro", + "main.cpp", + "window.cpp", + "window.h", + "animation.h", + "form.ui", + "images/qt-logo.png", + "resources.qrc"], + moveblocks => [ "moveblocks.pro", + "main.cpp" ], + animatedtiles => [ "animatedtiles.pro", + "animatedtiles.qrc", + "main.cpp", + "images/*"], + "sub-attaq" => ["sub-attaq.pro", + "animationmanager.cpp", + "animationmanager.h", + "boat.cpp", + "boat_p.h", + "boat.h", + "bomb.cpp", + "bomb.h", + "custompropertyanimation.h", + "custompropertyanimation_p.h", + "custompropertyanimation.cpp", + "graphicsscene.cpp", + "graphicsscene.h", + "main.cpp", + "mainwindow.cpp", + "mainwindow.h", + "pics/scalable/*", + "pics/big/*", + "pics/small/*", + "pics/welcome/*", + "pixmapitem.cpp", + "pixmapitem.h", + "subattaq.qrc", + "submarine.cpp", + "submarine.h", + "submarine_p.h", + "states.cpp", + "states.h", + "torpedo.cpp", + "torpedo.h"], + "stickman" => ["stickman.pro", + "main.cpp", + "animation.cpp", + "animation.h", + "graphicsview.cpp", + "graphicsview.h", + "lifecycle.cpp", + "lifecycle.h", + "node.cpp", + "node.h", + "stickman.cpp", + "stickman.h", + "animations/chilling", + "animations/dancing", + "animations/dead", + "animations/jumping"] + ); + +my $exDir; +print "COPYING EXAMPLES...\n"; +for $exDir ( keys %animation_examples ) { + print " $exDir...\n"; + my $i = 0; + for $i ( 0 .. $#{ $animation_examples{$exDir} } ) { + my $ex_file = $animation_examples{$exDir}[$i]; + + my $copyTargetPath; + my $glob = 0; + if (index($ex_file,"/") > 0) { + my($basefile, $fullPath) = fileparse("$targetPath/examples/$exDir/$ex_file"); + if ($basefile eq "*") { + $glob = 1; + } + mkpath "$fullPath", 0777 unless(-e "$fullPath"); + $copyTargetPath = "$fullPath"; + } else { + $copyTargetPath = "$targetPath/examples/$exDir"; + } + my $lastCh = substr($copyTargetPath, length($copyTargetPath) - 1, 1); + if ($lastCh eq "/" || $lastCh eq "\\") { + chop($copyTargetPath); + } + + if ($glob eq 1) { + my @globFiles = < $qtdir/examples/animation/$exDir/$ex_file >; + foreach my $globFile(@globFiles) { + copyFile("$globFile", "$copyTargetPath"); + } + } else { + copyFile("$qtdir/examples/animation/$exDir/$ex_file", "$copyTargetPath"); + } + } +} + +close OXML; +print("Finished!"); +###################################################################### +# Syntax: copyFile(gitfile, destinationPath) +# Params: gitfile, string, filename to create duplicate for +# destinationPath, string, destination name of duplicate +# +# Purpose: Copies to the solutions area. +# Returns: -- +# Warning: Dies if script cannot get write access. +###################################################################### +sub copyFile +{ + my ($gitfile, $destinationPath) = @_; + # Bi-directional synchronization + open( I, "< " . $gitfile ) || die "Could not open $gitfile for reading"; + local $/; + binmode I; + my $filecontents = ; + my ($baseFileName, $path, $ext) = fileparse($gitfile, qr/\.[^.]*/); + if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") { + # both public and private classes + $filecontents =~s/QAbstractAnimation/QtAbstractAnimation/g; + $filecontents =~s/QAnimationGroup/QtAnimationGroup/g; + $filecontents =~s/QParallelAnimationGroup/QtParallelAnimationGroup/g; + $filecontents =~s/QSequentialAnimationGroup/QtSequentialAnimationGroup/g; + $filecontents =~s/QEasingCurve/QtEasingCurve/g; + $filecontents =~s/QVariantAnimation/QtVariantAnimation/g; + $filecontents =~s/QPropertyAnimation/QtPropertyAnimation/g; + $filecontents =~s/QItemAnimation/QtItemAnimation/g; + $filecontents =~s/QPauseAnimation/QtPauseAnimation/g; + $filecontents =~s/QAbstractState/QtAbstractState/g; + $filecontents =~s/QAbstractStateGroup/QtAbstractStateGroup/g; + $filecontents =~s/QAbstractTransition/QtAbstractTransition/g; + $filecontents =~s/QActionState/QtActionState/g; + $filecontents =~s/QAnimationState/QtAnimationState/g; + $filecontents =~s/QEventTransition/QtEventTransition/g; + $filecontents =~s/QFinalState/QtFinalState/g; + $filecontents =~s/QHistoryState/QtHistoryState/g; + $filecontents =~s/QParallelStateGroup/QtParallelStateGroup/g; + $filecontents =~s/QSignalEvent/QtSignalEvent/g; + $filecontents =~s/QSignalTransition/QtSignalTransition/g; + $filecontents =~s/QState/QtState/g; + $filecontents =~s/QStateAction/QtStateAction/g; + $filecontents =~s/QStateSetPropertyAction/QtStateSetPropertyAction/g; + $filecontents =~s/QStateInvokeMethodAction/QtStateInvokeMethodAction/g; + $filecontents =~s/QStateFinishedEvent/QtStateFinishedEvent/g; + $filecontents =~s/QStateFinishedTransition/QtStateFinishedTransition/g; + $filecontents =~s/QStateMachine/QtStateMachine/g; + $filecontents =~s/QTransition/QtTransition/g; + $filecontents =~s/QMouseEventTransition/QtMouseEventTransition/g; + $filecontents =~s/QKeyEventTransition/QtKeyEventTransition/g; + $filecontents =~s/QGraphicsWidget/QtGraphicsWidget/g; + $filecontents =~s/Q_CORE_EXPORT/Q_ANIMATION_EXPORT/g; + $filecontents =~s/Q_GUI_EXPORT/Q_ANIMATION_EXPORT/g; + $filecontents =~s/QBoundEvent/QtBoundEvent/g; + + $filecontents =~s/class Q_GUI_EXPORT/class/g; + $filecontents =~s/class Q_AUTOTEST_EXPORT/class/g; + + $filecontents =~s/(#\s*include\s+["])q/${1}qt/g; + + # moc stuff + $filecontents =~s/(#\s*include\s+["])moc_q/${1}moc_qt/g; + + $filecontents =~s/\\since 4\.[0-9]//g; + $filecontents =~s/\\ingroup [a-z]+//g; + + if (substr($filecontents, 0, 10) eq "/*********") { + my $endOfComment = index($filecontents, "*/"); + $filecontents = substr($filecontents, $endOfComment + 2); + } + } + if ($ext eq ".pri" ) { + $filecontents =~s/\$\$PWD\/q/\$\$PWD\/qt/g; + $filecontents =~s/animation\/q/\$\$PWD\/qt/g; + + # oooh such a hack this is + if ($baseFileName eq "statemachine") { + if (index($gitfile, "corelib/statemachine") >= 0) { + $baseFileName = "corelib_statemachine"; + } + if (index($gitfile, "gui/statemachine") >= 0) { + $baseFileName = "gui_statemachine"; + } + + } + + } + + if ($ext eq ".pro") { + $filecontents = "$filecontents\ninclude(../../src/qtanimationframework.pri)\n"; + } + close I; + + mkpath $destinationPath, 0777 unless(-e "$destinationPath"); + + if ($ext eq ".h" or $ext eq ".cpp" or $ext eq ".qdoc") { + $baseFileName =~s/^q/qt/g; + } + my $targetFile = "$destinationPath/$baseFileName$ext"; + open(O, "> " . $targetFile) || die "Could not open $targetFile for writing (no write permission?)"; + local $/; + binmode O; + print O $filecontents; + close O; + + my $xmlEntry = substr($targetFile, length($targetPath) + 1); + print "$xmlEntry\n"; + print OXML "$xmlEntry\n"; +} + diff --git a/bin/syncqt b/bin/syncqt index 7a9f1d3..8f797e8 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -23,6 +23,7 @@ my $basedir = $ENV{"QTDIR"}; $basedir =~ s=\\=/=g; my %modules = ( # path to module name map "QtGui" => "$basedir/src/gui", + "QtAnimation" => "$basedir/src/animation", "QtOpenGL" => "$basedir/src/opengl", "QtCore" => "$basedir/src/corelib", "QtXml" => "$basedir/src/xml", @@ -30,6 +31,7 @@ my %modules = ( # path to module name map "QtSql" => "$basedir/src/sql", "QtNetwork" => "$basedir/src/network", "QtSvg" => "$basedir/src/svg", + "QtDeclarative" => "$basedir/src/declarative", "QtScript" => "$basedir/src/script", "QtScriptTools" => "$basedir/src/scripttools", "Qt3Support" => "$basedir/src/qt3support", @@ -680,8 +682,10 @@ foreach (@modules_to_sync) { foreach(split(/ /, "$1")) { $master_contents .= "#include \n" if("$_" eq "core"); $master_contents .= "#include \n" if("$_" eq "gui"); + $master_contents .= "#include \n" if("$_" eq "experimental-animation"); $master_contents .= "#include \n" if("$_" eq "network"); $master_contents .= "#include \n" if("$_" eq "svg"); + $master_contents .= "#include \n" if("$_" eq "declarative"); $master_contents .= "#include \n" if("$_" eq "script"); $master_contents .= "#include \n" if("$_" eq "scripttools"); $master_contents .= "#include \n" if("$_" eq "qt3support"); diff --git a/configure b/configure index 2298d5b..420994c 100755 --- a/configure +++ b/configure @@ -600,6 +600,7 @@ CFG_RELEASE_QMAKE=no CFG_PHONON=auto CFG_PHONON_BACKEND=yes CFG_SVG=yes +CFG_DECLARATIVE=yes CFG_WEBKIT=auto # (yes|no|auto) CFG_GFX_AVAILABLE="linuxfb transformed qvfb vnc multiscreen" @@ -830,7 +831,7 @@ while [ "$#" -gt 0 ]; do VAL=no ;; #Qt style yes options - -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-svg|-webkit|-scripttools|-rpath|-force-pkg-config) + -incremental|-qvfb|-profile|-shared|-static|-sm|-xinerama|-xshape|-xinput|-reduce-exports|-pch|-separate-debug-info|-stl|-freetype|-xcursor|-xfixes|-xrandr|-xrender|-mitshm|-fontconfig|-xkb|-nis|-qdbus|-dbus|-dbus-linked|-glib|-gstreamer|-gtkstyle|-cups|-iconv|-largefile|-h|-help|-v|-verbose|-debug|-release|-fast|-accessibility|-confirm-license|-gnumake|-framework|-qt3support|-debug-and-release|-exceptions|-cocoa|-universal|-prefix-install|-silent|-armfpa|-optimized-qmake|-dwarf2|-reduce-relocations|-sse|-openssl|-openssl-linked|-ptmalloc|-xmlpatterns|-phonon|-phonon-backend|-svg|-declarative|-webkit|-scripttools|-rpath|-force-pkg-config) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` VAL=yes ;; @@ -1724,6 +1725,17 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi fi + ;; + declarative) + if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then + CFG_DECLARATIVE="yes" + else + if [ "$VAL" = "no" ]; then + CFG_DECLARATIVE="no" + else + UNKNOWN_OPT=yes + fi + fi ;; webkit) if [ "$VAL" = "yes" ] || [ "$VAL" = "auto" ]; then @@ -3066,7 +3078,7 @@ Usage: $relconf [-h] [-prefix ] [-prefix-install] [-bindir ] [-libdir [-no-phonon] [-phonon] [-no-phonon-backend] [-phonon-backend] [-no-openssl] [-openssl] [-openssl-linked] [-no-gtkstyle] [-gtkstyle] [-no-svg] [-svg] [-no-webkit] [-webkit] - [-no-scripttools] [-scripttools] + [-no-scripttools] [-scripttools] [-no-declarative] [-declarative] [additional platform specific options (see below)] @@ -3215,6 +3227,9 @@ fi -no-scripttools .... Do not build the QtScriptTools module. + -scripttools ....... Build the QtScriptTools module. + -no-declarative .....Do not build the declarative module. + + -declarative ....... Build the declarative module. + -platform target ... The operating system and compiler you are building on ($PLATFORM). @@ -5961,6 +5976,12 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SVG" fi +if [ "$CFG_DECLARATIVE" = "yes" ]; then + QT_CONFIG="$QT_CONFIG declarative" +else + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DECLARATIVE" +fi + if [ "$CFG_WEBKIT" = "auto" ]; then CFG_WEBKIT="$canBuildWebKit" fi @@ -6846,6 +6867,7 @@ echo "QtXmlPatterns module $CFG_XMLPATTERNS" echo "Phonon module ....... $CFG_PHONON" echo "SVG module .......... $CFG_SVG" echo "WebKit module ....... $CFG_WEBKIT" +echo "Declarative module .. $CFG_DECLARATIVE" echo "STL support ......... $CFG_STL" echo "PCH support ......... $CFG_PRECOMPILE" echo "MMX/3DNOW/SSE/SSE2.. ${CFG_MMX}/${CFG_3DNOW}/${CFG_SSE}/${CFG_SSE2}" diff --git a/configure.exe b/configure.exe index ff71f08..54e8a60 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro index 6c1a331..a7b19a3 100644 --- a/demos/boxes/boxes.pro +++ b/demos/boxes/boxes.pro @@ -11,7 +11,6 @@ INCLUDEPATH += . HEADERS += 3rdparty/fbm.h \ glbuffers.h \ glextensions.h \ - glshaders.h \ gltrianglemesh.h \ qtbox.h \ roundedbox.h \ @@ -21,7 +20,6 @@ HEADERS += 3rdparty/fbm.h \ SOURCES += 3rdparty/fbm.c \ glbuffers.cpp \ glextensions.cpp \ - glshaders.cpp \ main.cpp \ qtbox.cpp \ roundedbox.cpp \ diff --git a/demos/boxes/glextensions.cpp b/demos/boxes/glextensions.cpp index 59256a8..5f168b6 100644 --- a/demos/boxes/glextensions.cpp +++ b/demos/boxes/glextensions.cpp @@ -47,23 +47,6 @@ bool GLExtensionFunctions::resolve(const QGLContext *context) { bool ok = true; - RESOLVE_GL_FUNC(CreateShaderObjectARB) - RESOLVE_GL_FUNC(ShaderSourceARB) - RESOLVE_GL_FUNC(CompileShaderARB) - RESOLVE_GL_FUNC(GetObjectParameterivARB) - RESOLVE_GL_FUNC(DeleteObjectARB) - RESOLVE_GL_FUNC(GetInfoLogARB) - RESOLVE_GL_FUNC(CreateProgramObjectARB) - RESOLVE_GL_FUNC(AttachObjectARB) - RESOLVE_GL_FUNC(DetachObjectARB) - RESOLVE_GL_FUNC(LinkProgramARB) - RESOLVE_GL_FUNC(UseProgramObjectARB) - RESOLVE_GL_FUNC(GetUniformLocationARB) - RESOLVE_GL_FUNC(Uniform1iARB) - RESOLVE_GL_FUNC(Uniform1fARB) - RESOLVE_GL_FUNC(Uniform4fARB) - RESOLVE_GL_FUNC(UniformMatrix4fvARB) - RESOLVE_GL_FUNC(GenFramebuffersEXT) RESOLVE_GL_FUNC(GenRenderbuffersEXT) RESOLVE_GL_FUNC(BindRenderbufferEXT) @@ -88,26 +71,6 @@ bool GLExtensionFunctions::resolve(const QGLContext *context) return ok; } -bool GLExtensionFunctions::glslSupported() { - return CreateShaderObjectARB - && CreateShaderObjectARB - && ShaderSourceARB - && CompileShaderARB - && GetObjectParameterivARB - && DeleteObjectARB - && GetInfoLogARB - && CreateProgramObjectARB - && AttachObjectARB - && DetachObjectARB - && LinkProgramARB - && UseProgramObjectARB - && GetUniformLocationARB - && Uniform1iARB - && Uniform1fARB - && Uniform4fARB - && UniformMatrix4fvARB; -} - bool GLExtensionFunctions::fboSupported() { return GenFramebuffersEXT && GenRenderbuffersEXT diff --git a/demos/boxes/glextensions.h b/demos/boxes/glextensions.h index 74617d6..4755532 100644 --- a/demos/boxes/glextensions.h +++ b/demos/boxes/glextensions.h @@ -47,23 +47,6 @@ /* Functions resolved: -glCreateShaderObjectARB -glShaderSourceARB -glCompileShaderARB -glGetObjectParameterivARB -glDeleteObjectARB -glGetInfoLogARB -glCreateProgramObjectARB -glAttachObjectARB -glDetachObjectARB -glLinkProgramARB -glUseProgramObjectARB -glGetUniformLocationARB -glUniform1iARB -glUniform1fARB -glUniform4fARB -glUniformMatrix4fvARB - glGenFramebuffersEXT glGenRenderbuffersEXT glBindRenderbufferEXT @@ -136,39 +119,6 @@ typedef ptrdiff_t GLsizeiptr; #define GL_DEPTH_ATTACHMENT_EXT 0x8D00 #endif -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#endif - -#ifndef GL_ARB_shader_objects -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#endif - -typedef GLhandleARB (APIENTRY *_glCreateShaderObjectARB) (GLenum); -typedef void (APIENTRY *_glShaderSourceARB) (GLhandleARB, GLuint, const GLcharARB**, GLint *); -typedef void (APIENTRY *_glCompileShaderARB) (GLhandleARB); -typedef void (APIENTRY *_glGetObjectParameterivARB) (GLhandleARB, GLenum, int *); -typedef void (APIENTRY *_glDeleteObjectARB) (GLhandleARB); -typedef void (APIENTRY *_glGetInfoLogARB) (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -typedef GLhandleARB (APIENTRY *_glCreateProgramObjectARB) (); -typedef void (APIENTRY *_glAttachObjectARB) (GLhandleARB, GLhandleARB); -typedef void (APIENTRY *_glDetachObjectARB) (GLhandleARB, GLhandleARB); -typedef void (APIENTRY *_glLinkProgramARB) (GLhandleARB); -typedef void (APIENTRY *_glUseProgramObjectARB) (GLhandleARB); -typedef GLint (APIENTRY *_glGetUniformLocationARB) (GLhandleARB, const GLcharARB *); -typedef void (APIENTRY *_glUniform1iARB) (GLint, GLint); -typedef void (APIENTRY *_glUniform1fARB) (GLint, GLfloat); -typedef void (APIENTRY *_glUniform4fARB) (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (APIENTRY *_glUniformMatrix4fvARB) (GLint, GLuint, GLboolean, const GLfloat *); - typedef void (APIENTRY *_glGenFramebuffersEXT) (GLsizei, GLuint *); typedef void (APIENTRY *_glGenRenderbuffersEXT) (GLsizei, GLuint *); typedef void (APIENTRY *_glBindRenderbufferEXT) (GLenum, GLuint); @@ -194,27 +144,9 @@ struct GLExtensionFunctions { bool resolve(const QGLContext *context); - bool glslSupported(); bool fboSupported(); bool openGL15Supported(); // the rest: multi-texture, 3D-texture, vertex buffer objects - _glCreateShaderObjectARB CreateShaderObjectARB; - _glShaderSourceARB ShaderSourceARB; - _glCompileShaderARB CompileShaderARB; - _glGetObjectParameterivARB GetObjectParameterivARB; - _glDeleteObjectARB DeleteObjectARB; - _glGetInfoLogARB GetInfoLogARB; - _glCreateProgramObjectARB CreateProgramObjectARB; - _glAttachObjectARB AttachObjectARB; - _glDetachObjectARB DetachObjectARB; - _glLinkProgramARB LinkProgramARB; - _glUseProgramObjectARB UseProgramObjectARB; - _glGetUniformLocationARB GetUniformLocationARB; - _glUniform1iARB Uniform1iARB; - _glUniform1fARB Uniform1fARB; - _glUniform4fARB Uniform4fARB; - _glUniformMatrix4fvARB UniformMatrix4fvARB; - _glGenFramebuffersEXT GenFramebuffersEXT; _glGenRenderbuffersEXT GenRenderbuffersEXT; _glBindRenderbufferEXT BindRenderbufferEXT; @@ -243,23 +175,6 @@ inline GLExtensionFunctions &getGLExtensionFunctions() return funcs; } -#define glCreateShaderObjectARB getGLExtensionFunctions().CreateShaderObjectARB -#define glShaderSourceARB getGLExtensionFunctions().ShaderSourceARB -#define glCompileShaderARB getGLExtensionFunctions().CompileShaderARB -#define glGetObjectParameterivARB getGLExtensionFunctions().GetObjectParameterivARB -#define glDeleteObjectARB getGLExtensionFunctions().DeleteObjectARB -#define glGetInfoLogARB getGLExtensionFunctions().GetInfoLogARB -#define glCreateProgramObjectARB getGLExtensionFunctions().CreateProgramObjectARB -#define glAttachObjectARB getGLExtensionFunctions().AttachObjectARB -#define glDetachObjectARB getGLExtensionFunctions().DetachObjectARB -#define glLinkProgramARB getGLExtensionFunctions().LinkProgramARB -#define glUseProgramObjectARB getGLExtensionFunctions().UseProgramObjectARB -#define glGetUniformLocationARB getGLExtensionFunctions().GetUniformLocationARB -#define glUniform1iARB getGLExtensionFunctions().Uniform1iARB -#define glUniform1fARB getGLExtensionFunctions().Uniform1fARB -#define glUniform4fARB getGLExtensionFunctions().Uniform4fARB -#define glUniformMatrix4fvARB getGLExtensionFunctions().UniformMatrix4fvARB - #define glGenFramebuffersEXT getGLExtensionFunctions().GenFramebuffersEXT #define glGenRenderbuffersEXT getGLExtensionFunctions().GenRenderbuffersEXT #define glBindRenderbufferEXT getGLExtensionFunctions().BindRenderbufferEXT diff --git a/demos/boxes/glshaders.cpp b/demos/boxes/glshaders.cpp deleted file mode 100644 index b6999a8..0000000 --- a/demos/boxes/glshaders.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "glshaders.h" - -#define GLSHADERS_ASSERT_OPENGL(prefix, assertion, returnStatement) \ -if (m_failed || !(assertion)) { \ - if (!m_failed) qCritical(prefix ": The necessary OpenGL functions are not available."); \ - m_failed = true; \ - returnStatement; \ -} - - -GLShader::GLShader(const char *data, int size, GLenum shaderType) -: m_compileError(false), m_failed(false) -{ - GLSHADERS_ASSERT_OPENGL("GLShader::GLShader", - glCreateShaderObjectARB && glShaderSourceARB && glCompileShaderARB && glGetObjectParameterivARB, return) - - m_shader = glCreateShaderObjectARB(shaderType); - - GLint glSize = size; - glShaderSourceARB(m_shader, 1, &data, &glSize); - glCompileShaderARB(m_shader); - int status; - glGetObjectParameterivARB(m_shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); - m_compileError = (status != 1); -} - -GLShader::GLShader(const QString& fileName, GLenum shaderType) - : m_compileError(false), m_failed(false) -{ - GLSHADERS_ASSERT_OPENGL("GLShader::GLShader", - glCreateShaderObjectARB && glShaderSourceARB && glCompileShaderARB && glGetObjectParameterivARB, return) - - m_shader = glCreateShaderObjectARB(shaderType); - - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - QByteArray bytes = file.readAll(); - GLint size = file.size(); - const char *p = bytes.data(); - file.close(); - glShaderSourceARB(m_shader, 1, &p, &size); - glCompileShaderARB(m_shader); - int status; - glGetObjectParameterivARB(m_shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); - m_compileError = (status != 1); - } else { - m_compileError = true; - } -} - -GLShader::~GLShader() -{ - GLSHADERS_ASSERT_OPENGL("GLShader::~GLShader", glDeleteObjectARB, return) - - glDeleteObjectARB(m_shader); -} - -QString GLShader::log() -{ - GLSHADERS_ASSERT_OPENGL("GLShader::log", glGetObjectParameterivARB - && glGetInfoLogARB, return QLatin1String("GLSL not supported.")) - - int length; - glGetObjectParameterivARB(m_shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - char *log = new char[length + 1]; - GLsizei glLength = length; - glGetInfoLogARB(m_shader, glLength, &glLength, log); - log[glLength] = '\0'; - QString result(log); - delete log; - return result; -} - -GLVertexShader::GLVertexShader(const char *data, int size) : GLShader(data, size, GL_VERTEX_SHADER_ARB) -{ -} - -GLVertexShader::GLVertexShader(const QString& fileName) : GLShader(fileName, GL_VERTEX_SHADER_ARB) -{ -} - -GLFragmentShader::GLFragmentShader(const char *data, int size) : GLShader(data, size, GL_FRAGMENT_SHADER_ARB) -{ -} - -GLFragmentShader::GLFragmentShader(const QString& fileName) : GLShader(fileName, GL_FRAGMENT_SHADER_ARB) -{ -} - -GLProgram::GLProgram() : m_linked(false), m_linkError(false), m_failed(false) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::GLProgram", glCreateProgramObjectARB, return) - - m_program = glCreateProgramObjectARB(); -} - -GLProgram::~GLProgram() -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::~GLProgram", glDeleteObjectARB, return) - - glDeleteObjectARB(m_program); -} - -void GLProgram::attach(const GLShader &shader) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::attach", glAttachObjectARB, return) - - glAttachObjectARB(m_program, shader.m_shader); - m_linked = m_linkError = false; -} - -void GLProgram::detach(const GLShader &shader) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::detach", glDetachObjectARB, return) - - glDetachObjectARB(m_program, shader.m_shader); - m_linked = m_linkError = false; -} - -bool GLProgram::failed() -{ - if (m_failed || m_linkError) - return true; - - if (m_linked) - return false; - - GLSHADERS_ASSERT_OPENGL("GLProgram::failed", glLinkProgramARB && glGetObjectParameterivARB, return true) - - glLinkProgramARB(m_program); - int status; - glGetObjectParameterivARB(m_program, GL_OBJECT_LINK_STATUS_ARB, &status); - m_linkError = !(m_linked = (status == 1)); - return m_linkError; -} - -QString GLProgram::log() -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::log", glGetObjectParameterivARB && glGetInfoLogARB, - return QLatin1String("Failed.")) - - int length; - glGetObjectParameterivARB(m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - char *log = new char[length + 1]; - GLsizei glLength = length; - glGetInfoLogARB(m_program, glLength, &glLength, log); - log[glLength] = '\0'; - QString result(log); - delete log; - return result; -} - -void GLProgram::bind() -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::bind", glUseProgramObjectARB, return) - - if (!failed()) - glUseProgramObjectARB(m_program); -} - -void GLProgram::unbind() -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::bind", glUseProgramObjectARB, return) - - glUseProgramObjectARB(0); -} - -bool GLProgram::hasParameter(const QString& name) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::hasParameter", glGetUniformLocationARB, return false) - - if (!failed()) { - QByteArray asciiName = name.toAscii(); - return -1 != glGetUniformLocationARB(m_program, asciiName.data()); - } - return false; -} - -void GLProgram::setInt(const QString& name, int value) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::setInt", glGetUniformLocationARB && glUniform1iARB, return) - - if (!failed()) { - QByteArray asciiName = name.toAscii(); - int loc = glGetUniformLocationARB(m_program, asciiName.data()); - glUniform1iARB(loc, value); - } -} - -void GLProgram::setFloat(const QString& name, float value) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::setFloat", glGetUniformLocationARB && glUniform1fARB, return) - - if (!failed()) { - QByteArray asciiName = name.toAscii(); - int loc = glGetUniformLocationARB(m_program, asciiName.data()); - glUniform1fARB(loc, value); - } -} - -void GLProgram::setColor(const QString& name, QRgb value) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::setColor", glGetUniformLocationARB && glUniform4fARB, return) - - //qDebug() << "Setting color" << name; - if (!failed()) { - QByteArray asciiName = name.toAscii(); - int loc = glGetUniformLocationARB(m_program, asciiName.data()); - //qDebug() << "Location of" << name << "is" << loc; - QColor color(value); - glUniform4fARB(loc, color.redF(), color.greenF(), color.blueF(), color.alphaF()); - } -} - -void GLProgram::setMatrix(const QString& name, const gfx::Matrix4x4f &mat) -{ - GLSHADERS_ASSERT_OPENGL("GLProgram::setMatrix", glGetUniformLocationARB && glUniformMatrix4fvARB, return) - - if (!failed()) { - QByteArray asciiName = name.toAscii(); - int loc = glGetUniformLocationARB(m_program, asciiName.data()); - //qDebug() << "Location of" << name << "is" << loc; - glUniformMatrix4fvARB(loc, 1, GL_FALSE, mat.bits()); - } -} \ No newline at end of file diff --git a/demos/boxes/glshaders.h b/demos/boxes/glshaders.h deleted file mode 100644 index 2b6209a..0000000 --- a/demos/boxes/glshaders.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GLSHADERS_H -#define GLSHADERS_H - -//#include -#include "glextensions.h" - -#include -#include - -#include "vector.h" - -class GLShader -{ -public: - friend class GLProgram; - virtual ~GLShader(); - bool failed() const {return m_failed;} - QString log(); -protected: - GLShader(const char *data, int size, GLenum shaderType); - GLShader(const QString& fileName, GLenum shaderType); - - GLhandleARB m_shader; - bool m_compileError; - bool m_failed; -}; - -class GLVertexShader : public GLShader -{ -public: - GLVertexShader(const char *data, int size); - GLVertexShader(const QString& fileName); -}; - -class GLFragmentShader : public GLShader -{ -public: - GLFragmentShader(const char *data, int size); - GLFragmentShader(const QString& fileName); -}; - -class GLProgram -{ -public: - GLProgram(); - ~GLProgram(); - void attach(const GLShader &shader); - void detach(const GLShader &shader); - void bind(); - void unbind(); - bool failed(); - QString log(); - bool hasParameter(const QString& name); - // use program before setting values - void setInt(const QString& name, int value); - void setFloat(const QString& name, float value); - void setColor(const QString& name, QRgb value); - void setMatrix(const QString& name, const gfx::Matrix4x4f &mat); - // TODO: add a bunch of set-functions for different types. -private: - GLhandleARB m_program; - bool m_linked; - bool m_linkError; - bool m_failed; -}; - -#endif diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp index 1040e17..5f1fe14 100644 --- a/demos/boxes/scene.cpp +++ b/demos/boxes/scene.cpp @@ -531,11 +531,11 @@ Scene::~Scene() if (texture) delete texture; if (m_mainCubemap) delete m_mainCubemap; - foreach (GLProgram *program, m_programs) + foreach (QGLShaderProgram *program, m_programs) if (program) delete program; if (m_vertexShader) delete m_vertexShader; - foreach (GLFragmentShader *shader, m_fragmentShaders) + foreach (QGLShader *shader, m_fragmentShaders) if (shader) delete shader; foreach (GLRenderTargetCube *rt, m_cubemaps) if (rt) delete rt; @@ -549,16 +549,18 @@ void Scene::initGL() { m_box = new GLRoundedBox(0.25f, 1.0f, 10); - m_vertexShader = new GLVertexShader(":/res/boxes/basic.vsh"); + m_vertexShader = new QGLShader(":/res/boxes/basic.vsh", QGLShader::VertexShader); QStringList list; list << ":/res/boxes/cubemap_posx.jpg" << ":/res/boxes/cubemap_negx.jpg" << ":/res/boxes/cubemap_posy.jpg" << ":/res/boxes/cubemap_negy.jpg" << ":/res/boxes/cubemap_posz.jpg" << ":/res/boxes/cubemap_negz.jpg"; m_environment = new GLTextureCube(list, qMin(1024, m_maxTextureSize)); - m_environmentShader = new GLFragmentShader(environmentShaderText, strlen(environmentShaderText)); - m_environmentProgram = new GLProgram; - m_environmentProgram->attach(*m_vertexShader); - m_environmentProgram->attach(*m_environmentShader); + m_environmentShader = new QGLShader(QGLShader::FragmentShader); + m_environmentShader->setSourceCode(environmentShaderText); + m_environmentProgram = new QGLShaderProgram; + m_environmentProgram->addShader(m_vertexShader); + m_environmentProgram->addShader(m_environmentShader); + m_environmentProgram->link(); const int NOISE_SIZE = 128; // for a different size, B and BM in fbm.c must also be changed m_noise = new GLTexture3D(NOISE_SIZE, NOISE_SIZE, NOISE_SIZE); @@ -610,19 +612,19 @@ void Scene::initGL() filter = QStringList("*.fsh"); files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable); foreach (QFileInfo file, files) { - GLProgram *program = new GLProgram; - GLFragmentShader* shader = new GLFragmentShader(file.absoluteFilePath()); + QGLShaderProgram *program = new QGLShaderProgram; + QGLShader* shader = new QGLShader(file.absoluteFilePath(), QGLShader::FragmentShader); // The program does not take ownership over the shaders, so store them in a vector so they can be deleted afterwards. - program->attach(*m_vertexShader); - program->attach(*shader); - if (program->failed()) { + program->addShader(m_vertexShader); + program->addShader(shader); + if (!program->link()) { qWarning("Failed to compile and link shader program"); qWarning("Vertex shader log:"); - qWarning() << m_vertexShader->log(); + qWarning() << m_vertexShader->errors(); qWarning() << "Fragment shader log ( file =" << file.absoluteFilePath() << "):"; - qWarning() << shader->log(); + qWarning() << shader->errors(); qWarning("Shader program log:"); - qWarning() << program->log(); + qWarning() << program->errors(); delete shader; delete program; @@ -633,13 +635,13 @@ void Scene::initGL() m_programs << program; m_renderOptions->addShader(file.baseName()); - program->bind(); - m_cubemaps << (program->hasParameter("env") ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : 0); - program->unbind(); + program->enable(); + m_cubemaps << ((program->uniformLocation("env") != -1) ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : 0); + program->disable(); } if (m_programs.size() == 0) - m_programs << new GLProgram; + m_programs << new QGLShaderProgram; m_renderOptions->emitParameterChanged(); } @@ -674,12 +676,12 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox) // Don't render the environment if the environment texture can't be set for the correct sampler. if (glActiveTexture) { m_environment->bind(); - m_environmentProgram->bind(); - m_environmentProgram->setInt("tex", 0); - m_environmentProgram->setInt("env", 1); - m_environmentProgram->setInt("noise", 2); + m_environmentProgram->enable(); + m_environmentProgram->setUniformValue("tex", GLint(0)); + m_environmentProgram->setUniformValue("env", GLint(1)); + m_environmentProgram->setUniformValue("noise", GLint(2)); m_box->draw(); - m_environmentProgram->unbind(); + m_environmentProgram->disable(); m_environment->unbind(); } @@ -707,14 +709,18 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox) else m_environment->bind(); } - m_programs[i]->bind(); - m_programs[i]->setInt("tex", 0); - m_programs[i]->setInt("env", 1); - m_programs[i]->setInt("noise", 2); - m_programs[i]->setMatrix("view", view); - m_programs[i]->setMatrix("invView", invView); + m_programs[i]->enable(); + m_programs[i]->setUniformValue("tex", GLint(0)); + m_programs[i]->setUniformValue("env", GLint(1)); + m_programs[i]->setUniformValue("noise", GLint(2)); + QMatrix4x4 mview; + QMatrix4x4 minvview; + memcpy(mview.data(), view.bits(), sizeof(float) * 16); + memcpy(minvview.data(), invView.bits(), sizeof(float) * 16); + m_programs[i]->setUniformValue("view", mview); + m_programs[i]->setUniformValue("invView", minvview); m_box->draw(); - m_programs[i]->unbind(); + m_programs[i]->disable(); if (glActiveTexture) { if (m_dynamicCubemap && m_cubemaps[i]) @@ -737,14 +743,18 @@ void Scene::renderBoxes(const gfx::Matrix4x4f &view, int excludeBox) m_environment->bind(); } - m_programs[m_currentShader]->bind(); - m_programs[m_currentShader]->setInt("tex", 0); - m_programs[m_currentShader]->setInt("env", 1); - m_programs[m_currentShader]->setInt("noise", 2); - m_programs[m_currentShader]->setMatrix("view", view); - m_programs[m_currentShader]->setMatrix("invView", invView); + m_programs[m_currentShader]->enable(); + m_programs[m_currentShader]->setUniformValue("tex", GLint(0)); + m_programs[m_currentShader]->setUniformValue("env", GLint(1)); + m_programs[m_currentShader]->setUniformValue("noise", GLint(2)); + QMatrix4x4 mview; + QMatrix4x4 minvview; + memcpy(mview.data(), view.bits(), sizeof(float) * 16); + memcpy(minvview.data(), invView.bits(), sizeof(float) * 16); + m_programs[m_currentShader]->setUniformValue("view", mview); + m_programs[m_currentShader]->setUniformValue("invView", minvview); m_box->draw(); - m_programs[m_currentShader]->unbind(); + m_programs[m_currentShader]->disable(); if (glActiveTexture) { if (m_dynamicCubemap) @@ -1021,20 +1031,20 @@ void Scene::toggleDynamicCubemap(int state) void Scene::setColorParameter(const QString &name, QRgb color) { // set the color in all programs - foreach (GLProgram *program, m_programs) { - program->bind(); - program->setColor(name, color); - program->unbind(); + foreach (QGLShaderProgram *program, m_programs) { + program->enable(); + program->setUniformValue(program->uniformLocation(name), QColor(color)); + program->disable(); } } void Scene::setFloatParameter(const QString &name, float value) { // set the color in all programs - foreach (GLProgram *program, m_programs) { - program->bind(); - program->setFloat(name, value); - program->unbind(); + foreach (QGLShaderProgram *program, m_programs) { + program->enable(); + program->setUniformValue(program->uniformLocation(name), value); + program->disable(); } } diff --git a/demos/boxes/scene.h b/demos/boxes/scene.h index 2db9317..c056739 100644 --- a/demos/boxes/scene.h +++ b/demos/boxes/scene.h @@ -53,7 +53,6 @@ #include "vector.h" #include "trackball.h" #include "glbuffers.h" -#include "glshaders.h" #include "qtbox.h" #define PI 3.14159265358979 @@ -231,11 +230,11 @@ private: GLTexture3D *m_noise; GLRenderTargetCube *m_mainCubemap; QVector m_cubemaps; - QVector m_programs; - GLVertexShader *m_vertexShader; - QVector m_fragmentShaders; - GLFragmentShader *m_environmentShader; - GLProgram *m_environmentProgram; + QVector m_programs; + QGLShader *m_vertexShader; + QVector m_fragmentShaders; + QGLShader *m_environmentShader; + QGLShaderProgram *m_environmentProgram; }; diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml new file mode 100644 index 0000000..c925314 --- /dev/null +++ b/demos/declarative/calculator/CalcButton.qml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/calculator/calculator.js b/demos/declarative/calculator/calculator.js new file mode 100644 index 0000000..774b232 --- /dev/null +++ b/demos/declarative/calculator/calculator.js @@ -0,0 +1,87 @@ + +var curVal = 0; +var memory = 0; +var lastOp = ""; +var timer = 0; + +function disabled(op) { + if (op == "." && CurNum.text.toString().search(/\./) != -1) { + return true; + } else if (op == "Sqrt" && CurNum.text.toString().search(/-/) != -1) { + return true; + } else { + return false; + } +} + +function doOp(op) { + if (disabled(op)) { + return; + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (CurNum.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp==".") ) { + CurNum.text = CurNum.text + op.toString(); + } else { + CurNum.text = op; + } + lastOp = op; + return; + } + lastOp = op; + + // Pending operations + if (CurrentOperation.text == "+") { + CurNum.text = Number(CurNum.text.valueOf()) + Number(curVal.valueOf()); + } else if (CurrentOperation.text == "-") { + CurNum.text = Number(curVal) - Number(CurNum.text.valueOf()); + } else if (CurrentOperation.text == "x") { + CurNum.text = Number(curVal) * Number(CurNum.text.valueOf()); + } else if (CurrentOperation.text == "/") { + CurNum.text = Number(Number(curVal) / Number(CurNum.text.valueOf())).toString(); + } else if (CurrentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == "x" || op == "/") { + CurrentOperation.text = op; + curVal = CurNum.text.valueOf(); + return; + } + curVal = 0; + CurrentOperation.text = ""; + + // Immediate operations + if (op == "1/x") { // reciprocal + CurNum.text = (1 / CurNum.text.valueOf()).toString(); + } else if (op == "^2") { // squared + CurNum.text = (CurNum.text.valueOf() * CurNum.text.valueOf()).toString(); + } else if (op == "Abs") { + CurNum.text = (Math.abs(CurNum.text.valueOf())).toString(); + } else if (op == "Int") { + CurNum.text = (Math.floor(CurNum.text.valueOf())).toString(); + } else if (op == "+/-") { // plus/minus + CurNum.text = (CurNum.text.valueOf() * -1).toString(); + } else if (op == "Sqrt") { // square root + CurNum.text = (Math.sqrt(CurNum.text.valueOf())).toString(); + } else if (op == "MC") { // memory clear + memory = 0; + } else if (op == "M+") { // memory increment + memory += CurNum.text.valueOf(); + } else if (op == "MR") { // memory recall + CurNum.text = memory.toString(); + } else if (op == "MS") { // memory set + memory = CurNum.text.valueOf(); + } else if (op == "Bksp") { + CurNum.text = CurNum.text.toString().slice(0, -1); + } else if (op == "C") { + CurNum.text = "0"; + } else if (op == "AC") { + curVal = 0; + memory = 0; + lastOp = ""; + CurNum.text ="0"; + } +} + diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml new file mode 100644 index 0000000..4ada896 --- /dev/null +++ b/demos/declarative/calculator/calculator.qml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/mediabrowser/content/ScrollBar.qml b/demos/declarative/mediabrowser/content/ScrollBar.qml new file mode 100644 index 0000000..974f4d0 --- /dev/null +++ b/demos/declarative/mediabrowser/content/ScrollBar.qml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/mediabrowser/content/Star.qml b/demos/declarative/mediabrowser/content/Star.qml new file mode 100644 index 0000000..1db29e8 --- /dev/null +++ b/demos/declarative/mediabrowser/content/Star.qml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/mediabrowser/content/pics/background.png b/demos/declarative/mediabrowser/content/pics/background.png new file mode 100644 index 0000000..5b37072 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/background.png differ diff --git a/demos/declarative/mediabrowser/content/pics/button-pressed.png b/demos/declarative/mediabrowser/content/pics/button-pressed.png new file mode 100644 index 0000000..e434d32 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/button-pressed.png differ diff --git a/demos/declarative/mediabrowser/content/pics/button.png b/demos/declarative/mediabrowser/content/pics/button.png new file mode 100644 index 0000000..56a63ce Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/button.png differ diff --git a/demos/declarative/mediabrowser/content/pics/ghns_star.png b/demos/declarative/mediabrowser/content/pics/ghns_star.png new file mode 100644 index 0000000..4ad43cc Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/ghns_star.png differ diff --git a/demos/declarative/mediabrowser/content/pics/reflection.png b/demos/declarative/mediabrowser/content/pics/reflection.png new file mode 100644 index 0000000..c143a48 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/reflection.png differ diff --git a/demos/declarative/mediabrowser/content/pics/shadow-bottom.png b/demos/declarative/mediabrowser/content/pics/shadow-bottom.png new file mode 100644 index 0000000..523f6e7 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/shadow-bottom.png differ diff --git a/demos/declarative/mediabrowser/content/pics/shadow-corner.png b/demos/declarative/mediabrowser/content/pics/shadow-corner.png new file mode 100644 index 0000000..ef8c856 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/shadow-corner.png differ diff --git a/demos/declarative/mediabrowser/content/pics/shadow-right-screen.png b/demos/declarative/mediabrowser/content/pics/shadow-right-screen.png new file mode 100644 index 0000000..9856c4f Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/shadow-right-screen.png differ diff --git a/demos/declarative/mediabrowser/content/pics/shadow-right.png b/demos/declarative/mediabrowser/content/pics/shadow-right.png new file mode 100644 index 0000000..f534a35 Binary files /dev/null and b/demos/declarative/mediabrowser/content/pics/shadow-right.png differ diff --git a/demos/declarative/mediabrowser/dummydata/MoviesModel.qml b/demos/declarative/mediabrowser/dummydata/MoviesModel.qml new file mode 100644 index 0000000..87bca37 --- /dev/null +++ b/demos/declarative/mediabrowser/dummydata/MoviesModel.qml @@ -0,0 +1,38 @@ + + + Repoman + http://www.impawards.com/1984/posters/repo_man.jpg + Cult classic. Car repossession. Radiation. Plate O' Shrimp. + 2 + + + Monsters vs Aliens + http://www.impawards.com/2009/posters/monsters_vs_aliens_ver6.jpg + Love Monsters? Love Aliens? You're in luck. + 1 + + + Cruel Intentions + http://impawards.com/1999/posters/cruel_intentions_ver1.jpg + Modern-day update of Les Liaisons Dangereuses. Better because it has nothing to do with the French. + 3 + + + Lord of War + http://www.impawards.com/2005/posters/lord_of_war_ver2.jpg + There are over 500 million fire arms in worldwide circulation. That is one fire arm for every twelve people on the planet. The only question is how do we arm the other eleven? + 4 + + + The Devil's Advocate + http://impawards.com/1997/posters/devils_advocate_ver1.jpg + An ambitious your district attorney joins a powerful New York law firm headed by the devil. + 4 + + + Team America: World Police + http://impawards.com/2004/posters/team_america_world_police.jpg + Hey terrorist, terrorize this. + 1 + + diff --git a/demos/declarative/mediabrowser/mediabrowser.qml b/demos/declarative/mediabrowser/mediabrowser.qml new file mode 100644 index 0000000..df7baa9 --- /dev/null +++ b/demos/declarative/mediabrowser/mediabrowser.qml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/webbrowser/README b/demos/declarative/webbrowser/README new file mode 100644 index 0000000..a081e30 --- /dev/null +++ b/demos/declarative/webbrowser/README @@ -0,0 +1,5 @@ +For good performance, be sure to use disk cache for remote content: + + duiviewer -cache WebBrowser.qml + +Otherwise everything always re-loads over the network. diff --git a/demos/declarative/webbrowser/WebBrowser.qml b/demos/declarative/webbrowser/WebBrowser.qml new file mode 100644 index 0000000..08b94e3 --- /dev/null +++ b/demos/declarative/webbrowser/WebBrowser.qml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml new file mode 100644 index 0000000..0235842 --- /dev/null +++ b/demos/declarative/webbrowser/content/RectSoftShadow.qml @@ -0,0 +1,10 @@ + + + + + + diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.png b/demos/declarative/webbrowser/content/pics/addressbar-filled.png new file mode 100644 index 0000000..c793a10 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/addressbar-filled.png differ diff --git a/demos/declarative/webbrowser/content/pics/addressbar-filled.sci b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci new file mode 100644 index 0000000..464dbf5 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/addressbar-filled.sci @@ -0,0 +1,6 @@ +gridLeft: 7 +gridTop: 7 +gridBottom: 7 +gridRight: 7 +imageFile: addressbar-filled.png + diff --git a/demos/declarative/webbrowser/content/pics/addressbar.png b/demos/declarative/webbrowser/content/pics/addressbar.png new file mode 100644 index 0000000..9b8e2c9 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/addressbar.png differ diff --git a/demos/declarative/webbrowser/content/pics/addressbar.sci b/demos/declarative/webbrowser/content/pics/addressbar.sci new file mode 100644 index 0000000..23a2a19 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/addressbar.sci @@ -0,0 +1,6 @@ +gridLeft: 7 +gridTop: 7 +gridBottom: 7 +gridRight: 7 +imageFile: addressbar.png + diff --git a/demos/declarative/webbrowser/content/pics/back-disabled.png b/demos/declarative/webbrowser/content/pics/back-disabled.png new file mode 100644 index 0000000..0ca0701 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/back-disabled.png differ diff --git a/demos/declarative/webbrowser/content/pics/back.png b/demos/declarative/webbrowser/content/pics/back.png new file mode 100644 index 0000000..3e88a6c Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/back.png differ diff --git a/demos/declarative/webbrowser/content/pics/footer.png b/demos/declarative/webbrowser/content/pics/footer.png new file mode 100644 index 0000000..f5fe95f Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/footer.png differ diff --git a/demos/declarative/webbrowser/content/pics/footer.sci b/demos/declarative/webbrowser/content/pics/footer.sci new file mode 100644 index 0000000..de0ed04 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/footer.sci @@ -0,0 +1,6 @@ +gridLeft: 10 +gridTop: 0 +gridBottom: 0 +gridRight: 10 +imageFile: footer.png + diff --git a/demos/declarative/webbrowser/content/pics/forward-disabled.png b/demos/declarative/webbrowser/content/pics/forward-disabled.png new file mode 100644 index 0000000..573aaa4 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/forward-disabled.png differ diff --git a/demos/declarative/webbrowser/content/pics/forward.png b/demos/declarative/webbrowser/content/pics/forward.png new file mode 100644 index 0000000..d4eb026 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/forward.png differ diff --git a/demos/declarative/webbrowser/content/pics/header.png b/demos/declarative/webbrowser/content/pics/header.png new file mode 100644 index 0000000..c4aff2e Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/header.png differ diff --git a/demos/declarative/webbrowser/content/pics/reload.png b/demos/declarative/webbrowser/content/pics/reload.png new file mode 100644 index 0000000..fa4d033 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/reload.png differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-bottom.png b/demos/declarative/webbrowser/content/pics/softshadow-bottom.png new file mode 100644 index 0000000..59c1ba1 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/softshadow-bottom.png differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.png b/demos/declarative/webbrowser/content/pics/softshadow-left.png new file mode 100644 index 0000000..d08f5c7 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/softshadow-left.png differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-left.sci b/demos/declarative/webbrowser/content/pics/softshadow-left.sci new file mode 100644 index 0000000..82e38f8 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/softshadow-left.sci @@ -0,0 +1,5 @@ +gridLeft: 0 +gridTop: 16 +gridBottom: 16 +gridRight: 0 +imageFile: softshadow-left.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.png b/demos/declarative/webbrowser/content/pics/softshadow-right.png new file mode 100644 index 0000000..1bb29d5 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/softshadow-right.png differ diff --git a/demos/declarative/webbrowser/content/pics/softshadow-right.sci b/demos/declarative/webbrowser/content/pics/softshadow-right.sci new file mode 100644 index 0000000..e9494ed --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/softshadow-right.sci @@ -0,0 +1,5 @@ +gridLeft: 0 +gridTop: 16 +gridBottom: 16 +gridRight: 0 +imageFile: softshadow-right.png diff --git a/demos/declarative/webbrowser/content/pics/softshadow-top.png b/demos/declarative/webbrowser/content/pics/softshadow-top.png new file mode 100644 index 0000000..ef86738 Binary files /dev/null and b/demos/declarative/webbrowser/content/pics/softshadow-top.png differ diff --git a/doc/src/animation.qdoc b/doc/src/animation.qdoc new file mode 100644 index 0000000..081660c --- /dev/null +++ b/doc/src/animation.qdoc @@ -0,0 +1,365 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page animation.html + \title The Animation Framework + \ingroup architecture + \ingroup animation + \brief An overview of the Animation Framework + + \keyword Animation + + The animation framework is part of the Kinetic project, and aims + to provide an easy way for creating animated and smooth GUI's. By + animating Qt properties, the framework provides great freedom for + animating widgets and other \l{QObject}s. The framework can also + be used with the Graphics View framework. + + In this overview, we explain the basics of its architecture. We + also show examples of the most common techniques that the + framework allows for animating QObjects and graphics items. + + \tableofcontents + + \section1 The Animation Architecture + + We will in this section take a high-level look at the animation + framework's architecture and how it is used to animate Qt + properties. + + The animation framework foundation consists of the base class + QAbstractAnimation, and its two subclasses QVariantAnimation and + QAnimationGroup. QAbstractAnimation is the ancestor of all + animations. It represents basic properties that are common for all + animations in the framework; notably, the ability to start, stop, + and pause an animation. It is also receives the time change + notifications. + + The animation framework further provides the QPropertyAnimation + class, which inherits QVariantAnimation and performs animation of + a Qt property, which is part of Qt's \l{Meta-Object + System}{meta-object system}. The class performs an interpolation + over the property using an easing curve. So when you want to + animate a value, you can declare it as a property and make your + class a QObject. Note that this gives us great freedom in + animating already existing widgets and other \l{QObject}s. + + Complex animations can be constructed by building a tree structure + of \l{QAbstractAnimation}s. The tree is built by using + \l{QAnimationGroup}s, which function as containers for other + animations. Note also that the groups are subclasses of + QAbstractAnimation, so groups can themselves contain other groups. + + The animation framework can be used on its own, but is also + designed to be part of the state machine framework (See the + \l{The State Machine Framework}{state machine framework} for an + introduction to the Qt state machine). The state machine provides + a special state that can play an animation. A QState can also set + properties when the state is entered or exited, and this special + animation state will interpolate between these values when given a + QPropertyAnimation. We will look more closely at this later. + + Behind the scenes, the animations are controlled by a global + timer, which sends \l{QAbstractAnimation::updateCurrentTime()}{updates} to + all animations that are playing. + + For detailed descriptions of the classes' function and roles in + the framework, please look up their class descriptions. + + \section1 Animating Qt Properties + + As mentioned in the previous section, the QPropertyAnimation class + can interpolate over Qt properties. It is this class that should + be used for animation of values; in fact, its superclass, + QVariantAnimation, is an abstract class, and cannot be used + directly. + + A major reason we chose to animate Qt properties is that it + presents us with freedom to animate already existing classes in + the Qt API. Notably, the QWidget class (which we can also embed in + a QGraphicsView) has properties for its bounds, colors, etc. + Let's look at a small example: + + \code + QPushButton button("Animated Button"); + button.show(); + + QPropertyAnimation animation(&button, "geometry"); + animation.setDuration(10000); + animation.setStartValue(QRect(0, 0, 100, 30)); + animation.setEndValue(QRect(250, 250, 100, 30)); + + animation.start(); + \endcode + + This code will move \c button from the top left corner of the + screen to the position (250, 250). + + The example above will do a linear interpolation between the + start and end value. It is also possible to set values + situated between the start and end value. The interpolation + will then go by these points. + + \code + QPushButton button("Animated Button"); + button.show(); + + QPropertyAnimation animation(&button, "geometry"); + animation.setDuration(10000); + + animation.setKeyValueAt(0, QRect(0, 0, 100, 30)); + animation.setKeyValueAt(0.8, QRect(250, 250, 100, 30)); + animation.setKeyValueAt(1, QRect(0, 0, 100, 30)); + + animation.start(); + \endcode + + In this example, the animation will take the button to (250, 250) + in 8 seconds, and then move it back to its original position in + the remaining 2 seconds. The movement will be linearly + interpolated between these points. + + You also have the possibility to animate values of a QObject + that is not declared as a Qt property. The only requirement is + that this value has a setter. You can then subclass the class + containing the value and declare a property that uses this setter. + Note that all Qt properties requires a getter, so you will need to + provide a getter yourself if this is not defined. + + \code + class MyGraphicsRectItem : public QObject, public QGraphicsRectItem + { + Q_OBJECT + Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry) + }; + \endcode + + In the above code example, we subclass QGraphicsRectItem and + define a geometry property. We can now animate the widgets + geometry even if QGraphicsRectItem does not provide the geometry + property. + + For a general introduction to the Qt property system, see its + \l{Qt's Property System}{overview}. + + \section1 Animations and the Graphics View Framework + + When you want to animate \l{QGraphicsItem}s, you also use + QPropertyAnimation. But, unfortunetly, QGraphicsItem does not + inherit QObject. A good solution is to subclass the graphics item + you wish to animate. This class will then also inherit QObject. + This way, QPropertyAnimation can be used for \l{QGraphicsItem}s. + The example below shows how this is done. Another possibility is + to inherit QGraphicsWidget, which already is a QObject. + + \code + class Pixmap : public QObject, public QGraphicsPixmapItem + { + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) + ... + \endcode + + As described in the previous section, we need to define + properties that we wish to animate. + + Note that QObject must be the first class inherited as the + meta-object system demands this. + + \warning The QItemAnimation class, which was initially intended + for animating \l{QGraphicsItem}s may be deprecated or removed from + the animation framework. + + \omit (need something about the list of animations). \endomit + + \section1 Easing Curves + + As mentioned, QPropertyAnimation performs an interpolation between + the start and end property value. In addition to adding more key + values to the animation, you can also use an easing curve. Easing + curves describe a function that controls how the speed of the + interpolation between 0 and 1 should be, and are useful if you + want to control the speed of an animation without changing the + path of the interpolation. + + \code + QPushButton button("Animated Button"); + button.show(); + + QPropertyAnimation animation(&button, "geometry"); + animation.setDuration(3000); + animation.setStartValue(QRect(0, 0, 100, 30)); + animation.setEndValue(QRect(250, 250, 100, 30)); + + animation.setEasingCurve(QEasingCurve::OutBounce); + + animation.start(); + \endcode + + Here the animation will follow a curve that makes it bounce like a + ball as if it was dropped from the start to the end position. + QEasingCurve has a large collection of curves for you to choose + from. These are defined by the QEasingCurve::Type enum. If you are + in need of another curve, you can also implement one yourself, and + register it with QEasingCurve. + + \omit Drop this for the first Lab release + (Example of custom easing curve (without the actual impl of + the function I expect) + \endomit + + \section1 Putting Animations Together + + An application will often contain more than one animation. For + instance, you might want to move more than one graphics item + simultaneously or move them in sequence after each other. + + The subclasses of QAnimationGroup (QSequentialAnimationGroup and + QParallelAnimationGroup) are containers for other animations so + that these animations can be animated either in sequence or + parallel. The QAnimationGroup is an example of an animation that + does not animate properties, but it gets notified of time changes + periodically. This enables it to forward those time changes to its + contained animations, and thereby controlling when its animations + are played. + + Let's look at code examples that use both + QSequentialAnimationGroup and QParallelAnimationGroup, starting + off with the latter. + + \code + QPushButton *bonnie = new QPushButton("Bonnie"); + bonnie.show(); + + QPushButton *clyde = new QPushButton("Clyde"); + clyde.show(); + + QPropertyAnimation *anim1 = new QPropertyAnimation(bonnie, "geometry"); + // Set up anim1 + + QPropertyAnimation *anim2 = new QPropertyAnimation(clyde, "geometry"); + // Set up anim2 + + QParallelAnimationGroup *group = new QParallelAnimationGroup; + group->addAnimation(anim1); + group->addAnimation(anim2); + + group->start(); + \endcode + + A parallel group plays more than one animation at the same time. + Calling its \l{QAbstractAnimation::}{start()} function will start + all animations it governs. + + \code + QPushButton button("Animated Button"); + button.show(); + + QPropertyAnimation anim1(&button, "geometry"); + anim1.setDuration(3000); + anim1.setStartValue(QRect(0, 0, 100, 30)); + anim1.setEndValue(QRect(500, 500, 100, 30)); + + QPropertyAnimation anim2(&button, "geometry"); + anim2.setDuration(3000); + anim2.setStartValue(QRect(500, 500, 100, 30)); + anim2.setEndValue(QRect(1000, 500, 100, 30)); + + QSequentialAnimationGroup group; + + group.addAnimation(&anim1); + group.addAnimation(&anim2); + + group.start(); + \endcode + + As you no doubt have guessed, QSequentialAnimationGroup plays + its animations in sequence. It starts the next animation in + the list after the previous is finished. + + Since an animation group is an animation itself, you can add + it to another group. This way, you can build a tree structure + of animations which specifies when the animations are played + in relation to each other. + + \section1 Animations and States + + When using a \l{The State Machine Framework}{state machine}, we + have a special state, QAnimationState, that will play one or more + animations. + + The QState::addAnimatedTransition() convenience function lets you + associate an animation to a state transition. The function will + create the QAnimationState for you, and insert it into the state + machine. We also have the possibility to associate properties with + the states rather than setting the start and end values ourselves. + Below is a complete code example that animates the geometry of a + QPushButton. + + \code + QPushButton *button = new QPushButton("Animated Button"); + button->show(); + + QStateMachine *machine = new QStateMachine; + + QState *state1 = new QState(machine->rootState()); + state1->setPropertyOnEntry(button, "geometry", + QRect(0, 0, 100, 30)); + machine->setInitialState(state1); + + QState *state2 = new QState(machine->rootState()); + state2->setPropertyOnEntry(button, "geometry", + QRect(250, 250, 100, 30)); + + state1->addAnimatedTransition(button, SIGNAL(clicked()), state2, + new QPropertyAnimation(button, "geometry")); + state2->addAnimatedTransition(button, SIGNAL(clicked()), state1, + new QPropertyAnimation(button, "geometry")); + + machine->start(); + \endcode + + For a more comprehensive example of how to use the state machine + framework for animations, see the states example (it lives in the + \c{examples/animation/states} directory). +*/ + diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc new file mode 100644 index 0000000..9647a72 --- /dev/null +++ b/doc/src/declarative/anchor-layout.qdoc @@ -0,0 +1,68 @@ +/*! +\page anchor-layout.html +\target anchor-layout +\title Anchor-based Layout + +In additional to the more traditional Fx layouts \l {xmlGridLayout}{GridLayout}, \l {xmlHorizontalLayout}{HorizontalLayout}, and \l {xmlVerticalLayout}{VerticalLayout}, QML also provides a way to layout items using the concept of anchors. Each visual Fx item can be thought of as having a set of 6 invisible "anchor lines": \e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, and \e bottom. + +\image edges_qml.png + +The Fx anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write: + +\code + + +\endcode + +In this case, the left edge of \e rect2 is bound to the right edge of rect1, producing the following: + +\image edge1.png + +The anchoring system also allows you to specify margins and offsets. Margins specify the amount of empty space to leave to the outside of an item, while offsets allow you to manipulate positioning using the center anchor lines. Note that margins specified using the anchor layout system only have meaning for anchors; they won't have any effect when using other layouts or absolute positioning. + +\image margins_qml.png + +The following example specifies a left margin: + +\code + + +\endcode + +In this case, a margin of 5 pixels is reserved to the left of \e rect2, producing the following: + +\image edge2.png + +You can specify multiple anchors. For example: + +\code + + +\endcode + +\image edge3.png + +By specifying multiple horizontal or vertical anchors you can control the size of an item. For example: + +\code + + + +\endcode + +\image edge4.png + +\section1 Limitations + +For performance reasons, you can only anchor an item to its siblings and direct parent. For example, the following anchor would be considered invalid and would produce a warning: + +\code + + + + + + +\endcode + +*/ diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc new file mode 100644 index 0000000..a1ab44b --- /dev/null +++ b/doc/src/declarative/animation.qdoc @@ -0,0 +1,130 @@ +/*! +\page animation.html +\target animation +\title QML Animation + +QML supports three different forms of animation - basic property animation, +states and transitions and property behaviors. + +\section1 Property Animation + +Animation in QML is done by animating properties of objects. + +Any property of a recognizable type can be animated. Currently those types include: +\list +\o qreal +\o int +\o Most of QVariant's built-in types +\endlist + +Animations can also involve numerous properties on numerous objects. + +Other Features: +\list +\o Support for a large set of parameterized easing curves. (based on the Penner easing equations) +\o Animation synchronization +\endlist + +The simplest form of animation is using \c <NumericAnimation/> + +The following example creates a bouncing effect: +\code + + + + + + + + + + +\endcode + +\image propanim.gif + +\target states-transitions +\section1 States and Transitions + +\section2 States + +QML states describe user interface configurations, including: +\list +\o What UI elements are present +\o The properties of those elements (including how they behave) +\o What actions are available +\endlist + +A state can also be thought of as a set of batched changes from a default configuration. + +Examples of states in modern UI: +\list +\o A Contacts application has a 'View Contact' state and an 'Edit Contact' State. In the first state the information presented is static (using labels), and in the second it is editable (using editors). +\o A button has a pressed and unpressed state. When pressed the text moves down and to the right, and the button has a slightly darker appearance. +\endlist + +In QML: +\list +\o Any object can use states. +\o There is a default state. The default state can be explicitly set. +\o A state can affect other the properties of other objects, not just the object owning the state (and not just that object's children). +\endlist + +The following example shows a simple use of states. In the default state \c myrect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. + +\code + + + + + + + + + +\endcode + +\section2 Transitions + +QML transitions describe animations to perform when state changes occur. + +For the previous example, a transition could describe how \c myrect moved from its initial position to its new position: + +\code + + + + + +\endcode + +QML transitions can use selectors to determine which state changes a transition should apply to: + +\code + +... + +\endcode + +Transitions can happen in parallel, in sequence, or in any combination of the two:; + +\code + + + + + + + + + + +\endcode + +\section1 Property Behaviors + +\todo Document. Should we remove property behaviour altogether? +*/ diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc new file mode 100644 index 0000000..d6dae77 --- /dev/null +++ b/doc/src/declarative/basictypes.qdoc @@ -0,0 +1,387 @@ +/*! + \page basicxmltypes.html + \title Common QML Types + + QML uses a range of property types, which you will see + referenced throughout the element documentation. Almost all of them are + exactly what you would expect. + + \target basicxmlint + \raw HTML +
+
+ + +
int
+
+
+ \endraw + + ints are whole numbers - things like 0, 10 and -20. The possible int + values range from around -2000000000 to around 2000000000, although most + elements will only accept a reduced range (which they mention in their + documentation). + + int's must be specified using the plain old syntax you learned at school - + none of that scientific notation nonsense is supported. + + Setting ints looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlbool + \raw HTML +
+
+
+ + +
bool
+
+
+ \endraw + + bools are a binary true/false value, represented by the strings + "true" and "false" in XML. + + Setting bools looks like this: + \code + + \endcode + + \note Technically bool treats an empty string, "false" and "0" as false and + everything else as true. Seriously, though, use "true" and "false". + + \raw HTML +
+
+ \endraw + + \target basicxmlreal + \raw HTML +
+
+
+ + +
real
+
+
+ \endraw + + reals are numbers - either whole numbers like ints, or fractional numbers + like 1.2 and -29.8. + + Setting reals looks like this: + \code + + \endcode + + \note In QML all reals are stored in single precision, \l {http://en.wikipedia.org/wiki/IEEE_754}{IEEE floating point} format. + + \raw HTML +
+
+ \endraw + + \target basicxmlstring + \raw HTML +
+
+
+ + +
string
+
+
+ \endraw + + strings are free form text, like "hello world", "QML is cool" and + anything else you can think of. + + Setting a string looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlcolor + \raw HTML +
+
+
+ + +
color
+
+
+ \endraw + + Colors are most commonly specified as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color name}. These names include colors like + "red", "green" and "lightsteelblue". + + If the color you want isn't part of this list, colors can also be specified + in hexidecimal triplets or quads that take the form \c "#RRGGBB" and + \c "#AARRGGBB" respectively. For example, the color red corresponds to a + triplet of \c "#FF0000" and a slightly transparent blue to a quad of + \c "#800000FF". + + Setting a color looks like this: + \code + + + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlpoint + \raw HTML +
+
+
+ + +
point
+
+
+ \endraw + + Points are specified in \c "x,y" format. + + Setting a point looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlsize + \raw HTML +
+
+
+ + +
size
+
+
+ \endraw + + Sizes are specified in \c "widthxheight" format. + + Setting a size looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlrectangle + \raw HTML +
+
+
+ + +
rectangle
+
+
+ \endraw + + Rectangles are specified in \c "x,y,widthxheight" format. + + Setting a rectangle looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmldate + \raw HTML +
+
+
+ + +
date
+
+
+ \endraw + + Dates are specified in \c "YYYY-MM-DD" format. + + Setting a date looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmltime + \raw HTML +
+
+
+ + +
time
+
+
+ \endraw + + Times are specified in \c "hh:mm:ss" format. + + Setting a time looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlfont + \raw HTML +
+
+
+ + +
font
+
+
+ \endraw + + The font type has components: + \list + \o string font.family + \o bool font.bold + \o bool font.italic + \o real font.size + \endlist + + Setting a font looks like this: + \code + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlaction + \raw HTML +
+
+
+ + +
action
+
+
+ \endraw + + The action type has all the properties of QAction, in particular: + \list + \o slot action.trigger - invoke the action + \o bool action.enabled - true if the action is enabled + \o string action.text - the text associated with the action + \endlist + + Actions are used like this: + + \code + + + + \endcode + + \raw HTML +
+
+ \endraw + + \target basicxmlany + \raw HTML +
+
+
+ + +
any
+
+
+ \endraw + + The any type can accept any basic type, object or list. Generally this + is only used in very special cases. The documentation for elements that + use the any type will explain the constraints in that particular case. + + \raw HTML +
+
+ \endraw + + \target basicxmllist + \raw HTML +
+
+
+ + +
Lists
+
+
+ \endraw + + While not technically a basic type, QML also supports lists of object + types. When used from QML, the engine automatically appends each value to the + list. + + For example, the \l {xmlItem}{Item} class has a children list property + that can be used like this: + \code + + + + + + + + \endcode + \c child1, \c child2 and \c child3 will all be added to the children list + in the order in which they appear. + \raw HTML +
+
+ \endraw +*/ diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc new file mode 100644 index 0000000..b711a08 --- /dev/null +++ b/doc/src/declarative/binding.qdoc @@ -0,0 +1,110 @@ +/*! +\page binding.html +\title Data Binding +\target binding + +Data binding provides a declarative way of specifying the data associated with objects, as well as the relationship between data of different objects. For example, you could bind the text of a label to the value of a slider: as the value of the slider changed, the label would be automatically updated with the new value. + +Bindings are indicated in Qml through the use of brackets: \c {}. For example, the following produces two Rects of equal size (\c rect2 is bound to the size of \c rect1): +\code + + +\endcode + +There is also a special \c element, which is typically used to bind from the UI to the underlying UI model (see \l {Passing Data Between C++ and Qml} for an example of this). The bindings above could be expressed using the \c element as: + +\code + + +\endcode + +In addition to binding directly to a property, you can also bind to the results of expressions involving properties. For example: +\code + + +\endcode + +Relevant items can also be bound to the contents of a model - see \l ListView for an example of this. + +Data can be bound to C++ objects - see \l {C++ Data Binding}. +*/ + +/*! +\page qtbinding.html +\target qtbinding +\title C++ Data Binding + +The QML mechanisms of \l {Data Binding} can also be used to bind Qt C++ objects. + +The data binding framework is based on Qt's property system (see the Qt documentation for more details on this system). If a binding is meant to be dynamic (where changes in one object are reflected in another object), \c NOTIFY must be specified for the property being tracked. If \c NOTIFY is not specified, any binding to that property will be an 'intialization' binding (the tracking object will be updated only once with the initial value of the tracked object). + +Relevant items can also be bound to the contents of a Qt model. For example, ListView can make use of data from a QListModelInterface-derived model. (QListModelInterface is part of the next generation Model/View architecture being developed for Qt.) + + +\section1 Passing Data Between C++ and Qml + +Data binding provides one method of data transfer between C++ and Qml. + +For example, lets say you want to implement a slider in Qml that changes the screen brightness of the device it is running on. You would start by declaring a brightness property on your QObject-derived class: +\code +class MyScreen : public QObject +{ + Q_OBJECT +public: + MyScreen(QObject *parent=0); + + Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged); + int brightness() const; + void setBrightness(int b); + ... + +signals: + void brightnessChanged(); + +private: + int m_brightness; +}; + +int brightness() const +{ + return m_brightness; +} + +void setBrightness(int b) +{ + if (b != m_brightness) { + m_brightness = b; + emit brightnessChanged(); + + //set device brightness + ... + } +} +\endcode + +\note One important thing to keep in mind is that the changed signal should only be emitted when there is a real change ( \c b \c != \c m_brightness ), or you may get an infinite loop. + +Next, make an instance of this class visible to the Qml bind engine: +\code +QFxView *view = new QFxView; +view->setXml("MyUI.qml"); + +MyScreen *screen = new MyScreen; +QmlBindContext *ctxt = view->bindContext(); +ctxt->setProperty("screen", screen); + +view->execute(); +\endcode + +\note Bindings must be made after setXml() but before execute(). + +Finally, in Qml you can make the appropriate bindings, so in \c "MyUI.qml": + +\code + + +\endcode + +The \l QBindableMap class provides a convenient way to make data visible to the bind engine. + +*/ diff --git a/doc/src/declarative/components.qdoc b/doc/src/declarative/components.qdoc new file mode 100644 index 0000000..b5c5ae7 --- /dev/null +++ b/doc/src/declarative/components.qdoc @@ -0,0 +1,74 @@ +/*! +\page components.html +\target components +\title Components + +A \b component is a reusable, encapsulated Qml element with a well-defined interface. + +Writing and using components allows you to: +\list +\o Reuse sections of Qml without copy-and-paste. +\o Have consistent Look and Feel between different parts of your UI. +\o Create new Qml elements without writing a new C++ class. (See \l {cppitem}{Creating Qml elements in C++}) +\endlist + +Components are placed in \e .qml files, allowing \e to then be used as a tag elsewhere. For example, if you have a Slider.qml file, you can then use \c to place a slider. + +Components may be collected into \l {qmlmodules}{modules}. + +\section1 Example: Creating a MyButton Component + +This example describes how to create a component from an existing snippet of Qml. + +Assume you have an existing UI with a single 'Save' button, defined as follows: + +\code + + + + +\endcode + +For the next release, you plan to add 'Cancel' and 'Reset' buttons. Rather than copying and pasting the above markup, you can create a component: + +\list 1 +\o Create a file called MyButton.qml, and copy the relevant Qml snippet into that file. +\o Make some minor changes to define the component's interface: + +\code + + + + + + +\endcode + +The \a label property and \a click signal that were added effectively become part of the 'public API' of the MyButton component. In a similar manner, the Text and MouseRegion elements become invisible to anyone using the component. Note that the Text element now binds in its data from \a label, and the MouseRegion emits a generic signal. + +\o The component can now be used elsewhere as MyButton: + +\code + +... + +... + +\endcode + +\endlist + +\section1 Placing .qml Files + +Component files should be placed in specific locations in order to be found by the Qml engine: + +\list +\o the run directory +\o the run directory + "/qml" +\o the directory of the Qml you are running +\o the directory of the Qml you are running + "/qml" +\endlist + +In the future library-like directories will be defined (in the meantime the first two options above effectively serve this purpose). + +*/ diff --git a/doc/src/declarative/cppitem.qdoc b/doc/src/declarative/cppitem.qdoc new file mode 100644 index 0000000..959bc6d --- /dev/null +++ b/doc/src/declarative/cppitem.qdoc @@ -0,0 +1,127 @@ +/*! +\page cppitem.html +\target cppitem +\title C++ Components + +\section1 Making a C++ object available in QML + +In QML, XML tags and attributes correspond to Qt objects and properties. Thus, any Qt object +can potentially be used as an element in QML. More specifically, to make an object available in QML, +it should: +\list +\o Be a subclass of QObject. +\o Provide a default constructor. +\o Declare Q_PROPERTYs. +\o Be registered via the QML_DECLARE_TYPE and QML_DEFINE_TYPE macros. +\endlist + +\section2 Declaring Q_PROPERTYs +\target properties + +Properties of QObject subclasses are available as properties in QML. +Like any QObject, these properties are defined by the Q_PROPERTY +macro in the header file. + +Properties should have a NOTIFY function if they can change dynamically and +if any useful response could be made to them changing in another object. Almost +all properties will thus need a NOTIFY function. + +\code + Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged); + qreal scale() const; + void setScale(qreal); + ... + signals: void scaleChanged(); +\endcode + +The property types currently supported by QML are: +\list +\o int +\o qreal +\o QString +\o QColor +\o QDate, QTime, and QDateTime +\o QSize and QSizeF +\o QPoint and QPointF +\o QRect and QRectF +\o QPixmap +\o QIcon +\o enums registered with Q_ENUMS +\o flags registered with Q_FLAGS +\o QVariant +\o QObject* (or subclass) +\endlist + +Custom property types that provide string-to-type conversion can be used as well, by: +\list +\o Registering them as a metatype (Q_DECLARE_METATYPE() and qRegisterMetaType()) +\o Registering a string-to-type convertor function (QML::addCustomStringConvertor()). +\endlist + +\section2 Registering your type +\target register + +In order for your type to be usable in QML, you must register it: + +\code +QML_DECLARE_TYPE(TypeName); +QML_DEFINE_TYPE(TypeName,QmlName); +\endcode + +These macros make the C++ \e TypeName available from the declarative markup language under the name \e QmlName. +Of course there's nothing stopping you using the same name for both the C++ and the QML name! + +For example: +\code +QML_DECLARE_TYPE(MyCircle); +QML_DEFINE_TYPE(MyCircle,Circle); +\endcode +would make the \e MyCircle class accessable though the \c tag in QML. + + +\section1 Creating a new 'Fx' item in C++ + +You can create a new type of 'Fx' item by: +\list 1 +\o Creating a subclass of QFxItem, +\o Adding Q_PROPERTYs appropriate for your item (see \l {properties}{Properties}), +\o Reimplementing the relevant paint functions, +\o Registering the type with the QML_DECLARE_TYPE and QML_DEFINE_TYPE macros (see \l {register}{Register}). +\endlist + +\section2 Creating a subclass of QFxItem + +To add a new type, you first must add a new C++ class derived from QFxItem. +You may of course extend existing QFxItem subclasses. + +One existing subclass is QFxPainted, which provides +a simple cached-image painting model. + +\section2 Reimplementing paint functions + +Two alternative painters are available, offering +different levels of performance and functionality: +QPainter, GLPainter. + +You can choose to subclass QFxPainted rather than QFxItem, +and then implement the virtual method: + +\code + void paint(QPainter *painter); +\endcode + +This paints into an offscreen pixmap which is then painted to the display (transformed, +etc. as needed). The cost of this offscreen pixmap should be carefully considered, as +should the specific performance of the painting done in the paint function. + +If you require more control, subclass QFxItem instead. +QFxItem subclasses must implement both simple software canvas painting +and GL painting: +\list +\o \c QFxItem::paintContents(QPainter &) for the simple software canvas, +\o \c QFxItem::paintGLContents(GLPainter &) for OpenGL. +\endlist + +See the documentation of those functions for detailed subclassing notes. + +*/ diff --git a/doc/src/declarative/effects.qdoc b/doc/src/declarative/effects.qdoc new file mode 100644 index 0000000..c7cd2f6 --- /dev/null +++ b/doc/src/declarative/effects.qdoc @@ -0,0 +1,31 @@ +/*! +\page effects.html +\target effects +\title Visual Effects + + +\section1 Basic Effects + +These effects are currently supported by all canvas backends. + +\list +\o Scaling (\l Item \bold scale property) +\o Opacity (\l Item \bold opacity property) +\o Z-Axis Rotation (\l Item \bold rotation property) +\endlist + +\section1 Advanced Effects + +These effects are currently only supported by the OpenGL canvas backend. Support for other +backends may be added if the performance can be made acceptable. + +\list +\o X/Y-Axis Rotation (see \l Transform) +\o \l Shadow +\o \l Blur +\o \l Reflection +\o \l Highlights +\o \l Particles +\endlist + +*/ diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc new file mode 100644 index 0000000..076ef13 --- /dev/null +++ b/doc/src/declarative/elements.qdoc @@ -0,0 +1,128 @@ +/*! +\page elements.html +\target elements +\title Qml Elements + +The following table lists the Qml elements provided by the Qt Declarative module. + +\bold {Standard Qt Declarative Elements} + +\table +\header +\o \bold {States} +\o \bold {Animation and Transitions} +\o \bold {Utility} +\row + +\o +\list +\o \l StateGroup +\o \l SetProperty +\o \l SetProperties +\o \l ParentChange +\o \l RunScript +\endlist + +\o +\list +\o \l NumericAnimation +\o \l ColorAnimation +\o \l VariantAnimation +\o \l PauseAnimation +\o \l SequentialAnimation +\o \l ParallelAnimation +\o \l SetPropertyAction +\o \l Transition +\o \l Behaviour +\o \l Follow +\endlist + +\o +\list +\o \l Script +\o \l Bind +\o \l Connection +\o \l ListModel +\o \l DateTimeFormatter +\endlist +\endtable + +\bold {Fluid UI Primitives} + +\table +\header +\o \bold {Basic Items} +\o \bold {Utility} +\o \bold {Widgets} + +\row +\o +\list +\o \l Item +\o \l Image +\o \l Text +\o \l TextEdit +\o \l Rect +\o \l MouseRegion +\o \l KeyActions +\o \l AnimatedImage +\endlist + +\o +\list +\o \l Repeater +\o \l Content +\o \l FocusPanel +\o \l FocusRealm +\o \l KeyProxy +\o \l ComponentInstance +\endlist + +\o +\list +\o \l Flickable +\o \l Flipable +\o \l WebView +\endlist + +\header +\o \bold {Views} +\o \bold {Layouts} +\o \bold {Effects} + +\row +\o + +\target xmlViews +\list +\o \l ListView +\o \l GridView +\o \l PathView + \list + \o \l Path + \endlist +\endlist + +\o +\list +\o \l VerticalLayout +\o \l HorizontalLayout +\o \l GridLayout +\endlist + +\o +\list +\o \l Shadow +\o \l Reflection +\o \l Blur +\o \l Highlight +\o \l Particles + \list + \o \l ParticleMotionLinear + \o \l ParticleMotionGravity + \o \l ParticleMotionWander + \endlist +\endlist +\endtable + +*/ diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc new file mode 100644 index 0000000..17fda4d --- /dev/null +++ b/doc/src/declarative/examples.qdoc @@ -0,0 +1,32 @@ +/*! +\page qmlexamples.html +\target qmlexamples +\title QML Examples + +A viewer application is included that allows you to quickly explore many of the +examples. It has some useful options, revealed by: + +\code + bin/duiviewer -help +\endcode + +There are several illustrative XML examples available. From your build +directory, + +\code + bin/duiviewer $QT_SOURCE_DIR/examples/declarative/mediabrowser/mediabrowser.qml +\endcode + +Many other simple demos can be found under the \c examples/declarative sub +directory. Some can be run directly using the viewer like those above, and +others require you to build and run an executable. + +Finally, check out the \l {tutorial} to learn a little more about writing your +own QML-based applications. + +\note When running applications that only use the Fluid UI atoms under the +software rasterizer, a simple canvas backend is used by default. To use +Graphics View instead, set \c QML_USE_GRAPHICSVIEW=1. + + +*/ diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc new file mode 100644 index 0000000..e0d4ca3 --- /dev/null +++ b/doc/src/declarative/focus.qdoc @@ -0,0 +1,248 @@ +/*! +\target qmlfocus +\page qmlfocus.html +\title Fluid UI Keyboard Focus + +When a key is pressed or released, a key event is generated and delivered to the +focused fluid UI \l Item. To facilitate the construction of reusable components +and to address some of the cases unique to fluid UIs, the fluid UI atoms add a +"realm" based extension to Qt's traditional keyboard focus model. + +\section1 Key Handling Overview + +When the user presses or releases a key, the following occurs: +\list 1 +\o Qt receives the key action and generates a key event. +\o If the Qt widget containing the fluid UI scene has focus, the key event is delivered to the fluid UI scene. Otherwise, regular Qt key handling continues. +\o The key event is delivered by the scene to the fluid UI \l Item with \e {active focus}. If no fluid UI \l Item has \e {active focus}, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. +\o If the fluid UI \l Item with \e {active focus} accepts the key event, propagation stops. Otherwise the event is "bubbled up", by recursively passing it to each \l Item's parent until either the event is accepted, or the root \l Item is reached. + +If the \c {} element in the following example has active focus and the \e A key is pressed, it will bubble up to the \c {}. However, pressing the \e B key will bubble up to the root item and thus subsequently be \l {QEvent::ignore()}{ignored}. + +\code + + + + + +\endcode + +\o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. + +\endlist + +\section1 Querying the Active Focus Item + +Whether or not an \l Item has \e {active focus} can be queried through the +read-only property \c {Item::activeFocus}. For example, here we have a \l Text +element whose text is determined by whether or not it has \e {active focus}. + +\code + + {activeFocus?"I have active focus!":"I do not have active focus"} + +\endcode + +\section1 Acquiring Focus and Focus Realms + +An \l Item requests focus by setting the \c {Item::focus} property to true. + +For very simple cases simply setting the \c {Item::focus} property is sometimes +sufficient. If we run the following example in the \c duiviewer, we see that +the \c {} element has \e {active focus} and pressing the +\e A, \e B, or \e C keys modifies the text appropriately. + +\table +\row +\o \code + + + + MyText.text = "Key A was pressed" + MyText.text = "Key B was pressed" + MyText.text = "Key C was pressed" + + +\endcode +\o \image declarative-qmlfocus1.png +\endtable + +However, were the above example to be used as a self-contained component, this +simple use of the \c {Item::focus} property is no longer sufficient. The left +hand side of the following table shows what we would like to be able to write. +Here we create two instances of our previously defined component, and set the +second one to have focus. The intention is that when the \e A, \e B, or \e C +keys are pressed, the second of the two components receives the event and +reponds accordingly. + +\table +\row +\o \code + + + + +\endcode +\o \code + + + + + MyText.text = "Key A was pressed" + MyText.text = "Key B was pressed" + MyText.text = "Key C was pressed" + + + + + + MyText.text = "Key A was pressed" + MyText.text = "Key B was pressed" + MyText.text = "Key C was pressed" + + +\endcode +\endtable + +The right hand side of the example shows the expanded code - the equivalent QML +without the use of the component \c {}. From this, the problem is +evident - there are no less than three elements that have the \c {Item::focus} +property set to true. Ultimately only one element can have focus, and the +system has to decide which on. In this case the first appearance of the +\c {Item::focus} property being set to true on line 4 is selected, and the value +of \c {Item::focus} in the other two instances is reverted back to false. This +is exactly the opposite of what was wanted! + +This problem is fundamentally one of visibility. The \c {} +components each set their \c {} as focused as that is all they can +do - they don't know how they are going to be used, but they do know that when +they're in use their \c {} element is what needs focus. Likewise +the code that uses the \c {}'s sets the second \c {} as +focused because, while it doesn't know exactly how the \c {} is +implemented, it knows that it wants the second one to be focused. No one piece +of code knows everything about the other, which is exactly how it should be. + +To solve this problem - allowing components to care about what they know about +and ignore everything else - the fluid UI atoms introduce a concept known as a +\e {focus realm}. For existing Qt users, a \e {focus realm} is like an +automatic focus proxy. A \e {focus realm} is created using the \l FocusRealm +element. + +In the next example, a \l FocusRealm is added to the component, and the visual +result shown. + +\table +\row +\o \code + + + + + MyText.text = "Key A was pressed" + MyText.text = "Key B was pressed" + MyText.text = "Key C was pressed" + + + +\endcode +\o \image declarative-qmlfocus2.png +\endtable + +Conceptually \e {focus realms} are quite simple. +\list +\o Within each \e {focus realm} one element may have \c {Item::focus} set to true. If more than one \l Item has the \c {Item::focus} property set, the first is selected and the others are unset, just like when there are no \e {focus realms}. +\o When a \e {focus realm} receives \e {active focus}, the contained element with \c {Item::focus} set (if any) also gets \e {active focus}. If this element is +also a \l FocusRealm, the proxying behaviour continues. Both the +\e {focus realm} and the sub-focused item will have \c {Item::activeFocus} set. +\endlist + +So far the example has the second component statically selected. It is trivial +now to extend this component to make it clickable, and add it to the original +application. We still set a one of the widgets as focused by default, but from +then on clicking the either one gives it focus. + +\table +\row +\o \code + + + + +\endcode +\o \code + + + + +\endcode +\endtable + +\image declarative-qmlfocus3.png + +When a fluid UI atom explicitly relinquishes focus (by setting its +\c {Item::focus} property to false while it has \e {active focus}), the system +does not automatically select another element to receive focus. That is, it +is possible for there to be no currently \e {active focus}. + +\section1 Advanced uses of Focus Realms + +Focus realms allow focus to allocation to be easily partitioned. Several +fluid UI atoms use it to this effect. + +\l ListView, for example, is itself a focus realm. Generally this isn't +noticable as \l ListView doesn't usually have manually added visual children. +By being a focus realm, \l ListView can focus the current list item without +worrying about how that will effect the rest of the application. This allows +the current item delegate to react to key presses. + +This contrived example shows how this works. Pressing the \c Return key will +print the name of the current list item. + +\table +\row +\o \code + + + + + + Bob + John + Michael + + + + + + + + + + + +\endcode +\o \image declarative-qmlfocus4.png +\endtable + +While the example is simple, there's a lot going on behind the scenes. Whenever +the current item changes, the \l ListView sets the delegate's \c {Item::focus} +property. As the \l ListView is a \e {focus realm}, this doesn't effect the +rest of the application. However, if the \l ListView itself has +\e {active focus} this causes the delegate itself to receive \e {active focus}. +In this example, the root element of the delegate is also a \e {focus realm}, +which in turn gives \e {active focus} to the \c {} element that +actually performs the work of handling the \e {Return} key. + +All of the fluid UI view classes, such as \l PathView and \l GridView, behave +in a similar mannor to allow key handling in their respective delegates. + +\section1 Focus Panels + +Traditional UIs are composed of many top-level windows. Windows actually +perform two tasks - they act as the visual bounds for a widget, and they segment +focus. Each window has a separate focused widget, that becomes (to mix +terminologies) the \e {active focus} widget when the window is the active +window. + +### Focus panels do basically the same thing. +*/ diff --git a/doc/src/declarative/index.qdoc b/doc/src/declarative/index.qdoc new file mode 100644 index 0000000..22195ba --- /dev/null +++ b/doc/src/declarative/index.qdoc @@ -0,0 +1,51 @@ +/*! +\page qml.html +\title 'Qt Declarative' Documentation + +\target qtdeclarativemainpage + +The Qt Declarative module provides a user interface framework for building +highly dynamic and fluid applications. It is targetted at the sorts of user +interface and the sorts of hardware in embedded devices such as phones, media +players, and set-top boxes. It is also appropriate for highly custom desktop +user-interfaces, or special elements in more traditional desktop +user-interfaces. + +Building fluid applications is done declaratively, rather than procedurally. +That is, you specify \e what the UI should look like and how it should behave +in an XML-based format called QML instead of specifying step-by-step \e how to +build it in a language like C++ or JavaScript. Specifying a UI declaratively +does not just include the layout of the interface items, but also the way each +individual item looks and behaves and the overall flow of the application. + +Getting Started: +\list +\o \l {qmlexamples}{Examples} +\o \l {tutorial}{Tutorial} +\o \l {qmlforcpp}{Qt Declarative Markup Language For C++ Programmers} +\endlist + +Core Features: +\list +\o \l {binding}{Data Binding} +\o \l {anchor-layout}{Layout Anchors} +\o \l {animation}{Animation} +\o \l {effects}{Visual Effects} +\o \l {components}{Components} +\o \l {qmlmodules}{Modules} +\o \l {qmlfocus}{Keyboard Focus} +\endlist + +QML Reference: +\list +\o \l {elements}{Qml Elements} +\endlist + +C++ Reference: +\list +\o \l {qtprogrammers}{QML for Qt programmers} +\o \l {qtbinding}{C++ Data Binding} +\o \l {cppitem}{C++ Components} +\endlist + +*/ diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc new file mode 100644 index 0000000..2387335 --- /dev/null +++ b/doc/src/declarative/measuring-performance.qdoc @@ -0,0 +1,81 @@ +/*! +\page optimizing-performance.html +\target optimizing-performance +\title Optimizing Performance + +The Qt Declarative module includes several tools to help measure performance. + +\section1 Performance Logging + +The declarative module uses the functionality provided by QPerformanceLog to log performance information. To see this information you can add the following to src.pro: + +\code +DEFINES += Q_ENABLE_PERFORMANCE_LOG +\endcode + +The performance information will be printed to screen on a QML application startup, or when running the viewer can be forced at anytime by pressing 'F3' on the keyboard. + +Additional logging can be enabled by adding the relevant categories to qfxperf.h and qfxperf.cpp. + +For example, to measure the cost of calculating the size of a text item, you would first define a TextSize category by adding the following: + +\code +//in qfxperf.h +Q_DECLARE_PERFORMANCE_METRIC(TextSize); + +//in qfxperf.cpp +Q_DEFINE_PERFORMANCE_METRIC(TextSize, "Text Size Calculation"); +\endcode + +You could then use this category in the code: + +\code +void QFxText::updateSize() +{ + QFxPerfTimer perf; + ... +} +\endcode + +Because there is no cost for a QFxPerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework. + +\section1 FPS Measurements + +When running the viewer, pressing 'F2' on the keyboard while a QML program is running will cause information on cost-per-frame and frames-per-second (FPS) to be printed to the console. + +The information printed includes: +\list +\o \e repaint(): the total time spent painting. +\o \e paint(): the time spent by Qt painting. +\o \e timeBetweenFrames: the total time spent per frame. This number minus repaint() gives a good idea of how much time is spent on things besides painting. A high number here with a low number for repaint() indicates expensive calculations happening each frame. +\endlist + +\section1 Improving Performance + +The following tips can help decrease startup time for QML-based appications. + +\section2 Images + +\list +\o Use jpg instead of png for photo-like images. On the N810, this can save 150ms for a large (320x480) image. + +\o If you are configuring Qt, configure out any image plugins you don't plan to support (mng and svg are the most expensive). On the N810, this can save 75-100ms startup time. For example: + +\code +configure -no-libmng -no-svg -no-libtiff +\endcode + +\o In some cases running pngcrush, optipng, gifsicle or other similar tools can give some improvement. + +We are also investigating support for the loading of uncompressed images. This will provide opportunites to decrease startup time at the cost of increased storage space. +\endlist + +\section2 Fonts + +\list +\o Use qpf instead of ttf. When using multiple font sizes and weights on the N810, this can save 125ms startup time compared to a ttf 'clean' run, and 40-50ms on subsequent runs (ttfs are shared by open applications). +\endlist + +*/ + +*/ diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc new file mode 100644 index 0000000..a97b5d7 --- /dev/null +++ b/doc/src/declarative/modules.qdoc @@ -0,0 +1,135 @@ +/*! +\page qmlmodules.html +\target qmlmodules +\title Modules of Components + +A \bold module is a collection of \l Components, in an XML namespace. + +Named component in QML may include a namespace qualification, +and standard XML namespace scoping is allowed. This allows +components to be provided by different modules (even if they otherwise +have the same name). + +To use a module: + +\code + + + ... + + +\endcode + +To create a modules: + +Create the components, with appropriate exported properties, signals, and slots (slots not currently supported), +in a single directory: + +\c Clock/Face.qml: ... + +\c Clock/Hand.qml: ... + +\c Clock/AnalogClock.qml: +\code + + + + + + ... + +\endcode + +Associate the directory with the namespace: + +\code + Qml::addNameSpacePath("http://nokia.com/qml/Clock", "/usr/lib/qml/Clock"); +\endcode + +Whole blocks of directories can be set: + +\code + Qml::addNameSpacePath("http://nokia.com/qml", "/usr/lib/qml"); +\endcode + +Associations can also be declared in the QML itself as a processing directive: + +\code + +\endcode + +*/ + +/* + +A kludgey way to do unexported components: + +Clock/AnalogClock.qml: + + + + + + ... + + + + + + +Another kludgey way (if _ handled specially)): + +Clock/_Hand.qml: ... + +A non-XML extension to improve syntax (XMLNS blows): + + + + + ... + + +*/ + +/* + IMPLEMENTATION + + Fully Qualifying names. CHOICE + IF QmlXmlParser qualifies names: + QmlXmlParser processes and tags to create a list of QmlModuleDependency. + It uses talks with the same creators as QmlCompiler::compileTypes to qualify the names. + Each of QmlMetaType, QmlCustomParser, and the QmlCompiledComponent::classFactory(ies) + must know fully-qualified names. + Pro: simpler + Con: may be harder to regenerate original XML if unqualified name is lost + Con: should QmlXmlParser "know" about the type creators? + ELSE + QmlXmlParser processes and tags to create a list of QmlModuleDependency, + which get stored in the QCompiledComponent. + When QmlCompiler::compileTypes creates components, module dependencies are used + to find the correct component - turning a name into a fully-qualified name + at "ref.className = type" before passing it to the creators. QmlMetaType::typeFunc must allow + qualified names even for builtin types, for example, QFxText might be + declared with the name Qt:Text. The QML::customParser must also understand + the concept, for example ListModel might be declared with the name Qt:ListModel. + QmlXmlParser::Object::typeName should be removed (used by DOM?), as redundant. + QmlXmlParser::Object::type will not define a fully qualified typename, just a name, + so types that are actually the same may have different type id because they + were named differently ("Qt:Text" vs "Text"). Need to check if this is a problem, + or whether QmlCompiler::output->types should be compressed. + + XML Namespaces. CHOICE CHOSEN + The advantage is that the namespaces could be fixed (per version), allowing proper DTDs, etc. + + Attached properties. PROBLEM + Type references in JavaScript can be either unqualified, in which case QmlMetaProperty + would have to FQ the type, which seems impossible, or qualified, the syntax + of which would be odd, like Qt.GridLayout.row or property["Qt:GridLayout.row"]. + + Access restrictions. PROBLEM + All use of the bind context must prevent direct access between objects that + are in different modules (i.e. between types with different module prefixes). + Maybe this is accomplishable just from having the right context tree. + Components in the same module can refer to their containing components (they + need to be careful if they're allowed to be used outside). +*/ diff --git a/doc/src/declarative/pics/ListViewHighlight.png b/doc/src/declarative/pics/ListViewHighlight.png new file mode 100644 index 0000000..02bf51d Binary files /dev/null and b/doc/src/declarative/pics/ListViewHighlight.png differ diff --git a/doc/src/declarative/pics/ListViewHorizontal.png b/doc/src/declarative/pics/ListViewHorizontal.png new file mode 100644 index 0000000..63c7c86 Binary files /dev/null and b/doc/src/declarative/pics/ListViewHorizontal.png differ diff --git a/doc/src/declarative/pics/ListViewVertical.png b/doc/src/declarative/pics/ListViewVertical.png new file mode 100644 index 0000000..e0b23d9 Binary files /dev/null and b/doc/src/declarative/pics/ListViewVertical.png differ diff --git a/doc/src/declarative/pics/anchors.svg b/doc/src/declarative/pics/anchors.svg new file mode 100644 index 0000000..08b00ed --- /dev/null +++ b/doc/src/declarative/pics/anchors.svg @@ -0,0 +1,92 @@ + + + + + + + + + image/svg+xml + + + + + + + + pic + label + + diff --git a/doc/src/declarative/pics/animatedimageitem.gif b/doc/src/declarative/pics/animatedimageitem.gif new file mode 100644 index 0000000..85c3cb5 Binary files /dev/null and b/doc/src/declarative/pics/animatedimageitem.gif differ diff --git a/doc/src/declarative/pics/blur_example.png b/doc/src/declarative/pics/blur_example.png new file mode 100644 index 0000000..763b112 Binary files /dev/null and b/doc/src/declarative/pics/blur_example.png differ diff --git a/doc/src/declarative/pics/declarative-qmlfocus1.png b/doc/src/declarative/pics/declarative-qmlfocus1.png new file mode 100644 index 0000000..fd05146 Binary files /dev/null and b/doc/src/declarative/pics/declarative-qmlfocus1.png differ diff --git a/doc/src/declarative/pics/declarative-qmlfocus2.png b/doc/src/declarative/pics/declarative-qmlfocus2.png new file mode 100644 index 0000000..a946e2c Binary files /dev/null and b/doc/src/declarative/pics/declarative-qmlfocus2.png differ diff --git a/doc/src/declarative/pics/declarative-qmlfocus3.png b/doc/src/declarative/pics/declarative-qmlfocus3.png new file mode 100644 index 0000000..ba55f76 Binary files /dev/null and b/doc/src/declarative/pics/declarative-qmlfocus3.png differ diff --git a/doc/src/declarative/pics/declarative-qmlfocus4.png b/doc/src/declarative/pics/declarative-qmlfocus4.png new file mode 100644 index 0000000..e21f2a6 Binary files /dev/null and b/doc/src/declarative/pics/declarative-qmlfocus4.png differ diff --git a/doc/src/declarative/pics/edge1.png b/doc/src/declarative/pics/edge1.png new file mode 100644 index 0000000..f4bc16d Binary files /dev/null and b/doc/src/declarative/pics/edge1.png differ diff --git a/doc/src/declarative/pics/edge2.png b/doc/src/declarative/pics/edge2.png new file mode 100644 index 0000000..71bda8e Binary files /dev/null and b/doc/src/declarative/pics/edge2.png differ diff --git a/doc/src/declarative/pics/edge3.png b/doc/src/declarative/pics/edge3.png new file mode 100644 index 0000000..51bb894 Binary files /dev/null and b/doc/src/declarative/pics/edge3.png differ diff --git a/doc/src/declarative/pics/edge4.png b/doc/src/declarative/pics/edge4.png new file mode 100644 index 0000000..aee3bd1 Binary files /dev/null and b/doc/src/declarative/pics/edge4.png differ diff --git a/doc/src/declarative/pics/edges.png b/doc/src/declarative/pics/edges.png new file mode 100644 index 0000000..211b101 Binary files /dev/null and b/doc/src/declarative/pics/edges.png differ diff --git a/doc/src/declarative/pics/edges.svg b/doc/src/declarative/pics/edges.svg new file mode 100644 index 0000000..25698ca --- /dev/null +++ b/doc/src/declarative/pics/edges.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + Top + VerticalCenter + Bottom + Left + Right + HorizontalCenter + + + diff --git a/doc/src/declarative/pics/edges_examples.svg b/doc/src/declarative/pics/edges_examples.svg new file mode 100644 index 0000000..31e9901 --- /dev/null +++ b/doc/src/declarative/pics/edges_examples.svg @@ -0,0 +1,109 @@ + + + + + + + + + image/svg+xml + + + + + + + + rect1 + rect2 + + rect3 + + diff --git a/doc/src/declarative/pics/edges_qml.png b/doc/src/declarative/pics/edges_qml.png new file mode 100644 index 0000000..73f22f9 Binary files /dev/null and b/doc/src/declarative/pics/edges_qml.png differ diff --git a/doc/src/declarative/pics/edges_qml.svg b/doc/src/declarative/pics/edges_qml.svg new file mode 100644 index 0000000..1814ec6 --- /dev/null +++ b/doc/src/declarative/pics/edges_qml.svg @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + top + verticalCenter + bottom + left + right + horizontalCenter + + + diff --git a/doc/src/declarative/pics/flickable.gif b/doc/src/declarative/pics/flickable.gif new file mode 100644 index 0000000..f7a3319 Binary files /dev/null and b/doc/src/declarative/pics/flickable.gif differ diff --git a/doc/src/declarative/pics/flipable.gif b/doc/src/declarative/pics/flipable.gif new file mode 100644 index 0000000..6386f06 Binary files /dev/null and b/doc/src/declarative/pics/flipable.gif differ diff --git a/doc/src/declarative/pics/gridLayout_example.png b/doc/src/declarative/pics/gridLayout_example.png new file mode 100644 index 0000000..6b120e9 Binary files /dev/null and b/doc/src/declarative/pics/gridLayout_example.png differ diff --git a/doc/src/declarative/pics/gridview.png b/doc/src/declarative/pics/gridview.png new file mode 100644 index 0000000..d5c8b4b Binary files /dev/null and b/doc/src/declarative/pics/gridview.png differ diff --git a/doc/src/declarative/pics/highlight.gif b/doc/src/declarative/pics/highlight.gif new file mode 100644 index 0000000..fbef256 Binary files /dev/null and b/doc/src/declarative/pics/highlight.gif differ diff --git a/doc/src/declarative/pics/horizontalLayout_example.png b/doc/src/declarative/pics/horizontalLayout_example.png new file mode 100644 index 0000000..42f90ec Binary files /dev/null and b/doc/src/declarative/pics/horizontalLayout_example.png differ diff --git a/doc/src/declarative/pics/layout-add.gif b/doc/src/declarative/pics/layout-add.gif new file mode 100644 index 0000000..86e9247 Binary files /dev/null and b/doc/src/declarative/pics/layout-add.gif differ diff --git a/doc/src/declarative/pics/layout-move.gif b/doc/src/declarative/pics/layout-move.gif new file mode 100644 index 0000000..1825c22 Binary files /dev/null and b/doc/src/declarative/pics/layout-move.gif differ diff --git a/doc/src/declarative/pics/layout-remove.gif b/doc/src/declarative/pics/layout-remove.gif new file mode 100644 index 0000000..7086511 Binary files /dev/null and b/doc/src/declarative/pics/layout-remove.gif differ diff --git a/doc/src/declarative/pics/margins_qml.png b/doc/src/declarative/pics/margins_qml.png new file mode 100644 index 0000000..d7d73a3 Binary files /dev/null and b/doc/src/declarative/pics/margins_qml.png differ diff --git a/doc/src/declarative/pics/margins_qml.svg b/doc/src/declarative/pics/margins_qml.svg new file mode 100644 index 0000000..1f0ff02 --- /dev/null +++ b/doc/src/declarative/pics/margins_qml.svg @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + topMargin + bottomMargin + leftMargin + rightMargin + + + + + + diff --git a/doc/src/declarative/pics/particles.gif b/doc/src/declarative/pics/particles.gif new file mode 100644 index 0000000..763a8a8 Binary files /dev/null and b/doc/src/declarative/pics/particles.gif differ diff --git a/doc/src/declarative/pics/pathview.gif b/doc/src/declarative/pics/pathview.gif new file mode 100644 index 0000000..4052eb2 Binary files /dev/null and b/doc/src/declarative/pics/pathview.gif differ diff --git a/doc/src/declarative/pics/propanim.gif b/doc/src/declarative/pics/propanim.gif new file mode 100644 index 0000000..f86406e Binary files /dev/null and b/doc/src/declarative/pics/propanim.gif differ diff --git a/doc/src/declarative/pics/qtlogo.png b/doc/src/declarative/pics/qtlogo.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/doc/src/declarative/pics/qtlogo.png differ diff --git a/doc/src/declarative/pics/reflection_example.png b/doc/src/declarative/pics/reflection_example.png new file mode 100644 index 0000000..fd9bb48 Binary files /dev/null and b/doc/src/declarative/pics/reflection_example.png differ diff --git a/doc/src/declarative/pics/scalegrid.svg b/doc/src/declarative/pics/scalegrid.svg new file mode 100644 index 0000000..e386f3d --- /dev/null +++ b/doc/src/declarative/pics/scalegrid.svg @@ -0,0 +1,183 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + diff --git a/doc/src/declarative/pics/shadow_example.png b/doc/src/declarative/pics/shadow_example.png new file mode 100644 index 0000000..6214620 Binary files /dev/null and b/doc/src/declarative/pics/shadow_example.png differ diff --git a/doc/src/declarative/pics/spacing_a.png b/doc/src/declarative/pics/spacing_a.png new file mode 100644 index 0000000..ff07e2e Binary files /dev/null and b/doc/src/declarative/pics/spacing_a.png differ diff --git a/doc/src/declarative/pics/spacing_b.png b/doc/src/declarative/pics/spacing_b.png new file mode 100644 index 0000000..94304ee Binary files /dev/null and b/doc/src/declarative/pics/spacing_b.png differ diff --git a/doc/src/declarative/pics/trivialListView.png b/doc/src/declarative/pics/trivialListView.png new file mode 100644 index 0000000..175e455 Binary files /dev/null and b/doc/src/declarative/pics/trivialListView.png differ diff --git a/doc/src/declarative/pics/verticalLayout_example.png b/doc/src/declarative/pics/verticalLayout_example.png new file mode 100644 index 0000000..458dc7f Binary files /dev/null and b/doc/src/declarative/pics/verticalLayout_example.png differ diff --git a/doc/src/declarative/pics/verticalLayout_transition.gif b/doc/src/declarative/pics/verticalLayout_transition.gif new file mode 100644 index 0000000..ed61adb Binary files /dev/null and b/doc/src/declarative/pics/verticalLayout_transition.gif differ diff --git a/doc/src/declarative/pics/webview.png b/doc/src/declarative/pics/webview.png new file mode 100644 index 0000000..0d24586 Binary files /dev/null and b/doc/src/declarative/pics/webview.png differ diff --git a/doc/src/declarative/qmlforcpp.qdoc b/doc/src/declarative/qmlforcpp.qdoc new file mode 100644 index 0000000..7aa2560 --- /dev/null +++ b/doc/src/declarative/qmlforcpp.qdoc @@ -0,0 +1,999 @@ +/*! + \page qmlforcpp.html + \target qmlforcpp + \title Qt Declarative Markup Language For C++ Programmers + + This page describes the QML format and how to use and extend it from C++. + + The QML syntax declaratively describes in XML how to construct an in memory + object tree. QML is usually used to describe a visual scene graph - using + \l {graphicsview}{GraphicsView} or the \l {fxprimitives}{Fx Primitives} - but it is not conceptually + limited to this: the QML format is an abstract XML description of \b any + object tree. + + QML also includes property bindings. Bindings are ECMAScript expressions + of a properties value. Whenever the value of the expression changes - + either for the first time at startup or subsequently thereafter - the + property is automatically updated with the new value. + + \section1 Loading and using QML Files + + QmlComponent is used to load a QML file and to create object instances. + + In QML a component is the unit of instantiation, and the most basic unit + of scope. A component is like a template for how to construct an object + tree. One component can create multiple instances of this tree, but the + template remains constant. + + The following code uses the C++ interface to create 100 red rectangles + based on a simple declarative component description. + \raw html + + + + +
+ \endraw + \code + QmlComponent redRectangle(""); + for (int ii = 0; ii < 100; ++ii) { + QObject *rectangle = redRectangle.create(); + // ... do something with the rectangle ... + } + \endcode + \raw html +
+ \endraw + + Each independent XML file describes a QML component, but it is + also possible to create sub-components within a QML file as will be + shown later. + + \section1 QML Format 101 + + This is some sample QML code. + +\raw HTML + + + + +
+\endraw + \code + + + 50 + white + 16 + Hello world! + + + \endcode +\raw HTML +
+\endraw + + In QML, XML tags and attributes correspond to Qt objects and properties. + The general rule of thumb is any tag or attribute name that starts with a + capital letter refers to a class, and names that start with a lower case + letter to properties. It is not possible to access a property that starts + with a capital letter from QML. + + The QML snippet shown above instantiates one \c Image instance and one + \c Text instance and sets properties on both. \b Everything in QML + ultimately comes down to either instantiating an object instance, or + assigning a property a value. QML relies heavily on Qt's meta object system + and can only instantiate classes that derive from QObject. + + Setting properties can be done in two ways: as an XML attribute directly on + the class tag that created the the object, or as sub-tags. + Although syntactically different, their behaviour is identical. The two QML + snippets below behave exactly the same. +\raw HTML + + + + + +
+\endraw + \code + + \endcode +\raw HTML + +\endraw + \code + + 10 + 10 + + \endcode +\raw HTML +
+\endraw + Arbitrary mixing and matching between the two is allowed. + + QML can set properties that are more complex than just simple types like + integers and strings. Properties can be object pointers or Qt interface pointers + or even lists of object or Qt interface pointers! QML is typesafe, and will + ensure that only the valid types are assigned to properties. + + Assigning an object to a property is as simple as assigning a basic + integer. Attempting to assign an object to a property when type coercian + fails will produce an error. The following shows an example of valid and of + invalid QML and the corresponding C++ classes. + +\raw HTML + + + + + +
+\endraw + \code + class Image : public QObject + { + ... + Q_PROPERTY(ImageFilter *filter READ filter WRITE setFilter) + }; + + class ImageFilter : public QObject + { + ... + }; + \endcode +\raw HTML + +\endraw + \code + + + + + + + + + + + + + + \endcode +\raw HTML +
+\endraw + + Classes can also define an optional default property. The default property + is used for assignment if no explicit property has been specified. + In the example below, the string "Hello World!" will be assigned to + the \c Text element's default property - which happens to be the \c text + property. Both lines do the same thing, one explicitly and one implicitly. + +\raw HTML + + + + + +
+\endraw + \code + + Hello World! + \endcode +\raw HTML + +\endraw + \code + class Text : public QObject + { + ... + Q_PROPERTY(QString text READ text WRITE setText) + Q_CLASSINFO("DefaultProperty", "text") + }; + \endcode +\raw HTML +
+\endraw + + Any object property can be the default, even complex properties like lists + of objects. The default property of the \c Rect class is the \c children + property, a list of \c Item's. In the following example, as both \c Image + and \c Text inherit from \c Item the \c Image and \c Text instances are + added to the parent's \c children property. + +\raw HTML + + + + +
+\endraw + \code + + + + + \endcode +\raw HTML +
+\endraw + + Properties that return read-only object pointers can be used recursively. + This can be used, for example, to group properties together. The + \c Text element has a \c font property that returns an object with a number + of sub-properties such as \c family, \c bold, \c italic and \c size. + QML makes it easy to interact with these grouped properties, as the + following shows - everything you would expect to work, just does. + +\raw HTML + + + + + +
+\endraw + \code + class Text : public ... + { + ... + Q_PROPERTY(Font *font READ font); + }; + class Font : public QObject + { + ... + Q_PROPERTY(QString family READ family WRITE setFamily); + Q_PROPERTY(bool bold READ bold WRITE setBold); + Q_PROPERTY(bool italic READ italic WRITE setItalic); + Q_PROPERTY(int size READ size WRITE setSize); + }; + \endcode +\raw HTML + +\endraw + \code + + + true + true + + 12 + + \endcode +\raw HTML +
+\endraw + + \section1 Defining QML Types + + The QML engine has no intrinsic knowledge of any class types. Instead + the programmer must define the C++ types, and their corresponding QML + name. There are three ways of adding known types to the QML engine: + \list + \o + \code + #define QML_DECLARE_TYPE(T) + #define QML_DEFINE_TYPE(T,QmlName) + \endcode + Adding these macros to your library or executable automatically makes the + C++ type \a T available from the declarative markup language under the + name \a QmlName. Of course there's nothing stopping you using the same + name for both the C++ and the QML name!
+ Most types are added to the QML engine using these macros. The only + requirement is that \a T inherits QObject and has a default constructor. + \o + \code + #define QML_DEFINE_CUSTOM_PARSER(QmlName, CustomParserClass) + \endcode + Custom parsers define a way to translate between declarative XML and an + object instance in the case the default object model lets you down. Free + form lists (\c {} are an example of a custom parser. + Custom parsers implement the \l QmlCustomParser interface. + + Custom parsers give a developer very fine grain control over how a type is + instantiated from the XML that describes it. During the + compilation phase, the custom parser is presented with the XML via a + QXmlStreamReader and must + compile this down into an opaque blob that is returned to the compiler. + When, at runtime, the type is instantiated, the opaque blob is passed into + the custom parser, which must return a QObject derived type. + + \o QML::ClassFactory + + The QML engine calls the class factory as a last resort when trying to + create a type. The class factory returns a \l QmlComponent instance for + the type if it can create it. This allows "on the fly" types to be created. + For example, a class factory is used to support automatic instantiation of + .qml template files. + \endlist + + \section1 Property Binding + + Assigning constant values and trees to properties will only get you so + far. Property binding allows a property's value to be dependant on the + value of other properties and data. Whenever these dependencies change, + the property's value is automatically updated. + + Property bindings are ECMAScript expressions and can be applied to any + object property. C++ classes don't have to do anything special to get + binding support other than define appropriate properties. Property binding + expressions are differentiated from regular constant literals by surrounding + them in braces. + + Here's a simple example that stacks a red, blue and green rectangle. + Bindings are used to ensure that the height of each is kept equal to it's + parent's. Were the root rectangle's height property to change, the child + rectangles height would be updated automatically. +\raw HTML + + + + +
+\endraw + \code + + + + + + \endcode +\raw HTML +
+\endraw + Binding expressions execute in a context. A context behaves as a scope and + defines how the expression resolves property and variable names. Although + the two expressions in the last example are the same, the value of \c parent + resolves differently because each executes in a different context. Although + QML generally takes care of everything for the programmer, a thorough + understanding of bind contexts is important in some of the more complex QML + structures. + + Every expression is executed in a bind context, encapsulated by the + QmlBindContext C++ class. As covered in the class documentation, a + bind context contains a map of names to values, and a list of default + objects. When resolving a name, the name to value map is searched first. + If the name cannot be found, the default object's are iterated in turn and + the context attempts to resolve the name as a property of one of the default + objects. + + There are generally two contexts involved in the execution of a binding. + The first is the "object context" - a bind context associated with the + closest instantiated object and containing just one default object, and + that's instantiated object itself. The effect of the object + context is pretty simple - names in the binding expression resolve to + properties on the object first. It is important to note - particularly in + the case of grouped properties - the object context is that of the + instantiated object, the consequences of which are shown below. + +\raw HTML + + + + +
+\endraw + \code + + + + {font.italic} {italic} + + + \endcode +\raw HTML +
+\endraw + + The second context is the "component context". Each QML component (and + consequently each QML file) is created in its own unique binding context. + Like the object context, the component context contains just one default + object - but in this case it is the component's root object. An example + will illustrate best - the resultant text will read "background.png". + +\raw HTML + + + + +
+\endraw + \code + + + + \endcode +\raw HTML +
+\endraw + + If the name is not found in either of these contexts, the context heirarchy + is searched parent-by-parent until the name is either found, or the + heirarchy is exhausted. + + The first property binding example shown involved fixing the height of three + rectangles. It did this by fixing the height of each rectangle to its + parent, rather than fixing them all to a single common point. Here's the + example rewritten to do just that. + +\raw HTML + + + + +
+\endraw + \code + + + + + + \endcode +\raw HTML +
+\endraw + + Clearly this sort of fragile relationship is undesirable and unmanageable - + moving the green rectangle to be a sibling of the blue or introducing a + further rectangle between the two would break the example. + + To address this problem, QML includes a way to directly reference any object + within a component (or parent component for that matter), called "ids". + Developers assign an object an id, and can then reference it directly by + name. Developers assign an object an id by setting the special \c id + property. Every object automatically has this magical property (if the + object also has an actual property called \c id, that gets set too). As + an id allows an object to be referenced directly, it must be unique within + a component. Any number of id's can exist, but they must all begin with + a capital letter. An id of "Root" is valid, while an id of "root" is not. + \note This is not technically true - lowercase id names do work, but are + slower. Support will probably be removed for them eventually. + +\raw HTML + + + + +
+\endraw + \code + + + + + + \endcode +\raw HTML +
+\endraw + + To relate id's back to QmlBindContext, id's exist as properties on the + component context. + + Bind expressions can reference any object property. The QML bind engine + relies on the presence of the NOTIFY signal in the Q_PROPERTY declaration + on a class to alert it that a property's value has changed. If this is + omitted, the bind expression can still access the property's value, but + the expression will not be updated if the value changes. The following is + an example of a QML friendly property declaration. + +\raw HTML + + + + +
+\endraw + \code + class Example : public QObject + { + Q_OBJECT + Q_PROPERTY(int sample READ sample WRITE setSample NOTIFY sampleChanged) + public: + int sample() const; + void setSample(int); + signals: + void sampleChanged(int); + }; + \endcode +\raw HTML +
+\endraw + + While generally no changes are needed to a C++ class to use property + binding, sometimes more advanced interaction between the binding engine and + an object is desirable. To facilitate this, there is a special exception + in the bind engine for allowing an object to access the binding directly. + + If a binding is assigned to a property with a type of QmlBindableValue + pointer (ie. QmlBindableValue *), each time the binding value changes, + a QmlBindableValue instance is assigned to that property. The + QmlBindableValue instance allows the object to read the binding and to + evaluate the binding's current value. + + \section1 Signal Properties + + In addition to reading and writing regular properties, QML allows you to + easily associate ECMAScript with signals. Consider the following example, + in which Button is a made-up type with a clicked() signal. + +\raw HTML + + + + +
+\endraw + \code +
+\endraw + + Clicking on the button causes "Hello world!" to be printed to the console + (or lost forever if you're running Windows). + + Like properties, signals automatically become available in QML without + any additional work. As illustrated signals are mapped into QML as special + "signal properties", using the name "on" where the first + character of the signal's name is uppercased. If more than one signal of + the same name is exist on a class, only the first is available (see the + \l {xmlConnection}{} element for more general signal connections). + + An important observation to make here is the lack of braces. While both + property bindings and signal properties involve executing ECMAScript code, + property bindings dynamically update the property value (hence the braces), + whereas with signal properties the constant script "value" is actually + assigned to the signal property. Trying to bind a value to a signal + property will not work! + + Signal parameters are also available to the executing script, as shown + below, as long as you remember to name the parameters of your signal + in C++ (see QMetaMethod::parameterNames()). + +\raw HTML + + + + + +
+\endraw + \code + + + for(var ii = 0; ii < count; ++ii) + print(message) + + + \endcode +\raw HTML + +\endraw + \code + class Example : public QObject + { + Q_OBJECT + signals: + void doSomething(int count, const QString &message); + }; + \endcode +\raw HTML +
+\endraw + + Just like property bindings, signal scripts are executed in a context. The + signal script context is identical in scope to the "object context" under + property binding, with the exception that it has the signal parameters + bound in. + + In addition to scripts, it is possible to assign objects to signal properties. + This automatically connects the signal to the object's default method. A + default method is defined just like a default property, though the special + "DefaultMethod" class info. + +\raw HTML + + + + +
+\endraw + \code + Q_CLASSINFO("DefaultMethod", "myMethod(int)"); + \endcode +\raw HTML +
+\endraw + + This is useful in achieving several use cases, like that below which moves + the button when it is clicked. + +\raw HTML + + + + +
+\endraw + \code + + \endcode +\raw HTML +
+\endraw + + + If the class itself actually defines a property called "on", this will + be assigned the string value and the signal handling behaviour will be + disabled. + + \section1 Attached Properties + + Attached properties allow unrelated types to annotate another type with some + additional properties. Some APIs or operations are inherintly imperative, + and attached properties help out when translating these APIs into the + declarative QML language. + + Qt's QGridLayout is one such example. + +\raw HTML + + + + +
+\endraw + \code + + + + + + + + \endcode +\raw HTML +
+\endraw + + Attached properties are identified by the use of a class name, in the + case shown \c QGridLayout, as a grouped property specifier. To prevent + ambiguity with actual class instantiations, attached properties must + always be specified to include a period but can otherwise be used just like + regular properties. + +\raw HTML + + + + +
+\endraw + \code + + + 0 + 0 + + + \endcode +\raw HTML +
+\endraw + + C++ types provide attached properties by declaring the public function \c qmlAttachedProperties like this example. + +\raw HTML + + + + + +
+\endraw + \code + static QObject *Type::qmlAttachedProperties(QObject *); + \endcode +\raw HTML + +\endraw + \code + class Example : public QObject + { + Q_OBJECT + public: + static QObject *qmlAttachedProperties(QObject *); + }; + \endcode +\raw HTML +
+\endraw + + When an attached property is accessed, the QML engine will call this method + to create an attachment object, passing in the object instance that the + attached property applies to. The attachment object should define all + the attached properties, and is generally parented to the provided object + instance to avoid memory leaks. The QML engine does not save this object, + so it is necessary for the attached property function to ensure that + multiple calls for the same instance object return the same attached object. + + While conceptually simple, implementing an attachment object is not quite + so easy. The \c qmlAttachedProperties function is static - attachment + objects are not associated with any particular instance. How the values + of the attached properties apply to the behaviour they are controlling is + entirely implementation dependent. An additional consequence of this is + that \b any object can attach \b any attached property. The following is + perfectly valid, although the attached property has no actual effect: + +\raw HTML + + + + +
+\endraw + \code + + +
+\endraw + + The property has no effect because the (made-up) FancyGridLayout type defines the meaning + of the \c row attached property only to apply to its direct children. It + is possible that other types may have attached properties that affect + objects that aren't their direct children. + + Attached properties are an advanced feature that should be used with + caution. + + \note We may implement a convenience wrapper that makes using attached + properties easier for the common "attach to children" case. + + \section1 Property Value Sources + + Intrinsically, the QML engine can assign a property either a static value, + such as a number of object tree, or a property binding. It is possible for + advanced users to extend the engine to assign other "types" of values to + properties. These "types" are known as property value sources. + + Consider the following \l {fxprimitives}{Fx Primitives} example. + +\raw HTML + + + + +
+\endraw + \code + + + + + + \endcode +\raw HTML +
+\endraw + + Here the \c x property of the rectangle will be animated from 0 to 100. + To support this, the NumericAnimation class inherits the + QmlPropertyValueSource class. If a type inherits this class and is assigned + to a property for which type assignment would otherwise fail (ie. the + property itself doesn't have a type of QmlPropertyValueSource *), the QML + engine will automatically set the property as the target of the value + source. + + \section1 Extending types in QML + + QML is designed to allow you to build fully working types without writing + a line of C++ code. This is, for example, used extensively when designing + applications using the \l {fxprimitives}{Fx Primitives}. To create new types, it is + necessary to be able to define new signals, slots and properties in QML. + + \note slots are not yet supported + + Any object is extensible in this way under QML, using the special + \c properties and \c signals properties. Like \c id, these two properties + are automatically available on all types under QML and accessible from + other QML files or directly from C++. + + In this example, a Button is extended to have an additional + "text2" property (which always returns "Hello world!") and an additional + signal "clicked2" that is also emitted when the button is clicked. Not + a very useful extension, but an extension nonetheless. + +\raw HTML + + + + + +
+\endraw + \code + QmlComponent component(xmlData); + QObject *object = component.create(); + // Will print "Hello world!" + qDebug() << object->property("text2"); + // Will be emitted whenever the button is clicked + QObject::connect(object, SIGNAL(clicked2()), this, SLOT(...)); + \endcode +\raw HTML + +\endraw + \code + + \endcode +\raw HTML +
+\endraw + + Any number of properties and signals can be added to an existing type. The + \c Property and \c Signal elements have the following properties that can + be set: + \table + \header \o Tag \o Property \o Description + \row \o Property \o name \o The name of the property + \row \o Property \o type \o The type of the property. The available types are: \list \o int \o bool \o double \o real \o string \o color \o date \o variant \endlist The default is variant. + \row \o Property \o value \o The initial value of the property. Setting this is just a shortcut for setting the property normally, as shown in the example above. + \row \o Property \o onValueChanged \o A special signal property that is emitted each time the property value changes. + \row \o Property \o default \o Set this as the object's default property + \row \o Signal \o name \o The name of the signal. + \endtable + + If the type itself actually defines a property called \c properties or + \c signals, the respective extension will be disabled for that type and + the types own properties will be set. + + \section1 Parser Status + + Generally using QML is a breeze - you implement your classes in C++, add + the appropriate properties, signals and slots and off you go. The QML + engine takes care of instantiating your classes and setting the properties + and everything works fine. + + However, sometimes it is helpful to know a little more about the status of + the QML parser. For example, it might be beneficial from a performance + standpoint to delay initializing some data structures until all the + properties have been set. + + To assist with this, the QML engine defines an interface class called + QmlParserStatus. The interface defines a number of virtual methods that are + invoked at various stages of the component instantiation. To receive + these notifications, all a class has to do is to inherit the interface, and + notify the Qt meta system using the Q_INTERFACES() macro. For example, + +\raw HTML + + + + +
+\endraw + \code + class Example : public QObject, public QmlParserStatus + { + Q_OBJECT + Q_INTERFACES(QmlParserStatus) + public: + virtual void componentComplete() + { + qDebug() << "Woohoo! Now to do my costly initialization"; + } + }; + \endcode +\raw HTML +
+\endraw + + \section1 Extended Type Definitions + + QML requires that types have the appropriate properties and signals to + work well within the declarative environment. In the case of existing + types, it is sometimes necessary to add signals, properties or slots to a + target class to make it more QML friendly but the original type cannot be + modified. For these cases, the QML engine supports extended type + definitions. + + An extended type definition allows the programmer to supply an additional + type - known as the extension type - when registering the target class + whose properties, signals and slots are transparently merged with the + original target class when used from within QML. + + An extension class is a regular QObject, with a constructor that takes a + QObject pointer. When needed (extension classes are delay created + until the first extension attribute is accessed) the extension + class is created and the target object is passed in as the parent. When + an extension attribute on the original is accessed, the appropriate signal, + property or slots on the extension object is used instead. + + When an extended type is installed, the +\raw HTML + + + + +
+\endraw + \code + #define QML_DEFINE_EXTENDED_TYPE(T,QmlName,ExtendedTypeName) + \endcode +\raw HTML +
+\endraw + macro should be used instead of the regular \c QML_DEFINE_TYPE. + + This example shows the addition of a read-only \c textLength property to + QLabel being implemented as an extension. + +\raw HTML + + + + + +
+\endraw + \code + class QLabelExtension : public QObject + { + Q_OBJECT + Q_PROPERTY(int textLength READ textLength) + public: + QWidgetExtension(QObject *parent) : QObject(parent) {} + int textLength() const { + return static_cast(parent())->text().count(); + } + }; + QML_DEFINE_EXTENDED_TYPE(QLabel,QLabel,QLabelExtension); + \endcode +\raw HTML + +\endraw + \code + + + \endcode +\raw HTML +
+\endraw + + Attributes defined through extensions are inherited, just like attributes + defined on a normal class. Any types that inherit from \c QLabel, will + also have the \c textLength property. Derived types can include additional + extensions which are merged together, but only a single extension can be + specified for each single C++ class. + + Extended type definitions can even be used to add an attached properties + function to a type - just declare the \c qmlAttachedProperties function on + the extension object. + +*/ + diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc new file mode 100644 index 0000000..92caa3f --- /dev/null +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -0,0 +1,121 @@ +/*! +\page qtprogrammers.html +\target qtprogrammers +\title QML for Qt programmers + +\section1 Overview + +While QML does not require Qt knowledge to use, if you \e are already familar with Qt, +much of your knowledge is directly relevant to learning and using QML. Of course, +an application with a UI defined in QML also uses Qt for all the non-UI logic. + +\section1 Familiar Concepts + +QML provides direct access to the following concepts from Qt: + +\list + \o QAction - the \l {basicxmlaction}{action} type + \o QObject signals and slots - available as functions to call in JavaScript + \o QObject properties - available as variables in JavaScript + \o QWidget - QFxView is a QML-displaying widget + \o Qt models - used directly in data binding (currently only next generation QListModelInterface) +\endlist + +Qt knowledge is \e required for \l {cppitem}{writing elements in C++}. + + +\section1 QML Items compared with QWidgets + +QML Items are very similar to QWidgets: they define the look and feel of the user interface. (Note that while QWidgets +haven't traditionally been used to define the look and feel of view delegates, QML Items can be used for this as well.) + +There are three structurally different types of QWidget: + +\list + \o Simple widgets that are not used as parents (QLabel, QCheckBox, QToolButton, etc.) + \o Parent widgets that are normally used as parents to other widgets (QGroupBox, QStackedWidget, QTabWidget, etc.) + \o Compound widgets that are internally composed of child widgets (QComboBox, QSpinBox, QFileDialog, QTabWidget, etc.) +\endlist + +QML Items also serve these purposes. Each is considered separately below. + +\section2 Simple Widgets + +The most important rule to remember while implementing a new QFxItem in C++ +is that it should not contain any look and feel policies - leave that to the +QML usage of the item. + +As an example, imagine you wanted a reusable Button item. If you therefore +decided to write a QFxItem subclass to implement a button, +just as QToolButton subclasses QWidget for this purpose, following the rule above, your +"QFxButton" would not have any appearance - just the notions of enabled, triggering, etc. + +But there is already an object in Qt that does this: QAction. + +QAction is the UI-agnostic essence of QPushButton, QCheckBox, QMenu items, QToolButton, +and other visual widgets that are commonly bound to a QAction. + +So, the job of implementing a checkbox abstraction for QML is already done - it's QAction. +The look and feel of an action - the appearance of the button, the transition between states, +and exactly how it respond to mouse, key, or touch input, should all be left for definition +in QML. + +It is illustrative to note that QFxTextEdit is built upon QTextControl, +QFxWebView is built upon QWebPage, and ListView uses QListModelInterface, +just as QTextEdit, QWebView, and QListView are built upon +those same UI-agnostic components. + +The encapsulation of the look and feel that QWidgets gives is important, and for this +the QML concept of \l components serves the same purpose. If you are building a complete +suite of applications which should have a consistent look and feel, you should build +a set of reusable components with the look and feel you desire. + +So, to implement your reusable button, you would simply build a QML component. + + +\section2 Parent Widgets + +Parent widgets each provide a generic way to interface to one or more arbitrary other widgets. +A QTabWidget provides an interface to multiple "pages", one of which is visible at any time, +and a mechnism for selecting among them (the QTabBar). A QScollArea provides scrollbars around +a widget that is otherwise too large to fit in available space. + +Nearly all such components can be created directly in QML. Only a few cases +which require very particular event handling, such as Flickable, require C++ implementations. + +As an example, imagine you decided to make a generic tab widget item to be used +through your application suite wherever information is in such quantity that it +needs to be divided up into pages. + +To do this in QML, ... \todo example of container definition. + +A significant difference in the parenting concept with QML compare to QWidgets +is that while child items are positioned relative to their parents, +there is no requirement that they be wholy contained ("clipped") to +the parent (although the clipped property of the child Item does allow +this where it is needed). +This difference has rather far-reaching consequences, for example: + +\list + \o A shadow or highlight around a widget could be a child of that widget. + \o Particle effects can flow outside the object where they originate. + \o Transitioning animations can "hide" items by visibly moving them beyond the screen bounds. +\endlist + + +\section2 Compound Widgets + +Some widgets provide functionality by composing other widgets as an "implementation detail", +providing a higher level API to the composition. QSpinBox for example is a line edit and some +buttons to increase/decrease the edited value. QFileDialog uses a whole host of widgets to +give the user a way of finding and selecting a file name. + +When developing reusable QML Items, you may choose to do the same: build an item composed +of other items you have already defined. + +The only caveat when doing this is to consider the possible animations and transitions that +users of the compound item might wish to employ. For example, a spinbox might need to smoothly +transition from an arbitrary Text item, or characters within a Text item, so your spinbox +item would need to be sufficiently flexible to allow such animation. + +*/ diff --git a/doc/src/declarative/scenegraph.qdoc b/doc/src/declarative/scenegraph.qdoc new file mode 100644 index 0000000..2340324 --- /dev/null +++ b/doc/src/declarative/scenegraph.qdoc @@ -0,0 +1,13 @@ +/*! + \page graphicsview.html + \target graphicsview + \title GraphicsView + +*/ + +/*! + \page fxprimitives.html + \target fxprimitives + \title FX Primitives + +*/ diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc new file mode 100644 index 0000000..6fe3929 --- /dev/null +++ b/doc/src/declarative/tutorial.qdoc @@ -0,0 +1,19 @@ +/*! +\page tutorial.html +\title Tutorial + +This tutorial gives an introduction to QML and the Fluid UI atoms. It doesn't cover everything; the emphasis is on teaching the key principles, and features are introduced as needed. + +Chapter one starts with a minimal "Hello world" program and the following chapters introduce new concepts. + +The tutorial's source code is located in the $QTDIR/examples/declarative/tutorials directory. + +Tutorial chapters: + +\list +\o \l {tutorial1}{Tutorial 1} +\o \l {tutorial2}{Tutorial 2} +\o \l {tutorial3}{Tutorial 3} +\endlist + +*/ diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc new file mode 100644 index 0000000..15edaff --- /dev/null +++ b/doc/src/declarative/tutorial1.qdoc @@ -0,0 +1,55 @@ +/*! +\page tutorial1.html +\title Tutorial 1 - Hello World! +\target tutorial1 + +This first program is a simple "Hello world" example. The picture below is a screenshot of this program. + +\image declarative-tutorial1.png + +Here is the QML code for the application: + +\code + + + +\endcode + +\section1 Walkthrough + +\section2 Rect element + +\code + +\endcode + +First, we declare a root element of type \l {xmlRect}{Rect}. It is one of the basic building blocks you can use to create an application in QML. +We give it an id to be able to refer to it later. In this case, we call it \e Page. We also set the \c width, \c height and \c color properties. +The \l {xmlRect}{Rect} element contains many other properties (such as \c x and \c y), but these are left at their default values. + +\section2 Text element + +\code + +\endcode + +We add a text element as a child of our root element to display the text 'Hello world!'. + +The \c y property is used to position the text vertically at 30 pixels from the top of its parent. + +The \c font.size and \c font.bold properties are related to fonts and use the 'dot' notation (see \l {declarative}{Declarative UI} ). + +The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we bind the center of our text element to the center of the \e Page element. We use braces to indicate that \c Page.horizontalCenter is a bound ECMAScript expression that needs to be evaluated. It also means that if the center of \e Page changes (for example if it is resized) our text will be re-centered automatically (see \l binding). + +\section2 Viewing the example + +To view what you have created, run the duiviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: + +\code +bin/duiviewer examples/tutorials/t1/tutorial1.qml +\endcode + +[\l tutorial] [Next: \l tutorial2] + +*/ + diff --git a/doc/src/declarative/tutorial2.qdoc b/doc/src/declarative/tutorial2.qdoc new file mode 100644 index 0000000..8898e68 --- /dev/null +++ b/doc/src/declarative/tutorial2.qdoc @@ -0,0 +1,94 @@ +/*! +\page tutorial2.html +\title Tutorial 2 - Some colors +\target tutorial2 + +This chapter adds a color picker to change the color of the text. + +\image declarative-tutorial2.png + +Our color picker is made of many cells with different colors. To avoid writing the same code many times, we first create a new \c Cell component with a color property (see \l components). + +Here is the QML code for \c Cell.qml: + +\code + + + + + + + +\endcode + +Then, we use our \c Cell component to create the color picker in the QML code for the application: + +\code + + + + + + + + + + + +\endcode + +\section1 Walkthrough + +\section2 The Cell Component + +\code + +\endcode + +The root element of our component is an \c Item. It is the most basic 'Fx' element in Qml and is often used as a container for other elements. + +\code + + + +\endcode + +We declare a \c color property. This property is accessible from \i outside our component, this allows us to instantiate the cells with different colors. + +\code + +\endcode + +Our cell component is basically a colored rectangle. + +The \c anchors.fill property is a convenient way to set the size of an element. In this case the \c Rect will have the same size as its parent. + +We bind the \c color property of this \c Rect to the color property of our component. + +\code + +\endcode + +In order to change the color of the text when clicking on a cell, we create a \c MouseRegion element with the same size as its parent. + +The \c onClick property sets the \c color property of the element named \i HelloText to our cell color. + +\section2 The main QML file + +\code + + + + + + + + +\endcode + +In the main QML file, the only thing we have to do is to create a color picker by putting 6 cells with different colors in a grid layout. + +[Previous: \l tutorial1] [Next: \l tutorial3] + +*/ + diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc new file mode 100644 index 0000000..91ab9f0 --- /dev/null +++ b/doc/src/declarative/tutorial3.qdoc @@ -0,0 +1,83 @@ +/*! +\page tutorial3.html +\title Tutorial 3 - States +\target tutorial3 + +In this chapter, we make this example a little bit more dynamic by introducing states. + +We want our text to jump at the bottom of the screen and become red when clicked. + +\image declarative-tutorial3_animation.gif + +Here is the QML code: + +\code + + + + + + + + + + + + + + + + + + + + + + + + + + + +\endcode + +\section1 Walkthrough + +\code + + + + + + +\endcode + +First, we create a new state \e down for our text element. This state will be activated when \l {xmlMouseRegion}{MouseRegion} is pressed, and deactivated when it is released. + +The \e down state includes a set of property changes from our implicit \e {default state} (the items as they were initially defined in the QML). Specifically, we set the \c y property of the text to 160 and the \c color to red. + +\code + +\endcode + +Because we don't want the text to appear at the bottom instantly but rather move smoothly, we add a transition between our two states. + +\c fromState and \c toState define the states between which the transition will run. In this case, we want a transition from any state to our \e down state. + +Because we want the same transition to be run in reverse when changing back from the \e down state to the default state, we set \c reversible to \c true. This is equivalent to writing the two transitions separately. + +\code + + + + +\endcode + +The \c ParallelAnimation element makes sure that the two animations (color and position) will start at the same time. We could also run them one after the other by using \c SequentialAnimation instead. + +For more details on states and transitions, see \l {states-transitions}{States and Transitions}. + +[Previous: \l tutorial2] [\l tutorial] + +*/ + diff --git a/doc/src/diagrams/programs/easingcurve/easingcurve.pro b/doc/src/diagrams/programs/easingcurve/easingcurve.pro new file mode 100644 index 0000000..0b80127 --- /dev/null +++ b/doc/src/diagrams/programs/easingcurve/easingcurve.pro @@ -0,0 +1,13 @@ +###################################################################### +# Automatically generated by qmake (2.01a) fr 13. feb 13:26:38 2009 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp + +CONFIG += console \ No newline at end of file diff --git a/doc/src/diagrams/programs/easingcurve/main.cpp b/doc/src/diagrams/programs/easingcurve/main.cpp new file mode 100644 index 0000000..98e9d37 --- /dev/null +++ b/doc/src/diagrams/programs/easingcurve/main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include + +void createCurveIcons(); + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + createCurveIcons(); + return app.exit(); +} + +void createCurveIcons() +{ + QDir dir(QDir::current()); + if (dir.dirName() == QLatin1String("debug") || dir.dirName() == QLatin1String("release")) { + dir.cdUp(); + } + dir.cdUp(); + dir.cdUp(); + dir.cdUp(); + QSize iconSize(128, 128); + QPixmap pix(iconSize); + QPainter painter(&pix); + QLinearGradient gradient(0,0, 0, iconSize.height()); + gradient.setColorAt(0.0, QColor(240, 240, 240)); + gradient.setColorAt(1.0, QColor(224, 224, 224)); + QBrush brush(gradient); + const QMetaObject &mo = QEasingCurve::staticMetaObject; + QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type")); + QFont oldFont = painter.font(); + // Skip QEasingCurve::Custom + QString output(QString::fromAscii("%1/images").arg(dir.absolutePath())); + printf("Generating images to %s\n", qPrintable(output)); + for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { + painter.setFont(oldFont); + QString name(QLatin1String(metaEnum.key(i))); + painter.fillRect(QRect(QPoint(0, 0), iconSize), brush); + QEasingCurve curve((QEasingCurve::Type)i); + painter.setPen(QColor(0, 0, 255, 64)); + qreal xAxis = iconSize.height()/1.5; + qreal yAxis = iconSize.width()/3; + painter.drawLine(0, xAxis, iconSize.width(), xAxis); // hor + painter.drawLine(yAxis, 0, yAxis, iconSize.height()); // ver + + qreal curveScale = iconSize.height()/2; + + painter.drawLine(yAxis - 2, xAxis - curveScale, yAxis + 2, xAxis - curveScale); // hor + painter.drawLine(yAxis + curveScale, xAxis + 2, yAxis + curveScale, xAxis - 2); // ver + painter.drawText(yAxis + curveScale - 8, xAxis - curveScale - 4, QLatin1String("(1,1)")); + + painter.drawText(yAxis + 42, xAxis + 10, QLatin1String("progress")); + painter.drawText(15, xAxis - curveScale - 10, QLatin1String("ease")); + + painter.setPen(QPen(Qt::red, 1, Qt::DotLine)); + painter.drawLine(yAxis, xAxis - curveScale, yAxis + curveScale, xAxis - curveScale); // hor + painter.drawLine(yAxis + curveScale, xAxis, yAxis + curveScale, xAxis - curveScale); // ver + + QPoint currentPos(yAxis, xAxis); + + painter.setPen(Qt::black); + QFont font = oldFont; + font.setPixelSize(oldFont.pixelSize() + 15); + painter.setFont(font); + painter.drawText(0, iconSize.height() - 20, iconSize.width(), 20, Qt::AlignHCenter, name); + + for (qreal t = 0; t < 1.0; t+=1.0/curveScale) { + QPoint to; + to.setX(yAxis + curveScale * t); + to.setY(xAxis - curveScale * curve.valueForProgress(t)); + painter.drawLine(currentPos, to); + currentPos = to; + } + QString fileName(QString::fromAscii("qeasingcurve-%1.png").arg(name.toLower())); + printf("%s\n", qPrintable(fileName)); + pix.save(QString::fromAscii("%1/%2").arg(output).arg(fileName), "PNG"); + } +} + + diff --git a/doc/src/duiviewer.qdoc b/doc/src/duiviewer.qdoc new file mode 100644 index 0000000..f967f87 --- /dev/null +++ b/doc/src/duiviewer.qdoc @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page duiviewer.html + \title Declarative UI Viewer (duiviewer) + \ingroup qttools + \keyword duiviewer + + This page documents the \e{Declarative UI Viewer} for the Qt GUI + toolkit. The \c duiviewer reads an XML format declarative user interface definition + (\c .qml) file + and displays the user interface it describes. + + \section1 Options + + When run with the \c -help option, duiviewer shows available options. + + \section1 Dummy Data + + One use of duiviewer is to allow QML files to be viewed stand-alone, + rather than being loaded from within a Qt program. Qt applications will + usually bind objects and properties into the execution context before + running the QML. To stand-in for such bindings, you can provide dummy + data: create a directory called "dummydata" in the same directory as + the target QML file and create files there with the "qml" extension. + All such files will be loaded as QML objects and bound to the root + context as a property with the name of the file (without ".qml"). + + For example, if the Qt application has a "clock.time" property + that is a qreal from 0 to 86400 representing the number of seconds since + midnight, dummy data for this could be provided by \c dummydata/clock.qml: + \code + + + + + + \endcode + Any QML can be used in the dummy data files. You could even animate the + fictional data! +*/ diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc index e3c2291..b750aa0 100644 --- a/doc/src/examples.qdoc +++ b/doc/src/examples.qdoc @@ -307,6 +307,12 @@ \o \l{sql/sqlwidgetmapper}{SQL Widget Mapper}\raisedaster \endlist + \section1 State Machine + + \list + \o \l{statemachine/trafficlight}{Traffic Light}\raisedaster + \endlist + \section1 Threads \list diff --git a/doc/src/examples/trafficlight.qdoc b/doc/src/examples/trafficlight.qdoc new file mode 100644 index 0000000..16ee8ad --- /dev/null +++ b/doc/src/examples/trafficlight.qdoc @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +/*! + \example statemachine/trafficlight + \title Traffic Light Example + + 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 examples/statemachine/trafficlight/main.cpp 0 + + The LightWidget class represents a single light of the traffic light. It + provides a setOn() function to turn the light on or off. It paints itself + in the color that's passed to the constructor. + + \snippet examples/statemachine/trafficlight/main.cpp 2 + + The TrafficLightWidget class represents the visual part of the traffic + light; it's a widget that contains three lights, and provides accessor + functions for these. + + \snippet examples/statemachine/trafficlight/main.cpp 1 + + The LightState class represents a state that turns a light on when the + state is entered, and off when the state is exited. The class is a timer, + and as we shall see the timeout is used to transition from one LightState + to another. + + \snippet examples/statemachine/trafficlight/main.cpp 3 + + The TrafficLight class combines the TrafficLightWidget with control flow + based on the LightState class. 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. + + \snippet examples/statemachine/trafficlight/main.cpp 4 + + The main() function constructs a TrafficLight and shows it. + +*/ diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index f48c3d7..3bfb5af 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -334,6 +334,16 @@ */ /*! + \externalpage http://www.w3.org/TR/scxml/ + \title State Chart XML: State Machine Notation for Control Abstraction +*/ + +/*! + \externalpage http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf + \title Statecharts: A visual formalism for complex systems +*/ + +/*! \externalpage http://www.gnu.org/licenses/gpl.html \title GNU General Public License */ diff --git a/doc/src/groups.qdoc b/doc/src/groups.qdoc index c9cedc4..0411c3a 100644 --- a/doc/src/groups.qdoc +++ b/doc/src/groups.qdoc @@ -69,6 +69,18 @@ */ /*! + \group animations + \ingroup groups + + \title Animation Framework + \brief Classes for animations, states and transitions. + + These classes provide a framework for creating both simple and complex + animations. The Animation Framework also provides states and animated + transitions, making it easy to create animated stateful forms. +*/ + +/*! \group abstractwidgets \title Abstract Widget Classes \ingroup groups @@ -597,3 +609,14 @@ These classes are relevant to developers who are working with Qt Script's debugging features. */ + +/*! + \group statemachine + \ingroup groups + + \title State Machine Classes + \brief Classes for constructing and executing state graphs. + + These classes are provided by \l{The State Machine Framework} for creating + event-driven state machines. +*/ diff --git a/doc/src/images/declarative-anchors_example.png b/doc/src/images/declarative-anchors_example.png new file mode 100644 index 0000000..293cd4b Binary files /dev/null and b/doc/src/images/declarative-anchors_example.png differ diff --git a/doc/src/images/declarative-anchors_example2.png b/doc/src/images/declarative-anchors_example2.png new file mode 100644 index 0000000..6d3be7d Binary files /dev/null and b/doc/src/images/declarative-anchors_example2.png differ diff --git a/doc/src/images/declarative-image_tile.png b/doc/src/images/declarative-image_tile.png new file mode 100644 index 0000000..b946a6d Binary files /dev/null and b/doc/src/images/declarative-image_tile.png differ diff --git a/doc/src/images/declarative-item_opacity1.png b/doc/src/images/declarative-item_opacity1.png new file mode 100644 index 0000000..cde973b Binary files /dev/null and b/doc/src/images/declarative-item_opacity1.png differ diff --git a/doc/src/images/declarative-item_opacity2.png b/doc/src/images/declarative-item_opacity2.png new file mode 100644 index 0000000..8627360 Binary files /dev/null and b/doc/src/images/declarative-item_opacity2.png differ diff --git a/doc/src/images/declarative-item_stacking1.png b/doc/src/images/declarative-item_stacking1.png new file mode 100644 index 0000000..18f4148 Binary files /dev/null and b/doc/src/images/declarative-item_stacking1.png differ diff --git a/doc/src/images/declarative-item_stacking2.png b/doc/src/images/declarative-item_stacking2.png new file mode 100644 index 0000000..7a71bcd Binary files /dev/null and b/doc/src/images/declarative-item_stacking2.png differ diff --git a/doc/src/images/declarative-item_stacking3.png b/doc/src/images/declarative-item_stacking3.png new file mode 100644 index 0000000..cde973b Binary files /dev/null and b/doc/src/images/declarative-item_stacking3.png differ diff --git a/doc/src/images/declarative-item_stacking4.png b/doc/src/images/declarative-item_stacking4.png new file mode 100644 index 0000000..3fdf627 Binary files /dev/null and b/doc/src/images/declarative-item_stacking4.png differ diff --git a/doc/src/images/declarative-qtlogo1.png b/doc/src/images/declarative-qtlogo1.png new file mode 100644 index 0000000..940d159 Binary files /dev/null and b/doc/src/images/declarative-qtlogo1.png differ diff --git a/doc/src/images/declarative-qtlogo2.png b/doc/src/images/declarative-qtlogo2.png new file mode 100644 index 0000000..b1d128a Binary files /dev/null and b/doc/src/images/declarative-qtlogo2.png differ diff --git a/doc/src/images/declarative-qtlogo3.png b/doc/src/images/declarative-qtlogo3.png new file mode 100644 index 0000000..3f2f93f Binary files /dev/null and b/doc/src/images/declarative-qtlogo3.png differ diff --git a/doc/src/images/declarative-qtlogo4.png b/doc/src/images/declarative-qtlogo4.png new file mode 100644 index 0000000..7c8aa64 Binary files /dev/null and b/doc/src/images/declarative-qtlogo4.png differ diff --git a/doc/src/images/declarative-rect.png b/doc/src/images/declarative-rect.png new file mode 100644 index 0000000..173759a Binary files /dev/null and b/doc/src/images/declarative-rect.png differ diff --git a/doc/src/images/declarative-rect_gradient.png b/doc/src/images/declarative-rect_gradient.png new file mode 100644 index 0000000..f79d579 Binary files /dev/null and b/doc/src/images/declarative-rect_gradient.png differ diff --git a/doc/src/images/declarative-rect_tint.png b/doc/src/images/declarative-rect_tint.png new file mode 100644 index 0000000..3a44013 Binary files /dev/null and b/doc/src/images/declarative-rect_tint.png differ diff --git a/doc/src/images/declarative-rotation.png b/doc/src/images/declarative-rotation.png new file mode 100644 index 0000000..994011b Binary files /dev/null and b/doc/src/images/declarative-rotation.png differ diff --git a/doc/src/images/declarative-scale.png b/doc/src/images/declarative-scale.png new file mode 100644 index 0000000..bab729e Binary files /dev/null and b/doc/src/images/declarative-scale.png differ diff --git a/doc/src/images/declarative-scalegrid.png b/doc/src/images/declarative-scalegrid.png new file mode 100644 index 0000000..32d87125 Binary files /dev/null and b/doc/src/images/declarative-scalegrid.png differ diff --git a/doc/src/images/declarative-text.png b/doc/src/images/declarative-text.png new file mode 100644 index 0000000..c1a4112 Binary files /dev/null and b/doc/src/images/declarative-text.png differ diff --git a/doc/src/images/declarative-textedit.gif b/doc/src/images/declarative-textedit.gif new file mode 100644 index 0000000..7186eb9 Binary files /dev/null and b/doc/src/images/declarative-textedit.gif differ diff --git a/doc/src/images/declarative-textformat.png b/doc/src/images/declarative-textformat.png new file mode 100644 index 0000000..ade1b45 Binary files /dev/null and b/doc/src/images/declarative-textformat.png differ diff --git a/doc/src/images/declarative-textstyle.png b/doc/src/images/declarative-textstyle.png new file mode 100644 index 0000000..858c1bc Binary files /dev/null and b/doc/src/images/declarative-textstyle.png differ diff --git a/doc/src/images/declarative-transformorigin.png b/doc/src/images/declarative-transformorigin.png new file mode 100644 index 0000000..fbb3b9b Binary files /dev/null and b/doc/src/images/declarative-transformorigin.png differ diff --git a/doc/src/images/declarative-tutorial1.png b/doc/src/images/declarative-tutorial1.png new file mode 100644 index 0000000..a936054 Binary files /dev/null and b/doc/src/images/declarative-tutorial1.png differ diff --git a/doc/src/images/declarative-tutorial2.png b/doc/src/images/declarative-tutorial2.png new file mode 100644 index 0000000..7871589 Binary files /dev/null and b/doc/src/images/declarative-tutorial2.png differ diff --git a/doc/src/images/declarative-tutorial3_animation.gif b/doc/src/images/declarative-tutorial3_animation.gif new file mode 100644 index 0000000..0465e61 Binary files /dev/null and b/doc/src/images/declarative-tutorial3_animation.gif differ diff --git a/doc/src/images/qeasingcurve-cosinecurve.png b/doc/src/images/qeasingcurve-cosinecurve.png new file mode 100644 index 0000000..b27e763 Binary files /dev/null and b/doc/src/images/qeasingcurve-cosinecurve.png differ diff --git a/doc/src/images/qeasingcurve-inback.png b/doc/src/images/qeasingcurve-inback.png new file mode 100644 index 0000000..8506c0f Binary files /dev/null and b/doc/src/images/qeasingcurve-inback.png differ diff --git a/doc/src/images/qeasingcurve-inbounce.png b/doc/src/images/qeasingcurve-inbounce.png new file mode 100644 index 0000000..275b38c Binary files /dev/null and b/doc/src/images/qeasingcurve-inbounce.png differ diff --git a/doc/src/images/qeasingcurve-incirc.png b/doc/src/images/qeasingcurve-incirc.png new file mode 100644 index 0000000..b985e9c Binary files /dev/null and b/doc/src/images/qeasingcurve-incirc.png differ diff --git a/doc/src/images/qeasingcurve-incubic.png b/doc/src/images/qeasingcurve-incubic.png new file mode 100644 index 0000000..e417ee1 Binary files /dev/null and b/doc/src/images/qeasingcurve-incubic.png differ diff --git a/doc/src/images/qeasingcurve-incurve.png b/doc/src/images/qeasingcurve-incurve.png new file mode 100644 index 0000000..d9a9340 Binary files /dev/null and b/doc/src/images/qeasingcurve-incurve.png differ diff --git a/doc/src/images/qeasingcurve-inelastic.png b/doc/src/images/qeasingcurve-inelastic.png new file mode 100644 index 0000000..b242fd3 Binary files /dev/null and b/doc/src/images/qeasingcurve-inelastic.png differ diff --git a/doc/src/images/qeasingcurve-inexpo.png b/doc/src/images/qeasingcurve-inexpo.png new file mode 100644 index 0000000..f06316c Binary files /dev/null and b/doc/src/images/qeasingcurve-inexpo.png differ diff --git a/doc/src/images/qeasingcurve-inoutback.png b/doc/src/images/qeasingcurve-inoutback.png new file mode 100644 index 0000000..9fd1446 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutback.png differ diff --git a/doc/src/images/qeasingcurve-inoutbounce.png b/doc/src/images/qeasingcurve-inoutbounce.png new file mode 100644 index 0000000..fb65f31 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutbounce.png differ diff --git a/doc/src/images/qeasingcurve-inoutcirc.png b/doc/src/images/qeasingcurve-inoutcirc.png new file mode 100644 index 0000000..123cc54 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutcirc.png differ diff --git a/doc/src/images/qeasingcurve-inoutcubic.png b/doc/src/images/qeasingcurve-inoutcubic.png new file mode 100644 index 0000000..b07695c Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutcubic.png differ diff --git a/doc/src/images/qeasingcurve-inoutelastic.png b/doc/src/images/qeasingcurve-inoutelastic.png new file mode 100644 index 0000000..65851e1 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutelastic.png differ diff --git a/doc/src/images/qeasingcurve-inoutexpo.png b/doc/src/images/qeasingcurve-inoutexpo.png new file mode 100644 index 0000000..7cbfb13 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutexpo.png differ diff --git a/doc/src/images/qeasingcurve-inoutquad.png b/doc/src/images/qeasingcurve-inoutquad.png new file mode 100644 index 0000000..c5eed06 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutquad.png differ diff --git a/doc/src/images/qeasingcurve-inoutquart.png b/doc/src/images/qeasingcurve-inoutquart.png new file mode 100644 index 0000000..3b66c0d Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutquart.png differ diff --git a/doc/src/images/qeasingcurve-inoutquint.png b/doc/src/images/qeasingcurve-inoutquint.png new file mode 100644 index 0000000..c74efe9 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutquint.png differ diff --git a/doc/src/images/qeasingcurve-inoutsine.png b/doc/src/images/qeasingcurve-inoutsine.png new file mode 100644 index 0000000..5964f31 Binary files /dev/null and b/doc/src/images/qeasingcurve-inoutsine.png differ diff --git a/doc/src/images/qeasingcurve-inquad.png b/doc/src/images/qeasingcurve-inquad.png new file mode 100644 index 0000000..3373310 Binary files /dev/null and b/doc/src/images/qeasingcurve-inquad.png differ diff --git a/doc/src/images/qeasingcurve-inquart.png b/doc/src/images/qeasingcurve-inquart.png new file mode 100644 index 0000000..28086d8 Binary files /dev/null and b/doc/src/images/qeasingcurve-inquart.png differ diff --git a/doc/src/images/qeasingcurve-inquint.png b/doc/src/images/qeasingcurve-inquint.png new file mode 100644 index 0000000..330aa85 Binary files /dev/null and b/doc/src/images/qeasingcurve-inquint.png differ diff --git a/doc/src/images/qeasingcurve-insine.png b/doc/src/images/qeasingcurve-insine.png new file mode 100644 index 0000000..63d9238 Binary files /dev/null and b/doc/src/images/qeasingcurve-insine.png differ diff --git a/doc/src/images/qeasingcurve-linear.png b/doc/src/images/qeasingcurve-linear.png new file mode 100644 index 0000000..2a05885 Binary files /dev/null and b/doc/src/images/qeasingcurve-linear.png differ diff --git a/doc/src/images/qeasingcurve-outback.png b/doc/src/images/qeasingcurve-outback.png new file mode 100644 index 0000000..7cb34c6 Binary files /dev/null and b/doc/src/images/qeasingcurve-outback.png differ diff --git a/doc/src/images/qeasingcurve-outbounce.png b/doc/src/images/qeasingcurve-outbounce.png new file mode 100644 index 0000000..932fc16 Binary files /dev/null and b/doc/src/images/qeasingcurve-outbounce.png differ diff --git a/doc/src/images/qeasingcurve-outcirc.png b/doc/src/images/qeasingcurve-outcirc.png new file mode 100644 index 0000000..a1a6cb6 Binary files /dev/null and b/doc/src/images/qeasingcurve-outcirc.png differ diff --git a/doc/src/images/qeasingcurve-outcubic.png b/doc/src/images/qeasingcurve-outcubic.png new file mode 100644 index 0000000..aa1d604 Binary files /dev/null and b/doc/src/images/qeasingcurve-outcubic.png differ diff --git a/doc/src/images/qeasingcurve-outcurve.png b/doc/src/images/qeasingcurve-outcurve.png new file mode 100644 index 0000000..a949ae4 Binary files /dev/null and b/doc/src/images/qeasingcurve-outcurve.png differ diff --git a/doc/src/images/qeasingcurve-outelastic.png b/doc/src/images/qeasingcurve-outelastic.png new file mode 100644 index 0000000..2a9ba39 Binary files /dev/null and b/doc/src/images/qeasingcurve-outelastic.png differ diff --git a/doc/src/images/qeasingcurve-outexpo.png b/doc/src/images/qeasingcurve-outexpo.png new file mode 100644 index 0000000..e771c2e Binary files /dev/null and b/doc/src/images/qeasingcurve-outexpo.png differ diff --git a/doc/src/images/qeasingcurve-outinback.png b/doc/src/images/qeasingcurve-outinback.png new file mode 100644 index 0000000..7523727 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinback.png differ diff --git a/doc/src/images/qeasingcurve-outinbounce.png b/doc/src/images/qeasingcurve-outinbounce.png new file mode 100644 index 0000000..ab73d02 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinbounce.png differ diff --git a/doc/src/images/qeasingcurve-outincirc.png b/doc/src/images/qeasingcurve-outincirc.png new file mode 100644 index 0000000..ec4b8d3 Binary files /dev/null and b/doc/src/images/qeasingcurve-outincirc.png differ diff --git a/doc/src/images/qeasingcurve-outincubic.png b/doc/src/images/qeasingcurve-outincubic.png new file mode 100644 index 0000000..8b8ae68 Binary files /dev/null and b/doc/src/images/qeasingcurve-outincubic.png differ diff --git a/doc/src/images/qeasingcurve-outinelastic.png b/doc/src/images/qeasingcurve-outinelastic.png new file mode 100644 index 0000000..89dde2c Binary files /dev/null and b/doc/src/images/qeasingcurve-outinelastic.png differ diff --git a/doc/src/images/qeasingcurve-outinexpo.png b/doc/src/images/qeasingcurve-outinexpo.png new file mode 100644 index 0000000..5909901 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinexpo.png differ diff --git a/doc/src/images/qeasingcurve-outinquad.png b/doc/src/images/qeasingcurve-outinquad.png new file mode 100644 index 0000000..7ddefee Binary files /dev/null and b/doc/src/images/qeasingcurve-outinquad.png differ diff --git a/doc/src/images/qeasingcurve-outinquart.png b/doc/src/images/qeasingcurve-outinquart.png new file mode 100644 index 0000000..00ef597 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinquart.png differ diff --git a/doc/src/images/qeasingcurve-outinquint.png b/doc/src/images/qeasingcurve-outinquint.png new file mode 100644 index 0000000..361bfaa4 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinquint.png differ diff --git a/doc/src/images/qeasingcurve-outinsine.png b/doc/src/images/qeasingcurve-outinsine.png new file mode 100644 index 0000000..1737041 Binary files /dev/null and b/doc/src/images/qeasingcurve-outinsine.png differ diff --git a/doc/src/images/qeasingcurve-outquad.png b/doc/src/images/qeasingcurve-outquad.png new file mode 100644 index 0000000..6f27cbd Binary files /dev/null and b/doc/src/images/qeasingcurve-outquad.png differ diff --git a/doc/src/images/qeasingcurve-outquart.png b/doc/src/images/qeasingcurve-outquart.png new file mode 100644 index 0000000..d45a0b8 Binary files /dev/null and b/doc/src/images/qeasingcurve-outquart.png differ diff --git a/doc/src/images/qeasingcurve-outquint.png b/doc/src/images/qeasingcurve-outquint.png new file mode 100644 index 0000000..6e7df0e Binary files /dev/null and b/doc/src/images/qeasingcurve-outquint.png differ diff --git a/doc/src/images/qeasingcurve-outsine.png b/doc/src/images/qeasingcurve-outsine.png new file mode 100644 index 0000000..7546a0d Binary files /dev/null and b/doc/src/images/qeasingcurve-outsine.png differ diff --git a/doc/src/images/qeasingcurve-sinecurve.png b/doc/src/images/qeasingcurve-sinecurve.png new file mode 100644 index 0000000..ca67d44 Binary files /dev/null and b/doc/src/images/qeasingcurve-sinecurve.png differ diff --git a/doc/src/images/statemachine-button-history.png b/doc/src/images/statemachine-button-history.png new file mode 100644 index 0000000..cd66478 Binary files /dev/null and b/doc/src/images/statemachine-button-history.png differ diff --git a/doc/src/images/statemachine-button-nested.png b/doc/src/images/statemachine-button-nested.png new file mode 100644 index 0000000..60360d1 Binary files /dev/null and b/doc/src/images/statemachine-button-nested.png differ diff --git a/doc/src/images/statemachine-button.png b/doc/src/images/statemachine-button.png new file mode 100644 index 0000000..75d9e53 Binary files /dev/null and b/doc/src/images/statemachine-button.png differ diff --git a/doc/src/images/statemachine-finished.png b/doc/src/images/statemachine-finished.png new file mode 100644 index 0000000..802621e Binary files /dev/null and b/doc/src/images/statemachine-finished.png differ diff --git a/doc/src/images/statemachine-nonparallel.png b/doc/src/images/statemachine-nonparallel.png new file mode 100644 index 0000000..1fe60d8 Binary files /dev/null and b/doc/src/images/statemachine-nonparallel.png differ diff --git a/doc/src/images/statemachine-parallel.png b/doc/src/images/statemachine-parallel.png new file mode 100644 index 0000000..1868792 Binary files /dev/null and b/doc/src/images/statemachine-parallel.png differ diff --git a/doc/src/images/trafficlight-example.png b/doc/src/images/trafficlight-example.png new file mode 100644 index 0000000..3431542 Binary files /dev/null and b/doc/src/images/trafficlight-example.png differ diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 49dfafd..cf75381 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -194,6 +194,7 @@
  • XML Patterns: XQuery & XPath
  • Phonon Multimedia Framework
  • Script Tools Module
  • +
  • Qt Markup Language
  • ActiveQt Framework
  • diff --git a/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp b/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp new file mode 100644 index 0000000..65358ea --- /dev/null +++ b/doc/src/snippets/code/src_corelib_tools_qeasingcurve.cpp @@ -0,0 +1,4 @@ +//! [0] +qreal myEasingFunction(qreal progress); +//! [0] + diff --git a/doc/src/statemachine.qdoc b/doc/src/statemachine.qdoc new file mode 100644 index 0000000..c79839f --- /dev/null +++ b/doc/src/statemachine.qdoc @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +/*! + \page statemachine-api.html + \title The State Machine Framework + \brief An overview of the State Machine framework for constructing and executing state graphs. + + \tableofcontents + + The State Machine framework provides classes for creating and executing + state graphs. The concepts and notation are based on those from Harel's + \l{Statecharts: A visual formalism for complex systems}{Statecharts}, which + is also the basis of UML state diagrams. The semantics of state machine + execution are based on \l{State Chart XML: State Machine Notation for + Control Abstraction}{State Chart XML (SCXML)}. + + Statecharts provide a graphical way of modeling how a system reacts to + stimuli. This is done by defining the possible \e states that the system can + be in, and how the system can move from one state to another (\e transitions + between states). A key characteristic of event-driven systems (such as Qt + applications) is that behavior often depends not only on the last or current + event, but also the events that preceded it. With statecharts, this + information is easy to express. + + The State Machine framework provides an API and execution model that can be + used to effectively embed the elements and semantics of statecharts in Qt + applications. The framework integrates tightly with Qt's existing event + system and meta-object system; for example, transitions between states can + be triggered by signals, and states can be configured to set properties and + invoke methods on QObjects. + + \section1 A Simple State Machine + + To demonstrate the core functionality of the State Machine API, let's look + at a small example: A state machine with three states, \c s1, \c s2 and \c + s3. The state machine is controlled by a single QPushButton; when the button + is clicked, the machine transitions to another state. Initially, the state + machine is in state \c s1. The statechart for this machine is as follows: + + \img statemachine-button.png + \omit + \caption This is a caption + \endomit + + The following snippet shows the code needed to create such a state machine. + + \code + QStateMachine machine; + QState *s1 = new QState(); + QState *s2 = new QState(); + QState *s3 = new QState(); + + s1->addTransition(button, SIGNAL(clicked()), s2); + s2->addTransition(button, SIGNAL(clicked()), s3); + s3->addTransition(button, SIGNAL(clicked()), s1); + + machine.addState(s1); + machine.addState(s2); + machine.addState(s3); + machine.setInitialState(s1); + + machine.start(); + \endcode + + Once the state machine has been set up, you need to start it by calling + QStateMachine::start(). The state machine executes asynchronously, i.e. it + becomes part of your application's event loop. + + The above state machine is perfectly fine, but it doesn't \e do anything; it + merely transitions from one state to another. The + QState::setPropertyOnEntry() function can be used to have a state set a + property of a QObject when the state is entered. In the following snippet, + the value that should be assigned to a QLabel's text property is specified + for each state: + + \code + s1->setPropertyOnEntry(label, "text", "In state s1"); + s2->setPropertyOnEntry(label, "text", "In state s2"); + s3->setPropertyOnEntry(label, "text", "In state s3"); + \endcode + + When any of the states is entered, the label's text will be changed + accordingly. + + The QState::invokeMethodOnEntry() function can be used to have a state + invoke a method (a slot) of a QObject when the state is entered. In the + following snippet, the button's showMaximized() slot will be called when + state \c s3 is entered: + + \code + s2->invokeMethodOnEntry(button, "showMaximized"); + \endcode + + \section1 Sharing Transitions By Grouping States + + The state machine defined in the previous section never finishes. In order + for a state machine to be able to finish, it needs to have a top-level \e + final state. When the state machine enters a top-level final state, the + machine will emit the finished() signal and halt. + + Assume we wanted the user to be able to quit the application at any time by + clicking a Quit button. In order to achieve this, we need to create a final + state and make it the target of a transition associated with the Quit + button's clicked() signal. We could add a transition from each of \c s1, \c + s2 and \c s3; however, this seems redundant, and one would also have to + remember to add such a transition from every new state that is added in the + future. + + We can achieve the same behavior (namely that clicking the Quit button quits + the state machine, regardless of which state the state machine is in) by + grouping states \c s1, \c s2 and \c s3. This is done by creating a new + top-level state and making the three original states children of the new + state. The following diagram shows the new state machine. + + \img statemachine-button-nested.png + \omit + \caption This is a caption + \endomit + + The three original states have been renamed \c s11, \c s12 and \c s13 to + reflect that they are now children of the new top-level state, \c s1. Child + states implicitly inherit the transitions of their parent state. This means + it is now sufficient to add a single transition from \c s1 to the final + state \c s2. New states added to \c s1 will also automatically inherit this + transition. + + All that's needed to group states is to specify the proper parent when the + state is created. You also need to specify which of the child states is the + initial one (i.e. which child state the state machine should enter when the + parent state is the target of a transition). + + \code + QState *s1 = new QState(); + QState *s11 = new QState(s1); + QState *s12 = new QState(s1); + QState *s13 = new QState(s1); + s1->setInitialState(s11); + machine.addState(s1); + \endcode + + \code + QFinalState *s2 = new QFinalState(); + s1->addTransition(quitButton, SIGNAL(clicked()), s2); + machine.addState(s2); + + QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); + \endcode + + In this case we want the application to quit when the state machine is + finished, so the machine's finished() signal is connected to the + application's quit() slot. + + A child state can override an inherited transition. For example, the + following code adds a transition that effectively causes the Quit button to + be ignored when the state machine is in state \c s12. + + \code + s12>addTransition(quitButton, SIGNAL(clicked()), s12); + \endcode + + \section1 Using History States to Save and Restore the Current State + + Imagine that we wanted to add an "interrupt" mechanism to the example + discussed in the previous section; the user should be able to click a button + to have the state machine perform some non-related task, after which the + state machine should resume whatever it was doing before (i.e. return to the + old state, which is one of \c s11, \c s12 and \c s13 in this case). + + Such behavior can easily be modeled using \e{history states}. A history + state (QHistoryState object) is a pseudo-state that represents the child + state that the parent state was in the last time the parent state was + exited. + + A history state is created as a child of the state for which we wish to + record the current child state; when the state machine detects the presence + of such a state at runtime, it automatically records the current (real) + child state when the parent state is exited. A transition to the history + state is in fact a transition to the child state that the state machine had + previously saved; the state machine automatically "forwards" the transition + to the real child state. + + The following diagram shows the state machine after the interrupt mechanism + has been added. + + \img statemachine-button-history.png + \omit + \caption This is a caption + \endomit + + The following code shows how it can be implemented; in this example we + simply display a message box when \c s3 is entered, then immediately return + to the previous child state of \c s1 via the history state. + + \code + QHistoryState *s1h = s1->addHistoryState(); + + QState *s3 = new QState(); + s3->setPropertyOnEntry(label, "text", "In s3"); + QMessageBox mbox; + mbox.addButton(QMessageBox::Ok); + mbox.setText("Interrupted!"); + mbox.setIcon(QMessageBox::Information); + s3->invokeMethodOnEntry(&mbox, "exec"); + s3->addTransition(s1h); + machine.addState(s3); + + s1->addTransition(interruptButton, SIGNAL(clicked()), s3); + \endcode + + \section1 Using Parallel States to Avoid a Combinatorial Explosion of States + + Assume that you wanted to model a set of mutually exclusive properties of a + car in a single state machine. Let's say the properties we are interested in + are Clean vs Dirty, and Moving vs Not moving. It would take four mutually + exclusive states and eight transitions to be able to represent and freely + move between all possible combinations. + + \img statemachine-nonparallel.png + \omit + \caption This is a caption + \endomit + + If we added a third property (say, Red vs Blue), the total number of states + would double, to eight; and if we added a fourth property (say, Enclosed vs + Convertible), the total number of states would double again, to 16. + + Using parallel states, the total number of states and transitions grows + linearly as we add more properties, instead of exponentially. Furthermore, + states can be added to or removed from the parallel state without affecting + any of their sibling states. + + \img statemachine-parallel.png + \omit + \caption This is a caption + \endomit + + To create a parallel state group, pass QState::ParallelStateGroup to the + QState constructor. + + \code + QState *s1 = new QState(QState::ParallelStateGroup); + // s11 and s12 will be entered in parallel + QState *s11 = new QState(s1); + QState *s12 = new QState(s1); + \endcode + + \section1 Detecting that a Composite State has Finished + + A child state can be final; when a final child state is entered, a + QStateFinishedEvent is generated for the parent state. You can use the + QStateFinishedTransition class to trigger a transition based on this event. + + \img statemachine-finished.png + \omit + \caption This is a caption + \endomit + + This is useful when you want to hide the internal details of a state; + i.e. the only thing the outside world should be able to do is enter the + state, and get a notification when the state has finished (i.e. when a final + child state has been entered). + + */ diff --git a/examples/animation/animatedtiles/animatedtiles.pro b/examples/animation/animatedtiles/animatedtiles.pro new file mode 100644 index 0000000..9e9062c --- /dev/null +++ b/examples/animation/animatedtiles/animatedtiles.pro @@ -0,0 +1,2 @@ +SOURCES += main.cpp +RESOURCES += animatedtiles.qrc diff --git a/examples/animation/animatedtiles/animatedtiles.qrc b/examples/animation/animatedtiles/animatedtiles.qrc new file mode 100644 index 0000000..c43a979 --- /dev/null +++ b/examples/animation/animatedtiles/animatedtiles.qrc @@ -0,0 +1,11 @@ + + + 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/animation/animatedtiles/images/Time-For-Lunch-2.jpg b/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg new file mode 100644 index 0000000..c57a555 Binary files /dev/null and b/examples/animation/animatedtiles/images/Time-For-Lunch-2.jpg differ diff --git a/examples/animation/animatedtiles/images/centered.png b/examples/animation/animatedtiles/images/centered.png new file mode 100644 index 0000000..e416156 Binary files /dev/null and b/examples/animation/animatedtiles/images/centered.png differ diff --git a/examples/animation/animatedtiles/images/ellipse.png b/examples/animation/animatedtiles/images/ellipse.png new file mode 100644 index 0000000..2c3ba88 Binary files /dev/null and b/examples/animation/animatedtiles/images/ellipse.png differ diff --git a/examples/animation/animatedtiles/images/figure8.png b/examples/animation/animatedtiles/images/figure8.png new file mode 100644 index 0000000..6b05804 Binary files /dev/null and b/examples/animation/animatedtiles/images/figure8.png differ diff --git a/examples/animation/animatedtiles/images/kinetic.png b/examples/animation/animatedtiles/images/kinetic.png new file mode 100644 index 0000000..55cfa55 Binary files /dev/null and b/examples/animation/animatedtiles/images/kinetic.png differ diff --git a/examples/animation/animatedtiles/images/random.png b/examples/animation/animatedtiles/images/random.png new file mode 100644 index 0000000..415d96f Binary files /dev/null and b/examples/animation/animatedtiles/images/random.png differ diff --git a/examples/animation/animatedtiles/images/tile.png b/examples/animation/animatedtiles/images/tile.png new file mode 100644 index 0000000..c8f39d8 Binary files /dev/null and b/examples/animation/animatedtiles/images/tile.png differ diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp new file mode 100644 index 0000000..e4a774c --- /dev/null +++ b/examples/animation/animatedtiles/main.cpp @@ -0,0 +1,242 @@ +#include +#ifdef QT_EXPERIMENTAL_SOLUTION +# include "qgraphicswidget.h" +# include "qstate.h" +# include "qstatemachine.h" +# include "qgraphicswidget.h" +# include "qparallelanimationgroup.h" +# include "qpropertyanimation.h" +#else +#include +#endif + +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 = 0) + : QGraphicsWidget(parent), _pix(pixmap) + { + setAcceptHoverEvents(true); + setCacheMode(DeviceCoordinateCache); + } + + QRectF boundingRect() const + { + return QRectF(-65, -65, 130, 130); + } + + QPainterPath shape() const + { + QPainterPath path; + path.addEllipse(boundingRect()); + return path; + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) + { + 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 *) + { + emit pressed(); + update(); + } + + void mouseReleaseEvent(QGraphicsSceneMouseEvent *) + { + update(); + } + +private: + QPixmap _pix; +}; + +class View : public QGraphicsView +{ +public: + View(QGraphicsScene *scene) : QGraphicsView(scene) { } + +protected: + void resizeEvent(QResizeEvent *event) + { + QGraphicsView::resizeEvent(event); + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +}; + +int main(int argc, char **argv) +{ + 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->scale(0.75, 0.75); + 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 < 64; ++i) { + Pixmap *item = items.at(i); + // Ellipse + ellipseState->setPropertyOnEntry(item, "pos", + QPointF(cos((i / 63.0) * 6.28) * 250, + sin((i / 63.0) * 6.28) * 250)); + + // Figure 8 + figure8State->setPropertyOnEntry(item, "pos", + QPointF(sin((i / 63.0) * 6.28) * 250, + sin(((i * 2)/63.0) * 6.28) * 250)); + + // Random + randomState->setPropertyOnEntry(item, "pos", + QPointF(-250 + qrand() % 500, + -250 + qrand() % 500)); + + // Tiled + tiledState->setPropertyOnEntry(item, "pos", + QPointF(((i % 8) - 4) * kineticPix.width() + kineticPix.width() / 2, + ((i / 8) - 4) * kineticPix.height() + kineticPix.height() / 2)); + + // Centered + centeredState->setPropertyOnEntry(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); + + // rootState->addTransition(ellipseButton, SIGNAL(pressed()), ellipseState); + QParallelAnimationGroup *group = new QParallelAnimationGroup; + for (int i = 0; i < 64; ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + rootState->addAnimatedTransition(ellipseButton, SIGNAL(pressed()), ellipseState, group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < 64; ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + rootState->addAnimatedTransition(figure8Button, SIGNAL(pressed()), figure8State, group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < 64; ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + rootState->addAnimatedTransition(randomButton, SIGNAL(pressed()), randomState, group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < 64; ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + rootState->addAnimatedTransition(tiledButton, SIGNAL(pressed()), tiledState, group); + + group = new QParallelAnimationGroup; + for (int i = 0; i < 64; ++i) { + QPropertyAnimation *anim = new QPropertyAnimation(items[i], "pos"); + anim->setDuration(750 + i * 25); + anim->setEasingCurve(QEasingCurve::InOutBack); + group->addAnimation(anim); + } + rootState->addAnimatedTransition(centeredButton, SIGNAL(pressed()), centeredState, group); + + states.start(); + QTimer timer; + timer.start(125); + timer.setSingleShot(true); + rootState->addAnimatedTransition(&timer, SIGNAL(timeout()), ellipseState, group); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/animation.pro b/examples/animation/animation.pro new file mode 100644 index 0000000..d5121a1 --- /dev/null +++ b/examples/animation/animation.pro @@ -0,0 +1,21 @@ +TEMPLATE = \ + subdirs +SUBDIRS += \ + animatedtiles \ + appchooser \ + easing \ + example \ + moveblocks \ + padnavigator-ng \ + photobrowser \ + piemenu \ + selectbutton \ + states \ + stickman \ + sub-attaq + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS animation.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/animation +INSTALLS += target sources diff --git a/examples/animation/appchooser/accessories-dictionary.png b/examples/animation/appchooser/accessories-dictionary.png new file mode 100644 index 0000000..e9bd55d Binary files /dev/null and b/examples/animation/appchooser/accessories-dictionary.png differ diff --git a/examples/animation/appchooser/akregator.png b/examples/animation/appchooser/akregator.png new file mode 100644 index 0000000..a086f45 Binary files /dev/null and b/examples/animation/appchooser/akregator.png differ diff --git a/examples/animation/appchooser/appchooser.pro b/examples/animation/appchooser/appchooser.pro new file mode 100644 index 0000000..8cda19a --- /dev/null +++ b/examples/animation/appchooser/appchooser.pro @@ -0,0 +1,9 @@ +# Input +SOURCES += main.cpp +RESOURCES += appchooser.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS appchooser.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/appchooser +INSTALLS += target sources diff --git a/examples/animation/appchooser/appchooser.qrc b/examples/animation/appchooser/appchooser.qrc new file mode 100644 index 0000000..28a3e1c --- /dev/null +++ b/examples/animation/appchooser/appchooser.qrc @@ -0,0 +1,8 @@ + + + accessories-dictionary.png + akregator.png + digikam.png + k3b.png + + diff --git a/examples/animation/appchooser/digikam.png b/examples/animation/appchooser/digikam.png new file mode 100644 index 0000000..9de9fb2 Binary files /dev/null and b/examples/animation/appchooser/digikam.png differ diff --git a/examples/animation/appchooser/k3b.png b/examples/animation/appchooser/k3b.png new file mode 100644 index 0000000..bbcafcf Binary files /dev/null and b/examples/animation/appchooser/k3b.png differ diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp new file mode 100644 index 0000000..536bbb6 --- /dev/null +++ b/examples/animation/appchooser/main.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include +#ifdef QT_EXPERIMENTAL_SOLUTION +#include "qtgraphicswidget.h" +#endif + + +class Pixmap : public QGraphicsWidget +{ + Q_OBJECT + +public: + Pixmap(const QPixmap &pix, QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), orig(pix), p(pix) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + + virtual void mousePressEvent(QGraphicsSceneMouseEvent * ) + { + emit clicked(); + } + + virtual void setGeometry(const QRectF &rect) + { + QGraphicsWidget::setGeometry(rect); + + if (rect.size().width() > orig.size().width()) + p = orig.scaled(rect.size().toSize()); + else + p = orig; + } + +Q_SIGNALS: + void clicked(); + +private: + QPixmap orig; + QPixmap p; +}; + +void createStateAndTransition(QObject *o1, const QRect &selectedRect, QState *parent) +{ + QState *state = new QState(parent); + state->setPropertyOnEntry(o1, "geometry", selectedRect); + + QPropertyAnimation *animation = new QPropertyAnimation(o1, "geometry"); + parent->addAnimatedTransition(o1, SIGNAL(clicked()), state, animation); +} + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(appchooser); + + QApplication app(argc, argv); + + 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")); + + p1->setObjectName("p1"); + p2->setObjectName("p2"); + p3->setObjectName("p3"); + p4->setObjectName("p4"); + + p1->setGeometry(QRectF(0.0, 0.0, 64.0, 64.0)); + p2->setGeometry(QRectF(236.0, 0.0, 64.0, 64.0)); + p3->setGeometry(QRectF(236.0, 236.0, 64.0, 64.0)); + p4->setGeometry(QRectF(0.0, 236.0, 64.0, 64.0)); + + QGraphicsScene scene(0, 0, 300, 300); + scene.setBackgroundBrush(Qt::white); + scene.addItem(p1); + scene.addItem(p2); + scene.addItem(p3); + scene.addItem(p4); + + QGraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + QStateMachine machine; + machine.setGlobalRestorePolicy(QState::RestoreProperties); + + QState *group = new QState(machine.rootState()); + group->setObjectName("group"); + QRect selectedRect(86, 86, 128, 128); + + QState *idleState = new QState(group); + group->setInitialState(idleState); + + createStateAndTransition(p1, selectedRect, group); + createStateAndTransition(p2, selectedRect, group); + createStateAndTransition(p3, selectedRect, group); + createStateAndTransition(p4, selectedRect, group); + + machine.setInitialState(group); + machine.start(); + + window.resize(300, 300); + window.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h new file mode 100644 index 0000000..db67810 --- /dev/null +++ b/examples/animation/easing/animation.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATION_H +#define ANIMATION_H + +#include + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qpropertyanimation.h" +#else +# include +#endif + +class Animation : public QPropertyAnimation { +public: + enum PathType { + LinearPath, + CirclePath, + NPathTypes + }; + Animation(QObject *target, const QByteArray &prop) + : QPropertyAnimation(target, prop) + { + setPathType(LinearPath); + } + + void setPathType(PathType pathType) + { + if (pathType >= NPathTypes) + qWarning("Unknown pathType %d", pathType); + + m_pathType = pathType; + m_path = QPainterPath(); + } + + void updateCurrentTime(int msecs) + { + if (m_pathType == CirclePath) { + if (m_path.isEmpty()) { + QPointF to = endValue().toPointF(); + QPointF from = startValue().toPointF(); + m_path.moveTo(from); + m_path.addEllipse(QRectF(from, to)); + } + int dura = duration(); + const qreal progress = ((dura == 0) ? 1 : ((((currentTime() - 1) % dura) + 1) / qreal(dura))); + + qreal easedProgress = easingCurve().valueForProgress(progress); + if (easedProgress > 1.0) { + easedProgress -= 1.0; + } else if (easedProgress < 0) { + easedProgress += 1.0; + } + QPointF pt = m_path.pointAtPercent(easedProgress); + updateCurrentValue(pt); + emit valueChanged(pt); + } else { + QPropertyAnimation::updateCurrentTime(msecs); + } + } + + QPainterPath m_path; + PathType m_pathType; +}; + +#endif // ANIMATION_H diff --git a/examples/animation/easing/easing.pro b/examples/animation/easing/easing.pro new file mode 100644 index 0000000..fa5b22d --- /dev/null +++ b/examples/animation/easing/easing.pro @@ -0,0 +1,16 @@ +###################################################################### +# Automatically generated by qmake (2.01a) to 2. okt 23:22:11 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += window.h animation.h +SOURCES += main.cpp window.cpp + +FORMS += form.ui + +RESOURCES = resources.qrc diff --git a/examples/animation/easing/form.ui b/examples/animation/easing/form.ui new file mode 100644 index 0000000..b60ade8 --- /dev/null +++ b/examples/animation/easing/form.ui @@ -0,0 +1,201 @@ + + + Form + + + + 0 + 0 + 545 + 471 + + + + Easing curves + + + + + + + 0 + 0 + + + + + 16777215 + 120 + + + + Qt::ScrollBarAlwaysOff + + + QListView::Static + + + false + + + QListView::IconMode + + + false + + + + + + + + + Path type + + + + + + Line + + + true + + + buttonGroup + + + + + + + Circle + + + buttonGroup + + + + + + + + + + + 0 + 0 + + + + Properties + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Period + + + + + + + false + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + Amplitude + + + + + + + false + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + Overshoot + + + + + + + false + + + -1.000000000000000 + + + 0.100000000000000 + + + -1.000000000000000 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + 0 + + + + + + + + + + + + diff --git a/examples/animation/easing/images/qt-logo.png b/examples/animation/easing/images/qt-logo.png new file mode 100644 index 0000000..14ddf2a Binary files /dev/null and b/examples/animation/easing/images/qt-logo.png differ diff --git a/examples/animation/easing/main.cpp b/examples/animation/easing/main.cpp new file mode 100644 index 0000000..139f2da --- /dev/null +++ b/examples/animation/easing/main.cpp @@ -0,0 +1,22 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include "window.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Window w; + w.resize(400, 400); + w.show(); + return app.exec(); +} diff --git a/examples/animation/easing/resources.qrc b/examples/animation/easing/resources.qrc new file mode 100644 index 0000000..7e112d3 --- /dev/null +++ b/examples/animation/easing/resources.qrc @@ -0,0 +1,5 @@ + + + images/qt-logo.png + + \ No newline at end of file diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp new file mode 100644 index 0000000..c6ea360 --- /dev/null +++ b/examples/animation/easing/window.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "window.h" + +Window::Window(QWidget *parent) + : QWidget(parent), m_iconSize(64, 64) +{ + m_ui.setupUi(this); + QButtonGroup *buttonGroup = qFindChild(this); // ### workaround for uic in 4.4 + m_ui.easingCurvePicker->setIconSize(m_iconSize); + m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); + buttonGroup->setId(m_ui.lineRadio, 0); + buttonGroup->setId(m_ui.circleRadio, 1); + + QEasingCurve dummy; + m_ui.periodSpinBox->setValue(dummy.period()); + m_ui.amplitudeSpinBox->setValue(dummy.amplitude()); + m_ui.overshootSpinBox->setValue(dummy.overshoot()); + + connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int))); + connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int))); + connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double))); + connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double))); + connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double))); + createCurveIcons(); + + QPixmap pix(QLatin1String(":/images/qt-logo.png")); + m_item = new PixmapItem(pix); + m_scene.addItem(m_item); + m_ui.graphicsView->setScene(&m_scene); + + m_anim = new Animation(m_item, "pos"); + m_anim->setEasingCurve(QEasingCurve::OutBounce); + m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); + + startAnimation(); +} + +void Window::createCurveIcons() +{ + QPixmap pix(m_iconSize); + QPainter painter(&pix); + QLinearGradient gradient(0,0, 0, m_iconSize.height()); + gradient.setColorAt(0.0, QColor(240, 240, 240)); + gradient.setColorAt(1.0, QColor(224, 224, 224)); + QBrush brush(gradient); + const QMetaObject &mo = QEasingCurve::staticMetaObject; + QMetaEnum metaEnum = mo.enumerator(mo.indexOfEnumerator("Type")); + // Skip QEasingCurve::Custom + for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { + painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); + QEasingCurve curve((QEasingCurve::Type)i); + painter.setPen(QColor(0, 0, 255, 64)); + qreal xAxis = m_iconSize.height()/1.5; + qreal yAxis = m_iconSize.width()/3; + painter.drawLine(0, xAxis, m_iconSize.width(), xAxis); + painter.drawLine(yAxis, 0, yAxis, m_iconSize.height()); + painter.setPen(Qt::black); + + qreal curveScale = m_iconSize.height()/2; + QPoint currentPos(yAxis, xAxis); + + for (qreal t = 0; t < 1.0; t+=1.0/curveScale) { + QPoint to; + to.setX(yAxis + curveScale * t); + to.setY(xAxis - curveScale * curve.valueForProgress(t)); + painter.drawLine(currentPos, to); + currentPos = to; + } + QListWidgetItem *item = new QListWidgetItem; + item->setIcon(QIcon(pix)); + item->setText(metaEnum.key(i)); + m_ui.easingCurvePicker->addItem(item); + } +} + +void Window::startAnimation() +{ + m_anim->setStartValue(QPointF(0, 0)); + m_anim->setEndValue(QPointF(100, 100)); + m_anim->setDuration(2000); + m_anim->setIterationCount(-1); // forever + m_anim->start(); +} + +void Window::curveChanged(int row) +{ + QEasingCurve::Type curveType = (QEasingCurve::Type)row; + m_anim->setEasingCurve(curveType); + m_anim->setCurrentTime(0); + + bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic; + bool isBounce = curveType >= QEasingCurve::InBounce && curveType <= QEasingCurve::OutInBounce; + m_ui.periodSpinBox->setEnabled(isElastic); + m_ui.amplitudeSpinBox->setEnabled(isElastic || isBounce); + m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack); +} + +void Window::pathChanged(int index) +{ + m_anim->setPathType((Animation::PathType)index); +} + +void Window::periodChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setPeriod(value); + m_anim->setEasingCurve(curve); +} + +void Window::amplitudeChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setAmplitude(value); + m_anim->setEasingCurve(curve); +} + +void Window::overshootChanged(double value) +{ + QEasingCurve curve = m_anim->easingCurve(); + curve.setOvershoot(value); + m_anim->setEasingCurve(curve); +} + diff --git a/examples/animation/easing/window.h b/examples/animation/easing/window.h new file mode 100644 index 0000000..4ba6eb6 --- /dev/null +++ b/examples/animation/easing/window.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include + +#include "ui_form.h" +#include "animation.h" + +class PixmapItem : public QObject, public QGraphicsPixmapItem +{ + Q_OBJECT + Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + PixmapItem(const QPixmap &pix) : QGraphicsPixmapItem(pix) + { + } +}; + +class Window : public QWidget { + Q_OBJECT +public: + Window(QWidget *parent = 0); +private slots: + void curveChanged(int row); + void pathChanged(int index); + void periodChanged(double); + void amplitudeChanged(double); + void overshootChanged(double); + +private: + void createCurveIcons(); + void startAnimation(); + + Ui::Form m_ui; + QGraphicsScene m_scene; + PixmapItem *m_item; + Animation *m_anim; + QSize m_iconSize; + + +}; diff --git a/examples/animation/example/example.pro b/examples/animation/example/example.pro new file mode 100644 index 0000000..bc79b82 --- /dev/null +++ b/examples/animation/example/example.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Thu Sep 25 14:03:47 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += mainwindow.h +SOURCES += main.cpp mainwindow.cpp diff --git a/examples/animation/example/main.cpp b/examples/animation/example/main.cpp new file mode 100644 index 0000000..d5f5607 --- /dev/null +++ b/examples/animation/example/main.cpp @@ -0,0 +1,23 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + //Q_INIT_RESOURCE(example); + QApplication app(argc, argv); + MainWindow w; + w.show(); + return app.exec(); +} + diff --git a/examples/animation/example/mainwindow.cpp b/examples/animation/example/mainwindow.cpp new file mode 100644 index 0000000..dfb5c70 --- /dev/null +++ b/examples/animation/example/mainwindow.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "mainwindow.h" + +MainWindow::MainWindow() : QMainWindow(0) +{ + // Text edit and button + listWidget = new QListWidget; + new QListWidgetItem("Rachel", listWidget); + new QListWidgetItem("Andreas", listWidget); + new QListWidgetItem("David", listWidget); + new QListWidgetItem("Olivier", listWidget); + new QListWidgetItem("Andy", listWidget); + new QListWidgetItem("Martial", listWidget); + new QListWidgetItem("Kazou", listWidget); + new QListWidgetItem("Fred", listWidget); + new QListWidgetItem("Ingrid", listWidget); + QGraphicsProxyWidget *listProxy = new QGraphicsProxyWidget; + listProxy->setWidget(listWidget); + + labelWidget = new QLabel; + QGraphicsProxyWidget *labelProxy = new QGraphicsProxyWidget; + labelProxy->setWidget(labelWidget); + labelWidget->setAttribute(Qt::WA_NoSystemBackground); + + label2Widget = new QLabel; + label2Widget->setAlignment(Qt::AlignCenter); + QGraphicsProxyWidget *label2Proxy = new QGraphicsProxyWidget; + label2Proxy->setWidget(label2Widget); + label2Widget->setAttribute(Qt::WA_NoSystemBackground); + + editWidget = new QLineEdit; + QGraphicsProxyWidget *editProxy = new QGraphicsProxyWidget; + editProxy->setWidget(editWidget); + editWidget->setAttribute(Qt::WA_NoSystemBackground); + + // Parent widget + QGraphicsWidget *widget = new QGraphicsWidget; + // Parent widget + QGraphicsWidget *widget2 = new QGraphicsWidget; + + QGraphicsLinearLayout *vLayout = new QGraphicsLinearLayout(Qt::Vertical, widget); + vLayout->addItem(listProxy); + vLayout->addItem(widget2); + widget->setLayout(vLayout); + + QPushButton *button = new QPushButton; + QGraphicsProxyWidget *buttonProxy = new QGraphicsProxyWidget; + buttonProxy->setWidget(button); + + QPushButton *button2 = new QPushButton; + QGraphicsProxyWidget *buttonProxy2 = new QGraphicsProxyWidget; + buttonProxy2->setWidget(button2); + + QPushButton *button3 = new QPushButton; + QGraphicsProxyWidget *buttonProxy3 = new QGraphicsProxyWidget; + buttonProxy3->setWidget(button3); + + QPushButton *button4 = new QPushButton; + QGraphicsProxyWidget *buttonProxy4 = new QGraphicsProxyWidget; + buttonProxy4->setWidget(button4); + + QGraphicsLinearLayout *hLayout = new QGraphicsLinearLayout(Qt::Horizontal, widget2); + hLayout->addItem(buttonProxy); + hLayout->addItem(buttonProxy2); + hLayout->addItem(buttonProxy3); + widget2->setLayout(hLayout); + + scene = new QGraphicsScene(0, 0, 700, 600); + scene->setBackgroundBrush(scene->palette().window()); + scene->addItem(widget); + scene->addItem(editProxy); + scene->addItem(label2Proxy); + scene->addItem(labelProxy); + scene->addItem(buttonProxy4); + + machine = new QStateMachine(); + + group = new QState(machine->rootState()); + state1 = new QState(group); + state2 = new QState(group); + state3 = new QState(group); + group->setInitialState(state1); + + machine->setInitialState(group); + + // State 1 + state1->setPropertyOnEntry(button, "text", "Edit"); + state1->setPropertyOnEntry(button2, "text", "Add"); + state1->setPropertyOnEntry(button3, "text", "Remove"); + state1->setPropertyOnEntry(button4, "text", "Accept"); + state1->addTransition(button2, SIGNAL(clicked()), state3); + state1->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 700, 560)); + state1->setPropertyOnEntry(widget, "geometry", QRectF(0, 0, 700, 600)); + state1->setPropertyOnEntry(editProxy, "opacity", double(0)); + state1->setPropertyOnEntry(labelProxy, "opacity", double(0)); + state1->setPropertyOnEntry(label2Proxy, "opacity", double(0)); + state1->setPropertyOnEntry(buttonProxy4, "opacity", double(0)); + state1->setPropertyOnEntry(labelWidget, "text", "Name : "); + state1->setPropertyOnEntry(label2Widget, "text", "Edit a contact"); + state1->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, -50, 300, 30)); + state1->setPropertyOnEntry(labelProxy, "geometry", QRectF(350, 300, 100, 30)); + state1->setPropertyOnEntry(editProxy, "geometry", QRectF(750, 300, 250, 30)); + state1->setPropertyOnEntry(buttonProxy4, "geometry", QRectF(500, 350, 80, 25)); + + // State 2 + state2->setPropertyOnEntry(button, "text", "Close Editing"); + state2->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 350, 560)); + state2->addTransition(button2, SIGNAL(clicked()), state3); + state2->addTransition(button4, SIGNAL(clicked()), state1); + + state2->setPropertyOnEntry(editProxy, "opacity", double(1)); + state2->setPropertyOnEntry(labelProxy, "opacity", double(1)); + state2->setPropertyOnEntry(label2Proxy, "opacity", double(1)); + state2->setPropertyOnEntry(buttonProxy4, "opacity", double(1)); + + state2->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, 250, 300, 30)); + state2->setPropertyOnEntry(editProxy, "geometry", QRectF(440, 300, 260, 30)); + + // State 3 + state3->setPropertyOnEntry(button4, "text", "Create New"); + state3->setPropertyOnEntry(listProxy, "geometry", QRectF(0, 0, 350, 560)); + state3->addTransition(button4, SIGNAL(clicked()), state1); + state3->addTransition(button, SIGNAL(clicked()), state1); + state3->setPropertyOnEntry(editProxy, "opacity", double(1)); + state3->setPropertyOnEntry(labelProxy, "opacity", double(1)); + state3->setPropertyOnEntry(label2Proxy, "opacity", double(1)); + state3->setPropertyOnEntry(buttonProxy4, "opacity", double(1)); + + state3->setPropertyOnEntry(label2Proxy, "geometry", QRectF(375, 250, 300, 30)); + state3->setPropertyOnEntry(editProxy, "geometry", QRectF(440, 300, 260, 30)); + + { + QAnimationGroup *animationGroup = new QParallelAnimationGroup; + QVariantAnimation *anim = new QPropertyAnimation(labelProxy, "opacity"); + animationGroup->addAnimation(anim); + anim = new QPropertyAnimation(label2Proxy, "geometry"); + animationGroup->addAnimation(anim); + anim = new QPropertyAnimation(editProxy, "geometry"); + animationGroup->addAnimation(anim); + anim = new QPropertyAnimation(listProxy, "geometry"); + animationGroup->addAnimation(anim); + + state1->addAnimatedTransition(button, SIGNAL(clicked()), state2, animationGroup); + } + + { + QVariantAnimation *anim; + QAnimationGroup *animationGroup = new QParallelAnimationGroup; + anim = new QPropertyAnimation(label2Proxy, "geometry"); + animationGroup->addAnimation(anim); + anim = new QPropertyAnimation(editProxy, "geometry"); + animationGroup->addAnimation(anim); + anim = new QPropertyAnimation(listProxy, "geometry"); + animationGroup->addAnimation(anim); + state2->addAnimatedTransition(button, SIGNAL(clicked()), state1, animationGroup); + } + + currentState = state1; + + view = new QGraphicsView(scene); + + setCentralWidget(view); + + state3->invokeMethodOnEntry(this, "onEnterState3"); + state2->invokeMethodOnEntry(this, "onEnterState2"); + state1->invokeMethodOnEntry(this, "onEnterState1"); + + connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*))); + connect(button3, SIGNAL(clicked()), this, SLOT(onRemoveClicked())); + + machine->start(); +} + +void MainWindow::onEnterState2() +{ + currentState = state2; + if (listWidget->currentItem()) + editWidget->setText(listWidget->currentItem()->text()); +} + +void MainWindow::onEnterState1() +{ + if (currentState == state2 && listWidget->currentItem()) + listWidget->currentItem()->setText(editWidget->text()); + if (currentState == state3 && !editWidget->text().isNull()) { + new QListWidgetItem(editWidget->text(), listWidget); + editWidget->clear(); + } + currentState = state1; +} + +void MainWindow::onEnterState3() +{ + currentState = state3; +} + +void MainWindow::onItemClicked(QListWidgetItem*) +{ + if (currentState == state2) + { + editWidget->setText(listWidget->currentItem()->text()); + editWidget->clear(); + } +} + +void MainWindow::onRemoveClicked() +{ + QListWidgetItem *listItem = listWidget->takeItem(listWidget->currentRow()); + delete listItem; +} diff --git a/examples/animation/example/mainwindow.h b/examples/animation/example/mainwindow.h new file mode 100644 index 0000000..6be7463 --- /dev/null +++ b/examples/animation/example/mainwindow.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef __MAINWINDOW__H__ +#define __MAINWINDOW__H__ + +#include + +class MainWindow : public QMainWindow +{ +Q_OBJECT +public: + MainWindow(); + +private slots : + void onEnterState3(); + void onEnterState2(); + void onEnterState1(); + void onItemClicked(QListWidgetItem*); + void onRemoveClicked(); +private: + QListWidget *listWidget; + QLabel *labelWidget; + QLabel *label2Widget; + QLineEdit *editWidget; + QGraphicsScene *scene; + QGraphicsView *view; + QState *state1; + QState *state2; + QState *state3; + QState *currentState; + QState *group; + QStateMachine *machine; +}; + +#endif //__MAINWINDOW__H__ + diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp new file mode 100644 index 0000000..f4c754d --- /dev/null +++ b/examples/animation/moveblocks/main.cpp @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qstatemachine.h" +#include "qabstracttransition.h" +#include "qanimationstate.h" +#include "qpropertyanimation.h" +#include "qsequentialanimationgroup.h" +#include "qparallelanimationgroup.h" +#include "qgraphicswidget.h" +#endif +#include + +class StateSwitchEvent: public QEvent +{ +public: + StateSwitchEvent() + : QEvent(Type(StateSwitchType)) + { + } + + StateSwitchEvent(int rand) + : QEvent(Type(StateSwitchType)), + m_rand(rand) + { + } + + enum { StateSwitchType = QEvent::User + 256 }; + + int rand() const { return m_rand; } + +private: + int m_rand; +}; + + +class QGraphicsRectWidget : public QGraphicsWidget +{ +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, + QWidget *) + { + painter->fillRect(rect(), Qt::blue); + } +}; + +class StateSwitchTransition: public QAbstractTransition +{ +public: + StateSwitchTransition(int rand) + : QAbstractTransition(), + m_rand(rand) + { + } + +protected: + virtual bool eventTest(QEvent *event) const + { + return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType)) + && (static_cast(event)->rand() == m_rand); + } + + virtual void onTransition() {} + +private: + int m_rand; +}; + +class StateSwitcher : public QState +{ + Q_OBJECT +public: + StateSwitcher(QStateMachine *machine) + : QState(machine->rootState()), m_machine(machine), + m_stateCount(0), m_lastIndex(0) + { } + + virtual void onEntry() + { + int n; + while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex) + { } + m_lastIndex = n; + m_machine->postEvent(new StateSwitchEvent(n)); + } + virtual void onExit() {} + + void addState(QState *state, QAbstractAnimation *animation) { + StateSwitchTransition *trans = new StateSwitchTransition(++m_stateCount); + trans->setTargetState(state); + addAnimatedTransition(trans, animation); + } + + +private: + QStateMachine *m_machine; + int m_stateCount; + int m_lastIndex; +}; + +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->setPropertyOnEntry(w1, "geometry", rect1); + result->setPropertyOnEntry(w1, "geometry", rect1); + result->setPropertyOnEntry(w2, "geometry", rect2); + result->setPropertyOnEntry(w3, "geometry", rect3); + result->setPropertyOnEntry(w4, "geometry", rect4); + + return result; +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + +#if 0 + QWidget window; + QPalette palette; + palette.setBrush(QPalette::Window, Qt::black); + window.setPalette(palette); + QPushButton *button1 = new QPushButton("A", &window); + QPushButton *button2 = new QPushButton("B", &window); + QPushButton *button3 = new QPushButton("C", &window); + QPushButton *button4 = new QPushButton("D", &window); + + button1->setObjectName("button1"); + button2->setObjectName("button2"); + button3->setObjectName("button3"); + button4->setObjectName("button4"); +#else + 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); + + QGraphicsView window(&scene); + window.setFrameStyle(0); + window.setAlignment(Qt::AlignLeft | Qt::AlignTop); + window.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + window.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +#endif + QStateMachine machine; + + QState *group = new QState(); + group->setObjectName("group"); + QTimer timer; + timer.setInterval(1250); + timer.setSingleShot(true); + group->invokeMethodOnEntry(&timer, "start"); + + 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); + 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); + 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); + + QParallelAnimationGroup animationGroup; + QSequentialAnimationGroup *subGroup; + + QPropertyAnimation *anim = new QPropertyAnimation(button4, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + animationGroup.addAnimation(anim); + + subGroup = new QSequentialAnimationGroup(&animationGroup); + subGroup->addPause(100); + anim = new QPropertyAnimation(button3, "geometry"); + anim->setDuration(1000); + anim->setEasingCurve(QEasingCurve::OutElastic); + subGroup->addAnimation(anim); + + 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); + + StateSwitcher *stateSwitcher = new StateSwitcher(&machine); + stateSwitcher->setObjectName("stateSwitcher"); + group->addTransition(&timer, SIGNAL(timeout()), stateSwitcher); + stateSwitcher->addState(state1, &animationGroup); + stateSwitcher->addState(state2, &animationGroup); + stateSwitcher->addState(state3, &animationGroup); + stateSwitcher->addState(state4, &animationGroup); + stateSwitcher->addState(state5, &animationGroup); + stateSwitcher->addState(state6, &animationGroup); + stateSwitcher->addState(state7, &animationGroup); + + machine.addState(group); + machine.setInitialState(group); + machine.start(); + + + window.resize(300, 300); + window.show(); + + qsrand(time(0)); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/moveblocks/moveblocks.pro b/examples/animation/moveblocks/moveblocks.pro new file mode 100644 index 0000000..7a82ca5 --- /dev/null +++ b/examples/animation/moveblocks/moveblocks.pro @@ -0,0 +1,8 @@ +# Input +SOURCES += main.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/moveblocks +INSTALLS += target sources diff --git a/examples/animation/padnavigator-ng/backside.ui b/examples/animation/padnavigator-ng/backside.ui new file mode 100644 index 0000000..afa488c --- /dev/null +++ b/examples/animation/padnavigator-ng/backside.ui @@ -0,0 +1,208 @@ + + BackSide + + + + 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/animation/padnavigator-ng/images/artsfftscope.png b/examples/animation/padnavigator-ng/images/artsfftscope.png new file mode 100644 index 0000000..b4b8775 Binary files /dev/null and b/examples/animation/padnavigator-ng/images/artsfftscope.png differ diff --git a/examples/animation/padnavigator-ng/images/blue_angle_swirl.jpg b/examples/animation/padnavigator-ng/images/blue_angle_swirl.jpg new file mode 100644 index 0000000..5bf0deb Binary files /dev/null and b/examples/animation/padnavigator-ng/images/blue_angle_swirl.jpg differ diff --git a/examples/animation/padnavigator-ng/images/kontact_contacts.png b/examples/animation/padnavigator-ng/images/kontact_contacts.png new file mode 100644 index 0000000..6fb4cc8 Binary files /dev/null and b/examples/animation/padnavigator-ng/images/kontact_contacts.png differ diff --git a/examples/animation/padnavigator-ng/images/kontact_journal.png b/examples/animation/padnavigator-ng/images/kontact_journal.png new file mode 100644 index 0000000..b1fedb6 Binary files /dev/null and b/examples/animation/padnavigator-ng/images/kontact_journal.png differ diff --git a/examples/animation/padnavigator-ng/images/kontact_mail.png b/examples/animation/padnavigator-ng/images/kontact_mail.png new file mode 100644 index 0000000..672f8fa Binary files /dev/null and b/examples/animation/padnavigator-ng/images/kontact_mail.png differ diff --git a/examples/animation/padnavigator-ng/images/kontact_notes.png b/examples/animation/padnavigator-ng/images/kontact_notes.png new file mode 100644 index 0000000..229bf73 Binary files /dev/null and b/examples/animation/padnavigator-ng/images/kontact_notes.png differ diff --git a/examples/animation/padnavigator-ng/images/kopeteavailable.png b/examples/animation/padnavigator-ng/images/kopeteavailable.png new file mode 100644 index 0000000..2eaf41a Binary files /dev/null and b/examples/animation/padnavigator-ng/images/kopeteavailable.png differ diff --git a/examples/animation/padnavigator-ng/images/metacontact_online.png b/examples/animation/padnavigator-ng/images/metacontact_online.png new file mode 100644 index 0000000..6a398dd Binary files /dev/null and b/examples/animation/padnavigator-ng/images/metacontact_online.png differ diff --git a/examples/animation/padnavigator-ng/images/minitools.png b/examples/animation/padnavigator-ng/images/minitools.png new file mode 100644 index 0000000..0248c9d Binary files /dev/null and b/examples/animation/padnavigator-ng/images/minitools.png differ diff --git a/examples/animation/padnavigator-ng/main.cpp b/examples/animation/padnavigator-ng/main.cpp new file mode 100644 index 0000000..5b35b62 --- /dev/null +++ b/examples/animation/padnavigator-ng/main.cpp @@ -0,0 +1,24 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include "panel.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(padnavigator); + + Panel panel(3, 3); + panel.show(); + + return app.exec(); +} diff --git a/examples/animation/padnavigator-ng/padnavigator.pro b/examples/animation/padnavigator-ng/padnavigator.pro new file mode 100644 index 0000000..0d094c6 --- /dev/null +++ b/examples/animation/padnavigator-ng/padnavigator.pro @@ -0,0 +1,24 @@ +HEADERS += \ + panel.h \ + roundrectitem.h \ + splashitem.h + +SOURCES += \ + panel.cpp \ + roundrectitem.cpp \ + splashitem.cpp \ + main.cpp + +RESOURCES += \ + padnavigator.qrc + +FORMS += \ + backside.ui + +contains(QT_CONFIG, opengl):QT += opengl + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/padnavigator +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS padnavigator.pro images +sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/padnavigator +INSTALLS += target sources diff --git a/examples/animation/padnavigator-ng/padnavigator.qrc b/examples/animation/padnavigator-ng/padnavigator.qrc new file mode 100644 index 0000000..30ee8e1 --- /dev/null +++ b/examples/animation/padnavigator-ng/padnavigator.qrc @@ -0,0 +1,14 @@ + + + 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 + images/blue_angle_swirl.jpg + + diff --git a/examples/animation/padnavigator-ng/panel.cpp b/examples/animation/padnavigator-ng/panel.cpp new file mode 100644 index 0000000..94dbdec --- /dev/null +++ b/examples/animation/padnavigator-ng/panel.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "panel.h" +#include "roundrectitem.h" +#include "splashitem.h" +#include "ui_backside.h" + +#ifndef QT_NO_OPENGL +#include +#else +#endif +#include + +Panel::Panel(int width, int height) + : selectedIndex(0), + grid(width*height), + width(width), + height(height), + flipped(false), + flippingGroup(0), + rotationXanim(0), + rotationYanim(0) +{ + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setCacheMode(CacheBackground); + setViewportUpdateMode(FullViewportUpdate); + setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg")); +#ifndef QT_NO_OPENGL + setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +#endif + + QRectF bounds((-width / 2.0) * 150, (-height / 2.0) * 150, width * 150, height * 150); + + setScene(new QGraphicsScene(bounds, this)); + + baseItem = new RoundRectItem(bounds, QColor(226, 255, 92, 64)); + scene()->addItem(baseItem); + + QWidget *embed = new QWidget; + ui = new Ui_BackSide; + ui->setupUi(embed); + ui->hostName->setFocus(); + + backItem = new RoundRectItem(bounds, embed->palette().window(), embed); + backItem->setYRotation(180); + backItem->setParentItem(baseItem); + + selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray); + selectionItem->setParentItem(baseItem); + selectionItem->setZValue(-1); + selectionItem->setPos(posForLocation(0)); + + int currentIndex = 0; + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + RoundRectItem *item = new RoundRectItem(QRectF(-54, -54, 108, 108), + QColor(214, 240, 110, 128)); + item->setPos(posForLocation(currentIndex)); + + item->setParentItem(baseItem); + item->setFlag(QGraphicsItem::ItemIsFocusable); + grid[currentIndex++] = item; + + switch (qrand() % 9) { + case 0: item->setPixmap(QPixmap(":/images/kontact_contacts.png")); break; + case 1: item->setPixmap(QPixmap(":/images/kontact_journal.png")); break; + case 2: item->setPixmap(QPixmap(":/images/kontact_notes.png")); break; + case 3: item->setPixmap(QPixmap(":/images/kopeteavailable.png")); break; + case 4: item->setPixmap(QPixmap(":/images/metacontact_online.png")); break; + case 5: item->setPixmap(QPixmap(":/images/minitools.png")); break; + case 6: item->setPixmap(QPixmap(":/images/kontact_journal.png")); break; + case 7: item->setPixmap(QPixmap(":/images/kontact_contacts.png")); break; + case 8: item->setPixmap(QPixmap(":/images/kopeteavailable.png")); break; + default: + break; + } + + connect(item, SIGNAL(activated()), this, SLOT(flip())); + } + } + + grid.first()->setFocus(); + + connect(backItem, SIGNAL(activated()), + this, SLOT(flip())); + + splash = new SplashItem; + splash->setZValue(5); + splash->setPos(-splash->rect().width() / 2, scene()->sceneRect().top()); + scene()->addItem(splash); + + splash->grabKeyboard(); + + //initialize the position + baseItem->setYRotation(selectionItem->x()/6.); + baseItem->setXRotation(selectionItem->y()/6.); + + setWindowTitle(tr("Pad Navigator Example")); +} + +Panel::~Panel() +{ +} + +void Panel::keyPressEvent(QKeyEvent *event) +{ + if (splash->isVisible() || event->key() == Qt::Key_Return || flipped) { + QGraphicsView::keyPressEvent(event); + return; + } + + selectedIndex = (selectedIndex + grid.count() + (event->key() == Qt::Key_Right) - (event->key() == Qt::Key_Left) + + width * ((event->key() == Qt::Key_Down) - (event->key() == Qt::Key_Up))) % grid.count(); + grid[selectedIndex]->setFocus(); + + const QPointF pos = posForLocation(selectedIndex); + + const double angleY = pos.x() / 6., + angleX = pos.y() / 6.; + + QAnimationGroup *group = new QParallelAnimationGroup(); + + QVariantAnimation *anim = new QPropertyAnimation(baseItem, "xRotation"); + anim->setEndValue(angleX); + anim->setDuration(150); + anim->setEasingCurve(QEasingCurve::OutInSine); + group->addAnimation(anim); + + anim = new QPropertyAnimation(baseItem, "yRotation"); + anim->setEndValue(angleY); + anim->setDuration(150); + anim->setEasingCurve(QEasingCurve::OutInSine); + group->addAnimation(anim); + + anim = new QPropertyAnimation(selectionItem, "pos"); + anim->setEndValue(pos); + anim->setDuration(150); + anim->setEasingCurve(QEasingCurve::Linear); + group->addAnimation(anim); + + group->start(QAbstractAnimation::DeleteWhenStopped); +} + +void Panel::resizeEvent(QResizeEvent *event) +{ + QGraphicsView::resizeEvent(event); + fitInView(scene()->sceneRect(), Qt::KeepAspectRatio); +} + +void Panel::flip() +{ + grid[selectedIndex]->setFocus(); + + if (flippingGroup == 0) { + flippingGroup = new QParallelAnimationGroup(this); + + const qreal zoomOut = qreal(.75); + + //slight scaling down while flipping + QVariantAnimation *anim = new QPropertyAnimation(baseItem, "yScale"); + anim->setKeyValueAt(qreal(.5), zoomOut); + anim->setEndValue(1); + anim->setEasingCurve(QEasingCurve::OutInSine); + anim->setDuration(500); + flippingGroup->addAnimation(anim); + + anim = new QPropertyAnimation(baseItem, "xScale"); + anim->setKeyValueAt(qreal(.5), zoomOut); + anim->setEndValue(1); + anim->setEasingCurve(QEasingCurve::OutInSine); + anim->setDuration(500); + flippingGroup->addAnimation(anim); + + rotationXanim = new QPropertyAnimation(baseItem, "xRotation"); + rotationXanim->setEndValue(0); + rotationXanim->setDuration(500); + flippingGroup->addAnimation(rotationXanim); + + rotationYanim = new QPropertyAnimation(baseItem, "yRotation"); + rotationYanim->setEndValue(180); + rotationYanim->setDuration(500); + flippingGroup->addAnimation(rotationYanim); + } + + if (flippingGroup->currentTime() != 0 && flippingGroup->direction() == QAbstractAnimation::Forward) { + flippingGroup->setDirection(QAbstractAnimation::Backward); + } else { + flippingGroup->setDirection(QAbstractAnimation::Forward); + if (flippingGroup->currentTime() == 0) { + //we always make sure when it is at the beginning + rotationXanim->setStartValue(baseItem->xRotation()); + rotationYanim->setStartValue(baseItem->yRotation()); + } + } + flippingGroup->start(); + flipped = !flipped; +} + +QPointF Panel::posForLocation(int index) const +{ + const int x = index % width, + y = index / width; + return QPointF(x * 150, y * 150) + - QPointF((width - 1) * 75, (height - 1) * 75); +} diff --git a/examples/animation/padnavigator-ng/panel.h b/examples/animation/padnavigator-ng/panel.h new file mode 100644 index 0000000..cbceed1 --- /dev/null +++ b/examples/animation/padnavigator-ng/panel.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#ifdef QT_EXPERIMENTAL_SOLUTION +#include "qtgraphicswidget.h" +#else +#include +#endif + +QT_BEGIN_NAMESPACE +class Ui_BackSide; +QT_END_NAMESPACE; + +class RoundRectItem; +class QAnimationGroup; +class QPropertyAnimation; + +class Panel : public QGraphicsView +{ + Q_OBJECT +public: + Panel(int width, int height); + ~Panel(); + +protected: + void keyPressEvent(QKeyEvent *event); + void resizeEvent(QResizeEvent *event); + +private Q_SLOTS: + void flip(); + +private: + QPointF posForLocation(int index) const; + + QGraphicsWidget *selectionItem; + QGraphicsWidget *baseItem; + RoundRectItem *backItem; + QGraphicsWidget *splash; + int selectedIndex; + + QVector grid; + + int width; + int height; + bool flipped; + Ui_BackSide *ui; + + QAnimationGroup *flippingGroup; + QPropertyAnimation *rotationXanim, *rotationYanim; +}; diff --git a/examples/animation/padnavigator-ng/roundrectitem.cpp b/examples/animation/padnavigator-ng/roundrectitem.cpp new file mode 100644 index 0000000..e498538 --- /dev/null +++ b/examples/animation/padnavigator-ng/roundrectitem.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "roundrectitem.h" + +#include + +RoundRectItem::RoundRectItem(const QRectF &rect, const QBrush &brush, QWidget *embeddedWidget) + : QGraphicsWidget(), + brush(brush), + proxyWidget(0), + m_rect(rect) +{ + if (embeddedWidget) { + proxyWidget = new QGraphicsProxyWidget(this); + proxyWidget->setFocusPolicy(Qt::StrongFocus); + proxyWidget->setWidget(embeddedWidget); + } +} + +void RoundRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + const bool widgetHidden = parentItem() == 0 || qAbs(static_cast(parentItem())->yRotation()) < 90; + + if (proxyWidget) { + if (widgetHidden) { + proxyWidget->hide(); + } else { + if (!proxyWidget->isVisible()) { + proxyWidget->setGeometry(boundingRect().adjusted(25, 25, -25, -25)); + proxyWidget->show(); + proxyWidget->setFocus(); + } + painter->setBrush(brush); + painter->setPen(QPen(Qt::black, 1)); + painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); + painter->drawRoundRect(m_rect); + } + } else if (widgetHidden) { + painter->setPen(Qt::NoPen); + painter->setBrush(QColor(0, 0, 0, 64)); + painter->drawRoundRect(m_rect.translated(2, 2)); + + QLinearGradient gradient(m_rect.topLeft(), m_rect.bottomRight()); + const QColor col = brush.color(); + gradient.setColorAt(0, col); + gradient.setColorAt(1, col.dark(200)); + painter->setBrush(gradient); + painter->setPen(QPen(Qt::black, 1)); + painter->drawRoundRect(m_rect); + if (!pix.isNull()) { + painter->scale(qreal(1.95), qreal(1.95)); + painter->drawPixmap(-pix.width() / 2, -pix.height() / 2, pix); + } + } + +} + +QRectF RoundRectItem::boundingRect() const +{ + qreal penW = qreal(.5); + qreal shadowW = 2; + return m_rect.adjusted(-penW, -penW, penW + shadowW, penW + shadowW); +} + +void RoundRectItem::setPixmap(const QPixmap &pixmap) +{ + pix = pixmap; + if (scene() && isVisible()) + update(); +} + +void RoundRectItem::keyPressEvent(QKeyEvent *event) +{ + if (event->isAutoRepeat() || event->key() != Qt::Key_Return) { + QGraphicsWidget::keyPressEvent(event); + return; + } + + if (!proxyWidget) { + setXScale(qreal(.9)); + setYScale(qreal(.9)); + } + emit activated(); +} + +void RoundRectItem::keyReleaseEvent(QKeyEvent *event) +{ + if (event->isAutoRepeat() || event->key() != Qt::Key_Return) { + QGraphicsWidget::keyReleaseEvent(event); + return; + } + + if (!proxyWidget) { + setXScale(1); + setYScale(1); + } +} diff --git a/examples/animation/padnavigator-ng/roundrectitem.h b/examples/animation/padnavigator-ng/roundrectitem.h new file mode 100644 index 0000000..56a6d3c --- /dev/null +++ b/examples/animation/padnavigator-ng/roundrectitem.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include +#ifdef QT_EXPERIMENTAL_SOLUTION +#include "qtgraphicswidget.h" +#else +#include +#endif + +QT_BEGIN_NAMESPACE +class QGraphicsProxyWidget; +QT_END_NAMESPACE; + +class RoundRectItem : public QGraphicsWidget +{ + Q_OBJECT +public: + RoundRectItem(const QRectF &rect, const QBrush &brush, QWidget *embeddedWidget = 0); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); + QRectF boundingRect() const; + + void setPixmap(const QPixmap &pixmap); + +Q_SIGNALS: + void activated(); + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + +private: + QRectF m_rect; + QBrush brush; + QPixmap pix; + QGraphicsProxyWidget *proxyWidget; +}; diff --git a/examples/animation/padnavigator-ng/splashitem.cpp b/examples/animation/padnavigator-ng/splashitem.cpp new file mode 100644 index 0000000..84a8945 --- /dev/null +++ b/examples/animation/padnavigator-ng/splashitem.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "splashitem.h" + +#include + +SplashItem::SplashItem(QGraphicsItem *parent) + : QGraphicsWidget(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. Please press any key to continue."); + resize(400, 175); +} + +void SplashItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + painter->setPen(QPen(Qt::black, 2)); + painter->setBrush(QColor(245, 245, 255, 220)); + painter->setClipRect(rect()); + painter->drawRoundRect(3, -100 + 3, 400 - 6, 250 - 6); + + QRectF textRect = rect().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); +} + +void SplashItem::keyPressEvent(QKeyEvent * /* event */) +{ + QVariantAnimation *anim = new QPropertyAnimation(this, "pos"); + anim->setEndValue(QPointF(x(), scene()->sceneRect().top() - rect().height())); + anim->setDuration(350); + anim->start(QAbstractAnimation::DeleteWhenStopped); + + anim = new QPropertyAnimation(this, "opacity"); + anim->setEndValue(0); + anim->start(QAbstractAnimation::DeleteWhenStopped); + + connect(anim, SIGNAL(finished()), SLOT(close())); +} diff --git a/examples/animation/padnavigator-ng/splashitem.h b/examples/animation/padnavigator-ng/splashitem.h new file mode 100644 index 0000000..6428b69 --- /dev/null +++ b/examples/animation/padnavigator-ng/splashitem.h @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#ifdef QT_EXPERIMENTAL_SOLUTION +#include "qtgraphicswidget.h" +#else +#include +#endif + +class SplashItem : public QGraphicsWidget +{ + Q_OBJECT +public: + SplashItem(QGraphicsItem *parent = 0); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + void keyPressEvent(QKeyEvent *event); + +private: + QString text; +}; diff --git a/examples/animation/photobrowser/main.cpp b/examples/animation/photobrowser/main.cpp new file mode 100644 index 0000000..98f2a9e --- /dev/null +++ b/examples/animation/photobrowser/main.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include + +#include "river.h" +#include "menu.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + if (app.arguments().size() == 1) { + qWarning("you have to specifiy a path to look for the photos"); + return 0; + } + + + QGraphicsScene scene; + scene.setSceneRect(QRectF(QPointF(), River::fixedSize())); + + QGraphicsView view(&scene); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + const int fw = view.frameWidth() * 2; + view.setFixedSize(River::fixedSize() + QSize(fw,fw)); + + River river(app.arguments()[1]); + scene.addItem(&river); + + Menu menu(&river); + menu.addAction(QLatin1String("River Mode"), &river, SLOT(setRiverMode())); + menu.addAction(QLatin1String("Grid Mode"), &river, SLOT(setGridMode())); + menu.addAction(QLatin1String("Cover Flow"), &river, SLOT(setCoverMode())); + menu.addAction(QLatin1String("Hide Menu"), &menu, SLOT(hide())); + menu.addAction(QLatin1String("Exit"), &app, SLOT(quit())); + menu.setZValue(2); + menu.setFocus(); + + river.menu = &menu; + view.show(); + + return app.exec(); +} diff --git a/examples/animation/photobrowser/menu.cpp b/examples/animation/photobrowser/menu.cpp new file mode 100644 index 0000000..d4efe9c --- /dev/null +++ b/examples/animation/photobrowser/menu.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "menu.h" + +Menu::Menu(QGraphicsItem *parent) : QGraphicsWidget(parent), m_selected(0) +{ + setFlag(QGraphicsItem::ItemIsFocusable); + m_selection = new QGraphicsRectItem(this); + QLinearGradient linearGrad(QPointF(0, 0), QPointF(0,50)); + linearGrad.setColorAt(0, QColor(255,255,255,128)); + linearGrad.setColorAt(1, QColor(255,255,255,16)); + m_selection->setBrush(linearGrad); + m_selection->setPen(QPen(Qt::transparent)); +} + +Menu::~Menu() +{ +} + + +MenuAction *Menu::addAction(const QString &text, QObject *receiver, const char* slot) +{ + MenuAction *action = new MenuAction(text, this); + if (!m_actions.isEmpty()) { + MenuAction *last = m_actions.last(); + action->setPos(last->pos() + last->boundingRect().bottomLeft()); + } + m_actions.append(action); + if (m_selection->boundingRect().width() < action->boundingRect().width()) + m_selection->setRect(action->boundingRect()); + + QObject::connect(action, SIGNAL(triggered()), receiver, slot); + return action; +} + +QRectF Menu::boundingRect() const +{ + QRectF res; + foreach (MenuAction *a, m_actions) + res |= a->boundingRect(); + return res; +} + +void Menu::keyPressEvent (QKeyEvent * event) +{ + switch (event->key()) { + case Qt::Key_Escape: + hide(); + break; + case Qt::Key_Up: + m_selected -= 2; + case Qt::Key_Down: + if (!m_actions.isEmpty()) { + m_selected = (m_selected + 1 + m_actions.count()) % m_actions.count(); + QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::Position); + anim->setEndValue(m_actions.at(m_selected)->pos()); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + break; + case Qt::Key_Enter: + case Qt::Key_Return: + if (!m_actions.isEmpty()) { + QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::RotationX); + anim->setEndValue(m_selection->xRotation() < 180 ? qreal(360) : qreal(0)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + m_actions.at(m_selected)->trigger(); + hide(); + } + break; + default: + QGraphicsItem::keyPressEvent(event); + } +} + +void Menu::show() +{ + QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Opacity); + anim->setEndValue(qreal(1.)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorX); + anim->setEndValue(qreal(1)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorY); + anim->setEndValue(qreal(1)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + setFocus(); +} + +void Menu::hide() +{ + QItemAnimation *anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorX); + anim->setEndValue(qreal(.1)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(m_selection, QItemAnimation::ScaleFactorY); + anim->setEndValue(qreal(.1)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(this, QItemAnimation::Opacity); + anim->setEndValue(qreal(0)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + parentItem()->setFocus(); +} + + +MenuAction::MenuAction(const QString &text, Menu * parent) + : QGraphicsTextItem(text,parent) +{ + QFont f = font(); + f.setPointSize(18); + setFont(f); + setDefaultTextColor(Qt::white); +} + +void MenuAction::trigger() +{ + emit triggered(); +} diff --git a/examples/animation/photobrowser/menu.h b/examples/animation/photobrowser/menu.h new file mode 100644 index 0000000..9514cfe --- /dev/null +++ b/examples/animation/photobrowser/menu.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef __MENU__H__ +#define __MENU__H__ + +#include + +class MenuAction; + +class Menu : public QGraphicsWidget +{ + Q_OBJECT +public: + Menu(QGraphicsItem *parent); + ~Menu(); + + MenuAction *addAction(const QString&, QObject *receiver = 0, const char* slot = 0 ); + + QRectF boundingRect() const; + void keyPressEvent ( QKeyEvent * event ); +public slots: + void show(); + void hide(); +private: + QList m_actions; + QGraphicsRectItem *m_selection; + int m_selected; +}; + +class MenuAction : public QGraphicsTextItem +{ + Q_OBJECT +public: + MenuAction(const QString &text, Menu * parent); + void trigger(); +signals: + void triggered(); +}; + + +#endif //__RIVERITEM__H__ diff --git a/examples/animation/photobrowser/photobrowser.pro b/examples/animation/photobrowser/photobrowser.pro new file mode 100644 index 0000000..21f03d6 --- /dev/null +++ b/examples/animation/photobrowser/photobrowser.pro @@ -0,0 +1,17 @@ +###################################################################### +# Automatically generated by qmake (2.01a) ven. 22. août 13:09:33 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp \ + river.cpp \ + riveritem.cpp \ + menu.cpp +HEADERS += river.h \ + riveritem.h \ + menu.h diff --git a/examples/animation/photobrowser/river.cpp b/examples/animation/photobrowser/river.cpp new file mode 100644 index 0000000..f3dd0746 --- /dev/null +++ b/examples/animation/photobrowser/river.cpp @@ -0,0 +1,561 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "river.h" +#include "riveritem.h" + +#include "qvariantanimation.h" + +#include +#include +#include +#include + + +#define GRID_ROW_COUNT 3 +#define GRID_COLUMN_COUNT 2 +#define GRID_DIMENSIONS (GRID_ROW_COUNT * GRID_COLUMN_COUNT) +#define ITEM_COUNT 12 + +#define RIVER_MAGNIFY(ITEM) (qreal(0.50) + (ITEM)->zValue()*2 ) +#define GRID_MAGNIFY qreal(1.5) +#define GRID_CURRENT_MAGNIFY 2 + +River::River(const QString &path) : +m_images(QDir(path).entryInfoList(QStringList() << QLatin1String("*.jpg") << QLatin1String("*.png"))), +m_currentImage(0), m_mode(RiverMode), m_selectedItem(-1) , m_topLeftIndex(-1) +{ + setFocusPolicy(Qt::StrongFocus); + setGeometry(QRectF( QPointF(), fixedSize())); + + + for (int i = 0; i < ITEM_COUNT; ++i) { + RiverItem * item = new RiverItem(this); + + //here we also randomize the x position (not when looping) + const int x = qrand() % fixedSize().width(); + item->setPos(x, -1); + + m_items.insert(m_currentImage, item); + addUnusedRiverItem(item); + } + +} + +QPointF River::gridItemPosition(int row, int col) const +{ + if (col < 0) { + col += GRID_COLUMN_COUNT; + row --; + } + return QPointF(rect().width()*(col*2 + 1)/(GRID_COLUMN_COUNT*2), + rect().height()*(row*2 + 1)/(GRID_ROW_COUNT*2)); +} + +QPixmap River::pixmap(int index) const +{ + if (index < 0 || index >= m_images.size()) + return QPixmap(); + + if (m_pixmaps.size() <= index) { + m_pixmaps.resize(index+1); + } + + if (m_pixmaps.at(index).isNull()) { + m_pixmaps[index] = QPixmap(m_images.at(index).absoluteFilePath()); + } + + return m_pixmaps.at(index); +} + +void River::addUnusedRiverItem(RiverItem * item) +{ + if (m_images.isEmpty()) + return; + + QRectF realItemRect = item->mapToParent(item->boundingRect()).boundingRect(); + + int y = item->pos().y(); + int x = item->pos().x(); + if (x >= fixedSize().width() || x < -realItemRect.width() || y < 0) { + //we set the new pixmap + + m_items.remove(m_items.key(item)); + + while (m_items.contains(m_currentImage)) + m_currentImage = (m_currentImage + 1 ) % m_images.size(); + + item->setPixmap(pixmap(m_currentImage)); + + m_items.insert(m_currentImage, item); + //this manages looping as well + m_currentImage = (m_currentImage + 1 ) % m_images.size(); + + item->setZValue(qreal(qrand()%100)/200.0); + + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(RIVER_MAGNIFY(item)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(RIVER_MAGNIFY(item)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + + realItemRect = item->mapToParent(item->boundingRect()).boundingRect(); + + y = -realItemRect.y() + qrand() % (fixedSize().height() - int(realItemRect.height())); + if (x >= fixedSize().width()) { + x = -realItemRect.width()/2; + } + } + + item->setPos(x, y); + + const QPointF target(QPointF(fixedSize().width() + realItemRect.width()/2, y)); + + const int distance = target.x() - x; + + const int duration = (40 - 50*item->zValue() ) * distance; + QItemAnimation *a = new QItemAnimation(item, QItemAnimation::Position, scene()); + a->setEndValue(target); + a->setDuration(duration); + a->start(QAbstractAnimation::DeleteWhenStopped); + connect(a, SIGNAL(finished()), SLOT(animationFinished())); +} + +void River::animationFinished() +{ + QItemAnimation *anim = qobject_cast(sender()); + if (!anim || anim->propertyName() != QItemAnimation::Position) + return; + + /*RiverItem *item = static_cast(anim->graphicsItem()); + if (m_mode != RiverMode) {*/ + /*int key = m_items.key(item); + if (key < m_topLeftIndex || key >= m_topLeftIndex + GRID_DIMENSIONS) { + delete item; + m_items.remove(key); + }*/ + //return; + + //} + + addUnusedRiverItem(static_cast(anim->targetItem())); +} + +void River::switchPaused() +{ + const bool paused = m_pausedAnimations.isEmpty(); + if (paused) + m_pausedAnimations = scene()->findChildren(); + + foreach(QItemAnimation *anim, m_pausedAnimations) { + if (paused) + anim->pause(); + else + anim->resume(); + } + + if (!paused) + m_pausedAnimations.clear(); +} + +void River::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) +{ + painter->fillRect(option->rect, Qt::black); +} + +void River::setMode(Mode m) +{ + if (m_mode == m) + return; + + Mode oldMode = m_mode; + m_mode = m; + switch(m) + { + case RiverMode: + m_mode = oldMode; //some animation may be stopt, and we don't want that animationFinished we were in that mode yet + foreach (RiverItem *item, m_items) { + const int x = qrand() % fixedSize().width(); + const int y = qrand() % fixedSize().width(); + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(RIVER_MAGNIFY(item)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(RIVER_MAGNIFY(item)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::Position, scene()); + anim->setEndValue(QPointF(x, y)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + connect(anim, SIGNAL(finished()), SLOT(animationFinished())); + } + m_mode = m; + break; + + case GridMode: + + if (oldMode == GridFullScreenMode) { + currentItem()->setFullScreen(false, GRID_CURRENT_MAGNIFY); + } else { + m_topLeftIndex = -GRID_DIMENSIONS; + foreach (RiverItem *item, m_items) { + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + adjustGrid(m_currentImage - GRID_DIMENSIONS + 1); + setCurrentItem(m_topLeftIndex); + } + break; + case GridFullScreenMode: + //let's put the current item fullscreen + currentItem()->setFullScreen(true, GRID_CURRENT_MAGNIFY); + break; + case CoverMode: + m_gridItem = m_items.values(); + setCurrentItem(m_gridItem.count()/2); + default: + break; + } +} + +River::Mode River::mode() const +{ + return m_mode; +} + +QSize River::fixedSize() +{ + return QSize(352, 416); +} + +//the name of this method is not that good... +void River::makeCenterAvailable(qreal size) +{ + QRectF center(QPointF(), QSizeF(size, size)); + center.moveCenter(rect().center()); + + const QList list = scene()->items(center); + + foreach(QGraphicsItem *item, m_items) { + + if (!list.contains(item)) + continue; + + QPointF pos = item->pos(); + + if (pos.y() < rect().center().y()) { + //item is above center + pos.ry() = center.top() - item->boundingRect().height() - 1; + } else { + //item is below the center + pos.ry() = center.bottom() + 1; + } + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); + anim->setEndValue(pos); + anim->setDuration(150); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } +} + + +//this is there just to test small interaction +void River::keyPressEvent ( QKeyEvent * keyEvent ) +{ + switch(keyEvent->key()) + { + case Qt::Key_O: + { + QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Opacity, scene()); + anim->setDuration(2000); + anim->setEndValue(qreal(.5)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + break; + case Qt::Key_N: + //that's a test + makeCenterAvailable(60); + break; + case Qt::Key_P: + switchPaused(); + break; + case Qt::Key_V: + setMode(GridMode); + break; + case Qt::Key_R: + setMode(RiverMode); + break; + case Qt::Key_C: + setMode(CoverMode); + break; + case Qt::Key_Return: + case Qt::Key_Enter: + if (m_mode == RiverMode) { + setMode(GridMode); + } else if (m_mode == GridMode) { + setMode(GridFullScreenMode); + } else if (m_mode == GridFullScreenMode) { + setMode(GridMode); + } + break; + case Qt::Key_Escape: + if (m_mode == GridFullScreenMode) { + setMode(GridMode); + } else if (m_mode == GridMode || m_mode == CoverMode) { + setMode(RiverMode); + } else if (m_mode == RiverMode) { + menu->show(); + } + break; + case Qt::Key_Right: + if (m_mode == GridMode) { + navigateBy(+1); + } else if (m_mode == CoverMode) { + setCurrentItem(m_selectedItem + 1); + } + break; + case Qt::Key_Left: + if (m_mode == GridMode) { + navigateBy(-1); + } else if (m_mode == CoverMode) { + setCurrentItem(m_selectedItem - 1); + } + break; + case Qt::Key_Down: + if (m_mode == GridMode) { + navigateBy(GRID_COLUMN_COUNT); + } + break; + case Qt::Key_Up: + if (m_mode == GridMode) { + navigateBy(-GRID_COLUMN_COUNT); + } + break; +// case Qt::Key_PageUp: + case Qt::Key_M: + menu->show(); + break; + case Qt::Key_Space: + if (m_mode == GridMode) { + RiverItem *item = currentItem(); + if(!item) + break; + + //stupid sequence. + QPointF pos = item->pos(); + QAnimationGroup *group = new QSequentialAnimationGroup(); + //item->animator()->beginSequence(); + + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); + anim->setEndValue(pos); + group->addAnimation(anim); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(qreal(1.)); + anim->setDuration(500); + group->addAnimation(anim); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(qreal(1.)); + anim->setDuration(500); + group->addAnimation(anim); + anim = new QItemAnimation(item, QItemAnimation::RotationX, scene()); + anim->setEndValue(qreal(0)); + group->addAnimation(anim); + group->start(QAbstractAnimation::DeleteWhenStopped); + } + default: + break; + } + + QGraphicsItem::keyPressEvent(keyEvent); +} + + +void River::setGridMode() +{ + setMode(GridMode); +} + +void River::setRiverMode() +{ + setMode(RiverMode); +} + +void River::setCoverMode() +{ + setMode(CoverMode); +} + + +void River::adjustGrid(int newTopLeft) +{ + for (int i = newTopLeft ; i < newTopLeft + GRID_DIMENSIONS; i++) { + if (!m_items.contains(i)) { + RiverItem *item = createItem(i); + int row = (i - m_topLeftIndex) / GRID_COLUMN_COUNT; + int col = (i - m_topLeftIndex) % GRID_COLUMN_COUNT; + item->setPos(gridItemPosition(row, col)); + item->setXScale(0); + item->setYScale(0); + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + } + newTopLeft = newTopLeft - newTopLeft % GRID_COLUMN_COUNT; + + QHash::iterator it = m_items.begin(); + while (it != m_items.constEnd()) { + const int imageIdx = it.key(); + RiverItem *item = *it; + QSizeF itemSize = item->boundingRect().size(); + if ((imageIdx >= newTopLeft && imageIdx < newTopLeft + GRID_DIMENSIONS) + || boundingRect().adjusted(-itemSize.width()/2, -itemSize.height()/2, itemSize.width()/2, itemSize.height()/2) + .contains(item->pos())) { + int row = (imageIdx-newTopLeft) / GRID_COLUMN_COUNT; + int col = (imageIdx-newTopLeft) % GRID_COLUMN_COUNT; + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::Position, scene()); + anim->setEndValue(gridItemPosition(row, col)); + anim->start(QAbstractAnimation::DeleteWhenStopped); + ++it; + } else { + ++it; /* ### ideally we should remove the items, but this cause the photobrowser to crash + because the QItemAnimations are not notified the item is deleted + delete item; + it = m_items.erase(it); + */ + } + } + + m_topLeftIndex = newTopLeft; +} + + +RiverItem *River::createItem(int imageIndex) +{ + Q_ASSERT(!m_items.contains(imageIndex)); + RiverItem * item = new RiverItem(this); + item->setPixmap(pixmap(imageIndex)); + m_items.insert(imageIndex,item); + return item; +} + +void River::setCurrentItem(int newCurrentItem) +{ + if (m_mode == CoverMode) + { + m_selectedItem = newCurrentItem; + for (int i = 0; i < m_gridItem.count(); i++) { + QVariantAnimation *anim; + RiverItem *item = m_gridItem.at(i); + + qreal rotation = 0; + qreal width = boundingRect().width() / 2; + qreal x = width; + qreal scale = 3; + qreal z = 1; + qreal y = boundingRect().height()/2; + + if (i < newCurrentItem - 4) { + item->setVisible(false); + item->setPos(QPointF(0, y)); + continue; + } else if(i > newCurrentItem + 4) { + item->setVisible(false); + item->setPos(QPointF(boundingRect().width(), y)); + continue; + } else if (i < newCurrentItem) { + x = (i - newCurrentItem + 4) * width/7; + rotation = -75; + scale = 2; + z = 1.+qreal(i-newCurrentItem)/10.; + } else if (i > newCurrentItem) { + x = width + (i - newCurrentItem + 3) * width/7; + rotation = 75; + scale = 2; + z = 1.-qreal(i-newCurrentItem)/8.; + } + + item->setVisible(true); + item->setZValue(z); + + anim = new QItemAnimation(item, QItemAnimation::RotationY, scene()); + anim->setEndValue(rotation); + anim->start(QAbstractAnimation::DeleteWhenStopped); + + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(scale); + anim->start(QVariantAnimation::DeleteWhenStopped); + + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(scale); + anim->start(QVariantAnimation::DeleteWhenStopped); + + anim = new QItemAnimation(item, QItemAnimation::Position, scene()); + anim->setEndValue(QPointF(x,y)); + anim->start(QVariantAnimation::DeleteWhenStopped); + } + return; + } + + + //deselect the current item + if (m_selectedItem >= 0 && m_items.contains(m_selectedItem)) { + RiverItem *item = m_items.value(m_selectedItem); + item->setZValue(qreal(qrand()%100)/200.0); + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(GRID_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + } + + if (newCurrentItem < 0) { + m_selectedItem = newCurrentItem; + return; + } + + //ensure visible; + if (newCurrentItem < m_topLeftIndex) { + adjustGrid(newCurrentItem); + } else if (newCurrentItem >= m_topLeftIndex + GRID_DIMENSIONS) { + adjustGrid(newCurrentItem - GRID_DIMENSIONS + GRID_COLUMN_COUNT); + } + + //select the new one + m_selectedItem = newCurrentItem; + RiverItem *item = currentItem(); + Q_ASSERT(item); + item->setZValue(1); + + QItemAnimation *anim = new QItemAnimation(item, QItemAnimation::ScaleFactorX, scene()); + anim->setEndValue(GRID_CURRENT_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); + anim = new QItemAnimation(item, QItemAnimation::ScaleFactorY, scene()); + anim->setEndValue(GRID_CURRENT_MAGNIFY); + anim->start(QAbstractAnimation::DeleteWhenStopped); +} + +void River::navigateBy(int offset) +{ + int newSelection = m_selectedItem + offset; + const int imageCount = m_images.size(); + while (newSelection < 0) + newSelection += imageCount; + newSelection %= imageCount; + setCurrentItem(newSelection); +} diff --git a/examples/animation/photobrowser/river.h b/examples/animation/photobrowser/river.h new file mode 100644 index 0000000..25bf62a --- /dev/null +++ b/examples/animation/photobrowser/river.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef __RIVER__H__ +#define __RIVER__H__ + +#include +#include + +#include "menu.h" + +class RiverItem; + +class River : public QGraphicsWidget +{ + Q_OBJECT +public: + enum Mode + { + RiverMode, + GridMode, + GridFullScreenMode, + CoverMode + }; + + River(const QString &path); + void addUnusedRiverItem(RiverItem * item); + + static QSize fixedSize(); + + void switchPaused(); + + void setMode(Mode m); + Mode mode() const; + + Menu *menu; + +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void keyPressEvent ( QKeyEvent * keyEvent ); + void makeCenterAvailable(qreal size); + QPointF gridItemPosition(int row, int col) const; + QPixmap pixmap(int index) const; + +protected slots: + void animationFinished(); +public slots: + void setRiverMode(); + void setGridMode(); + void setCoverMode(); + +private: + const QFileInfoList m_images; + int m_currentImage; + mutable QVector m_pixmaps; + QHash m_items; + QList m_gridItem; + QList m_pausedAnimations; + Mode m_mode; + + void adjustGrid(int topRight); + RiverItem *currentItem() { return m_items.value(m_selectedItem); } + RiverItem *createItem(int imageIndex); + void setCurrentItem(int currentItem); + void navigateBy(int offset); + + int m_selectedItem; + int m_topLeftIndex; + +}; + + +#endif //__RIVERITEM__H__ diff --git a/examples/animation/photobrowser/riveritem.cpp b/examples/animation/photobrowser/riveritem.cpp new file mode 100644 index 0000000..f6523a7 --- /dev/null +++ b/examples/animation/photobrowser/riveritem.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "riveritem.h" +#include "river.h" + +RiverItem::RiverItem(QGraphicsItem *parent) : QGraphicsPixmapItem(parent), m_fullscreen(false) +{ + setCacheMode(DeviceCoordinateCache); +} + +RiverItem::~RiverItem() +{ +} + +void RiverItem::setPixmap(const QPixmap &pix) +{ + const QSize oldSize = pixmap().size(); + const QSize newSize = pix.size(); + QGraphicsPixmapItem::setPixmap(pix); + + if (newSize != oldSize) { + setOffset(-newSize.width()/2, -newSize.height()/2); + const qreal scaleFactor = qreal(River::fixedSize().height())/(qreal(pix.height()*7)); + setTransform(QTransform().scale(scaleFactor, scaleFactor)); + prepareGeometryChange(); + } +} + + +void RiverItem::setFullScreen(bool b, qreal originScaleFactor) +{ + if (m_fullscreen == b) + return; + + m_fullscreen = b; + + QPointF newPos; + qreal rotationZ; + qreal scaleX, scaleY; + + if (b) { + const QSizeF basePixmapSize = transform().map(boundingRect()).boundingRect().size(); + + newPos = parentItem()->boundingRect().center(); + rotationZ = 90; + scaleY = qreal(River::fixedSize().width()) / basePixmapSize.height() * yScale(); + scaleX = qreal(River::fixedSize().height()) / basePixmapSize.width() * xScale(); + + if (m_nonFSPos.isNull()) { + m_nonFSPos = pos(); //let's save our current (non fullscreen) position + } + + } else { + Q_ASSERT(!m_nonFSPos.isNull()); + rotationZ = 0; + scaleX = originScaleFactor; + scaleY = originScaleFactor; + newPos = m_nonFSPos; + } + + QAnimationGroup *group = new QParallelAnimationGroup(scene()); + QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::Position); + anim->setEndValue(newPos); + group->addAnimation(anim); + anim = new QItemAnimation(this, QItemAnimation::RotationZ); + anim->setEndValue(rotationZ); + group->addAnimation(anim); + anim = new QItemAnimation(this, QItemAnimation::ScaleFactorX); + anim->setEndValue(scaleX); + group->addAnimation(anim); + anim = new QItemAnimation(this, QItemAnimation::ScaleFactorY); + anim->setEndValue(scaleY); + group->addAnimation(anim); + group->start(QAbstractAnimation::DeleteWhenStopped); +} + +void RiverItem::mousePressEvent(QGraphicsSceneMouseEvent*) +{ + //just let it rotate on itself + QItemAnimation *anim = new QItemAnimation(this, QItemAnimation::RotationY); + anim->setEndValue(yRotation() < 180 ? 360 : 0); + anim->setDuration(500); + anim->start(QAbstractAnimation::DeleteWhenStopped); +} + + diff --git a/examples/animation/photobrowser/riveritem.h b/examples/animation/photobrowser/riveritem.h new file mode 100644 index 0000000..39fdcc2 --- /dev/null +++ b/examples/animation/photobrowser/riveritem.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef __RIVERITEM__H__ +#define __RIVERITEM__H__ + +#include + +class RiverItemAnimator; + +class RiverItem : public QGraphicsPixmapItem +{ +public: + RiverItem(QGraphicsItem *parent); + ~RiverItem(); + + void setPixmap(const QPixmap &); + void setFullScreen(bool b, qreal originScaleFactor); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent*); + +private: + QPointF m_nonFSPos; //to save the position when not in fullscreen + bool m_fullscreen; +}; + +#endif //__RIVERITEM__H__ diff --git a/examples/animation/piemenu/main.cpp b/examples/animation/piemenu/main.cpp new file mode 100644 index 0000000..28f62d0 --- /dev/null +++ b/examples/animation/piemenu/main.cpp @@ -0,0 +1,26 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#include "scene.h" +#include "qgraphicspiemenu.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + Scene scene; + + QGraphicsView view(&scene); + view.show(); + + return app.exec(); +} diff --git a/examples/animation/piemenu/piemenu.pro b/examples/animation/piemenu/piemenu.pro new file mode 100644 index 0000000..4d7a067 --- /dev/null +++ b/examples/animation/piemenu/piemenu.pro @@ -0,0 +1,8 @@ +SOURCES += \ + main.cpp \ + qgraphicspiemenu.cpp \ + scene.cpp +HEADERS += \ + qgraphicspiemenu.h \ + qgraphicspiemenu_p.h \ + scene.h diff --git a/examples/animation/piemenu/qgraphicspiemenu.cpp b/examples/animation/piemenu/qgraphicspiemenu.cpp new file mode 100644 index 0000000..c913423 --- /dev/null +++ b/examples/animation/piemenu/qgraphicspiemenu.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicspiemenu.h" +#include "qgraphicspiemenu_p.h" + +#include + +QGraphicsPieMenu::QGraphicsPieMenu(QGraphicsItem *parent) + : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) +{ + d_ptr->q_ptr = this; + d_ptr->machine = new QStateMachine(); + d_ptr->popupState = new QState(d_ptr->machine->rootState()); + d_ptr->machine->setInitialState(d_ptr->popupState); + d_ptr->menuAction = new QAction(this); +} + +QGraphicsPieMenu::QGraphicsPieMenu(const QString &title, QGraphicsItem *parent) + : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) +{ + d_ptr->q_ptr = this; + d_ptr->machine = new QStateMachine(); + d_ptr->popupState = new QState(d_ptr->machine->rootState()); + d_ptr->machine->setInitialState(d_ptr->popupState); + d_ptr->menuAction = new QAction(this); + setTitle(title); +} + +QGraphicsPieMenu::QGraphicsPieMenu(const QIcon &icon, const QString &title, QGraphicsItem *parent) + : QGraphicsWidget(parent), d_ptr(new QGraphicsPieMenuPrivate) +{ + d_ptr->q_ptr = this; + d_ptr->machine = new QStateMachine(); + d_ptr->popupState = new QState(d_ptr->machine->rootState()); + d_ptr->machine->setInitialState(d_ptr->popupState); + d_ptr->menuAction = new QAction(this); + setIcon(icon); + setTitle(title); +} + +QGraphicsPieMenu::~QGraphicsPieMenu() +{ + delete d_ptr; +} + +QAction *QGraphicsPieMenu::addAction(const QString &text) +{ + QAction *action = new QAction(text, this); + addAction(action); + return action; +} + +QAction *QGraphicsPieMenu::addAction(const QIcon &icon, const QString &text) +{ + QAction *action = new QAction(icon, text, this); + addAction(action); + return action; +} + +QAction *QGraphicsPieMenu::addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) +{ + QAction *action = new QAction(text, this); + action->setShortcut(shortcut); + connect(action, SIGNAL(triggered(bool)), receiver, member); + addAction(action); + return action; +} + +QAction *QGraphicsPieMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut) +{ + QAction *action = new QAction(icon, text, this); + action->setShortcut(shortcut); + connect(action, SIGNAL(triggered(bool)), receiver, member); + addAction(action); + return action; +} + +QAction *QGraphicsPieMenu::addMenu(QGraphicsPieMenu *menu) +{ + QAction *action = menu->menuAction(); + addAction(action); + return action; +} + +QGraphicsPieMenu *QGraphicsPieMenu::addMenu(const QString &title) +{ + QGraphicsPieMenu *menu = new QGraphicsPieMenu(title, this); + addMenu(menu); + return menu; +} + +QGraphicsPieMenu *QGraphicsPieMenu::addMenu(const QIcon &icon, const QString &title) +{ + QGraphicsPieMenu *menu = new QGraphicsPieMenu(icon, title, this); + addMenu(menu); + return menu; +} + +QAction *QGraphicsPieMenu::addSeparator() +{ + QAction *action = new QAction(this); + action->setSeparator(true); + addAction(action); + return action; +} + +QAction *QGraphicsPieMenu::insertMenu(QAction *before, QGraphicsPieMenu *menu) +{ + QAction *action = menu->menuAction(); + insertAction(before, action); + return action; +} + +QAction *QGraphicsPieMenu::insertSeparator(QAction *before) +{ + QAction *action = new QAction(this); + action->setSeparator(true); + insertAction(before, action); + return action; +} + +QAction *QGraphicsPieMenu::menuAction() const +{ + return d_func()->menuAction; +} + +bool QGraphicsPieMenu::isEmpty() const +{ + // ### d->actions + QList actionList = actions(); + bool ret = true; + for (int i = 0; ret && i < actionList.size(); ++i) { + const QAction *action = actionList.at(i); + if (!action->isSeparator() && action->isVisible()) { + ret = false; + break; + } + } + return ret; +} + +void QGraphicsPieMenu::clear() +{ + // ### d->actions + QList actionList = actions(); + for(int i = 0; i < actionList.size(); i++) { + QAction *action = actionList.at(i); + removeAction(action); + if (action->parent() == this && action->associatedGraphicsWidgets().isEmpty()) + delete action; + } +} + +void QGraphicsPieMenu::popup(const QPointF &pos) +{ + Q_UNUSED(pos); + Q_D(QGraphicsPieMenu); + d->machine->start(); +} + +QAction *QGraphicsPieMenu::exec() +{ + return exec(pos()); +} + +QAction *QGraphicsPieMenu::exec(const QPointF &pos) +{ + Q_UNUSED(pos); + return 0; +} + +QAction *QGraphicsPieMenu::exec(QList actions, const QPointF &pos) +{ + QGraphicsPieMenu menu; + for (QList::ConstIterator it = actions.constBegin(); it != actions.constEnd(); ++it) + menu.addAction(*it); + return menu.exec(pos); +} + +QString QGraphicsPieMenu::title() const +{ + Q_D(const QGraphicsPieMenu); + return d->title; +} + +void QGraphicsPieMenu::setTitle(const QString &title) +{ + Q_D(QGraphicsPieMenu); + d->title = title; + updateGeometry(); +} + +QIcon QGraphicsPieMenu::icon() const +{ + Q_D(const QGraphicsPieMenu); + return d->icon; +} + +void QGraphicsPieMenu::setIcon(const QIcon &icon) +{ + Q_D(QGraphicsPieMenu); + d->icon = icon; + updateGeometry(); +} + +QSizeF QGraphicsPieMenu::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ + Q_UNUSED(which); + Q_UNUSED(constraint); + return QSizeF(1, 1); +} diff --git a/examples/animation/piemenu/qgraphicspiemenu.h b/examples/animation/piemenu/qgraphicspiemenu.h new file mode 100644 index 0000000..68b4ba9 --- /dev/null +++ b/examples/animation/piemenu/qgraphicspiemenu.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSPIEMENU_H +#define QGRAPHICSPIEMENU_H + +#include + +class QGraphicsPieMenuPrivate; +class QGraphicsPieMenu : public QGraphicsWidget +{ + Q_OBJECT +public: + QGraphicsPieMenu(QGraphicsItem *parent = 0); + QGraphicsPieMenu(const QString &title, QGraphicsItem *parent = 0); + QGraphicsPieMenu(const QIcon &icon, const QString &title, QGraphicsItem *parent = 0); + ~QGraphicsPieMenu(); + +#ifdef Q_NO_USING_KEYWORD + inline void addAction(QAction *action) { QGraphicsWidget::addAction(action); } +#else + using QGraphicsWidget::addAction; +#endif + QAction *addAction(const QString &text); + QAction *addAction(const QIcon &icon, const QString &text); + QAction *addAction(const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); + QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char *member, const QKeySequence &shortcut = 0); + QAction *addMenu(QGraphicsPieMenu *menu); + QGraphicsPieMenu *addMenu(const QString &title); + QGraphicsPieMenu *addMenu(const QIcon &icon, const QString &title); + QAction *addSeparator(); + QAction *insertMenu(QAction *before, QGraphicsPieMenu *menu); + QAction *insertSeparator(QAction *before); + + QAction *menuAction() const; + + bool isEmpty() const; + void clear(); + + void popup(const QPointF &pos); + QAction *exec(); + QAction *exec(const QPointF &pos); + static QAction *exec(QList actions, const QPointF &pos); + + QString title() const; + void setTitle(const QString &title); + + QIcon icon() const; + void setIcon(const QIcon &icon); + +Q_SIGNALS: + void aboutToShow(); + void aboutToHide(); + void triggered(QAction *action); + void hovered(QAction *action); + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + +private: + Q_DISABLE_COPY(QGraphicsPieMenu) + Q_DECLARE_PRIVATE(QGraphicsPieMenu) + QGraphicsPieMenuPrivate *d_ptr; +}; + +#endif diff --git a/examples/animation/piemenu/qgraphicspiemenu_p.h b/examples/animation/piemenu/qgraphicspiemenu_p.h new file mode 100644 index 0000000..87a749c --- /dev/null +++ b/examples/animation/piemenu/qgraphicspiemenu_p.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSPIEMENU_P_H +#define QGRAPHICSPIEMENU_P_H + +#include "qgraphicspiemenu.h" +#include "qgraphicspiemenusection_p.h" + +#include +#include +#include +#include + +class QAction; +class QEventLoop; +class QGraphicsPieMenuSection; + +class QGraphicsPieMenuPrivate +{ + Q_DECLARE_PUBLIC(QGraphicsPieMenu); +public: + void init(const QIcon &icon = QIcon(), const QString &title = QString()); + + QIcon icon; + QString title; + QStateMachine *machine; + QState *popupState; + //QTransition *transition; + QList sections; + + QEventLoop *eventLoop; + + QAction *menuAction; + QGraphicsPieMenu *q_ptr; + + void updatePopupState(); +}; + +#endif diff --git a/examples/animation/piemenu/qgraphicspiemenusection_p.h b/examples/animation/piemenu/qgraphicspiemenusection_p.h new file mode 100644 index 0000000..328f742 --- /dev/null +++ b/examples/animation/piemenu/qgraphicspiemenusection_p.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef QGRAPHICSPIEMENUSECTION_H +#define QGRAPHICSPIEMENUSECTION_H + +#include +#include + +class QGraphicsPieMenuSection : public QGraphicsWidget +{ + Q_OBJECT + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) +public: + QGraphicsPieMenuSection(QGraphicsItem *parent = 0) + : QGraphicsWidget(parent), rot(0) + { } + + qreal rotation() const + { + return rot; + } + void setRotation(qreal rotation) + { + rot = rotation; + setTransform(QTransform().rotate(rot)); + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) + { + Q_UNUSED(option); + Q_UNUSED(widget); + painter->setPen(QPen(Qt::black, 1)); + painter->setBrush(QBrush(Qt::gray)); + painter->drawPie(QRectF(-100, -100, 200, 200), 0, -30 * 16); + } + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &size = QSizeF()) const + { + Q_UNUSED(which); + Q_UNUSED(size); + return QSizeF(100, 30); + } + +private: + qreal rot; +}; + +#endif diff --git a/examples/animation/piemenu/scene.cpp b/examples/animation/piemenu/scene.cpp new file mode 100644 index 0000000..08aad06 --- /dev/null +++ b/examples/animation/piemenu/scene.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include "qgraphicspiemenu.h" +#include "scene.h" + +#include +#include + +Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent) + : QGraphicsScene(x, y, width, height, parent) +{ +} + +Scene::Scene(const QRectF &sceneRect, QObject *parent) + : QGraphicsScene(sceneRect, parent) +{ +} + +Scene::Scene(QObject *parent) + : QGraphicsScene(parent) +{ +} + +Scene::~Scene() +{ +} + +void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + QGraphicsPieMenu *menu = new QGraphicsPieMenu; + for (int i = 0; i < 5; ++i) + menu->addAction(new QAction(QString("Item %1").arg(i), menu)); + menu->popup(event->scenePos()); +} diff --git a/examples/animation/piemenu/scene.h b/examples/animation/piemenu/scene.h new file mode 100644 index 0000000..676f55f --- /dev/null +++ b/examples/animation/piemenu/scene.h @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef SCENE_H +#define SCENE_H + +#include + +class Scene : public QGraphicsScene +{ + Q_OBJECT +public: + Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0); + Scene(const QRectF &sceneRect, QObject *parent = 0); + Scene(QObject *parent = 0); + ~Scene(); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); +}; + +#endif diff --git a/examples/animation/research/memberfunctions/main.cpp b/examples/animation/research/memberfunctions/main.cpp new file mode 100644 index 0000000..9142f29 --- /dev/null +++ b/examples/animation/research/memberfunctions/main.cpp @@ -0,0 +1,48 @@ +#include +#include "qvalueanimation.h" + +AbstractProperty *qGraphicsItemProperty(QGraphicsItem *item, const char *property) +{ + if (qstrcmp(property, "pos") == 0) { + return new MemberFunctionProperty(item, &QGraphicsItem::pos, &QGraphicsItem::setPos); + } + return 0; +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsItem *item = new QGraphicsRectItem(QRectF(0,0, 200, 100)); + scene.addItem(item); + + QValueAnimation *posAnim = new QValueAnimation; + posAnim->setStartValue(QPointF(0,0)); + posAnim->setEndValue(QPointF(400, 0)); + posAnim->setDuration(1000); + // Alternative 1 + //posAnim->setMemberFunction(item, &QGraphicsItem::pos, &QGraphicsItem::setPos); + + // Alternative 2 + //posAnim->setProperty(qMemberFunctionProperty(item, &QGraphicsItem::pos, &QGraphicsItem::setPos)); + + // Alternative 3 + posAnim->setProperty(qGraphicsItemProperty(item, "pos")); + + // Alternative 4, (by implementing the qGraphicsItemProperty QGraphicsItem::property()) + //posAnim->setProperty(item->property("pos")); + + // can also do this, which abstracts away the whole property thing. + // i.e. this interface can also be used for QObject-properties: + //posAnim->setAnimationProperty(animationProperty); + + posAnim->start(); + + view.resize(800,600); + view.show(); + return app.exec(); +} + diff --git a/examples/animation/research/memberfunctions/memberfunctions.pro b/examples/animation/research/memberfunctions/memberfunctions.pro new file mode 100644 index 0000000..6b67895 --- /dev/null +++ b/examples/animation/research/memberfunctions/memberfunctions.pro @@ -0,0 +1,16 @@ +###################################################################### +# Automatically generated by qmake (2.01a) fr 26. sep 13:21:57 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp \ + qvalueanimation.cpp +HEADERS += qvalueanimation.h + +CONFIG += console + diff --git a/examples/animation/research/memberfunctions/qvalueanimation.cpp b/examples/animation/research/memberfunctions/qvalueanimation.cpp new file mode 100644 index 0000000..2fe9be9 --- /dev/null +++ b/examples/animation/research/memberfunctions/qvalueanimation.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + + + +#include "qvalueanimation.h" +#include "qvalueanimation_p.h" + +QT_BEGIN_NAMESPACE + + +void QValueAnimationPrivate::initDefaultStartValue() +{ + Q_Q(QValueAnimation); + if (animProp && !q->startValue().isValid() + && ((currentTime == 0 && (currentIteration || currentIteration == 0)) + || (currentTime == duration && currentIteration == (iterationCount - 1)))) { + setDefaultStartValue(animProp->read()); + } +} + + +QValueAnimation::QValueAnimation(QObject *parent) : QVariantAnimation(*new QValueAnimationPrivate, parent) +{ +} + +QValueAnimation::~QValueAnimation() +{ +} + +void QValueAnimation::setProperty(AbstractProperty *animProp) +{ + Q_D(QValueAnimation); + d->animProp = animProp; +} + +/*! + \reimp + */ +void QValueAnimation::updateCurrentValue(const QVariant &value) +{ + Q_D(QValueAnimation); + if (state() == QAbstractAnimation::Stopped) + return; + + d->animProp->write(value); +} + + +/*! + \reimp +*/ +void QValueAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) +{ + Q_D(QValueAnimation); + // Initialize start value + if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) + d->initDefaultStartValue(); +} + + + +#include "moc_qvalueanimation.cpp" + +QT_END_NAMESPACE diff --git a/examples/animation/research/memberfunctions/qvalueanimation.h b/examples/animation/research/memberfunctions/qvalueanimation.h new file mode 100644 index 0000000..a4aa213 --- /dev/null +++ b/examples/animation/research/memberfunctions/qvalueanimation.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef QVALUEANIMATION_H +#define QVALUEANIMATION_H + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qvariantanimation.h" +#else +# include +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QGraphicsItem; +class QValueAnimationPrivate; + +QT_MODULE(Gui) + +struct AbstractProperty { + virtual void write(const QVariant &value) = 0; + virtual QVariant read() const = 0; +}; + +# define CALL_MEMBER_FN(object,ptrToMember) ((object)->*(ptrToMember)) +template +class MemberFunctionProperty : public AbstractProperty { +public: + typedef void (Target::*RefWrite)(const T &); + typedef T (Target::*ValRead)(void) const; + + MemberFunctionProperty(Target *target, ValRead readFunc, RefWrite writeFunc) + : m_target(target), m_readFn(readFunc), m_writeFn(writeFunc) {} + + virtual void write(const QVariant &value) { + CALL_MEMBER_FN(m_target, m_writeFn)(qVariantValue(value)); + } + + virtual QVariant read() const { + if (m_readFn) + return qVariantFromValue(CALL_MEMBER_FN(m_target, m_readFn)()); + return QVariant(); + } + +private: + Target *m_target; + ValRead m_readFn; + RefWrite m_writeFn; +}; + + +class QValueAnimation : public QVariantAnimation +{ + Q_OBJECT + +public: + QValueAnimation(QObject *parent = 0); + ~QValueAnimation(); + + template + void setMemberFunction(Target *target, + T (Target::*readFunc)(void) const, // ### useValRead typedef + void (Target::*writeFunc)(const T &) // ### use RefWrite typedef + ) { + // ### ownership of MemberFunctionProperty + AbstractProperty *animProp = new MemberFunctionProperty(target, readFunc, writeFunc); + setProperty(animProp); + } + + void updateCurrentValue(const QVariant &value); + void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); + void setProperty(AbstractProperty *animProp); + +private: + Q_DISABLE_COPY(QValueAnimation); + Q_DECLARE_PRIVATE(QValueAnimation); +}; + +#endif // QVALUEANIMATION_H diff --git a/examples/animation/research/memberfunctions/qvalueanimation_p.h b/examples/animation/research/memberfunctions/qvalueanimation_p.h new file mode 100644 index 0000000..e6e7682 --- /dev/null +++ b/examples/animation/research/memberfunctions/qvalueanimation_p.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#ifndef QVALUEANIMATION_P_H +#define QVALUEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of QIODevice. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include //### + +QT_BEGIN_NAMESPACE + +class QValueAnimationPrivate : public QVariantAnimationPrivate +{ + Q_DECLARE_PUBLIC(QValueAnimation) +public: + QValueAnimationPrivate() : QVariantAnimationPrivate(), animProp(0) + { + } + + void initDefaultStartValue(); + + AbstractProperty *animProp; + + //###TODO +}; + +QT_END_NAMESPACE + +#endif //QVALUEANIMATION_P_H diff --git a/examples/animation/research/propertytransform/main.cpp b/examples/animation/research/propertytransform/main.cpp new file mode 100644 index 0000000..80002c9 --- /dev/null +++ b/examples/animation/research/propertytransform/main.cpp @@ -0,0 +1,47 @@ +#include + +#include "qpropertytransform.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsItem *item = new QGraphicsRectItem(QRectF(0,0, 200, 100)); + scene.addItem(item); + QPropertyTransform transform; + transform.setTargetItem(item); + + QAnimationGroup *group = new QAnimationGroup(QAnimationGroup::Parallel, &scene); + QPropertyAnimation *scaleAnim = new QPropertyAnimation(&transform, "scaleX"); + scaleAnim->setStartValue(1.0); + scaleAnim->setTargetValue(2.0); + scaleAnim->setDuration(10000); + group->add(scaleAnim); + + QPropertyAnimation *scaleAnim2 = new QPropertyAnimation(&transform, "scaleY"); + scaleAnim2->setStartValue(.0); + scaleAnim2->setTargetValue(2.0); + scaleAnim2->setDuration(10000); + QEasingCurve curve(QEasingCurve::InElastic); + curve.setPeriod(2); + curve.setAmplitude(2); + + //scaleAnim2->setEasingCurve(curve); + //scaleAnim2->setEasingCurve(QEasingCurve(QEasingCurve::OutElastic , 2, 2 )); + group->add(scaleAnim2); + + QPropertyAnimation *rotAnim = new QPropertyAnimation(&transform, "rotation"); + rotAnim->setStartValue(0); + rotAnim->setTargetValue(90); + rotAnim->setDuration(10000); + group->add(rotAnim); + + group->start(); + + view.resize(800,600); + view.show(); + return app.exec(); +} diff --git a/examples/animation/research/propertytransform/propertytransform.pro b/examples/animation/research/propertytransform/propertytransform.pro new file mode 100644 index 0000000..94c36b8 --- /dev/null +++ b/examples/animation/research/propertytransform/propertytransform.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) fr 26. sep 13:21:57 2008 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp +HEADERS += qpropertytransform.h +CONFIG += console + diff --git a/examples/animation/research/propertytransform/qpropertytransform.h b/examples/animation/research/propertytransform/qpropertytransform.h new file mode 100644 index 0000000..e052625 --- /dev/null +++ b/examples/animation/research/propertytransform/qpropertytransform.h @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include + +/** + * Experimental. + * Pros: + * 1. Does not add ugly/confusing API to QGraphicsItem. + * + * Cons: + * 1. apply() /m_item->setTransform() is called too many times. (FIXED NOW?) + * + * + */ +class QPropertyTransform : public QObject { + Q_OBJECT +public: + Q_PROPERTY(QPointF center READ center WRITE setCenter); + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation); + Q_PROPERTY(qreal scaleX READ scaleX WRITE setScaleX); + Q_PROPERTY(qreal scaleY READ scaleY WRITE setScaleY); +public: + QPropertyTransform() : m_item(0), m_rotationZ(0), m_scaleX(1.), m_scaleY(1.) {} + + void setTargetItem(QGraphicsItem *item) { + m_item = item; + } + + void setCenter(const QPointF ¢er) { + m_center = center; + apply(); + } + + QPointF center() const { return m_center; } + + void setRotation(qreal rotation) { + m_rotationZ = rotation; + apply(); + } + + qreal rotation() const { return m_rotationZ; } + + void setScaleX(qreal scale) { + m_scaleX = scale; + apply(); + } + + qreal scaleX() const { return m_scaleX; } + + void setScaleY(qreal scale) { + m_scaleY = scale; + apply(); + } + + qreal scaleY() const { return m_scaleY; } + +private: + QTransform transform() const { + return QTransform().translate(m_center.x(), m_center.y()) + .rotate(m_rotationZ) + .scale(m_scaleX, m_scaleY) + .translate(-m_center.x(), -m_center.y()); + } + + void apply() { + if (m_item) + m_item->setTransform(transform()); + } + + QGraphicsItem *m_item; + QPointF m_center; + qreal m_rotationZ; + qreal m_scaleX; + qreal m_scaleY; +}; + diff --git a/examples/animation/research/sound/main.cpp b/examples/animation/research/sound/main.cpp new file mode 100644 index 0000000..2c9fa47 --- /dev/null +++ b/examples/animation/research/sound/main.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +//The purpose of this example is to show that it is possible to have your own +// animation with undefined duration + +#include +#include + +class SoundAnimation : public QAbstractAnimation +{ +public: + SoundAnimation(const QString &file) + { + //in an idea case we should also control the errors + Phonon::createPath(&m_media, &m_audio); + m_media.setCurrentSource(file); + connect(&m_media, SIGNAL(finished()), SLOT(stop())); + } + + int duration() const + { + return -1; + } + + void updateCurrentTime(int msecs) + { + //nothing to do here... + qDebug() << "updateCurrentTime" << msecs; + } + + void updateState(State state) + { + switch(state) + { + case Running: + m_media.play(); + break; + case Stopped: + m_media.stop(); + break; + case Paused: + m_media.pause(); + break; + } + } + + +private: + Phonon::MediaObject m_media; + Phonon::AudioOutput m_audio; + +}; + + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(sound); + + SoundAnimation anim(QLatin1String(":/media/sax.mp3")); + app.connect(&anim, SIGNAL(finished()), SLOT(quit())); + anim.start(); + + return app.exec(); +} \ No newline at end of file diff --git a/examples/animation/research/sound/media/sax.mp3 b/examples/animation/research/sound/media/sax.mp3 new file mode 100644 index 0000000..0a078b1 Binary files /dev/null and b/examples/animation/research/sound/media/sax.mp3 differ diff --git a/examples/animation/research/sound/sound.pro b/examples/animation/research/sound/sound.pro new file mode 100644 index 0000000..0ad3050 --- /dev/null +++ b/examples/animation/research/sound/sound.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) mer. 21. janv. 13:53:26 2009 +###################################################################### + +TEMPLATE = app +QT += phonon +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +RESOURCES = sound.qrc + +# Input +SOURCES += main.cpp diff --git a/examples/animation/research/sound/sound.qrc b/examples/animation/research/sound/sound.qrc new file mode 100644 index 0000000..8919142 --- /dev/null +++ b/examples/animation/research/sound/sound.qrc @@ -0,0 +1,5 @@ + + +media/sax.mp3 + + diff --git a/examples/animation/states/accessories-dictionary.png b/examples/animation/states/accessories-dictionary.png new file mode 100644 index 0000000..e9bd55d Binary files /dev/null and b/examples/animation/states/accessories-dictionary.png differ diff --git a/examples/animation/states/akregator.png b/examples/animation/states/akregator.png new file mode 100644 index 0000000..a086f45 Binary files /dev/null and b/examples/animation/states/akregator.png differ diff --git a/examples/animation/states/digikam.png b/examples/animation/states/digikam.png new file mode 100644 index 0000000..9de9fb2 Binary files /dev/null and b/examples/animation/states/digikam.png differ diff --git a/examples/animation/states/help-browser.png b/examples/animation/states/help-browser.png new file mode 100644 index 0000000..db92faa Binary files /dev/null and b/examples/animation/states/help-browser.png differ diff --git a/examples/animation/states/k3b.png b/examples/animation/states/k3b.png new file mode 100644 index 0000000..bbcafcf Binary files /dev/null and b/examples/animation/states/k3b.png differ diff --git a/examples/animation/states/kchart.png b/examples/animation/states/kchart.png new file mode 100644 index 0000000..1dd115b Binary files /dev/null and b/examples/animation/states/kchart.png differ diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp new file mode 100644 index 0000000..5c004a2 --- /dev/null +++ b/examples/animation/states/main.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +****************************************************************************/ + +#include +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qstate.h" +# include "qstatemachine.h" +# include "qtransition.h" +# include "qparallelanimationgroup.h" +# include "qsequentialanimationgroup.h" +# include "qpropertyanimation.h" +#endif + +class Pixmap : public QGraphicsWidget +{ + Q_OBJECT +public: + Pixmap(const QPixmap &pix) : QGraphicsWidget(), p(pix) + { + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->drawPixmap(QPointF(), p); + } + +protected: + QSizeF sizeHint(Qt::SizeHint, const QSizeF & = QSizeF()) + { + return QSizeF(p.width(), p.height()); + } + +private: + QPixmap p; +}; + +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 *root = machine.rootState(); + QState *state1 = new QState(root); + QState *state2 = new QState(root); + QState *state3 = new QState(root); + machine.setInitialState(state1); + + // State 1 + state1->setPropertyOnEntry(button, "text", "Switch to state 2"); + state1->setPropertyOnEntry(widget, "geometry", QRectF(0, 0, 400, 150)); + state1->setPropertyOnEntry(box, "geometry", QRect(-200, 150, 200, 150)); + state1->setPropertyOnEntry(p1, "geometry", QRectF(68, 185, 64, 64)); + state1->setPropertyOnEntry(p2, "geometry", QRectF(168, 185, 64, 64)); + state1->setPropertyOnEntry(p3, "geometry", QRectF(268, 185, 64, 64)); + state1->setPropertyOnEntry(p4, "geometry", QRectF(68-150, 48-150, 64, 64)); + state1->setPropertyOnEntry(p5, "geometry", QRectF(168, 48-150, 64, 64)); + state1->setPropertyOnEntry(p6, "geometry", QRectF(268+150, 48-150, 64, 64)); + state1->setPropertyOnEntry(p1, "zRotation", qreal(0)); + state1->setPropertyOnEntry(p2, "zRotation", qreal(0)); + state1->setPropertyOnEntry(p3, "zRotation", qreal(0)); + state1->setPropertyOnEntry(p4, "zRotation", qreal(-270)); + state1->setPropertyOnEntry(p5, "zRotation", qreal(-90)); + state1->setPropertyOnEntry(p6, "zRotation", qreal(270)); + state1->setPropertyOnEntry(boxProxy, "opacity", qreal(0)); + state1->setPropertyOnEntry(p1, "opacity", qreal(1)); + state1->setPropertyOnEntry(p2, "opacity", qreal(1)); + state1->setPropertyOnEntry(p3, "opacity", qreal(1)); + state1->setPropertyOnEntry(p4, "opacity", qreal(0)); + state1->setPropertyOnEntry(p5, "opacity", qreal(0)); + state1->setPropertyOnEntry(p6, "opacity", qreal(0)); + + // State 2 + state2->setPropertyOnEntry(button, "text", "Switch to state 3"); + state2->setPropertyOnEntry(widget, "geometry", QRectF(200, 150, 200, 150)); + state2->setPropertyOnEntry(box, "geometry", QRect(9, 150, 190, 150)); + state2->setPropertyOnEntry(p1, "geometry", QRectF(68-150, 185+150, 64, 64)); + state2->setPropertyOnEntry(p2, "geometry", QRectF(168, 185+150, 64, 64)); + state2->setPropertyOnEntry(p3, "geometry", QRectF(268+150, 185+150, 64, 64)); + state2->setPropertyOnEntry(p4, "geometry", QRectF(64, 48, 64, 64)); + state2->setPropertyOnEntry(p5, "geometry", QRectF(168, 48, 64, 64)); + state2->setPropertyOnEntry(p6, "geometry", QRectF(268, 48, 64, 64)); + state2->setPropertyOnEntry(p1, "zRotation", qreal(-270)); + state2->setPropertyOnEntry(p2, "zRotation", qreal(90)); + state2->setPropertyOnEntry(p3, "zRotation", qreal(270)); + state2->setPropertyOnEntry(p4, "zRotation", qreal(0)); + state2->setPropertyOnEntry(p5, "zRotation", qreal(0)); + state2->setPropertyOnEntry(p6, "zRotation", qreal(0)); + state2->setPropertyOnEntry(boxProxy, "opacity", qreal(1)); + state2->setPropertyOnEntry(p1, "opacity", qreal(0)); + state2->setPropertyOnEntry(p2, "opacity", qreal(0)); + state2->setPropertyOnEntry(p3, "opacity", qreal(0)); + state2->setPropertyOnEntry(p4, "opacity", qreal(1)); + state2->setPropertyOnEntry(p5, "opacity", qreal(1)); + state2->setPropertyOnEntry(p6, "opacity", qreal(1)); + + // State 3 + state3->setPropertyOnEntry(button, "text", "Switch to state 1"); + state3->setPropertyOnEntry(p1, "geometry", QRectF(5, 5, 64, 64)); + state3->setPropertyOnEntry(p2, "geometry", QRectF(5, 5 + 64 + 5, 64, 64)); + state3->setPropertyOnEntry(p3, "geometry", QRectF(5, 5 + (64 + 5) + 64, 64, 64)); + state3->setPropertyOnEntry(p4, "geometry", QRectF(5 + 64 + 5, 5, 64, 64)); + state3->setPropertyOnEntry(p5, "geometry", QRectF(5 + 64 + 5, 5 + 64 + 5, 64, 64)); + state3->setPropertyOnEntry(p6, "geometry", QRectF(5 + 64 + 5, 5 + (64 + 5) + 64, 64, 64)); + state3->setPropertyOnEntry(widget, "geometry", QRectF(138, 5, 400 - 138, 200)); + state3->setPropertyOnEntry(box, "geometry", QRect(5, 205, 400, 90)); + state3->setPropertyOnEntry(p1, "opacity", qreal(1)); + state3->setPropertyOnEntry(p2, "opacity", qreal(1)); + state3->setPropertyOnEntry(p3, "opacity", qreal(1)); + state3->setPropertyOnEntry(p4, "opacity", qreal(1)); + state3->setPropertyOnEntry(p5, "opacity", qreal(1)); + state3->setPropertyOnEntry(p6, "opacity", qreal(1)); + + QParallelAnimationGroup animation1; + + QSequentialAnimationGroup *animation1SubGroup; + animation1SubGroup = new QSequentialAnimationGroup(&animation1); + animation1SubGroup->addPause(250); + animation1SubGroup->addAnimation(new QPropertyAnimation(box, "geometry")); + + animation1.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation1.addAnimation(new QPropertyAnimation(p1, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p2, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p3, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p4, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p5, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p6, "zRotation")); + animation1.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation1.addAnimation(new QPropertyAnimation(p6, "opacity")); + + QParallelAnimationGroup animation2; + animation2.addAnimation(new QPropertyAnimation(box, "geometry")); + animation2.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation2.addAnimation(new QPropertyAnimation(p1, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p2, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p3, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p4, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p5, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p6, "zRotation")); + animation2.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation2.addAnimation(new QPropertyAnimation(p6, "opacity")); + + QParallelAnimationGroup animation3; + animation3.addAnimation(new QPropertyAnimation(box, "geometry")); + animation3.addAnimation(new QPropertyAnimation(widget, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p1, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p2, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p3, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p4, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p5, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p6, "geometry")); + animation3.addAnimation(new QPropertyAnimation(p1, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p2, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p3, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p4, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p5, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p6, "zRotation")); + animation3.addAnimation(new QPropertyAnimation(p1, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p2, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p3, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p4, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p5, "opacity")); + animation3.addAnimation(new QPropertyAnimation(p6, "opacity")); + + state1->addAnimatedTransition(button, SIGNAL(clicked()), state2, &animation1); + state2->addAnimatedTransition(button, SIGNAL(clicked()), state3, &animation2); + state3->addAnimatedTransition(button, SIGNAL(clicked()), state1, &animation3); + + machine.start(); + + QGraphicsView view(&scene); + view.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/animation/states/states.pro b/examples/animation/states/states.pro new file mode 100644 index 0000000..f4d1e0b --- /dev/null +++ b/examples/animation/states/states.pro @@ -0,0 +1,8 @@ +SOURCES += main.cpp +RESOURCES += states.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/animation/states +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS states.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/animation/states +INSTALLS += target sources diff --git a/examples/animation/states/states.qrc b/examples/animation/states/states.qrc new file mode 100644 index 0000000..60ab3f7 --- /dev/null +++ b/examples/animation/states/states.qrc @@ -0,0 +1,10 @@ + + + accessories-dictionary.png + akregator.png + digikam.png + help-browser.png + k3b.png + kchart.png + + diff --git a/examples/animation/stickman/animation.cpp b/examples/animation/stickman/animation.cpp new file mode 100644 index 0000000..998632a --- /dev/null +++ b/examples/animation/stickman/animation.cpp @@ -0,0 +1,152 @@ +#include "animation.h" + +#include +#include +#include + +class Frame +{ +public: + Frame() { + } + + int nodeCount() const + { + return m_nodePositions.size(); + } + + void setNodeCount(int nodeCount) + { + while (nodeCount > m_nodePositions.size()) + m_nodePositions.append(QPointF()); + + while (nodeCount < m_nodePositions.size()) + m_nodePositions.removeLast(); + } + + 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(); +} + +int Animation::totalFrames() const +{ + return m_frames.size(); +} + +void Animation::setCurrentFrame(int currentFrame) +{ + m_currentFrame = qMax(qMin(currentFrame, totalFrames()-1), 0); +} + +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(); + foreach (Frame *frame, m_frames) { + stream << frame->nodeCount(); + for (int i=0; inodeCount(); ++i) + stream << frame->nodePos(i); + } +} + +void Animation::load(QIODevice *device) +{ + if (!m_frames.isEmpty()) + qDeleteAll(m_frames); + + m_frames.clear(); + + QDataStream stream(device); + stream >> m_name; + + int frameCount; + stream >> frameCount; + + for (int i=0; i> nodeCount; + + Frame *frame = new Frame; + frame->setNodeCount(nodeCount); + + for (int j=0; j> pos; + + frame->setNodePos(j, pos); + } + + m_frames.append(frame); + } +} \ No newline at end of file diff --git a/examples/animation/stickman/animation.h b/examples/animation/stickman/animation.h new file mode 100644 index 0000000..22afab6 --- /dev/null +++ b/examples/animation/stickman/animation.h @@ -0,0 +1,40 @@ +#ifndef ANIMATION_H +#define ANIMATION_H + +#include +#include +#include + +class Frame; +class QIODevice; +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/animation/stickman/animations/chilling b/examples/animation/stickman/animations/chilling new file mode 100644 index 0000000..a81fc7a Binary files /dev/null and b/examples/animation/stickman/animations/chilling differ diff --git a/examples/animation/stickman/animations/dancing b/examples/animation/stickman/animations/dancing new file mode 100644 index 0000000..462f66f Binary files /dev/null and b/examples/animation/stickman/animations/dancing differ diff --git a/examples/animation/stickman/animations/dead b/examples/animation/stickman/animations/dead new file mode 100644 index 0000000..9859b4b Binary files /dev/null and b/examples/animation/stickman/animations/dead differ diff --git a/examples/animation/stickman/animations/jumping b/examples/animation/stickman/animations/jumping new file mode 100644 index 0000000..12661a1 Binary files /dev/null and b/examples/animation/stickman/animations/jumping differ diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp new file mode 100644 index 0000000..1b6afa9 --- /dev/null +++ b/examples/animation/stickman/graphicsview.cpp @@ -0,0 +1,15 @@ +#include "graphicsview.h" + +#include + +GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent) {} + +void GraphicsView::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Escape) + close(); + + emit keyPressed(Qt::Key(e->key())); +} + + diff --git a/examples/animation/stickman/graphicsview.h b/examples/animation/stickman/graphicsview.h new file mode 100644 index 0000000..9ea2cfb --- /dev/null +++ b/examples/animation/stickman/graphicsview.h @@ -0,0 +1,19 @@ +#ifndef GRAPHICSVIEW_H +#define GRAPHICSVIEW + +#include + +class GraphicsView: public QGraphicsView +{ + Q_OBJECT +public: + GraphicsView(QWidget *parent = 0); + +protected: + void keyPressEvent(QKeyEvent *); + +signals: + void keyPressed(int key); +}; + +#endif diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp new file mode 100644 index 0000000..3e92aec --- /dev/null +++ b/examples/animation/stickman/lifecycle.cpp @@ -0,0 +1,176 @@ +#include "lifecycle.h" +#include "stickman.h" +#include "node.h" +#include "animation.h" +#include "graphicsview.h" + +#include +#include + +class KeyPressTransition: public QSignalTransition +{ +public: + KeyPressTransition(GraphicsView *receiver, Qt::Key key) + : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + { + } + KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) + : QSignalTransition(receiver, SIGNAL(keyPressed(int)), QList() << target), m_key(key) + { + } + + virtual bool eventTest(QEvent *e) const + { + 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; +}; + +class LightningStrikesTransition: public QEventTransition +{ +public: + LightningStrikesTransition(QAbstractState *target) + : QEventTransition(this, QEvent::Timer, QList() << target) + { + qsrand((uint)QDateTime::currentDateTime().toTime_t()); + startTimer(1000); + } + + virtual bool eventTest(QEvent *e) const + { + return QEventTransition::eventTest(e) && ((qrand() % 50) == 0); + } +}; + +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; inode(i), "position"); + m_animationGroup->addAnimation(pa); + } + + // Set up intial state graph + m_machine = new QStateMachine(); + m_machine->setGlobalRestorePolicy(QState::RestoreProperties); + + m_alive = new QState(m_machine->rootState()); + m_alive->setObjectName("alive"); + + // Make it blink when lightning strikes before entering dead animation + QState *lightningBlink = new QState(m_machine->rootState()); + lightningBlink->setRestorePolicy(QState::DoNotRestoreProperties); + lightningBlink->setPropertyOnEntry(m_stickMan->scene(), "backgroundBrush", Qt::white); + lightningBlink->setPropertyOnEntry(m_stickMan, "penColor", Qt::black); + lightningBlink->setPropertyOnEntry(m_stickMan, "fillColor", Qt::white); + lightningBlink->setPropertyOnEntry(m_stickMan, "isDead", true); + + m_dead = new QState(m_machine->rootState()); + m_dead->setRestorePolicy(QState::DoNotRestoreProperties); + m_dead->setPropertyOnEntry(m_stickMan->scene(), "backgroundBrush", Qt::black); + m_dead->setPropertyOnEntry(m_stickMan, "penColor", Qt::white); + m_dead->setPropertyOnEntry(m_stickMan, "fillColor", 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)); + m_alive->addTransition(new KeyPressTransition(m_keyReceiver, Qt::Key_L, lightningBlink)); + connectByAnimation(m_machine->rootState(), lightningBlink, m_dead); + + m_machine->setInitialState(m_alive); +} + +void LifeCycle::setResetKey(Qt::Key resetKey) +{ + // When resetKey is pressed, enter the idle state and do a restoration animation + // (requires no animation pointer, since no property is being set in the idle state) + m_alive->addAnimatedTransition(new KeyPressTransition(m_keyReceiver, resetKey, m_idle)); +} + +void LifeCycle::setDeathAnimation(const QString &fileName) +{ + QState *deathAnimation = makeState(m_dead, fileName); + m_dead->setInitialState(deathAnimation); +} + +void LifeCycle::start() +{ + m_machine->start(); +} + +void LifeCycle::connectByAnimation(QState *parentState, + QState *s1, QAbstractState *s2, + QAbstractTransition *transition) +{ + QAnimationState *animationState = new QAnimationState(m_animationGroup, parentState); + + if (transition == 0) + s1->addTransition(animationState); + else { + transition->setTargetStates(QList() << animationState); + s1->addTransition(transition); + } + + animationState->addFinishedTransition(s2); +} + +void LifeCycle::addActivity(const QString &fileName, Qt::Key key) +{ + QState *state = makeState(m_alive, fileName); + connectByAnimation(m_alive, m_alive, state, new KeyPressTransition(m_keyReceiver, key)); +} + +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 = 0; + for (int i=0; isetPropertyOnEntry(m_stickMan->node(j), "position", animation.nodePos(j)); + + if (previousState == 0) + topLevel->setInitialState(frameState); + else + connectByAnimation(topLevel, previousState, frameState); + previousState = frameState; + } + + // Loop + connectByAnimation(topLevel, previousState, topLevel->initialState()); + + return topLevel; + +} + +LifeCycle::~LifeCycle() +{ + delete m_machine; + delete m_animationGroup; +} diff --git a/examples/animation/stickman/lifecycle.h b/examples/animation/stickman/lifecycle.h new file mode 100644 index 0000000..8094a76 --- /dev/null +++ b/examples/animation/stickman/lifecycle.h @@ -0,0 +1,40 @@ +#ifndef LIFECYCLE_H +#define LIFECYCLE_H + +#include + +class StickMan; +class QStateMachine; +class QAnimationGroup; +class QState; +class QAbstractState; +class QAbstractTransition; +class GraphicsView; +class LifeCycle +{ +public: + LifeCycle(StickMan *stickMan, GraphicsView *keyEventReceiver); + ~LifeCycle(); + + void setDeathAnimation(const QString &fileName); + void setResetKey(Qt::Key key); + void addActivity(const QString &fileName, Qt::Key key); + + void start(); + +private: + void connectByAnimation(QState *parentState, QState *s1, QAbstractState *s2, + QAbstractTransition *transition = 0); + 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/animation/stickman/main.cpp b/examples/animation/stickman/main.cpp new file mode 100644 index 0000000..a094e28 --- /dev/null +++ b/examples/animation/stickman/main.cpp @@ -0,0 +1,58 @@ +#include "animation.h" +#include "node.h" +#include "lifecycle.h" +#include "stickman.h" +#include "graphicsview.h" + +#include +#include + +int main(int argc, char **argv) +{ + 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.
  • " + "
  • Press Return to make him return to his original position.
  • " + "
  • When you are done, press Escape.
  • " + "

    " + "

    If you are 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 = new QGraphicsScene(); + scene->addItem(stickMan); + scene->addItem(textItem); + scene->setBackgroundBrush(Qt::black); + + GraphicsView *view = new GraphicsView(); + view->setRenderHints(QPainter::Antialiasing); + view->setTransformationAnchor(QGraphicsView::NoAnchor); + view->setScene(scene); + view->showFullScreen(); + view->setFocus(); + view->setSceneRect(scene->sceneRect()); + + LifeCycle *cycle = new LifeCycle(stickMan, view); + cycle->setResetKey(Qt::Key_Return); + cycle->setDeathAnimation("animations/dead"); + + cycle->addActivity("animations/jumping", Qt::Key_J); + cycle->addActivity("animations/dancing", Qt::Key_D); + cycle->addActivity("animations/chilling", Qt::Key_C); + cycle->start(); + + return app.exec(); +} diff --git a/examples/animation/stickman/node.cpp b/examples/animation/stickman/node.cpp new file mode 100644 index 0000000..f3468d0 --- /dev/null +++ b/examples/animation/stickman/node.cpp @@ -0,0 +1,42 @@ +#include "node.h" + +#include +#include +#include + +Node::Node(const QPointF &pos, QGraphicsItem *parent) + : QGraphicsItem(parent), m_dragging(false) +{ + setPos(pos); +} + +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); +} + +void Node::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + m_dragging = true; +} + +void Node::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if (m_dragging) + setPos(mapToParent(event->pos())); +} + +void Node::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + m_dragging = false; +} \ No newline at end of file diff --git a/examples/animation/stickman/node.h b/examples/animation/stickman/node.h new file mode 100644 index 0000000..b796774 --- /dev/null +++ b/examples/animation/stickman/node.h @@ -0,0 +1,26 @@ +#ifndef NODE_H +#define NODE_H + +#include + +class Node: public QObject, public QGraphicsItem +{ + Q_OBJECT + Q_PROPERTY(QPointF position READ pos WRITE setPos); +public: + Node(const QPointF &pos, QGraphicsItem *parent = 0); + ~Node(); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *); + void mouseMoveEvent(QGraphicsSceneMouseEvent *); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *); + +private: + bool m_dragging; +}; + +#endif diff --git a/examples/animation/stickman/stickman.cpp b/examples/animation/stickman/stickman.cpp new file mode 100644 index 0000000..22d48d3 --- /dev/null +++ b/examples/animation/stickman/stickman.cpp @@ -0,0 +1,299 @@ +#include "stickman.h" +#include "node.h" + +#include +#include + +#define _USE_MATH_DEFINES +#include + +static const int NodeCount = 16; +static const 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 const int BoneCount = 24; +static const 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() +{ + m_nodes = new Node*[NodeCount]; + m_sticks = true; + m_isDead = false; + m_pixmap = QPixmap("images/head.png"); + m_penColor = Qt::white; + m_fillColor = Qt::black; + + // Set up start position of limbs + for (int i=0; ipos() - node2->pos(); + m_perfectBoneLengths[i] = sqrt(pow(dist.x(),2) + pow(dist.y(),2)); + } + + startTimer(10); +} + +StickMan::~StickMan() +{ + delete m_nodes; +} + +void StickMan::setDrawSticks(bool on) +{ + m_sticks = on; + for (int i=0;isetVisible(on); + } +} + +QRectF StickMan::boundingRect() const +{ + // account for head radius=50.0 plus pen which is 5.0, plus jump height :-) + return QRectF(-125, -200, 250, 450 + 50).adjusted(-55.0, -55.0, 55.0, 55.0); +} + +int StickMan::nodeCount() const +{ + return NodeCount; +} + +Node *StickMan::node(int idx) const +{ + const_cast(this)->prepareGeometryChange(); + if (idx >= 0 && idx < NodeCount) + return m_nodes[idx]; + else + return 0; +} + +void StickMan::timerEvent(QTimerEvent *e) +{ + prepareGeometryChange(); +} + +void StickMan::stabilize() +{ + for (int i=0; ipos(); + 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; + + pos1 -= dist * (0.5 * diff); + pos2 += dist * (0.5 * diff); + + 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; idrawLine(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 = asin(sinAngle) * 180.0 / M_PI; + + QPointF headPos = node1->pos(); + painter->save(); + painter->translate(headPos); + painter->rotate(-angle); + + painter->setBrush(m_fillColor); + painter->drawEllipse(QPointF(0,0), 50.0, 50.0); + + /*painter->drawArc(QRectF(-20.0, 0.0, 40.0, 20.0), 30.0 * 16, 120.0 * 16); + + painter->setBrush(m_penColor); + painter->drawEllipse(QPointF(-30.0, -30.0), 2.5, 2.5); + painter->drawEllipse(QPointF(30.0, -30.0), 2.5, 2.5);*/ + + 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); + } + + + painter->restore(); + } + } +} + + + diff --git a/examples/animation/stickman/stickman.h b/examples/animation/stickman/stickman.h new file mode 100644 index 0000000..ae406ca --- /dev/null +++ b/examples/animation/stickman/stickman.h @@ -0,0 +1,59 @@ +#ifndef STICKMAN_H +#define STICKMAN_H + +#include + +const int LimbCount = 16; + +class Node; +class QTimer; +class StickMan: public QObject, public QGraphicsItem +{ + 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(); + ~StickMan(); + + virtual QRectF boundingRect() const; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + 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(); + +protected: + void timerEvent(QTimerEvent *e); + +private: + QPointF posFor(int idx) const; + + Node **m_nodes; + qreal *m_perfectBoneLengths; + + uint m_sticks : 1; + uint m_isDead : 1; + uint m_reserved : 30; + + QPixmap m_pixmap; + QColor m_penColor; + QColor m_fillColor; +}; + +#endif // STICKMAN_H diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro new file mode 100644 index 0000000..136cb44 --- /dev/null +++ b/examples/animation/stickman/stickman.pro @@ -0,0 +1,12 @@ +###################################################################### +# Automatically generated by qmake (2.01a) ti 3. feb 19:50:14 2009 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += stickman.h animation.h node.h lifecycle.h graphicsview.h +SOURCES += main.cpp stickman.cpp animation.cpp node.cpp lifecycle.cpp graphicsview.cpp diff --git a/examples/animation/sub-attaq/animationmanager.cpp b/examples/animation/sub-attaq/animationmanager.cpp new file mode 100644 index 0000000..9f99426 --- /dev/null +++ b/examples/animation/sub-attaq/animationmanager.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "animationmanager.h" + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qabstractanimation.h" +#else +# include +#endif +#include + +// the universe's only animation manager +AnimationManager *AnimationManager::instance = 0; + +AnimationManager::AnimationManager() +{ +} + +AnimationManager *AnimationManager::self() +{ + if (!instance) + instance = new AnimationManager; + return instance; +} + +void AnimationManager::registerAnimation(QAbstractAnimation *anim) +{ + animations.append(anim); +} + +void AnimationManager::unregisterAnimation(QAbstractAnimation *anim) +{ + animations.removeAll(anim); +} + +void AnimationManager::unregisterAllAnimations() +{ + animations.clear(); +} + +void AnimationManager::pauseAll() +{ + foreach (QAbstractAnimation* animation, animations) + { + if (animation->state() == QAbstractAnimation::Running) + animation->pause(); + } +} +void AnimationManager::resumeAll() +{ + foreach (QAbstractAnimation* animation, animations) + { + if (animation->state() == QAbstractAnimation::Paused) + animation->resume(); + } +} diff --git a/examples/animation/sub-attaq/animationmanager.h b/examples/animation/sub-attaq/animationmanager.h new file mode 100644 index 0000000..fe92680 --- /dev/null +++ b/examples/animation/sub-attaq/animationmanager.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ANIMATIONMANAGER_H +#define ANIMATIONMANAGER_H + +#include + +class QAbstractAnimation; + +class AnimationManager : public QObject +{ +Q_OBJECT +public: + AnimationManager(); + void registerAnimation(QAbstractAnimation *anim); + void unregisterAnimation(QAbstractAnimation *anim); + void unregisterAllAnimations(); + static AnimationManager *self(); + +public slots: + void pauseAll(); + void resumeAll(); + +private: + static AnimationManager *instance; + QList animations; +}; + +#endif // ANIMATIONMANAGER_H diff --git a/examples/animation/sub-attaq/boat.cpp b/examples/animation/sub-attaq/boat.cpp new file mode 100644 index 0000000..6824f17 --- /dev/null +++ b/examples/animation/sub-attaq/boat.cpp @@ -0,0 +1,293 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "boat.h" +#include "boat_p.h" +#include "bomb.h" +#include "pixmapitem.h" +#include "graphicsscene.h" +#include "animationmanager.h" +#include "custompropertyanimation.h" + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qpropertyanimation.h" +# include "qstatemachine.h" +# include "qhistorystate.h" +# include "qfinalstate.h" +# include "qstate.h" +#include "qsequentialanimationgroup.h" +#include "qanimationstate.h" +#else +#include +#include +#include +#include +#include +#include +#include +#endif + +static QAbstractAnimation *setupDestroyAnimation(Boat *boat) +{ + QSequentialAnimationGroup *group = new QSequentialAnimationGroup(boat); +#if QT_VERSION >=0x040500 + PixmapItem *step1 = new PixmapItem(QString("explosion/boat/step1"),GraphicsScene::Big, boat); + step1->setZValue(6); + PixmapItem *step2 = new PixmapItem(QString("explosion/boat/step2"),GraphicsScene::Big, boat); + step2->setZValue(6); + PixmapItem *step3 = new PixmapItem(QString("explosion/boat/step3"),GraphicsScene::Big, boat); + step3->setZValue(6); + PixmapItem *step4 = new PixmapItem(QString("explosion/boat/step4"),GraphicsScene::Big, boat); + step4->setZValue(6); + step1->setOpacity(0); + step2->setOpacity(0); + step3->setOpacity(0); + step4->setOpacity(0); + CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(boat); + anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim1->setDuration(100); + anim1->setEndValue(1); + CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(boat); + anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim2->setDuration(100); + anim2->setEndValue(1); + CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(boat); + anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim3->setDuration(100); + anim3->setEndValue(1); + CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(boat); + anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim4->setDuration(100); + anim4->setEndValue(1); + group->addAnimation(anim1); + group->addAnimation(anim2); + group->addAnimation(anim3); + group->addAnimation(anim4); +#else + // work around for a bug where we don't transition if the duration is zero. + QtPauseAnimation *anim = new QtPauseAnimation(group); + anim->setDuration(1); + group->addAnimation(anim); +#endif + AnimationManager::self()->registerAnimation(group); + return group; +} + + + +Boat::Boat(QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent,wFlags), speed(0), bombsAlreadyLaunched(0), direction(Boat::None), movementAnimation(0) +{ + pixmapItem = new PixmapItem(QString("boat"),GraphicsScene::Big, this); + setZValue(4); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable); + resize(pixmapItem->boundingRect().size()); + + //The movement animation used to animate the boat + movementAnimation = new QPropertyAnimation(this, "pos"); + AnimationManager::self()->registerAnimation(movementAnimation); + + //We setup the state machien of the boat + QStateMachine *machine = new QStateMachine(this); + QState *moving = new QState(machine->rootState()); + 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->rootState()); + LaunchStateLeft *launchStateLeft = new LaunchStateLeft(this,machine->rootState()); + + //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, SIGNAL(finished()), stopState); + moveStateRight->addTransition(movementAnimation, SIGNAL(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 = moving->addHistoryState(); + launchStateLeft->addTransition(historyState); + launchStateRight->addTransition(historyState); + + QFinalState *final = new QFinalState(machine->rootState()); + + //This state play the destroyed animation + QAnimationState *destroyedState = new QAnimationState(machine->rootState()); + destroyedState->addAnimation(setupDestroyAnimation(this)); + + //Play a nice animation when the boat is destroyed + moving->addTransition(this, SIGNAL(boatDestroyed()),destroyedState); + + //Transition to final state when the destroyed animation is finished + destroyedState->addFinishedTransition(final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(boatExecutionFinished())); + + machine->start(); +} + +void Boat::updateBoatMovement() +{ + if (speed == 0 || direction == Boat::None) { + movementAnimation->stop(); + return; + } + + movementAnimation->stop(); + movementAnimation->setStartValue(pos()); + + 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/animation/sub-attaq/boat.h b/examples/animation/sub-attaq/boat.h new file mode 100644 index 0000000..4c4a737 --- /dev/null +++ b/examples/animation/sub-attaq/boat.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __BOAT__H__ +#define __BOAT__H__ + +//Qt +#include +#include + +#include + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qgraphicswidget.h" +#else +# include +#endif + +class PixmapItem; +class Bomb; +class QVariantAnimation; + +class Boat : public QGraphicsWidget +{ +Q_OBJECT +Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + enum Movement { + None = 0, + Left, + Right + }; + enum { Type = UserType + 2 }; + Boat(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0); + void destroy(); + + int bombsLaunched() const; + void setBombsLaunched(int number); + + int currentSpeed() const; + void setCurrentSpeed(int speed); + + enum Movement currentDirection() const; + void setCurrentDirection(Movement direction); + + void updateBoatMovement(); + + virtual int type() const; + +Q_SIGNALS: + void boatDestroyed(); + void boatExecutionFinished(); + +private: + int speed; + int bombsAlreadyLaunched; + Movement direction; + QVariantAnimation *movementAnimation; + PixmapItem *pixmapItem; +}; + +#endif //__BOAT__H__ diff --git a/examples/animation/sub-attaq/boat_p.h b/examples/animation/sub-attaq/boat_p.h new file mode 100644 index 0000000..8dacaba --- /dev/null +++ b/examples/animation/sub-attaq/boat_p.h @@ -0,0 +1,258 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef BOAT_P_H +#define BOAT_P_H + +//Own +#include "bomb.h" +#include "graphicsscene.h" + +// Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qkeyeventtransition.h" +#else +# include +#endif + +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 *boat, QEvent::Type type, int key) + : QKeyEventTransition(boat,type, key) + { + this->boat = boat; + this->key = key; +#if defined(Q_OS_MAC) + setModifiers(Qt::KeypadModifier); +#endif + } +protected: + virtual bool eventTest(QEvent *event) const + { + Q_UNUSED(event); + if (!QKeyEventTransition::eventTest(event)) + return false; + if (boat->currentSpeed() == 1) + return true; + else + return false; + } +private: + Boat * boat; + int key; +}; + +//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 *boat, QEvent::Type type, int key) + : QKeyEventTransition(boat,type, key) + { + this->boat = boat; + this->key = key; +#if defined(Q_OS_MAC) + setModifiers(Qt::KeypadModifier); +#endif + } +protected: + virtual bool eventTest(QEvent *event) const + { + Q_UNUSED(event); + if (!QKeyEventTransition::eventTest(event)) + return false; + if (boat->currentSpeed() >= 0) + return true; + else + return false; + + } + void onTransition() + { + //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) + { + this->boat = boat; + this->key = key; +#if defined(Q_OS_MAC) + setModifiers(Qt::KeypadModifier); +#endif + } +protected: + virtual bool eventTest(QEvent *event) const + { + Q_UNUSED(event); + if (!QKeyEventTransition::eventTest(event)) + return false; + //We have enough bomb? + if (boat->bombsLaunched() < MAX_BOMB) + return true; + else + return false; + } +private: + Boat * boat; + int key; +}; + +//This state is describing when the boat is moving right +class MoveStateRight : public QState +{ +public: + MoveStateRight(Boat *boat,QState *parent = 0) : QState(parent) + { + this->boat = boat; + } +protected: + void onEntry() + { + boat->setCurrentDirection(Boat::Right); + boat->updateBoatMovement(); + } +private: + Boat * boat; +}; + + //This state is describing when the boat is moving left +class MoveStateLeft : public QState +{ +public: + MoveStateLeft(Boat *boat,QState *parent = 0) : QState(parent) + { + this->boat = boat; + } +protected: + void onEntry() + { + 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: + StopState(Boat *boat,QState *parent = 0) : QState(parent) + { + this->boat = boat; + } +protected: + void onEntry() + { + 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: + LaunchStateRight(Boat *boat,QState *parent = 0) : QState(parent) + { + this->boat = boat; + } +protected: + void onEntry() + { + 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: + LaunchStateLeft(Boat *boat,QState *parent = 0) : QState(parent) + { + this->boat = boat; + } +protected: + void onEntry() + { + 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/animation/sub-attaq/bomb.cpp b/examples/animation/sub-attaq/bomb.cpp new file mode 100644 index 0000000..b6ae5a3 --- /dev/null +++ b/examples/animation/sub-attaq/bomb.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "bomb.h" +#include "submarine.h" +#include "pixmapitem.h" +#include "animationmanager.h" + +//Qt + +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qpropertyanimation.h" +#include "qsequentialanimationgroup.h" +#include "qanimationstate.h" +#include "qstatemachine.h" +#include "qfinalstate.h" +#else +#include +#include +#include +#include +#include +#endif + +Bomb::Bomb(QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent,wFlags), launchAnimation(0) +{ + pixmapItem = new PixmapItem(QString("bomb"),GraphicsScene::Big, this); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setFlags(QGraphicsItem::ItemIsMovable); + setZValue(2); + resize(pixmapItem->boundingRect().size()); +} + +void Bomb::launch(Bomb::Direction direction) +{ + 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,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &))); + + //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(launchAnimation,machine->rootState()); + + machine->setInitialState(launched); + + //End + QFinalState *final = new QFinalState(machine->rootState()); + + //### Add a nice animation when the bomb is destroyed + launched->addTransition(this, SIGNAL(bombExplosed()),final); + + //If the animation is finished, then we move to the final state + launched->addFinishedTransition(final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(bombExecutionFinished())); + + machine->start(); + +} + +void Bomb::onAnimationLaunchValueChanged(const QVariant &) +{ + foreach (QGraphicsItem * item , collidingItems(Qt::IntersectsItemBoundingRect)) { + if (item->type() == SubMarine::Type) { + SubMarine *s = static_cast(item); + destroy(); + s->destroy(); + } + } +} + +void Bomb::destroy() +{ + launchAnimation->stop(); + emit bombExplosed(); +} diff --git a/examples/animation/sub-attaq/bomb.h b/examples/animation/sub-attaq/bomb.h new file mode 100644 index 0000000..9191e6e --- /dev/null +++ b/examples/animation/sub-attaq/bomb.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __BOMB__H__ +#define __BOMB__H__ + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qanimationgroup.h" +# include "qgraphicswidget.h" +#else +# include +# include +#endif + +class PixmapItem; + +class Bomb : public QGraphicsWidget +{ +Q_OBJECT +Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + enum Direction { + Left = 0, + Right + }; + Bomb(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); + void launch(Direction direction); + void destroy(); + +Q_SIGNALS: + void bombExplosed(); + void bombExecutionFinished(); + +private slots: + void onAnimationLaunchValueChanged(const QVariant &); + +private: + QAnimationGroup *launchAnimation; + PixmapItem *pixmapItem; +}; + +#endif //__BOMB__H__ diff --git a/examples/animation/sub-attaq/custompropertyanimation.cpp b/examples/animation/sub-attaq/custompropertyanimation.cpp new file mode 100644 index 0000000..45997af --- /dev/null +++ b/examples/animation/sub-attaq/custompropertyanimation.cpp @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "custompropertyanimation.h" +#include "custompropertyanimation_p.h" + +// Qt +#include + +QT_BEGIN_NAMESPACE + + +void CustomPropertyAnimationPrivate::initDefaultStartValue() +{ + if (!animProp) + return; + QVariant def = animProp->read(); + if (def.isValid()) + convertValues(def.userType()); + if (animProp && !defaultStartValue.isValid() + && ((currentTime == 0 && (currentIteration || currentIteration == 0)) + || (currentTime == duration && currentIteration == (iterationCount - 1)))) { + setDefaultStartValue(def); + } +} + + +CustomPropertyAnimation::CustomPropertyAnimation(QObject *parent) : + QVariantAnimation(*new CustomPropertyAnimationPrivate, parent) +{ +} + +CustomPropertyAnimation::~CustomPropertyAnimation() +{ +} + +void CustomPropertyAnimation::setProperty(AbstractProperty *animProp) +{ + Q_D(CustomPropertyAnimation); + if (d->animProp == animProp) + return; + delete d->animProp; + d->animProp = animProp; +} + +/*! + \reimp + */ +void CustomPropertyAnimation::updateCurrentValue(const QVariant &value) +{ + Q_D(CustomPropertyAnimation); + if (!d->animProp || state() == QAbstractAnimation::Stopped) + return; + + d->animProp->write(value); +} + + +/*! + \reimp +*/ +void CustomPropertyAnimation::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState) +{ + Q_D(CustomPropertyAnimation); + // Initialize start value + if (oldState == QAbstractAnimation::Stopped) + d->initDefaultStartValue(); + + QVariantAnimation::updateState(oldState, newState); +} + + + +#include "moc_custompropertyanimation.cpp" + +QT_END_NAMESPACE diff --git a/examples/animation/sub-attaq/custompropertyanimation.h b/examples/animation/sub-attaq/custompropertyanimation.h new file mode 100644 index 0000000..ba6ef55 --- /dev/null +++ b/examples/animation/sub-attaq/custompropertyanimation.h @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMPROPERTYANIMATION_H +#define CUSTOMPROPERTYANIMATION_H + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qvariantanimation.h" +#else +# include +#endif + +class QGraphicsItem; +class CustomPropertyAnimationPrivate; + +struct AbstractProperty +{ + virtual QVariant read() const = 0; + virtual void write(const QVariant &value) = 0; +}; + + +class CustomPropertyAnimation : public QVariantAnimation +{ + Q_OBJECT + + template + class MemberFunctionProperty : public AbstractProperty + { + public: + typedef T (Target::*Getter)(void) const; + typedef void (Target::*Setter)(T2); + + MemberFunctionProperty(Target* target, Getter getter, Setter setter) + : m_target(target), m_getter(getter), m_setter(setter) {} + + virtual void write(const QVariant &value) + { + if (m_setter) (m_target->*m_setter)(qVariantValue(value)); + } + + virtual QVariant read() const + { + if (m_getter) return qVariantFromValue((m_target->*m_getter)()); + return QVariant(); + } + + private: + Target *m_target; + Getter m_getter; + Setter m_setter; + }; + +public: + CustomPropertyAnimation(QObject *parent = 0); + ~CustomPropertyAnimation(); + + template + void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(const T& )) + { + setProperty(new MemberFunctionProperty(target, getter, setter)); + } + + template + void setMemberFunctions(Target* target, T (Target::*getter)() const, void (Target::*setter)(T)) + { + setProperty(new MemberFunctionProperty(target, getter, setter)); + } + + void updateCurrentValue(const QVariant &value); + void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState); + void setProperty(AbstractProperty *animProp); + +private: + Q_DISABLE_COPY(CustomPropertyAnimation); + Q_DECLARE_PRIVATE(CustomPropertyAnimation); +}; + +#endif // CUSTOMPROPERTYANIMATION_H diff --git a/examples/animation/sub-attaq/custompropertyanimation_p.h b/examples/animation/sub-attaq/custompropertyanimation_p.h new file mode 100644 index 0000000..89fc757 --- /dev/null +++ b/examples/animation/sub-attaq/custompropertyanimation_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CUSTOMPROPERTYANIMATION_P_H +#define CUSTOMPROPERTYANIMATION_P_H + +#ifdef QT_EXPERIMENTAL_SOLUTION +# include "qvariantanimation_p.h" +#else +# include +#endif + +class CustomPropertyAnimationPrivate : public QVariantAnimationPrivate +{ + Q_DECLARE_PUBLIC(CustomPropertyAnimation) +public: + CustomPropertyAnimationPrivate() : QVariantAnimationPrivate(), animProp(0) + { + } + + void initDefaultStartValue(); + + AbstractProperty *animProp; +}; + +#endif //QTCUSTOMPROPERTYANIMATION_P_H diff --git a/examples/animation/sub-attaq/data.xml b/examples/animation/sub-attaq/data.xml new file mode 100644 index 0000000..41d4754 --- /dev/null +++ b/examples/animation/sub-attaq/data.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/graphicsscene.cpp b/examples/animation/sub-attaq/graphicsscene.cpp new file mode 100644 index 0000000..a7f4c1b --- /dev/null +++ b/examples/animation/sub-attaq/graphicsscene.cpp @@ -0,0 +1,368 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "graphicsscene.h" +#include "states.h" +#include "boat.h" +#include "submarine.h" +#include "torpedo.h" +#include "bomb.h" +#include "pixmapitem.h" +#include "custompropertyanimation.h" +#include "animationmanager.h" + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qpropertyanimation.h" +#include "qsequentialanimationgroup.h" +#include "qparallelanimationgroup.h" +#include "qstatemachine.h" +#include "qanimationstate.h" +#include "qfinalstate.h" +#include "qpauseanimation.h" +#else +#include +#include +#include +#include +#include +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +//helper function that creates an animation for position and inserts it into group +static CustomPropertyAnimation *addGraphicsItemPosAnimation(QSequentialAnimationGroup *group, + QGraphicsItem *item, const QPointF &endPos) +{ + CustomPropertyAnimation *ret = new CustomPropertyAnimation(group); + ret->setMemberFunctions(item, &QGraphicsItem::pos, &QGraphicsItem::setPos); + ret->setEndValue(endPos); + ret->setDuration(200); + ret->setEasingCurve(QEasingCurve::OutElastic); + group->addPause(50); + return ret; +} + +//helper function that creates an animation for opacity and inserts it into group +static void addGraphicsItemFadeoutAnimation(QAnimationGroup *group, QGraphicsItem *item) +{ +#if QT_VERSION >=0x040500 + CustomPropertyAnimation *anim = new CustomPropertyAnimation(group); + anim->setMemberFunctions(item, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim->setDuration(800); + anim->setEndValue(0); + anim->setEasingCurve(QEasingCurve::OutQuad); +#else + // work around for a bug where we don't transition if the duration is zero. + QtPauseAnimation *anim = new QtPauseAnimation(group); + anim->setDuration(1); +#endif +} + +GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode) + : QGraphicsScene(x,y,width,height), mode(mode), newAction(0), quitAction(0), boat(0) +{ + backgroundItem = new PixmapItem(QString("background"),mode); + backgroundItem->setZValue(1); + backgroundItem->setPos(0,0); + addItem(backgroundItem); + + PixmapItem *surfaceItem = new PixmapItem(QString("surface"),mode); + surfaceItem->setZValue(3); + surfaceItem->setPos(0,sealLevel() - surfaceItem->boundingRect().height()/2); + addItem(surfaceItem); + + //parse the xml that contain all data of the game + QXmlStreamReader reader; + QFile file(QDir::currentPath() + "/data.xml"); + file.open(QIODevice::ReadOnly); + reader.setDevice(&file); + LevelDescription currentLevel; + while (!reader.atEnd()) { + reader.readNext(); + if (reader.tokenType() == QXmlStreamReader::StartElement) { + if (reader.name() == "submarine") + { + SubmarineDescription desc; + desc.name = reader.attributes().value("name").toString(); + desc.points = reader.attributes().value("points").toString().toInt(); + desc.type = reader.attributes().value("type").toString().toInt(); + submarinesData.append(desc); + } + if (reader.name() == "level") + { + currentLevel.id = reader.attributes().value("id").toString().toInt(); + currentLevel.name = reader.attributes().value("name").toString(); + } + if (reader.name() == "subinstance") + { + currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toString().toInt(),reader.attributes().value("nb").toString().toInt())); + } + } + if (reader.tokenType() == QXmlStreamReader::EndElement) { + if (reader.name() == "level") + { + levelsData.insert(currentLevel.id,currentLevel); + currentLevel.submarines.clear(); + } + } + } +} + +qreal GraphicsScene::sealLevel() const +{ + if (mode == Big) + return 220; + else + return 160; +} + +void GraphicsScene::setupScene(const QList &actions) +{ + newAction = actions.at(0); + quitAction = actions.at(1); + + QGraphicsItem *logo_s = addWelcomeItem(QPixmap(":/logo-s")); + QGraphicsItem *logo_u = addWelcomeItem(QPixmap(":/logo-u")); + QGraphicsItem *logo_b = addWelcomeItem(QPixmap(":/logo-b")); + QGraphicsItem *logo_dash = addWelcomeItem(QPixmap(":/logo-dash")); + QGraphicsItem *logo_a = addWelcomeItem(QPixmap(":/logo-a")); + QGraphicsItem *logo_t = addWelcomeItem(QPixmap(":/logo-t")); + QGraphicsItem *logo_t2 = addWelcomeItem(QPixmap(":/logo-t2")); + QGraphicsItem *logo_a2 = addWelcomeItem(QPixmap(":/logo-a2")); + QGraphicsItem *logo_q = addWelcomeItem(QPixmap(":/logo-q")); + QGraphicsItem *logo_excl = addWelcomeItem(QPixmap(":/logo-excl")); + logo_s->setZValue(3); + logo_u->setZValue(4); + logo_b->setZValue(5); + logo_dash->setZValue(6); + logo_a->setZValue(7); + logo_t->setZValue(8); + logo_t2->setZValue(9); + logo_a2->setZValue(10); + logo_q->setZValue(11); + logo_excl->setZValue(12); + logo_s->setPos(QPointF(-1000, -1000)); + logo_u->setPos(QPointF(-800, -1000)); + logo_b->setPos(QPointF(-600, -1000)); + logo_dash->setPos(QPointF(-400, -1000)); + logo_a->setPos(QPointF(1000, 2000)); + logo_t->setPos(QPointF(800, 2000)); + logo_t2->setPos(QPointF(600, 2000)); + logo_a2->setPos(QPointF(400, 2000)); + logo_q->setPos(QPointF(200, 2000)); + logo_excl->setPos(QPointF(0, 2000)); + + QSequentialAnimationGroup * lettersGroupMoving = new QSequentialAnimationGroup(this); + QParallelAnimationGroup * lettersGroupFading = new QParallelAnimationGroup(this); + + //creation of the animations for moving letters + addGraphicsItemPosAnimation(lettersGroupMoving, logo_s, QPointF(300, 150)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_u, QPointF(350, 150)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_b, QPointF(400, 120)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_dash, QPointF(460, 150)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_a, QPointF(350, 250)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_t, QPointF(400, 250)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_t2, QPointF(430, 250)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_a2, QPointF(465, 250)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_q, QPointF(510, 250)); + addGraphicsItemPosAnimation(lettersGroupMoving, logo_excl, QPointF(570, 220)); + + //creation of the animations for fading out the letters + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_s); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_u); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_b); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_dash); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_t2); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_a2); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_q); + addGraphicsItemFadeoutAnimation(lettersGroupFading, logo_excl); + connect(lettersGroupFading, SIGNAL(finished()), this, SLOT(onIntroAnimationFinished())); + + QStateMachine *machine = new QStateMachine(this); + + //This state is when the player is playing + PlayState *gameState = new PlayState(this,machine->rootState()); + + //Final state + QFinalState *final = new QFinalState(machine->rootState()); + + //Animation when the player enter in the game + QAnimationState *animationState = new QAnimationState(lettersGroupMoving, machine->rootState()); + animationState->addAnimatedTransition(newAction, SIGNAL(triggered()),gameState,lettersGroupFading); + + //New Game is triggered then player start playing + gameState->addTransition(newAction, SIGNAL(triggered()),gameState); + + //Wanna quit, then connect to CTRL+Q + gameState->addTransition(quitAction, SIGNAL(triggered()),final); + animationState->addTransition(quitAction, SIGNAL(triggered()),final); + + //Welcome screen is the initial state + machine->setInitialState(animationState); + + machine->start(); + + //We reach the final state, then we quit + connect(machine,SIGNAL(finished()),this, SLOT(onQuitGameTriggered())); +} + +void GraphicsScene::addItem(Bomb *bomb) +{ + bombs.insert(bomb); + connect(bomb,SIGNAL(bombExecutionFinished()),this, SLOT(onBombExecutionFinished())); + QGraphicsScene::addItem(bomb); +} + +void GraphicsScene::addItem(Torpedo *torpedo) +{ + torpedos.insert(torpedo); + connect(torpedo,SIGNAL(torpedoExecutionFinished()),this, SLOT(onTorpedoExecutionFinished())); + QGraphicsScene::addItem(torpedo); +} + +void GraphicsScene::addItem(SubMarine *submarine) +{ + submarines.insert(submarine); + connect(submarine,SIGNAL(subMarineExecutionFinished()),this, SLOT(onSubMarineExecutionFinished())); + QGraphicsScene::addItem(submarine); +} + +void GraphicsScene::addItem(QGraphicsItem *item) +{ + QGraphicsScene::addItem(item); +} + +void GraphicsScene::mousePressEvent (QGraphicsSceneMouseEvent * event) +{ + event->ignore(); +} + +void GraphicsScene::onQuitGameTriggered() +{ + qApp->closeAllWindows(); +} + +void GraphicsScene::onBombExecutionFinished() +{ + Bomb *bomb = qobject_cast(sender()); + bombs.remove(bomb); + bomb->deleteLater(); + if (boat) + boat->setBombsLaunched(boat->bombsLaunched() - 1); +} + +void GraphicsScene::onTorpedoExecutionFinished() +{ + Torpedo *torpedo = qobject_cast(sender()); + torpedos.remove(torpedo); + torpedo->deleteLater(); +} + +void GraphicsScene::onSubMarineExecutionFinished() +{ + SubMarine *submarine = qobject_cast(sender()); + submarines.remove(submarine); + if (submarines.count() == 0) { + emit allSubMarineDestroyed(submarine->points()); + } else { + emit subMarineDestroyed(submarine->points()); + } + submarine->deleteLater(); +} + +int GraphicsScene::remainingSubMarines() const +{ + return submarines.count(); +} + +void GraphicsScene::clearScene() +{ + foreach (SubMarine *sub,submarines) { + sub->destroy(); + delete sub; + } + + foreach (Torpedo *torpedo,torpedos) { + torpedo->destroy(); + delete torpedo; + } + + foreach (Bomb *bomb,bombs) { + bomb->destroy(); + delete bomb; + } + + submarines.clear(); + bombs.clear(); + torpedos.clear(); + + AnimationManager::self()->unregisterAllAnimations(); + + if (boat) { + delete boat; + boat = 0; + } +} + +QGraphicsPixmapItem *GraphicsScene::addWelcomeItem(const QPixmap &pm) +{ + QGraphicsPixmapItem *item = addPixmap(pm); + welcomeItems << item; + return item; +} + +void GraphicsScene::onIntroAnimationFinished() +{ + qDeleteAll(welcomeItems); + welcomeItems.clear(); +} + diff --git a/examples/animation/sub-attaq/graphicsscene.h b/examples/animation/sub-attaq/graphicsscene.h new file mode 100644 index 0000000..875f59f --- /dev/null +++ b/examples/animation/sub-attaq/graphicsscene.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __GRAPHICSSCENE__H__ +#define __GRAPHICSSCENE__H__ + +//Qt +#include +#include + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qstate.h" +#else +# include +#endif + + +class Boat; +class SubMarine; +class Torpedo; +class Bomb; +class PixmapItem; +class QAction; + +class GraphicsScene : public QGraphicsScene +{ +Q_OBJECT +public: + enum Mode { + Big = 0, + Small + }; + + struct SubmarineDescription { + int type; + int points; + QString name; + }; + + struct LevelDescription { + int id; + QString name; + QList > submarines; + }; + + GraphicsScene(int x, int y, int width, int height, Mode mode = Big); + qreal sealLevel() const; + void setupScene(const QList &actions); + void addItem(Bomb *bomb); + void addItem(Torpedo *torpedo); + void addItem(SubMarine *submarine); + void addItem(QGraphicsItem *item); + int remainingSubMarines() const; + void clearScene(); + QGraphicsPixmapItem *addWelcomeItem(const QPixmap &pm); + +Q_SIGNALS: + void subMarineDestroyed(int); + void allSubMarineDestroyed(int); + +protected: + void mousePressEvent (QGraphicsSceneMouseEvent * event); + +private slots: + void onQuitGameTriggered(); + void onBombExecutionFinished(); + void onTorpedoExecutionFinished(); + void onSubMarineExecutionFinished(); + void onIntroAnimationFinished(); + +private: + Mode mode; + PixmapItem *backgroundItem; + QAction * newAction; + QAction * quitAction; + Boat *boat; + QSet submarines; + QSet bombs; + QSet torpedos; + QVector welcomeItems; + QVector submarinesData; + QHash levelsData; + + friend class PauseState; + friend class PlayState; + friend class LostState; + friend class WinState; +}; + +#endif //__GRAPHICSSCENE__H__ + diff --git a/examples/animation/sub-attaq/main.cpp b/examples/animation/sub-attaq/main.cpp new file mode 100644 index 0000000..ffaa86f --- /dev/null +++ b/examples/animation/sub-attaq/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(subattaq); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + MainWindow w; + w.show(); + + return app.exec(); +} diff --git a/examples/animation/sub-attaq/mainwindow.cpp b/examples/animation/sub-attaq/mainwindow.cpp new file mode 100644 index 0000000..c25b9ef --- /dev/null +++ b/examples/animation/sub-attaq/mainwindow.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "mainwindow.h" +#include "graphicsscene.h" + +#ifndef QT_NO_OPENGL + #include +#endif +//Qt +#include + +MainWindow::MainWindow() : QMainWindow(0) +{ + QMenuBar *menuBar = new QMenuBar; + QMenu *file = new QMenu(tr("&File"),menuBar); + + QAction *newAction = new QAction(tr("New Game"),file); + newAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N)); + file->addAction(newAction); + QAction *quitAction = new QAction(tr("Quit"),file); + quitAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); + file->addAction(quitAction); + + menuBar->addMenu(file); + setMenuBar(menuBar); + + QStringList list = QApplication::arguments(); + if (list.contains("-fullscreen")) { + scene = new GraphicsScene(0, 0, 750, 400,GraphicsScene::Small); + setWindowState(Qt::WindowFullScreen); + } else { + scene = new GraphicsScene(0, 0, 880, 630); + layout()->setSizeConstraint(QLayout::SetFixedSize); + } + + view = new QGraphicsView(scene,this); + view->setAlignment(Qt::AlignLeft | Qt::AlignTop); + QList actions; + actions << newAction << quitAction; + scene->setupScene(actions); +#ifndef QT_NO_OPENGL + view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); +#endif + + setCentralWidget(view); + +} + +MainWindow::~MainWindow() +{ +} + diff --git a/examples/animation/sub-attaq/mainwindow.h b/examples/animation/sub-attaq/mainwindow.h new file mode 100644 index 0000000..6289b3f --- /dev/null +++ b/examples/animation/sub-attaq/mainwindow.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __MAINWINDOW__H__ +#define __MAINWINDOW__H__ + +//Qt +#include + +class GraphicsScene; +class QGraphicsView; + +class MainWindow : public QMainWindow +{ +Q_OBJECT +public: + MainWindow(); + ~MainWindow(); + +private: + GraphicsScene *scene; + QGraphicsView *view; +}; + +#endif //__MAINWINDOW__H__ diff --git a/examples/animation/sub-attaq/pics/big/background.png b/examples/animation/sub-attaq/pics/big/background.png new file mode 100644 index 0000000..9f58157 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/background.png differ diff --git a/examples/animation/sub-attaq/pics/big/boat.png b/examples/animation/sub-attaq/pics/big/boat.png new file mode 100644 index 0000000..be82dff Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/boat.png differ diff --git a/examples/animation/sub-attaq/pics/big/bomb.png b/examples/animation/sub-attaq/pics/big/bomb.png new file mode 100644 index 0000000..3af5f2f Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/bomb.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png new file mode 100644 index 0000000..c9fd8b0 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/boat/step1.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png new file mode 100644 index 0000000..7528f2d Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/boat/step2.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png new file mode 100644 index 0000000..aae9c9c Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/boat/step3.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png b/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png new file mode 100644 index 0000000..d697c1b Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/boat/step4.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png new file mode 100644 index 0000000..88ca514 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/submarine/step1.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png new file mode 100644 index 0000000..524f589 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/submarine/step2.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png new file mode 100644 index 0000000..2cca1e8 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/submarine/step3.png differ diff --git a/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png b/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png new file mode 100644 index 0000000..82100a8 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/explosion/submarine/step4.png differ diff --git a/examples/animation/sub-attaq/pics/big/submarine.png b/examples/animation/sub-attaq/pics/big/submarine.png new file mode 100644 index 0000000..df435dc Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/submarine.png differ diff --git a/examples/animation/sub-attaq/pics/big/surface.png b/examples/animation/sub-attaq/pics/big/surface.png new file mode 100644 index 0000000..4eba29e Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/surface.png differ diff --git a/examples/animation/sub-attaq/pics/big/torpedo.png b/examples/animation/sub-attaq/pics/big/torpedo.png new file mode 100644 index 0000000..f9c2687 Binary files /dev/null and b/examples/animation/sub-attaq/pics/big/torpedo.png differ diff --git a/examples/animation/sub-attaq/pics/scalable/background-n810.svg b/examples/animation/sub-attaq/pics/scalable/background-n810.svg new file mode 100644 index 0000000..ece9f7a --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/background-n810.svg @@ -0,0 +1,171 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/background.svg b/examples/animation/sub-attaq/pics/scalable/background.svg new file mode 100644 index 0000000..0be2680 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/background.svg @@ -0,0 +1,171 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/boat.svg b/examples/animation/sub-attaq/pics/scalable/boat.svg new file mode 100644 index 0000000..5298821b --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/boat.svg @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/bomb.svg b/examples/animation/sub-attaq/pics/scalable/bomb.svg new file mode 100644 index 0000000..294771a --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/bomb.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/sand.svg b/examples/animation/sub-attaq/pics/scalable/sand.svg new file mode 100644 index 0000000..8af11b7 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/sand.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/see.svg b/examples/animation/sub-attaq/pics/scalable/see.svg new file mode 100644 index 0000000..0666691 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/see.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/sky.svg b/examples/animation/sub-attaq/pics/scalable/sky.svg new file mode 100644 index 0000000..1546c08 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/sky.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg b/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg new file mode 100644 index 0000000..b075179 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/sub-attaq.svg @@ -0,0 +1,1473 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/submarine.svg b/examples/animation/sub-attaq/pics/scalable/submarine.svg new file mode 100644 index 0000000..8a0ffdd --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/submarine.svg @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/surface.svg b/examples/animation/sub-attaq/pics/scalable/surface.svg new file mode 100644 index 0000000..40ed239 --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/surface.svg @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/scalable/torpedo.svg b/examples/animation/sub-attaq/pics/scalable/torpedo.svg new file mode 100644 index 0000000..48e429d --- /dev/null +++ b/examples/animation/sub-attaq/pics/scalable/torpedo.svg @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/animation/sub-attaq/pics/small/background.png b/examples/animation/sub-attaq/pics/small/background.png new file mode 100644 index 0000000..5ad3db6 Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/background.png differ diff --git a/examples/animation/sub-attaq/pics/small/boat.png b/examples/animation/sub-attaq/pics/small/boat.png new file mode 100644 index 0000000..114ccc3 Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/boat.png differ diff --git a/examples/animation/sub-attaq/pics/small/bomb.png b/examples/animation/sub-attaq/pics/small/bomb.png new file mode 100644 index 0000000..3af5f2f Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/bomb.png differ diff --git a/examples/animation/sub-attaq/pics/small/submarine.png b/examples/animation/sub-attaq/pics/small/submarine.png new file mode 100644 index 0000000..0c0c350 Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/submarine.png differ diff --git a/examples/animation/sub-attaq/pics/small/surface.png b/examples/animation/sub-attaq/pics/small/surface.png new file mode 100644 index 0000000..06d0e47 Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/surface.png differ diff --git a/examples/animation/sub-attaq/pics/small/torpedo.png b/examples/animation/sub-attaq/pics/small/torpedo.png new file mode 100644 index 0000000..f9c2687 Binary files /dev/null and b/examples/animation/sub-attaq/pics/small/torpedo.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-a.png b/examples/animation/sub-attaq/pics/welcome/logo-a.png new file mode 100644 index 0000000..67dd76d Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-a.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-a2.png b/examples/animation/sub-attaq/pics/welcome/logo-a2.png new file mode 100644 index 0000000..17668b0 Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-a2.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-b.png b/examples/animation/sub-attaq/pics/welcome/logo-b.png new file mode 100644 index 0000000..cf6c045 Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-b.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-dash.png b/examples/animation/sub-attaq/pics/welcome/logo-dash.png new file mode 100644 index 0000000..219233c Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-dash.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-excl.png b/examples/animation/sub-attaq/pics/welcome/logo-excl.png new file mode 100644 index 0000000..8dd0a2e Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-excl.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-q.png b/examples/animation/sub-attaq/pics/welcome/logo-q.png new file mode 100644 index 0000000..86e588d Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-q.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-s.png b/examples/animation/sub-attaq/pics/welcome/logo-s.png new file mode 100644 index 0000000..7b6a36e Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-s.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-t.png b/examples/animation/sub-attaq/pics/welcome/logo-t.png new file mode 100644 index 0000000..b2e3526 Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-t.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-t2.png b/examples/animation/sub-attaq/pics/welcome/logo-t2.png new file mode 100644 index 0000000..b11a778 Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-t2.png differ diff --git a/examples/animation/sub-attaq/pics/welcome/logo-u.png b/examples/animation/sub-attaq/pics/welcome/logo-u.png new file mode 100644 index 0000000..24eede8 Binary files /dev/null and b/examples/animation/sub-attaq/pics/welcome/logo-u.png differ diff --git a/examples/animation/sub-attaq/pixmapitem.cpp b/examples/animation/sub-attaq/pixmapitem.cpp new file mode 100644 index 0000000..aa8b552 --- /dev/null +++ b/examples/animation/sub-attaq/pixmapitem.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "pixmapitem.h" + +//Qt +#include + +PixmapItem::PixmapItem(const QString &fileName,GraphicsScene::Mode mode, QGraphicsItem * parent) : QGraphicsPixmapItem(parent),name(fileName) +{ + loadPixmap(mode); +} + +void PixmapItem::loadPixmap(GraphicsScene::Mode mode) +{ + if (mode == GraphicsScene::Big) + setPixmap(":/big/" + name); + else + setPixmap(":/small/" + name); +} diff --git a/examples/animation/sub-attaq/pixmapitem.h b/examples/animation/sub-attaq/pixmapitem.h new file mode 100644 index 0000000..f3c1a41 --- /dev/null +++ b/examples/animation/sub-attaq/pixmapitem.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __PIXMAPITEM__H__ +#define __PIXMAPITEM__H__ + +//Own +#include "graphicsscene.h" + +//Qt +#include + +class PixmapItem : public QGraphicsPixmapItem +{ +public: + PixmapItem(const QString &fileName, GraphicsScene::Mode mode, QGraphicsItem * parent = 0); + +private: + void loadPixmap(GraphicsScene::Mode mode); + + QString name; + QPixmap pixmap; +}; + +#endif //__PIXMAPITEM__H__ diff --git a/examples/animation/sub-attaq/states.cpp b/examples/animation/sub-attaq/states.cpp new file mode 100644 index 0000000..32e0bb8 --- /dev/null +++ b/examples/animation/sub-attaq/states.cpp @@ -0,0 +1,289 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "states.h" +#include "graphicsscene.h" +#include "boat.h" +#include "submarine.h" +#include "torpedo.h" +#include "animationmanager.h" + +//Qt +#include +#include +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qstatemachine.h" +#include "qkeyeventtransition.h" +#include "qsignalevent.h" +#include "qfinalstate.h" +#else +#include +#include +#include +#include +#endif + +PlayState::PlayState(GraphicsScene *scene, QState *parent) + : QState(parent), + scene(scene), + machine(0), + currentLevel(0), + score(0) +{ +} + +PlayState::~PlayState() +{ +} + +void PlayState::onEntry() +{ + //We are now playing? + if (machine) { + machine->stop(); + scene->clearScene(); + delete machine; + } + + machine = new QStateMachine(this); + + //This state is when player is playing + QState *playState = new QState(machine->rootState()); + + initializeLevel(); + + //This state is when the game is paused + PauseState *pauseState = new PauseState(scene, machine->rootState()); + + //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(playState); + + //Pause "P" is triggered, the player pause the game + playState->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->rootState()); + + //This state is when player have won + WinState *winState = new WinState(scene, this, machine->rootState()); + + //The boat has been destroyed then the game is finished + playState->addTransition(scene->boat, SIGNAL(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 + playState->addTransition(winTransition); + + //This state is an animation when the score changed + UpdateScoreState *scoreState = new UpdateScoreState(this, machine->rootState()); + + //This transition update the score when a submarine die + UpdateScoreTransition *scoreTransition = new UpdateScoreTransition(scene, this, scoreState); + + //The boat has been destroyed then the game is finished + playState->addTransition(scoreTransition); + + //We go back to play state + scoreState->addFinishedTransition(playState); + + //We start playing!!! + machine->setInitialState(playState); + + //Final state + QFinalState *final = new QFinalState(machine->rootState()); + + //We win we should reach the final state + winState->addFinishedTransition(final); + + //We lost we should reach the final state + lostState->addFinishedTransition(final); + + machine->start(); +} + +void PlayState::initializeLevel() +{ + scene->boat = new Boat(); + scene->addItem(scene->boat); + scene->setFocusItem(scene->boat,Qt::OtherFocusReason); + scene->boat->setPos(scene->width()/2, scene->sealLevel() - scene->boat->size().height()); + + GraphicsScene::LevelDescription currentLevelDescription = scene->levelsData.value(currentLevel); + + for (int i = 0; i < currentLevelDescription.submarines.size(); ++i ) { + + QPair subContent = currentLevelDescription.submarines.at(i); + 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 = (qrand() % 15 + 1); + qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width(); + qreal y = scene->height() -(qrand() % 150 + 1) - sub->size().height(); + sub->setPos(x,y); + sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left); + sub->setCurrentSpeed(qrand() % 3 + 1); + } + } +} + +/** Pause State */ +PauseState::PauseState(GraphicsScene *scene, QState *parent) : QState(parent),scene(scene) +{ +} +void PauseState::onEntry() +{ + AnimationManager::self()->pauseAll(); + scene->boat->setEnabled(false); +} +void PauseState::onExit() +{ + 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() +{ + //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 have only one view + QMessageBox::information(scene->views().at(0),"You lose",message); +} + +/** Win State */ +WinState::WinState(GraphicsScene *scene, PlayState *game, QState *parent) : QState(parent), scene(scene), game(game) +{ +} + +void WinState::onEntry() +{ + //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.").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 have only one view + QMessageBox::information(scene->views().at(0),"You win",message); +} + +/** UpdateScore State */ +UpdateScoreState::UpdateScoreState(PlayState *game, QState *parent) : QAnimationState(parent) +{ + this->game = game; +} +void UpdateScoreState::onEntry() +{ + //### Make a nice anim to update the score in the scene + QAnimationState::onEntry(); +} + +/** Win transition */ +UpdateScoreTransition::UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) + : QSignalTransition(scene,SIGNAL(subMarineDestroyed(int)), QList() << target), + game(game) +{ +} + +bool UpdateScoreTransition::eventTest(QEvent *event) const +{ + if (!QSignalTransition::eventTest(event)) + return false; + else { + QSignalEvent *se = static_cast(event); + game->score += se->arguments().at(0).toInt(); + return true; + } +} + +/** Win transition */ +WinTransition::WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target) + : QSignalTransition(scene,SIGNAL(allSubMarineDestroyed(int)), QList() << target), + game(game) +{ +} + +bool WinTransition::eventTest(QEvent *event) const +{ + if (!QSignalTransition::eventTest(event)) + return false; + else { + QSignalEvent *se = static_cast(event); + game->score += se->arguments().at(0).toInt(); + return true; + } +} diff --git a/examples/animation/sub-attaq/states.h b/examples/animation/sub-attaq/states.h new file mode 100644 index 0000000..1001827 --- /dev/null +++ b/examples/animation/sub-attaq/states.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STATES_H +#define STATES_H + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qstate.h" +#include "qsignaltransition.h" +#include "qanimationstate.h" +#include "qpropertyanimation.h" +#else +#include +#include +#include +#include +#endif +#include + +class GraphicsScene; +class Boat; +class SubMarine; +class QStateMachine; + +class PlayState : public QState +{ +public: + PlayState(GraphicsScene *scene, QState *parent = 0); + ~PlayState(); + void initializeLevel(); + + protected: + void onEntry(); + +private : + GraphicsScene *scene; + QStateMachine *machine; + int currentLevel; + int score; + QState *parallelChild; + + friend class UpdateScoreState; + friend class UpdateScoreTransition; + friend class WinTransition; + friend class WinState; + friend class LostState; +}; + +class PauseState : public QState +{ +public: + PauseState(GraphicsScene *scene, QState *parent = 0); + +protected: + void onEntry(); + void onExit(); +private : + GraphicsScene *scene; + Boat *boat; +}; + +class LostState : public QState +{ +public: + LostState(GraphicsScene *scene, PlayState *game, QState *parent = 0); + +protected: + void onEntry(); +private : + GraphicsScene *scene; + PlayState *game; +}; + +class WinState : public QState +{ +public: + WinState(GraphicsScene *scene, PlayState *game, QState *parent = 0); + +protected: + void onEntry(); +private : + GraphicsScene *scene; + PlayState *game; +}; + +class UpdateScoreState : public QAnimationState +{ +public: + UpdateScoreState(PlayState *game, QState *parent); +protected: + void onEntry(); +private: + QPropertyAnimation *scoreAnimation; + PlayState *game; +}; + +//These transtion is used to update the score +class UpdateScoreTransition : public QSignalTransition +{ +public: + UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); +protected: + virtual bool eventTest(QEvent *event) const; +private: + PlayState * game; +}; + +//These transtion test if we have won the game +class WinTransition : public QSignalTransition +{ +public: + WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target); +protected: + virtual bool eventTest(QEvent *event) const; +private: + PlayState * game; +}; + +#endif // STATES_H diff --git a/examples/animation/sub-attaq/sub-attaq.pro b/examples/animation/sub-attaq/sub-attaq.pro new file mode 100644 index 0000000..d8de6f5 --- /dev/null +++ b/examples/animation/sub-attaq/sub-attaq.pro @@ -0,0 +1,36 @@ +# ##################################################################### +# Automatically generated by qmake (2.01a) Thu Oct 9 10:53:30 2008 +# ##################################################################### +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +QT+= xml +contains(QT_CONFIG, opengl):QT += opengl + +# Input +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 \ + custompropertyanimation_p.h \ + custompropertyanimation.h +SOURCES += boat.cpp \ + bomb.cpp \ + main.cpp \ + mainwindow.cpp \ + submarine.cpp \ + torpedo.cpp \ + pixmapitem.cpp \ + graphicsscene.cpp \ + animationmanager.cpp \ + states.cpp \ + custompropertyanimation.cpp +RESOURCES += subattaq.qrc diff --git a/examples/animation/sub-attaq/subattaq.qrc b/examples/animation/sub-attaq/subattaq.qrc new file mode 100644 index 0000000..c76f8ef --- /dev/null +++ b/examples/animation/sub-attaq/subattaq.qrc @@ -0,0 +1,38 @@ + + + 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 + + diff --git a/examples/animation/sub-attaq/submarine.cpp b/examples/animation/sub-attaq/submarine.cpp new file mode 100644 index 0000000..481c748 --- /dev/null +++ b/examples/animation/sub-attaq/submarine.cpp @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "submarine.h" +#include "submarine_p.h" +#include "torpedo.h" +#include "pixmapitem.h" +#include "graphicsscene.h" +#include "animationmanager.h" +#include "custompropertyanimation.h" + +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qpropertyanimation.h" +#include "qstatemachine.h" +#include "qfinalstate.h" +#include "qanimationstate.h" +#include "qsequentialanimationgroup.h" +#else +#include +#include +#include +#include +#include +#endif + +static QAbstractAnimation *setupDestroyAnimation(SubMarine *sub) +{ + QSequentialAnimationGroup *group = new QSequentialAnimationGroup(sub); +#if QT_VERSION >=0x040500 + PixmapItem *step1 = new PixmapItem(QString("explosion/submarine/step1"),GraphicsScene::Big, sub); + step1->setZValue(6); + PixmapItem *step2 = new PixmapItem(QString("explosion/submarine/step2"),GraphicsScene::Big, sub); + step2->setZValue(6); + PixmapItem *step3 = new PixmapItem(QString("explosion/submarine/step3"),GraphicsScene::Big, sub); + step3->setZValue(6); + PixmapItem *step4 = new PixmapItem(QString("explosion/submarine/step4"),GraphicsScene::Big, sub); + step4->setZValue(6); + step1->setOpacity(0); + step2->setOpacity(0); + step3->setOpacity(0); + step4->setOpacity(0); + CustomPropertyAnimation *anim1 = new CustomPropertyAnimation(sub); + anim1->setMemberFunctions((QGraphicsItem*)step1, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim1->setDuration(100); + anim1->setEndValue(1); + CustomPropertyAnimation *anim2 = new CustomPropertyAnimation(sub); + anim2->setMemberFunctions((QGraphicsItem*)step2, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim2->setDuration(100); + anim2->setEndValue(1); + CustomPropertyAnimation *anim3 = new CustomPropertyAnimation(sub); + anim3->setMemberFunctions((QGraphicsItem*)step3, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim3->setDuration(100); + anim3->setEndValue(1); + CustomPropertyAnimation *anim4 = new CustomPropertyAnimation(sub); + anim4->setMemberFunctions((QGraphicsItem*)step4, &QGraphicsItem::opacity, &QGraphicsItem::setOpacity); + anim4->setDuration(100); + anim4->setEndValue(1); + group->addAnimation(anim1); + group->addAnimation(anim2); + group->addAnimation(anim3); + group->addAnimation(anim4); +#else + // work around for a bug where we don't transition if the duration is zero. + QtPauseAnimation *anim = new QtPauseAnimation(group); + anim->setDuration(1); + group->addAnimation(anim); +#endif + AnimationManager::self()->registerAnimation(group); + return group; +} + + +SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent,wFlags), subType(type), subName(name), subPoints(points), speed(0), direction(SubMarine::None) +{ + pixmapItem = new PixmapItem(QString("submarine"),GraphicsScene::Big, this); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setZValue(5); + setFlags(QGraphicsItem::ItemIsMovable); + resize(pixmapItem->boundingRect().width(),pixmapItem->boundingRect().height()); + setTransformOrigin(boundingRect().center()); + + //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->rootState()); + + //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, SIGNAL(subMarineStateChanged()),moving); + + //This is the initial state of the machine + machine->setInitialState(moving); + + //End + QFinalState *final = new QFinalState(machine->rootState()); + + //If the moving animation is finished we move to the return state + movement->addFinishedTransition(rotation); + + //If the return animation is finished we move to the moving state + rotation->addFinishedTransition(movement); + + //This state play the destroyed animation + QAnimationState *destroyedState = new QAnimationState(machine->rootState()); + destroyedState->addAnimation(setupDestroyAnimation(this)); + + //Play a nice animation when the submarine is destroyed + moving->addTransition(this, SIGNAL(subMarineDestroyed()),destroyedState); + + //Transition to final state when the destroyed animation is finished + destroyedState->addFinishedTransition(final); + + //The machine has finished to be executed, then the submarine is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(subMarineExecutionFinished())); + + machine->start(); +} + +int SubMarine::points() +{ + return subPoints; +} + +void SubMarine::setCurrentDirection(SubMarine::Movement direction) +{ + if (this->direction == direction) + return; + if (direction == SubMarine::Right && this->direction == SubMarine::None) { + setYRotation(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(x(), y()); + torp->setCurrentSpeed(speed); + torp->launch(); +} + +void SubMarine::destroy() +{ + emit subMarineDestroyed(); +} + +int SubMarine::type() const +{ + return Type; +} diff --git a/examples/animation/sub-attaq/submarine.h b/examples/animation/sub-attaq/submarine.h new file mode 100644 index 0000000..562b4cf --- /dev/null +++ b/examples/animation/sub-attaq/submarine.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __SUBMARINE__H__ +#define __SUBMARINE__H__ + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qvariantanimation.h" +#include "qgraphicswidget.h" +#else +#include +#include +#endif + +class PixmapItem; + +class Torpedo; + +class SubMarine : public QGraphicsWidget +{ +Q_OBJECT +public: + enum Movement { + None = 0, + Left, + Right + }; + enum { Type = UserType + 1 }; + SubMarine(int type, const QString &name, int points, QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); + + int points(); + + void setCurrentDirection(Movement direction); + enum Movement currentDirection() const; + + void setCurrentSpeed(int speed); + int currentSpeed() const; + + void launchTorpedo(int speed); + void destroy(); + + virtual int type() const; + +Q_SIGNALS: + void subMarineDestroyed(); + void subMarineExecutionFinished(); + void subMarineStateChanged(); + +private: + int subType; + QString subName; + int subPoints; + int speed; + Movement direction; + PixmapItem *pixmapItem; +}; + +#endif //__SUBMARINE__H__ diff --git a/examples/animation/sub-attaq/submarine_p.h b/examples/animation/sub-attaq/submarine_p.h new file mode 100644 index 0000000..5aa84b6 --- /dev/null +++ b/examples/animation/sub-attaq/submarine_p.h @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SUBMARINE_P_H +#define SUBMARINE_P_H + +//Own +#include "animationmanager.h" +#include "submarine.h" + +//Qt +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qanimationstate.h" +#include "qpropertyanimation.h" +#else +#include +#include +#endif +#include + + +//This state is describing when the boat is moving right +class MovementState : public QAnimationState +{ +Q_OBJECT +public: + MovementState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + { + movementAnimation = new QPropertyAnimation(submarine, "pos"); + connect(movementAnimation,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationMovementValueChanged(const QVariant &))); + addAnimation(movementAnimation); + AnimationManager::self()->registerAnimation(movementAnimation); + this->submarine = submarine; + } +protected slots: + void onAnimationMovementValueChanged(const QVariant &) + { + if (qrand() % 200 + 1 == 3) + submarine->launchTorpedo(qrand() % 3 + 1); + } +protected: + void onEntry() + { + 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); + } + movementAnimation->setStartValue(submarine->pos()); + QAnimationState::onEntry(); + } + + void onExit() + { + movementAnimation->stop(); + QAnimationState::onExit(); + } +private: + SubMarine *submarine; + QPropertyAnimation *movementAnimation; +}; + +//This state is describing when the boat is moving right +class ReturnState : public QAnimationState +{ +public: + ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent) + { + returnAnimation = new QPropertyAnimation(submarine, "yRotation"); + AnimationManager::self()->registerAnimation(returnAnimation); + addAnimation(returnAnimation); + this->submarine = submarine; + } +protected: + void onEntry() + { + returnAnimation->stop(); + returnAnimation->setStartValue(submarine->yRotation()); + returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.); + returnAnimation->setDuration(500); + QAnimationState::onEntry(); + } + + void onExit() + { + returnAnimation->stop(); + submarine->currentDirection() == SubMarine::Right ? submarine->setCurrentDirection(SubMarine::Left) : submarine->setCurrentDirection(SubMarine::Right); + QAnimationState::onExit(); + } +private: + SubMarine *submarine; + QPropertyAnimation *returnAnimation; +}; + +#endif // SUBMARINE_P_H diff --git a/examples/animation/sub-attaq/torpedo.cpp b/examples/animation/sub-attaq/torpedo.cpp new file mode 100644 index 0000000..4964192 --- /dev/null +++ b/examples/animation/sub-attaq/torpedo.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//Own +#include "torpedo.h" +#include "pixmapitem.h" +#include "boat.h" +#include "graphicsscene.h" +#include "animationmanager.h" + +#if defined(QT_EXPERIMENTAL_SOLUTION) +#include "qpropertyanimation.h" +#include "qstatemachine.h" +#include "qfinalstate.h" +#include "qanimationstate.h" +#else +#include +#include +#include +#include +#endif + +Torpedo::Torpedo(QGraphicsItem * parent, Qt::WindowFlags wFlags) + : QGraphicsWidget(parent,wFlags), currentSpeed(0), launchAnimation(0) +{ + pixmapItem = new PixmapItem(QString::fromLatin1("torpedo"),GraphicsScene::Big, this); + setZValue(2); + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + setFlags(QGraphicsItem::ItemIsMovable); + resize(pixmapItem->boundingRect().size()); +} + +void Torpedo::launch() +{ + 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,SIGNAL(valueChanged(const QVariant &)),this,SLOT(onAnimationLaunchValueChanged(const QVariant &))); + + //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(launchAnimation,machine->rootState()); + + machine->setInitialState(launched); + + //End + QFinalState *final = new QFinalState(machine->rootState()); + + //### Add a nice animation when the torpedo is destroyed + launched->addTransition(this, SIGNAL(torpedoExplosed()),final); + + //If the animation is finished, then we move to the final state + launched->addFinishedTransition(final); + + //The machine has finished to be executed, then the boat is dead + connect(machine,SIGNAL(finished()),this, SIGNAL(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 &) +{ + foreach (QGraphicsItem *item , collidingItems(Qt::IntersectsItemBoundingRect)) { + if (item->type() == Boat::Type) { + Boat *b = static_cast(item); + b->destroy(); + } + } +} + +void Torpedo::destroy() +{ + launchAnimation->stop(); + emit torpedoExplosed(); +} diff --git a/examples/animation/sub-attaq/torpedo.h b/examples/animation/sub-attaq/torpedo.h new file mode 100644 index 0000000..33bbc04 --- /dev/null +++ b/examples/animation/sub-attaq/torpedo.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef __TORPEDO__H__ +#define __TORPEDO__H__ + +//Qt +#include + +#if defined(QT_EXPERIMENTAL_SOLUTION) +# include "qvariantanimation.h" +# include "qgraphicswidget.h" +#else +# include +# include +#endif + +class PixmapItem; + +class Torpedo : public QGraphicsWidget +{ +Q_OBJECT +Q_PROPERTY(QPointF pos READ pos WRITE setPos) +public: + Torpedo(QGraphicsItem * parent = 0, Qt::WindowFlags wFlags = 0); + void launch(); + void setCurrentSpeed(int speed); + void destroy(); + +Q_SIGNALS: + void torpedoExplosed(); + void torpedoExecutionFinished(); + +private slots: + void onAnimationLaunchValueChanged(const QVariant &); + +private: + int currentSpeed; + PixmapItem *pixmapItem; + QVariantAnimation *launchAnimation; +}; + +#endif //__TORPEDO__H__ diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml new file mode 100644 index 0000000..1d60ac0 --- /dev/null +++ b/examples/declarative/animation/animation.qml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/behaviours/MyRect.qml b/examples/declarative/behaviours/MyRect.qml new file mode 100644 index 0000000..e40bd1b --- /dev/null +++ b/examples/declarative/behaviours/MyRect.qml @@ -0,0 +1,4 @@ + + + + diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml new file mode 100644 index 0000000..a544028 --- /dev/null +++ b/examples/declarative/behaviours/test.qml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml new file mode 100644 index 0000000..3146338 --- /dev/null +++ b/examples/declarative/connections/connections.qml @@ -0,0 +1,9 @@ + + + + + color="green"; + dot.x = x-1; + dot.y = y-1; + + diff --git a/examples/declarative/contacts/contacts.pro b/examples/declarative/contacts/contacts.pro new file mode 100644 index 0000000..18293ee --- /dev/null +++ b/examples/declarative/contacts/contacts.pro @@ -0,0 +1,22 @@ +TEMPLATE = app +TARGET = contacts + +MOC_DIR = .moc +OBJECTS_DIR = .obj + +QT += declarative script sql + +unix { + sqlitedb.output = ${QMAKE_FILE_BASE}.sqlite + sqlitedb.commands = rm -f ${QMAKE_FILE_OUT}; if which sqlite3 ; then sqlite3 ${QMAKE_FILE_OUT} < ${QMAKE_FILE_NAME} ; fi + sqlitedb.input = SQL_SOURCES + sqlitedb.CONFIG += no_link target_predeps + + QMAKE_EXTRA_COMPILERS += sqlitedb + QMAKE_EXTRA_TARGETS = sqlitedb +} + +SQL_SOURCES += data/contacts.sql + +SOURCES += main.cpp + diff --git a/examples/declarative/contacts/contacts.qml b/examples/declarative/contacts/contacts.qml new file mode 100644 index 0000000..d4647f9 --- /dev/null +++ b/examples/declarative/contacts/contacts.qml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + {Math.max(email_layout.height + name.height + 25, portraitPic.height+20)} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/contacts/dummydata/contactModel.qml b/examples/declarative/contacts/dummydata/contactModel.qml new file mode 100644 index 0000000..341b7a6 --- /dev/null +++ b/examples/declarative/contacts/dummydata/contactModel.qml @@ -0,0 +1,103 @@ + + + Aaron + Kennedy + contact.png + + + + + + + Contact + 1 + contact.png + + + Contact + 2 + contact.png + + + Contact + 3 + contact.png + + + Contact + 4 + contact.png + + + Contact + 5 + contact.png + + + Contact + 6 + contact.png + + + Contact + 7 + contact.png + + + Contact + 8 + contact.png + + + Contact + 9 + contact.png + + + Alan + Alpert + contact.png + + + Betty + Boo + contact.png + + + Foo + Bar + contact.png + + + Marius + Bugge Monsen + contact.png + + + Martin + Jones + contact.png + + + + + + + Michael + Brasser + contact.png + + + + + + Yann + Bodson + contact.png + + + Yogi + Bear + contact.png + + diff --git a/examples/declarative/contacts/main.cpp b/examples/declarative/contacts/main.cpp new file mode 100644 index 0000000..6bf9daf --- /dev/null +++ b/examples/declarative/contacts/main.cpp @@ -0,0 +1,80 @@ +#include "qml.h" +#include + +#include +#include +#include +#include +#include + +const char *defaultFileName("contacts.xml"); + +class Contacts : public QWidget +{ +Q_OBJECT +public: + Contacts(const QString &fileName, int = 240, int = 320, QWidget *parent=0, Qt::WindowFlags flags=0); + +public slots: + void sceneResized(QSize size) + { + if(size.width() > 0 && size.height() > 0) + canvas->setFixedSize(size.width(), size.height()); + } + +private: + QFxView *canvas; +}; + +Contacts::Contacts(const QString &fileName, int width, int height, QWidget *parent, Qt::WindowFlags flags) +: QWidget(parent, flags), canvas(0) +{ + setAttribute(Qt::WA_OpaquePaintEvent); + setAttribute(Qt::WA_NoSystemBackground); + + QVBoxLayout *vbox = new QVBoxLayout; + vbox->setMargin(0); + setLayout(vbox); + + canvas = new QFxView(this); + QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); + canvas->setFixedSize(width, height); + vbox->addWidget(canvas); + + QFile file(fileName); + file.open(QFile::ReadOnly); + QString xml = file.readAll(); + canvas->setXml(xml, fileName); + + canvas->execute(); +} + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + bool frameless = false; + + int width = 240; + int height = 320; + + QString fileName; + for (int i = 1; i < argc; ++i) { + QString arg = argv[i]; + if (arg == "-frameless") { + frameless = true; + } else { + fileName = arg; + break; + } + } + if (fileName.isEmpty()) + fileName = QLatin1String(defaultFileName); + + Contacts contacts(fileName, width, height, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); + contacts.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro new file mode 100644 index 0000000..3083800 --- /dev/null +++ b/examples/declarative/declarative.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +CONFIG = ordered + +SUBDIRS += minehunt \ diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml new file mode 100644 index 0000000..acff119 --- /dev/null +++ b/examples/declarative/dial/DialLibrary/Dial.qml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/examples/declarative/dial/DialLibrary/background.svg b/examples/declarative/dial/DialLibrary/background.svg new file mode 100644 index 0000000..415320d --- /dev/null +++ b/examples/declarative/dial/DialLibrary/background.svg @@ -0,0 +1,385 @@ + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 + +1 +0 + +2 +0 + +3 +0 + +4 +0 + +5 +0 + +6 +0 + +7 +0 + +8 +0 + +9 +0 + +1 +0 +0 + +1 +1 +0 + +1 +2 +0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/dial/DialLibrary/needle.svg b/examples/declarative/dial/DialLibrary/needle.svg new file mode 100644 index 0000000..dce7d7e --- /dev/null +++ b/examples/declarative/dial/DialLibrary/needle.svg @@ -0,0 +1,26 @@ + + + +]> + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/dial/DialLibrary/needle_shadow.svg b/examples/declarative/dial/DialLibrary/needle_shadow.svg new file mode 100644 index 0000000..6aab197 --- /dev/null +++ b/examples/declarative/dial/DialLibrary/needle_shadow.svg @@ -0,0 +1,30 @@ + + + +]> + + + + + + diff --git a/examples/declarative/dial/DialLibrary/overlay.svg b/examples/declarative/dial/DialLibrary/overlay.svg new file mode 100644 index 0000000..8530dd5 --- /dev/null +++ b/examples/declarative/dial/DialLibrary/overlay.svg @@ -0,0 +1,47 @@ + + + +]> + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml new file mode 100644 index 0000000..ce43b01 --- /dev/null +++ b/examples/declarative/dial/dial.qml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml new file mode 100644 index 0000000..f95d8c6 --- /dev/null +++ b/examples/declarative/easing/easing.qml @@ -0,0 +1,67 @@ + + + + + easeLinear + easeInQuad + easeOutQuad + easeInOutQuad + easeOutInQuad + easeInCubic + easeOutCubic + easeInOutCubic + easeOutInCubic + easeInQuart + easeOutQuart + easeInOutQuart + easeOutInQuart + easeInQuint + easeOutQuint + easeInOutQuint + easeOutInQuint + easeInSine + easeOutSine + easeInOutSine + easeOutInSine + easeInExpo + easeOutExpo + easeInOutExpo + easeOutInExpo + easeInCirc + easeOutCirc + easeInOutCirc + easeOutInCirc + easeInElastic + easeOutElastic + easeInOutElastic + easeOutInElastic + easeInBack + easeOutBack + easeInOutBack + easeOutInBack + easeOutBounce + easeInBounce + easeInOutBounce + easeOutInBounce + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml new file mode 100644 index 0000000..0f3e772 --- /dev/null +++ b/examples/declarative/follow/follow.qml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml new file mode 100644 index 0000000..4fbf323 --- /dev/null +++ b/examples/declarative/follow/pong.qml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + if (y <= 0) + targetY = Page.height-20; + else if (y >= Page.height-20) + targetY = 0; + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/listview/content/MediaButton.qml b/examples/declarative/listview/content/MediaButton.qml new file mode 100644 index 0000000..c92305a --- /dev/null +++ b/examples/declarative/listview/content/MediaButton.qml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + {Image.width} + + + + + + + diff --git a/examples/declarative/listview/content/pics/button-pressed.png b/examples/declarative/listview/content/pics/button-pressed.png new file mode 100644 index 0000000..e434d32 Binary files /dev/null and b/examples/declarative/listview/content/pics/button-pressed.png differ diff --git a/examples/declarative/listview/content/pics/button.png b/examples/declarative/listview/content/pics/button.png new file mode 100644 index 0000000..56a63ce Binary files /dev/null and b/examples/declarative/listview/content/pics/button.png differ diff --git a/examples/declarative/listview/content/pics/fruit-salad.jpg b/examples/declarative/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000..da5a6b1 Binary files /dev/null and b/examples/declarative/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/declarative/listview/content/pics/hamburger.jpg b/examples/declarative/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000..d0a15be Binary files /dev/null and b/examples/declarative/listview/content/pics/hamburger.jpg differ diff --git a/examples/declarative/listview/content/pics/lemonade.jpg b/examples/declarative/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000..db445c9 Binary files /dev/null and b/examples/declarative/listview/content/pics/lemonade.jpg differ diff --git a/examples/declarative/listview/content/pics/pancakes.jpg b/examples/declarative/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000..60c4396 Binary files /dev/null and b/examples/declarative/listview/content/pics/pancakes.jpg differ diff --git a/examples/declarative/listview/content/pics/vegetable-soup.jpg b/examples/declarative/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000..9dce332 Binary files /dev/null and b/examples/declarative/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml new file mode 100644 index 0000000..5af7fbf --- /dev/null +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -0,0 +1,51 @@ + + + + Rover + Dog + 5 + + + Whiskers + Cat + 2 + + + Warren + Rabbit + 2 + + + Polly + Parrot + 12 + + + Spot + Dog + 9 + + + Tiny + Elephant + 15 + + + Penny + Turtle + 4 + + + Joey + Kangaroo + 1 + + + Kimba + Bunny + 65 + + diff --git a/examples/declarative/listview/dummydata/Recipies.qml b/examples/declarative/listview/dummydata/Recipies.qml new file mode 100644 index 0000000..49bc610 --- /dev/null +++ b/examples/declarative/listview/dummydata/Recipies.qml @@ -0,0 +1,112 @@ + + + + +
      +
    • 1 cup (150g) self-raising flour +
    • 1 tbs caster sugar +
    • 3/4 cup (185ml) milk +
    • 1 egg +
    + + ]]> +
    + + +
      +
    1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
    2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
    3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
    4. Turn over and cook other side until golden. +
    + ]]> +
    +
    + + + * Seasonal Fruit + + + * Chop fruit and place in a bowl. + + + + + +
      +
    • 1 onion +
    • 1 turnip +
    • 1 potato +
    • 1 carrot +
    • 1 head of celery +
    • 1 1/2 litres of water +
    + + ]]> +
    + + +
      +
    1. Chop vegetables. +
    2. Boil in water until vegetables soften. +
    3. Season with salt and pepper to taste. +
    + + ]]> +
    +
    + + + +
      +
    • 500g minced beef +
    • Seasoning +
    • lettuce, tomato, onion, cheese +
    • 1 hamburger bun for each burger +
    + + ]]> +
    + + +
      +
    1. Mix the beef, together with seasoning, in a food processor. +
    2. Shape the beef into burgers. +
    3. Grill the burgers for about 5 mins on each side (until cooked through) +
    4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
    + + ]]> +
    +
    + + + +
      +
    • 1 cup Lemon Juice +
    • 1 cup Sugar +
    • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
    + + ]]> +
    + + +
      +
    1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
    2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
    3. Chill or serve over ice cubes. +
    + + ]]> +
    +
    +
    diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml new file mode 100644 index 0000000..5ce7acb --- /dev/null +++ b/examples/declarative/listview/highlight.qml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml new file mode 100644 index 0000000..08c8f18 --- /dev/null +++ b/examples/declarative/listview/listview.qml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml new file mode 100644 index 0000000..7d32532 --- /dev/null +++ b/examples/declarative/listview/recipes.qml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 68 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml new file mode 100644 index 0000000..5bda5f8 --- /dev/null +++ b/examples/declarative/minehunt/Description.qml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/declarative/minehunt/Explosion.qml b/examples/declarative/minehunt/Explosion.qml new file mode 100644 index 0000000..aec685b --- /dev/null +++ b/examples/declarative/minehunt/Explosion.qml @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp new file mode 100644 index 0000000..9db717b --- /dev/null +++ b/examples/declarative/minehunt/main.cpp @@ -0,0 +1,312 @@ +#include "qmlbindablevalue.h" +#include "qmlengine.h" +#include "qmlcontext.h" +#include "qml.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +QString fileName = "minehunt.qml"; + +class Tile : public QObject +{ + Q_OBJECT +public: + Tile() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged); + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged); + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged); + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()); + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +QML_DECLARE_TYPE(Tile); +QML_DEFINE_TYPE(Tile,Tile); + +class MyWidget : public QWidget +{ +Q_OBJECT +public: + MyWidget(int = 370, int = 480, QWidget *parent=0, Qt::WindowFlags flags=0); + ~MyWidget(); + + Q_PROPERTY(QList *tiles READ tiles); + QList *tiles() { return &_tiles; } + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged); + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged); + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged); + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged); + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE void flip(int row, int col); + Q_INVOKABLE void flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + Tile *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QFxView *canvas; + + QList _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; + +MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags) +: QWidget(parent, flags), canvas(0), numCols(9), numRows(9), playing(true), won(false) +{ + setObjectName("mainWidget"); + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + //initialize array + for(int ii = 0; ii < numRows * numCols; ++ii) { + _tiles << new Tile; + } + + reset(); + + QVBoxLayout *vbox = new QVBoxLayout; + vbox->setMargin(0); + setLayout(vbox); + + canvas = new QFxView(this); + canvas->setFixedSize(width, height); + vbox->addWidget(canvas); + + QFile file(fileName); + file.open(QFile::ReadOnly); + QString xml = file.readAll(); + canvas->setXml(xml, fileName); + + QmlContext *ctxt = canvas->rootContext(); + ctxt->activate(); + ctxt->addDefaultObject(this); + ctxt->deactivate(); + + canvas->execute(); +} + +MyWidget::~MyWidget() +{ +} + +void MyWidget::setBoard() +{ + foreach(Tile* t, _tiles){ + t->setHasMine(false); + t->setHint(-1); + } + //place mines + int mines = nMines; + remaining = numRows*numCols-mines; + while ( mines ) { + int col = int((double(rand()) / double(RAND_MAX)) * numCols); + int row = int((double(rand()) / double(RAND_MAX)) * numRows); + + Tile* t = tile( row, col ); + + if (t && !t->hasMine()) { + t->setHasMine( true ); + mines--; + } + } + + //set hints + for (int r = 0; r < numRows; r++) + for (int c = 0; c < numCols; c++) { + Tile* t = tile(r, c); + if (t && !t->hasMine()) { + int hint = getHint(r,c); + t->setHint(hint); + } + } + + setPlaying(true); +} + +void MyWidget::reset() +{ + foreach(Tile* t, _tiles){ + t->unflip(); + t->setHasFlag(false); + } + nMines = 12; + nFlags = 0; + setPlaying(false); + QTimer::singleShot(900,this, SLOT(setBoard())); +} + +int MyWidget::getHint(int row, int col) +{ + int hint = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + Tile* t = tile(r, c); + if (t && t->hasMine()) + hint++; + } + return hint; +} + +void MyWidget::flip(int row, int col) +{ + if(!playing) + return; + + Tile *t = tile(row, col); + if (!t || t->hasFlag()) + return; + + if(t->flipped()){ + int flags = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + Tile *nearT = tile(r, c); + if(!nearT || nearT == t) + continue; + if(nearT->hasFlag()) + flags++; + } + if(!t->hint() || t->hint() != flags) + return; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + Tile *nearT = tile(r, c); + if (nearT && !nearT->flipped() && !nearT->hasFlag()) { + flip( r, c ); + } + } + return; + } + + t->flip(); + + if (t->hint() == 0) { + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + Tile* t = tile(r, c); + if (t && !t->flipped()) { + flip( r, c ); + } + } + } + + if(t->hasMine()){ + for (int r = 0; r < numRows; r++)//Flip all other mines + for (int c = 0; c < numCols; c++) { + Tile* t = tile(r, c); + if (t && t->hasMine()) { + flip(r, c); + } + } + won = false; + hasWonChanged(); + setPlaying(false); + } + + remaining--; + if(!remaining){ + won = true; + hasWonChanged(); + setPlaying(false); + } +} + +void MyWidget::flag(int row, int col) +{ + Tile *t = tile(row, col); + if(!t) + return; + + t->setHasFlag(!t->hasFlag()); + nFlags += (t->hasFlag()?1:-1); + emit numFlagsChanged(); +} +///////////////////////////////////////////////////////// + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + bool frameless = false; + + int width = 370; + int height = 480; + + for (int i = 1; i < argc; ++i) { + QString arg = argv[i]; + if (arg == "-frameless") { + frameless = true; + } else if(arg == "-width" && i < (argc - 1)) { + ++i; + width = ::atoi(argv[i]); + } else if(arg == "-height" && i < (argc - 1)) { + ++i; + height = ::atoi(argv[i]); + } else if (arg[0] != '-') { + fileName = arg; + } + } + + MyWidget wid(width, height, 0, frameless ? Qt::FramelessWindowHint : Qt::Widget); + wid.show(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro new file mode 100644 index 0000000..08b6254 --- /dev/null +++ b/examples/declarative/minehunt/minehunt.pro @@ -0,0 +1,8 @@ +SOURCES = main.cpp + +QT += script declarative + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS minehunt.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/minehunt +INSTALLS += target sources diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml new file mode 100644 index 0000000..9cde164 --- /dev/null +++ b/examples/declarative/minehunt/minehunt.qml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + In play: + + + + + + + + + + diff --git a/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg b/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg new file mode 100644 index 0000000..445567f Binary files /dev/null and b/examples/declarative/minehunt/pics/No-Ones-Laughing-3.jpg differ diff --git a/examples/declarative/minehunt/pics/bomb-color.png b/examples/declarative/minehunt/pics/bomb-color.png new file mode 100644 index 0000000..61ad0a9 Binary files /dev/null and b/examples/declarative/minehunt/pics/bomb-color.png differ diff --git a/examples/declarative/minehunt/pics/bomb.png b/examples/declarative/minehunt/pics/bomb.png new file mode 100644 index 0000000..a992575 Binary files /dev/null and b/examples/declarative/minehunt/pics/bomb.png differ diff --git a/examples/declarative/minehunt/pics/cachepix-black.png b/examples/declarative/minehunt/pics/cachepix-black.png new file mode 100644 index 0000000..53db3ae Binary files /dev/null and b/examples/declarative/minehunt/pics/cachepix-black.png differ diff --git a/examples/declarative/minehunt/pics/cachepix-black.sci b/examples/declarative/minehunt/pics/cachepix-black.sci new file mode 100644 index 0000000..21d5436 --- /dev/null +++ b/examples/declarative/minehunt/pics/cachepix-black.sci @@ -0,0 +1,5 @@ +gridLeft: 10 +gridTop: 10 +gridBottom: 10 +gridRight: 10 +imageFile: cachepix-black.png diff --git a/examples/declarative/minehunt/pics/cachepix-boxless.png b/examples/declarative/minehunt/pics/cachepix-boxless.png new file mode 100644 index 0000000..288e0e4 Binary files /dev/null and b/examples/declarative/minehunt/pics/cachepix-boxless.png differ diff --git a/examples/declarative/minehunt/pics/cachepix-boxless.sci b/examples/declarative/minehunt/pics/cachepix-boxless.sci new file mode 100644 index 0000000..d224fd9 --- /dev/null +++ b/examples/declarative/minehunt/pics/cachepix-boxless.sci @@ -0,0 +1,5 @@ +gridLeft: 10 +gridTop: 10 +gridBottom: 10 +gridRight: 10 +imageFile: cachepix-boxless.png diff --git a/examples/declarative/minehunt/pics/flag-color.png b/examples/declarative/minehunt/pics/flag-color.png new file mode 100644 index 0000000..aadad0f Binary files /dev/null and b/examples/declarative/minehunt/pics/flag-color.png differ diff --git a/examples/declarative/minehunt/pics/flag.png b/examples/declarative/minehunt/pics/flag.png new file mode 100644 index 0000000..39cde4d Binary files /dev/null and b/examples/declarative/minehunt/pics/flag.png differ diff --git a/examples/declarative/minehunt/pics/frown.png b/examples/declarative/minehunt/pics/frown.png new file mode 100644 index 0000000..52684b3 Binary files /dev/null and b/examples/declarative/minehunt/pics/frown.png differ diff --git a/examples/declarative/minehunt/pics/glee.png b/examples/declarative/minehunt/pics/glee.png new file mode 100644 index 0000000..59ea583 Binary files /dev/null and b/examples/declarative/minehunt/pics/glee.png differ diff --git a/examples/declarative/minehunt/pics/smile.png b/examples/declarative/minehunt/pics/smile.png new file mode 100644 index 0000000..ccd52cd Binary files /dev/null and b/examples/declarative/minehunt/pics/smile.png differ diff --git a/examples/declarative/minehunt/pics/star.png b/examples/declarative/minehunt/pics/star.png new file mode 100644 index 0000000..3772359 Binary files /dev/null and b/examples/declarative/minehunt/pics/star.png differ diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml new file mode 100644 index 0000000..f0f22ac --- /dev/null +++ b/examples/declarative/mouseregion/mouse.qml @@ -0,0 +1,24 @@ + + + + + + + + + + diff --git a/examples/declarative/namespaces/BlueStuff/Rect.qml b/examples/declarative/namespaces/BlueStuff/Rect.qml new file mode 100644 index 0000000..94e066c --- /dev/null +++ b/examples/declarative/namespaces/BlueStuff/Rect.qml @@ -0,0 +1 @@ + diff --git a/examples/declarative/namespaces/Local.qml b/examples/declarative/namespaces/Local.qml new file mode 100644 index 0000000..5fb2aef --- /dev/null +++ b/examples/declarative/namespaces/Local.qml @@ -0,0 +1 @@ +This is a local component diff --git a/examples/declarative/namespaces/components.qml b/examples/declarative/namespaces/components.qml new file mode 100644 index 0000000..ea5e2d9 --- /dev/null +++ b/examples/declarative/namespaces/components.qml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/namespaces/lib/Chronos/Clock.qml b/examples/declarative/namespaces/lib/Chronos/Clock.qml new file mode 100644 index 0000000..088a45c --- /dev/null +++ b/examples/declarative/namespaces/lib/Chronos/Clock.qml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/examples/declarative/namespaces/lib/Chronos/Hand.qml b/examples/declarative/namespaces/lib/Chronos/Hand.qml new file mode 100644 index 0000000..3662e74 --- /dev/null +++ b/examples/declarative/namespaces/lib/Chronos/Hand.qml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/examples/declarative/namespaces/lib/Chronos/pics/clockface.png b/examples/declarative/namespaces/lib/Chronos/pics/clockface.png new file mode 100644 index 0000000..a885950 Binary files /dev/null and b/examples/declarative/namespaces/lib/Chronos/pics/clockface.png differ diff --git a/examples/declarative/namespaces/lib/Path/PathLabel.qml b/examples/declarative/namespaces/lib/Path/PathLabel.qml new file mode 100644 index 0000000..c4b08b0 --- /dev/null +++ b/examples/declarative/namespaces/lib/Path/PathLabel.qml @@ -0,0 +1 @@ + diff --git a/examples/declarative/namespaces/lib/RedStuff/Rect.qml b/examples/declarative/namespaces/lib/RedStuff/Rect.qml new file mode 100644 index 0000000..3429b09 --- /dev/null +++ b/examples/declarative/namespaces/lib/RedStuff/Rect.qml @@ -0,0 +1 @@ + diff --git a/examples/declarative/namespaces/lib/Wrong/Wrong.qml b/examples/declarative/namespaces/lib/Wrong/Wrong.qml new file mode 100644 index 0000000..3af55f6 --- /dev/null +++ b/examples/declarative/namespaces/lib/Wrong/Wrong.qml @@ -0,0 +1,3 @@ + + + diff --git a/examples/declarative/namespaces/library.qml b/examples/declarative/namespaces/library.qml new file mode 100644 index 0000000..ae10ed8 --- /dev/null +++ b/examples/declarative/namespaces/library.qml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/examples/declarative/namespaces/path.qml b/examples/declarative/namespaces/path.qml new file mode 100644 index 0000000..795447b --- /dev/null +++ b/examples/declarative/namespaces/path.qml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/examples/declarative/namespaces/simple.qml b/examples/declarative/namespaces/simple.qml new file mode 100644 index 0000000..16d9815 --- /dev/null +++ b/examples/declarative/namespaces/simple.qml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/declarative/namespaces/wrong1.qml b/examples/declarative/namespaces/wrong1.qml new file mode 100644 index 0000000..721c45a --- /dev/null +++ b/examples/declarative/namespaces/wrong1.qml @@ -0,0 +1,4 @@ + + + + diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml new file mode 100644 index 0000000..470a170 --- /dev/null +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml new file mode 100644 index 0000000..697b68a --- /dev/null +++ b/examples/declarative/scrollbar/display.qml @@ -0,0 +1,28 @@ + + + + + + {Picture.width} + {Picture.height} + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/scrollbar/pics/niagara_falls.jpg b/examples/declarative/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000..618d808 Binary files /dev/null and b/examples/declarative/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml new file mode 100644 index 0000000..90e6e64 --- /dev/null +++ b/examples/declarative/slideswitch/Switch.qml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/slideswitch/background.svg b/examples/declarative/slideswitch/background.svg new file mode 100644 index 0000000..f920d3e --- /dev/null +++ b/examples/declarative/slideswitch/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/display.qml new file mode 100644 index 0000000..b62422c --- /dev/null +++ b/examples/declarative/slideswitch/display.qml @@ -0,0 +1,3 @@ + + + diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/knob.svg new file mode 100644 index 0000000..fb69337 --- /dev/null +++ b/examples/declarative/slideswitch/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml new file mode 100644 index 0000000..e540d25 --- /dev/null +++ b/examples/declarative/states/states.qml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml new file mode 100644 index 0000000..c3f3515 --- /dev/null +++ b/examples/declarative/states/transitions.qml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/support/contact.cpp b/examples/declarative/support/contact.cpp new file mode 100644 index 0000000..7d90fc4 --- /dev/null +++ b/examples/declarative/support/contact.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "contact.h" +#include "qmltypes.h" + +QML_DEFINE_TYPE(Contact,Contact); +Contact::Contact() : QObject(0) +{ + m_firstName = "John"; + m_lastName = "Smith"; + m_portraitFile = "contact.png"; + m_company = "Trollkia"; + m_emails << "smith@trollkia.com" << "john45@gmail.com"; + + m_numbers << new PhoneNumber; + m_numbers << new PhoneNumber; + m_numbers << new PhoneNumber; + + m_numbers.at(0)->setType(PhoneNumber::HomePhone); + m_numbers.at(0)->setNumber("35412451"); + + m_numbers.at(1)->setType(PhoneNumber::BusinessPhone); + m_numbers.at(1)->setNumber("33424994"); + + m_numbers.at(2)->setType(PhoneNumber::MobilePhone); + m_numbers.at(2)->setNumber("0424655137"); + + m_addresses << new Address; + m_addresses << new Address; + m_addresses << new Address; + m_addresses.at(0)->setNumber(13); + m_addresses.at(0)->setStreet("Blackhill Cr"); + m_addresses.at(0)->setCountry("Australia"); + m_addresses.at(1)->setNumber(116); + m_addresses.at(1)->setStreet("Sandankerveien"); + m_addresses.at(1)->setCountry("Norway"); + m_addresses.at(2)->setNumber(92); + m_addresses.at(2)->setStreet("Elizibeth St"); + m_addresses.at(2)->setCountry("Australia"); +} + +void Contact::addNumber(PhoneNumber *newNumber) +{ + + m_numbers << newNumber; + emit numbersChanged(); +} + +void Contact::addAddress(Address *newAddress) +{ + m_addresses << newAddress; + emit addressesChanged(); +} + +void Contact::addEmail(QString &newEmail) +{ + + m_emails << newEmail; + emit emailsChanged(); +} + +QML_DEFINE_TYPE(Address,Address); +Address::Address() +: _number(0) +{ +} + +QML_DEFINE_TYPE(PhoneNumber, PhoneNumber); +PhoneNumber::PhoneNumber() +: _type(HomePhone) +{ +} diff --git a/examples/declarative/support/contact.h b/examples/declarative/support/contact.h new file mode 100644 index 0000000..c403f8b --- /dev/null +++ b/examples/declarative/support/contact.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef CONTACT_H +#define CONTACT_H + +#include +#include + + +class Address : public QObject +{ + Q_OBJECT +public: + Address(); + + Q_PROPERTY(int number READ number WRITE setNumber NOTIFY changed); + Q_PROPERTY(QString street READ street WRITE setStreet NOTIFY changed); + Q_PROPERTY(QString country READ country WRITE setCountry NOTIFY changed); + + int number() const { return _number; } + void setNumber(int n) { _number = n; emit changed(); } + + QString street() const { return _street; } + void setStreet(const QString &s) { _street = s; emit changed(); } + + QString country() const { return _country; } + void setCountry(const QString &c) { _country = c; emit changed(); } + +signals: + void changed(); + +private: + int _number; + QString _street; + QString _country; +}; +QML_DECLARE_TYPE(Address); + +class PhoneNumber : public QObject +{ + Q_OBJECT + Q_ENUMS(PhoneType) +public: + PhoneNumber(); + + enum PhoneType { + HomePhone, + BusinessPhone, + MobilePhone + }; + + Q_PROPERTY(QString number READ number WRITE setNumber NOTIFY changed); + Q_PROPERTY(PhoneType type READ type WRITE setType NOTIFY changed); + + QString number() const { return _number; } + void setNumber(QString n) { _number = n; emit changed(); } + + PhoneType type() const { return _type; } + void setType(PhoneType type) { _type = type; emit changed(); } + +signals: + void changed(); + +private: + QString _number; + PhoneType _type; +}; +QML_DECLARE_TYPE(PhoneNumber); + +class Contact : public QObject +{ + Q_OBJECT +public: + Contact(); + + Q_PROPERTY(QString firstName READ firstName WRITE setFirstName NOTIFY nameChanged); + QString firstName() const { return m_firstName; } + + Q_PROPERTY(QString lastName READ lastName WRITE setLastName NOTIFY nameChanged); + QString lastName() const { return m_lastName; } + + Q_PROPERTY(QString portraitFile READ portraitFile WRITE setPortraitFile NOTIFY portraitChanged); + QString portraitFile() const { return m_portraitFile; } + + Q_PROPERTY(QString company READ company WRITE setCompany NOTIFY companyChanged); + QString company() const { return m_company; } + + Q_PROPERTY(QStringList emails READ emails WRITE setEmails NOTIFY emailsChanged); + QStringList emails() const { return m_emails; } + + Q_PROPERTY(QList
    * addresses READ addresses); + QList
    * addresses() { return &m_addresses; } + + Q_PROPERTY(QList* numbers READ numbers); + QList* numbers() { return &m_numbers; } + + + void addEmail(QString&); + void addAddress(Address*); + void addNumber(PhoneNumber*); + +public slots: + void setFirstName(const QString &name) { m_firstName = name; emit nameChanged(); } + void setLastName(const QString &name) { m_lastName = name; emit nameChanged(); } + void setPortraitFile(const QString &portraitFile) { m_portraitFile = portraitFile; emit portraitChanged(); } + void setCompany(const QString &company) { m_company = company; emit companyChanged(); } + void setEmails(const QStringList &emails) { m_emails = emails; emit emailsChanged(); } + +signals: + void nameChanged(); + void portraitChanged(); + void companyChanged(); + void emailsChanged(); + void numbersChanged(); + void addressesChanged(); + +private: + QString m_firstName; + QString m_lastName; + QString m_portraitFile; + + QString m_company; + + QList
    m_addresses; + QListm_numbers; + QStringList m_emails; +}; +QML_DECLARE_TYPE(Contact); + +#endif diff --git a/examples/declarative/support/contactmodel.cpp b/examples/declarative/support/contactmodel.cpp new file mode 100644 index 0000000..efe108fb --- /dev/null +++ b/examples/declarative/support/contactmodel.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "contactmodel.h" +#include "qmltypes.h" + +ContactModel::ContactModel(QObject *parent) : QListModelInterface(parent) +{ + QFile f("../contacts/contacts.txt"); + f.open(QIODevice::ReadOnly); + QTextStream ts(&f); + QString text = ts.readLine(); + while(!text.isEmpty()) { + Contact *c = new Contact; + QStringList list = text.split(" "); + c->setFirstName(list[0]); + c->setLastName(list[1]); + for (int i = 2; i < list.count(); ++i) + c->addEmail(list[i]); + //contactList.append(c); + insertContact(c); + + text = ts.readLine(); + } + f.close(); +} + +ContactModel::~ContactModel() +{ + while (!contactList.isEmpty()) { + Contact *c = contactList.takeFirst(); + delete c; + } +} + +int ContactModel::count() const +{ + return contactList.count(); +} + +QHash ContactModel::data(int index, const QList &roles) const +{ + QHash returnHash; + + for (int i = 0; i < roles.size(); ++i) { + int role = roles.at(i); + QVariant info; + switch(role) { + case PortraitRole: + info = "contact.png"; + break; + case FirstNameRole: + info = contactList.at(index)->firstName(); + break; + case LastNameRole: + info = contactList.at(index)->lastName(); + break; + case CompanyRole: + info = contactList.at(index)->company(); + break; + case EmailsRole: + info = contactList.at(index)->emails(); + break; + case AddressesRole: + //returns QVariant BOOL + info = QVariant::fromValue(contactList.at(index)->addresses()); + break; + case NumbersRole: + info = QVariant::fromValue(contactList.at(index)->numbers()); + break; + default: + break; + } + returnHash.insert(role, info); + } + + return returnHash; +} + +QString ContactModel::toString(int role) const +{ + switch(role) { + case PortraitRole: + return "portrait"; + case FirstNameRole: + return "firstName"; + case LastNameRole: + return "lastName"; + case CompanyRole: + return "company"; + case EmailsRole: + return "emails"; + case AddressesRole: + return "addresses"; + case NumbersRole: + return "numbers"; + default: + return ""; + } +} + +QList ContactModel::roles() const +{ + return QList() << PortraitRole << FirstNameRole << LastNameRole << CompanyRole << EmailsRole << AddressesRole << NumbersRole; +} + +void ContactModel::deleteContact(int index) +{ + delete contactList.takeAt(index); + emit itemsRemoved(index, 1); +} + +int ContactModel::insertContact(Contact *contact) +{ + int index = 0; + QString fullName = contact->lastName(); + index = findIndex(fullName); + contactList.insert(index, contact); + emit itemsInserted(index, 1); + return index; +} + + +//search - binary search algorithm lastname only + +int ContactModel::findIndex(QString &searchName) const +{ + int start = 0; + int end = contactList.size()-1; + int middle = 0; + QString middleString; + + while (start <= end) + { + middle = (start+end)/2; + middleString = contactList.at(middle)->lastName(); + if (isAfter(searchName, middleString) < 0) start = middle+1; + else if( isAfter(middleString, searchName) < 0) end = middle-1; + else return middle; + } + return start; +} + +int ContactModel::isAfter(QString &name1, QString &name2) const +{ + //if c1 is after c2 alphabetically, return positive + int compString = QString::compare(name1, name2, Qt::CaseInsensitive); + return -compString; +} diff --git a/examples/declarative/support/contactmodel.h b/examples/declarative/support/contactmodel.h new file mode 100644 index 0000000..e262358 --- /dev/null +++ b/examples/declarative/support/contactmodel.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ $TROLLTECH$. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $TROLLTECH_DUAL_LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef _CONTACTMODEL_H_ +#define _CONTACTMODEL_H_ + +#include +#include "contact.h" + +class ContactModel : public QListModelInterface +{ + Q_OBJECT +public: + ContactModel(QObject *parent = 0); + ~ContactModel(); + + enum Roles { + PortraitRole, + FirstNameRole, + LastNameRole, + CompanyRole, + EmailsRole, + AddressesRole, + NumbersRole + }; + + int count() const; + + QHash data(int index, const QList &roles) const; + QList roles() const; + + + QString toString(int role) const; + + void deleteContact(int index); + int insertContact(Contact *contact); + + int isAfter(QString &name1, QString &name2) const; + int findIndex(QString &searchName) const; + +private: + QList contactList; +}; + +#endif diff --git a/examples/declarative/support/support.pro b/examples/declarative/support/support.pro new file mode 100644 index 0000000..1da1a28 --- /dev/null +++ b/examples/declarative/support/support.pro @@ -0,0 +1,12 @@ +TEMPLATE = lib +TARGET = QtFxSupport +DEPENDPATH += . +INCLUDEPATH += . +MOC_DIR = .moc +OBJECTS_DIR = .obj +DESTDIR = ../../lib +QT += script declarative + +HEADERS += contact.h contactmodel.h +SOURCES += contact.cpp contactmodel.cpp + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_an_animation.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_an_animation.qml new file mode 100644 index 0000000..06c9f5a --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_an_animation.qml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton1.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton1.qml new file mode 100644 index 0000000..dc3f505 --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton1.qml @@ -0,0 +1,4 @@ + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton2.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton2.qml new file mode 100644 index 0000000..2ba488d --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton2.qml @@ -0,0 +1,10 @@ + + + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton3.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton3.qml new file mode 100644 index 0000000..9a364c5 --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton3.qml @@ -0,0 +1,23 @@ + + + + + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton4.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton4.qml new file mode 100644 index 0000000..45ca19d --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton4.qml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton5.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton5.qml new file mode 100644 index 0000000..68c1838 --- /dev/null +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/RemoveButton5.qml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml new file mode 100644 index 0000000..29fdf51 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/Contact3.qml b/examples/declarative/tutorials/contacts/2_Reuse/Contact3.qml new file mode 100644 index 0000000..fdd0c6d --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/Contact3.qml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/Contact4.qml b/examples/declarative/tutorials/contacts/2_Reuse/Contact4.qml new file mode 100644 index 0000000..b1882da --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/Contact4.qml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/ContactField1.qml b/examples/declarative/tutorials/contacts/2_Reuse/ContactField1.qml new file mode 100644 index 0000000..5547a3b --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/ContactField1.qml @@ -0,0 +1,17 @@ + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/ContactField2.qml b/examples/declarative/tutorials/contacts/2_Reuse/ContactField2.qml new file mode 100644 index 0000000..b69e03c --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/ContactField2.qml @@ -0,0 +1,19 @@ + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/ContactField3.qml b/examples/declarative/tutorials/contacts/2_Reuse/ContactField3.qml new file mode 100644 index 0000000..f3a11f9 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/ContactField3.qml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/ContactField4.qml b/examples/declarative/tutorials/contacts/2_Reuse/ContactField4.qml new file mode 100644 index 0000000..13ccbc0 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/ContactField4.qml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/FieldText3.qml b/examples/declarative/tutorials/contacts/2_Reuse/FieldText3.qml new file mode 100644 index 0000000..c807aed --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/FieldText3.qml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/FieldText4.qml b/examples/declarative/tutorials/contacts/2_Reuse/FieldText4.qml new file mode 100644 index 0000000..a4df42b --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/FieldText4.qml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton1.qml b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton1.qml new file mode 100644 index 0000000..68c1838 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton1.qml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton2.qml b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton2.qml new file mode 100644 index 0000000..d9ff4c5 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton2.qml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton3.qml b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton3.qml new file mode 100644 index 0000000..d9ff4c5 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton3.qml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton4.qml b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton4.qml new file mode 100644 index 0000000..a489e95 --- /dev/null +++ b/examples/declarative/tutorials/contacts/2_Reuse/RemoveButton4.qml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml new file mode 100644 index 0000000..ed2a3dc --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/Button.qml b/examples/declarative/tutorials/contacts/3_Collections/Button.qml new file mode 100644 index 0000000..8290d35 --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/Button.qml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/Contact.qml b/examples/declarative/tutorials/contacts/3_Collections/Contact.qml new file mode 100644 index 0000000..f620c25 --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/Contact.qml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/ContactField.qml b/examples/declarative/tutorials/contacts/3_Collections/ContactField.qml new file mode 100644 index 0000000..819914c --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/ContactField.qml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/ContactView1.qml b/examples/declarative/tutorials/contacts/3_Collections/ContactView1.qml new file mode 100644 index 0000000..d6f7bad --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/ContactView1.qml @@ -0,0 +1,22 @@ + + + + + SELECT recid, label, email, phone FROM contacts ORDER BY label, recid + + + + + + + diff --git a/examples/declarative/tutorials/contacts/3_Collections/ContactView2.qml b/examples/declarative/tutorials/contacts/3_Collections/ContactView2.qml new file mode 100644 index 0000000..da1e5db --- /dev/null +++ b/examples/declarative/tutorials/contacts/3_Collections/ContactView2.qml @@ -0,0 +1,62 @@ + + + + + SELECT recid AS contactid, label, email, phone FROM contacts ORDER BY label, recid + + + + + + + + + + + + + + + + + + + + + + + if (wrapper.state == 'opened') { + wrapper.state = ''; + } + + + + +