aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/demos')
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.pro9
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.qml110
-rw-r--r--examples/quick/demos/calqlatr/calqlatr.qmlproject16
-rw-r--r--examples/quick/demos/calqlatr/content/Button.qml80
-rw-r--r--examples/quick/demos/calqlatr/content/Display.qml124
-rw-r--r--examples/quick/demos/calqlatr/content/NumberPad.qml69
-rw-r--r--examples/quick/demos/calqlatr/content/StyleLabel.qml50
-rw-r--r--examples/quick/demos/calqlatr/content/audio/touch.wavbin0 -> 950 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/calculator.js143
-rw-r--r--examples/quick/demos/calqlatr/content/images/icon-back.pngbin0 -> 328 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/icon-close.pngbin0 -> 488 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/icon-settings.pngbin0 -> 503 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/logo.pngbin0 -> 5950 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-edge-left.pngbin0 -> 12401 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-edge-right.pngbin0 -> 12967 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/paper-grip.pngbin0 -> 298 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/settings-selected-a.pngbin0 -> 2326 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/settings-selected-b.pngbin0 -> 2334 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/touch-green.pngbin0 -> 4808 bytes
-rw-r--r--examples/quick/demos/calqlatr/content/images/touch-white.pngbin0 -> 4601 bytes
-rw-r--r--examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.pngbin0 -> 37120 bytes
-rw-r--r--examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc39
-rw-r--r--examples/quick/demos/calqlatr/main.cpp41
-rw-r--r--examples/quick/demos/clocks/clocks.qml88
-rw-r--r--examples/quick/demos/clocks/content/Clock.qml140
-rw-r--r--examples/quick/demos/clocks/content/arrow.pngbin0 -> 692 bytes
-rw-r--r--examples/quick/demos/clocks/content/background.pngbin0 -> 46895 bytes
-rw-r--r--examples/quick/demos/clocks/content/center.pngbin0 -> 765 bytes
-rw-r--r--examples/quick/demos/clocks/content/clock-night.pngbin0 -> 23359 bytes
-rw-r--r--examples/quick/demos/clocks/content/clock.pngbin0 -> 20653 bytes
-rw-r--r--examples/quick/demos/clocks/content/hour.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/demos/clocks/content/minute.pngbin0 -> 625 bytes
-rw-r--r--examples/quick/demos/clocks/content/quit.pngbin0 -> 583 bytes
-rw-r--r--examples/quick/demos/clocks/content/second.pngbin0 -> 303 bytes
-rw-r--r--examples/quick/demos/demos.pro11
-rw-r--r--examples/quick/demos/maroon/content/BuildButton.qml90
-rw-r--r--examples/quick/demos/maroon/content/GameCanvas.qml240
-rw-r--r--examples/quick/demos/maroon/content/GameOverScreen.qml115
-rw-r--r--examples/quick/demos/maroon/content/InfoBar.qml84
-rw-r--r--examples/quick/demos/maroon/content/NewGameScreen.qml111
-rw-r--r--examples/quick/demos/maroon/content/SoundEffect.qml53
-rw-r--r--examples/quick/demos/maroon/content/audio/bomb-action.wavbin0 -> 20972 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/catch-action.wavbin0 -> 13274 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/catch.wavbin0 -> 8638 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/currency.wavbin0 -> 15790 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/factory-action.wavbin0 -> 4936 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/melee-action.wavbin0 -> 17798 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/projectile-action.wavbin0 -> 2562 bytes
-rw-r--r--examples/quick/demos/maroon/content/audio/shooter-action.wavbin0 -> 27554 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/background.pngbin0 -> 5802 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb-action.pngbin0 -> 23974 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb-idle.pngbin0 -> 12238 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/bomb.pngbin0 -> 4067 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/button-help.pngbin0 -> 8916 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/button-play.pngbin0 -> 13945 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/catch-action.pngbin0 -> 6760 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/catch.pngbin0 -> 4771 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/cloud.pngbin0 -> 3398 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/currency.pngbin0 -> 1889 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-bomb.pngbin0 -> 3751 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-factory.pngbin0 -> 3946 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-melee.pngbin0 -> 4392 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-pointer.pngbin0 -> 911 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog-shooter.pngbin0 -> 3737 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/dialog.pngbin0 -> 3362 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory-action.pngbin0 -> 22440 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory-idle.pngbin0 -> 12729 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/factory.pngbin0 -> 4138 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/grid.pngbin0 -> 2830 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/help.pngbin0 -> 38255 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/lifes.pngbin0 -> 1675 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo-bubble.pngbin0 -> 7706 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo-fish.pngbin0 -> 3477 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/logo.pngbin0 -> 18332 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee-action.pngbin0 -> 7797 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee-idle.pngbin0 -> 22832 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/melee.pngbin0 -> 4046 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/mob-idle.pngbin0 -> 6181 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/mob.pngbin0 -> 2391 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/points.pngbin0 -> 1561 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/projectile-action.pngbin0 -> 6257 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/projectile.pngbin0 -> 801 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/scores.pngbin0 -> 1535 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter-action.pngbin0 -> 18121 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter-idle.pngbin0 -> 11929 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/shooter.pngbin0 -> 4137 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/sunlight.pngbin0 -> 248412 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-1.pngbin0 -> 2777 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-2.pngbin0 -> 4959 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-3.pngbin0 -> 5063 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-blank.pngbin0 -> 1326 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-gameover.pngbin0 -> 1515 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/text-go.pngbin0 -> 4230 bytes
-rw-r--r--examples/quick/demos/maroon/content/gfx/wave.pngbin0 -> 2763 bytes
-rw-r--r--examples/quick/demos/maroon/content/logic.js264
-rw-r--r--examples/quick/demos/maroon/content/mobs/MobBase.qml262
-rw-r--r--examples/quick/demos/maroon/content/towers/Bomb.qml133
-rw-r--r--examples/quick/demos/maroon/content/towers/Factory.qml114
-rw-r--r--examples/quick/demos/maroon/content/towers/Melee.qml83
-rw-r--r--examples/quick/demos/maroon/content/towers/Ranged.qml128
-rw-r--r--examples/quick/demos/maroon/content/towers/TowerBase.qml72
-rw-r--r--examples/quick/demos/maroon/main.cpp41
-rw-r--r--examples/quick/demos/maroon/maroon.pro9
-rw-r--r--examples/quick/demos/maroon/maroon.qml233
-rw-r--r--examples/quick/demos/maroon/maroon.qmlproject16
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml147
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml50
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml72
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml85
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml189
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml57
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml57
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml91
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.pngbin0 -> 588 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.pngbin0 -> 8844 bytes
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/qmldir8
-rw-r--r--examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js27
-rw-r--r--examples/quick/demos/photoviewer/i18n/base.ts30
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.qmbin0 -> 268 bytes
-rw-r--r--examples/quick/demos/photoviewer/i18n/qml_fr.ts30
-rw-r--r--examples/quick/demos/photoviewer/photoviewer.qml110
-rw-r--r--examples/quick/demos/photoviewer/photoviewer.qmlproject20
-rw-r--r--examples/quick/demos/rssnews/content/BusyIndicator.qml53
-rw-r--r--examples/quick/demos/rssnews/content/CategoryDelegate.qml82
-rw-r--r--examples/quick/demos/rssnews/content/NewsDelegate.qml71
-rw-r--r--examples/quick/demos/rssnews/content/RssFeeds.qml59
-rw-r--r--examples/quick/demos/rssnews/content/ScrollBar.qml107
-rw-r--r--examples/quick/demos/rssnews/content/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/scrollbar.pngbin0 -> 161 bytes
-rw-r--r--examples/quick/demos/rssnews/rssnews.qml112
-rw-r--r--examples/quick/demos/rssnews/rssnews.qmlproject16
-rw-r--r--examples/quick/demos/samegame/content/Block.qml114
-rw-r--r--examples/quick/demos/samegame/content/BlockEmitter.qml57
-rw-r--r--examples/quick/demos/samegame/content/Button.qml70
-rw-r--r--examples/quick/demos/samegame/content/GameArea.qml226
-rw-r--r--examples/quick/demos/samegame/content/LogoAnimation.qml102
-rw-r--r--examples/quick/demos/samegame/content/MenuEmitter.qml53
-rw-r--r--examples/quick/demos/samegame/content/PaintEmitter.qml98
-rw-r--r--examples/quick/demos/samegame/content/PrimaryPack.qml122
-rw-r--r--examples/quick/demos/samegame/content/PuzzleBlock.qml111
-rw-r--r--examples/quick/demos/samegame/content/SamegameText.qml49
-rw-r--r--examples/quick/demos/samegame/content/SimpleBlock.qml108
-rw-r--r--examples/quick/demos/samegame/content/SmokeText.qml83
-rw-r--r--examples/quick/demos/samegame/content/gfx/background-puzzle.pngbin0 -> 86666 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/background.pngbin0 -> 101018 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bar.pngbin0 -> 10970 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/blue-puzzle.pngbin0 -> 2219 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/blue.pngbin0 -> 1018 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bubble-highscore.pngbin0 -> 2276 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/bubble-puzzle.pngbin0 -> 2811 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-1.pngbin0 -> 2728 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-2.pngbin0 -> 3378 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-3.pngbin0 -> 1423 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-4.pngbin0 -> 2096 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-game-new.pngbin0 -> 3662 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-menu.pngbin0 -> 2391 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-puzzle-next.pngbin0 -> 3658 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/but-quit.pngbin0 -> 2100 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/green-puzzle.pngbin0 -> 2271 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/green.pngbin0 -> 1024 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-fail.pngbin0 -> 6549 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-ok.pngbin0 -> 7190 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/icon-time.pngbin0 -> 1159 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-a.pngbin0 -> 1814 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-e.pngbin0 -> 1725 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-g.pngbin0 -> 1765 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-m.pngbin0 -> 1743 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo-s.pngbin0 -> 1791 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/logo.pngbin0 -> 3608 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-brick.pngbin0 -> 861 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-paint.pngbin0 -> 714 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/particle-smoke.pngbin0 -> 5409 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/red-puzzle.pngbin0 -> 2218 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/red.pngbin0 -> 1018 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-highscore-new.pngbin0 -> 6767 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-highscore.pngbin0 -> 3179 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-no-winner.pngbin0 -> 6321 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1-go.pngbin0 -> 5395 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1-won.pngbin0 -> 5618 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p1.pngbin0 -> 1751 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2-go.pngbin0 -> 5874 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2-won.pngbin0 -> 6177 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/text-p2.pngbin0 -> 2381 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/yellow-puzzle.pngbin0 -> 2239 bytes
-rw-r--r--examples/quick/demos/samegame/content/gfx/yellow.pngbin0 -> 1008 bytes
-rw-r--r--examples/quick/demos/samegame/content/levels/TemplateBase.qml70
-rw-r--r--examples/quick/demos/samegame/content/levels/level0.qml59
-rw-r--r--examples/quick/demos/samegame/content/levels/level1.qml59
-rw-r--r--examples/quick/demos/samegame/content/levels/level2.qml61
-rw-r--r--examples/quick/demos/samegame/content/levels/level3.qml60
-rw-r--r--examples/quick/demos/samegame/content/levels/level4.qml58
-rw-r--r--examples/quick/demos/samegame/content/levels/level5.qml59
-rw-r--r--examples/quick/demos/samegame/content/levels/level6.qml60
-rw-r--r--examples/quick/demos/samegame/content/levels/level7.qml58
-rw-r--r--examples/quick/demos/samegame/content/levels/level8.qml59
-rw-r--r--examples/quick/demos/samegame/content/levels/level9.qml62
-rwxr-xr-xexamples/quick/demos/samegame/content/samegame.js581
-rw-r--r--examples/quick/demos/samegame/main.cpp41
-rw-r--r--examples/quick/demos/samegame/samegame.pro9
-rw-r--r--examples/quick/demos/samegame/samegame.qml371
-rw-r--r--examples/quick/demos/samegame/samegame.qmlproject16
-rw-r--r--examples/quick/demos/samegame/settings.js56
-rw-r--r--examples/quick/demos/stocqt/content/Button.qml59
-rw-r--r--examples/quick/demos/stocqt/content/DatePicker.qml122
-rw-r--r--examples/quick/demos/stocqt/content/StockChart.qml324
-rw-r--r--examples/quick/demos/stocqt/content/StockListModel.qml147
-rw-r--r--examples/quick/demos/stocqt/content/StockListView.qml87
-rw-r--r--examples/quick/demos/stocqt/content/StockModel.qml160
-rw-r--r--examples/quick/demos/stocqt/content/StockSettings.qml317
-rw-r--r--examples/quick/demos/stocqt/content/StockView.qml129
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar-anim.pngbin0 -> 1088 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-calendar.pngbin0 -> 884 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-items.pngbin0 -> 887 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/icon-settings.pngbin0 -> 1066 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/logo.pngbin0 -> 4266 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/stock-selected.pngbin0 -> 6480 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel-touch.pngbin0 -> 4767 bytes
-rw-r--r--examples/quick/demos/stocqt/content/images/wheel.pngbin0 -> 36223 bytes
-rw-r--r--examples/quick/demos/stocqt/main.cpp41
-rw-r--r--examples/quick/demos/stocqt/stocqt.pro9
-rw-r--r--examples/quick/demos/stocqt/stocqt.qml101
-rw-r--r--examples/quick/demos/stocqt/stocqt.qmlproject16
-rw-r--r--examples/quick/demos/tweetsearch/content/FlipBar.qml173
-rw-r--r--examples/quick/demos/tweetsearch/content/LineInput.qml98
-rw-r--r--examples/quick/demos/tweetsearch/content/ListFooter.qml154
-rw-r--r--examples/quick/demos/tweetsearch/content/ListHeader.qml81
-rw-r--r--examples/quick/demos/tweetsearch/content/SearchDelegate.qml121
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetDelegate.qml189
-rw-r--r--examples/quick/demos/tweetsearch/content/TweetsModel.qml91
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/anonymous.pngbin0 -> 1788 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.pngbin0 -> 11079 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-clear.pngbin0 -> 1166 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-loading.pngbin0 -> 1542 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-refresh.pngbin0 -> 1202 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/resources/icon-search.pngbin0 -> 1284 bytes
-rw-r--r--examples/quick/demos/tweetsearch/content/tweetsearch.js19
-rw-r--r--examples/quick/demos/tweetsearch/main.cpp41
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.pro9
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qml130
-rw-r--r--examples/quick/demos/tweetsearch/tweetsearch.qmlproject16
241 files changed, 10007 insertions, 0 deletions
diff --git a/examples/quick/demos/calqlatr/calqlatr.pro b/examples/quick/demos/calqlatr/calqlatr.pro
new file mode 100644
index 0000000000..fec0d6416b
--- /dev/null
+++ b/examples/quick/demos/calqlatr/calqlatr.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/calqlatr
+qml.files = calqlatr.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/calqlatr
+INSTALLS += target qml
diff --git a/examples/quick/demos/calqlatr/calqlatr.qml b/examples/quick/demos/calqlatr/calqlatr.qml
new file mode 100644
index 0000000000..7640fbd738
--- /dev/null
+++ b/examples/quick/demos/calqlatr/calqlatr.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+import "content/calculator.js" as CalcEngine
+
+
+Rectangle {
+ id: window
+ width: 320
+ height: 480
+ focus: true
+ color: "#272822"
+
+ onWidthChanged: controller.reload()
+
+ function operatorPressed(operator) { CalcEngine.operatorPressed(operator) }
+ function digitPressed(digit) { CalcEngine.digitPressed(digit) }
+
+ Item {
+ id: pad
+ width: window.width * 0.58
+ NumberPad { y: 10; anchors.horizontalCenter: parent.horizontalCenter }
+ }
+
+ AnimationController {
+ id: controller
+ animation: ParallelAnimation {
+ id: anim
+ NumberAnimation { target: display; property: "x"; duration: 400; from: -16; to: window.width - display.width; easing.type: Easing.InOutQuad }
+ NumberAnimation { target: pad; property: "x"; duration: 400; from: window.width - pad.width; to: 0; easing.type: Easing.InOutQuad }
+ SequentialAnimation {
+ NumberAnimation { target: pad; property: "scale"; duration: 200; from: 1; to: 0.97; easing.type: Easing.InOutQuad }
+ NumberAnimation { target: pad; property: "scale"; duration: 200; from: 0.97; to: 1; easing.type: Easing.InOutQuad }
+ }
+ }
+ }
+
+ Display {
+ id: display
+ x: -16
+ width: window.width * 0.42
+ height: parent.height
+
+ MouseArea {
+ property real startX: 0
+ property real oldP: 0
+ property bool rewind: false
+
+ anchors.fill: parent
+ onPositionChanged: {
+ var reverse = startX > window.width / 2
+ var mx = mapToItem(window, mouse.x).x
+ var p = Math.abs((mx - startX) / (window.width - display.width))
+ if (p < oldP)
+ rewind = reverse ? false : true
+ else
+ rewind = reverse ? true : false
+ controller.progress = reverse ? 1 - p : p
+ oldP = p
+ }
+ onPressed: startX = mapToItem(window, mouse.x).x
+ onReleased: {
+ if (rewind)
+ controller.completeToBeginning()
+ else
+ controller.completeToEnd()
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/demos/calqlatr/calqlatr.qmlproject b/examples/quick/demos/calqlatr/calqlatr.qmlproject
new file mode 100644
index 0000000000..ce2d59d310
--- /dev/null
+++ b/examples/quick/demos/calqlatr/calqlatr.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "calqlatr.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/demos/calqlatr/content/Button.qml b/examples/quick/demos/calqlatr/content/Button.qml
new file mode 100644
index 0000000000..c355c2d105
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/Button.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property alias text: textItem.text
+ property alias color: textItem.color
+
+ property bool operator: false
+
+ signal clicked
+
+ width: 30
+ height: 50
+
+ Text {
+ id: textItem
+ font.pixelSize: 48
+ wrapMode: Text.WordWrap
+ lineHeight: 0.75
+ color: "white"
+ }
+
+// Rectangle {
+// color: "red"
+// opacity: 0.2
+// anchors.fill: mouse
+// }
+
+ MouseArea {
+ id: mouse
+ anchors.fill: parent
+ anchors.margins: -5
+ onClicked: {
+ //parent.clicked()
+ if (operator)
+ window.operatorPressed(parent.text)
+ else
+ window.digitPressed(parent.text)
+ }
+ }
+}
diff --git a/examples/quick/demos/calqlatr/content/Display.qml b/examples/quick/demos/calqlatr/content/Display.qml
new file mode 100644
index 0000000000..3c1d9c0cd5
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/Display.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: display
+
+ function displayOperator(operator)
+ {
+ listView.model.append({ "operator": operator, "operand": "" })
+ }
+
+ function newLine(operator, operand)
+ {
+ listView.model.append({ "operator": operator, "operand": operand })
+ }
+
+ function appendDigit(digit)
+ {
+ if (!listView.model.count)
+ listView.model.append({ "operator": "", "operand": "" })
+ var i = listView.model.count - 1;
+ listView.model.get(i).operand = listView.model.get(i).operand + digit;
+ }
+
+ Item {
+ id: theItem
+ width: parent.width + 32
+ height: parent.height
+
+ Rectangle {
+ id: rect
+ x: 16
+ color: "white"
+ height: parent.height
+ width: display.width - 16
+ }
+ Image {
+ anchors.right: rect.left
+ source: "images/paper-edge-left.png"
+ height: parent.height
+ fillMode: Image.TileVertically
+ }
+ Image {
+ anchors.left: rect.right
+ source: "images/paper-edge-right.png"
+ height: parent.height
+ fillMode: Image.TileVertically
+ }
+
+ Image {
+ source: "images/paper-grip.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 20
+ }
+
+ ListView {
+ id: listView
+ x: 16; y: 30
+ width: display.width
+ height: display.height
+ delegate: Item {
+ height: 20
+ width: parent.width
+ Text {
+ id: operator
+ x: 8
+ font.pixelSize: 18
+ color: "#6da43d"
+ text: model.operator
+ }
+ Text {
+ id: operand
+ font.pixelSize: 18
+ anchors.right: parent.right
+ anchors.rightMargin: 26
+ text: model.operand
+ }
+ }
+ model: ListModel { }
+ }
+
+ }
+
+}
diff --git a/examples/quick/demos/calqlatr/content/NumberPad.qml b/examples/quick/demos/calqlatr/content/NumberPad.qml
new file mode 100644
index 0000000000..853c7631c9
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/NumberPad.qml
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Grid {
+ columns: 3
+ columnSpacing: 32
+ rowSpacing: 16
+
+ Button { text: "7" }
+ Button { text: "8" }
+ Button { text: "9" }
+ Button { text: "4" }
+ Button { text: "5" }
+ Button { text: "6" }
+ Button { text: "1" }
+ Button { text: "2" }
+ Button { text: "3" }
+ Button { text: "0" }
+ Button { text: "." }
+ Button { text: " " }
+ Button { text: "±"; color: "#6da43d"; operator: true }
+ Button { text: "−"; color: "#6da43d"; operator: true }
+ Button { text: "+"; color: "#6da43d"; operator: true }
+ Button { text: " "; color: "#6da43d"; operator: true }
+ Button { text: "÷"; color: "#6da43d"; operator: true }
+ Button { text: "×"; color: "#6da43d"; operator: true }
+ Button { text: "C"; color: "#6da43d"; operator: true }
+ Button { text: " "; color: "#6da43d"; operator: true }
+ Button { text: "="; color: "#6da43d"; operator: true }
+}
diff --git a/examples/quick/demos/calqlatr/content/StyleLabel.qml b/examples/quick/demos/calqlatr/content/StyleLabel.qml
new file mode 100644
index 0000000000..3bdea86129
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/StyleLabel.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Text {
+ width: 64
+ font.pixelSize: 14
+ font.bold: false
+ wrapMode: Text.WordWrap
+ lineHeight: 0.75
+ color: "#676764"
+}
diff --git a/examples/quick/demos/calqlatr/content/audio/touch.wav b/examples/quick/demos/calqlatr/content/audio/touch.wav
new file mode 100644
index 0000000000..94cccb7546
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/audio/touch.wav
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/calculator.js b/examples/quick/demos/calqlatr/content/calculator.js
new file mode 100644
index 0000000000..843ef39c02
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/calculator.js
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+var curVal = 0
+var memory = 0
+var lastOp = ""
+var previousOperator = ""
+var digits = ""
+
+function disabled(op) {
+ if (op == "." && digits.toString().search(/\./) != -1) {
+ return true
+ } else if (op == window.squareRoot && digits.toString().search(/-/) != -1) {
+ return true
+ } else {
+ return false
+ }
+}
+
+function digitPressed(op)
+{
+ if (disabled(op))
+ return
+ if (digits.toString().length >= 14)
+ return
+ if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) {
+ digits = digits + op.toString()
+ display.appendDigit(op.toString())
+ } else {
+ digits = op
+ display.appendDigit(op.toString())
+ }
+ lastOp = op
+}
+
+function operatorPressed(op)
+{
+ if (disabled(op))
+ return
+ lastOp = op
+
+ if (previousOperator == "+") {
+ digits = Number(digits.valueOf()) + Number(curVal.valueOf())
+ } else if (previousOperator == "−") {
+ digits = Number(curVal) - Number(digits.valueOf())
+ } else if (previousOperator == "×") {
+ digits = Number(curVal) * Number(digits.valueOf())
+ } else if (previousOperator == "÷") {
+ digits = Number(Number(curVal) / Number(digits.valueOf())).toString()
+ } else if (previousOperator == "=") {
+ }
+
+ if (op == "+" || op == "−" || op == "×" || op == "÷") {
+ previousOperator = op
+ curVal = digits.valueOf()
+ display.displayOperator(previousOperator)
+ return
+ }
+
+ if (op == "=") {
+ display.newLine("=", digits.toString())
+ }
+
+ curVal = 0
+ previousOperator = ""
+
+ if (op == "1/x") {
+ digits = (1 / digits.valueOf()).toString()
+ } else if (op == "x^2") {
+ digits = (digits.valueOf() * digits.valueOf()).toString()
+ } else if (op == "Abs") {
+ digits = (Math.abs(digits.valueOf())).toString()
+ } else if (op == "Int") {
+ digits = (Math.floor(digits.valueOf())).toString()
+ } else if (op == window.plusminus) {
+ digits = (digits.valueOf() * -1).toString()
+ } else if (op == window.squareRoot) {
+ digits = (Math.sqrt(digits.valueOf())).toString()
+ } else if (op == "mc") {
+ memory = 0;
+ } else if (op == "m+") {
+ memory += digits.valueOf()
+ } else if (op == "mr") {
+ digits = memory.toString()
+ } else if (op == "m-") {
+ memory = digits.valueOf()
+ } else if (op == window.leftArrow) {
+ digits = digits.toString().slice(0, -1)
+ if (digits.length == 0) {
+ digits = "0"
+ }
+ } else if (op == "Off") {
+ Qt.quit();
+ } else if (op == "C") {
+ digits = "0"
+ } else if (op == "AC") {
+ curVal = 0
+ memory = 0
+ lastOp = ""
+ digits ="0"
+ }
+
+
+}
+
diff --git a/examples/quick/demos/calqlatr/content/images/icon-back.png b/examples/quick/demos/calqlatr/content/images/icon-back.png
new file mode 100644
index 0000000000..2989ee2e35
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/icon-back.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/icon-close.png b/examples/quick/demos/calqlatr/content/images/icon-close.png
new file mode 100644
index 0000000000..3e21248232
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/icon-close.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/icon-settings.png b/examples/quick/demos/calqlatr/content/images/icon-settings.png
new file mode 100644
index 0000000000..98e662f53f
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/icon-settings.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/logo.png b/examples/quick/demos/calqlatr/content/images/logo.png
new file mode 100644
index 0000000000..6bc65610bc
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/logo.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/paper-edge-left.png b/examples/quick/demos/calqlatr/content/images/paper-edge-left.png
new file mode 100644
index 0000000000..ca29a3ae10
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/paper-edge-left.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/paper-edge-right.png b/examples/quick/demos/calqlatr/content/images/paper-edge-right.png
new file mode 100644
index 0000000000..7c2da7b930
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/paper-edge-right.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/paper-grip.png b/examples/quick/demos/calqlatr/content/images/paper-grip.png
new file mode 100644
index 0000000000..953c408bca
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/paper-grip.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/settings-selected-a.png b/examples/quick/demos/calqlatr/content/images/settings-selected-a.png
new file mode 100644
index 0000000000..e08ddface8
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/settings-selected-a.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/settings-selected-b.png b/examples/quick/demos/calqlatr/content/images/settings-selected-b.png
new file mode 100644
index 0000000000..d9aa7e3431
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/settings-selected-b.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/touch-green.png b/examples/quick/demos/calqlatr/content/images/touch-green.png
new file mode 100644
index 0000000000..64dbde66b1
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/touch-green.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/content/images/touch-white.png b/examples/quick/demos/calqlatr/content/images/touch-white.png
new file mode 100644
index 0000000000..bb02b000cf
--- /dev/null
+++ b/examples/quick/demos/calqlatr/content/images/touch-white.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png b/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png
new file mode 100644
index 0000000000..af67f63dd1
--- /dev/null
+++ b/examples/quick/demos/calqlatr/doc/images/qml-calqlatr-demo-small.png
Binary files differ
diff --git a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc
new file mode 100644
index 0000000000..366f01ea2c
--- /dev/null
+++ b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \title QML Demo - Calqlatr
+ \example demos/calqlatr
+ \brief This is an example calculator written in QML.
+ \image qml-calqlatr-demo-small.png
+ \ingroup qmldemos
+
+ This demo implements a simple calculator app, designed for portrait devices.
+
+ This app has the logic implemented in Javascipt and the appearance implemented in QML.
+*/
+
diff --git a/examples/quick/demos/calqlatr/main.cpp b/examples/quick/demos/calqlatr/main.cpp
new file mode 100644
index 0000000000..9000bfc7d7
--- /dev/null
+++ b/examples/quick/demos/calqlatr/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(calqlatr)
diff --git a/examples/quick/demos/clocks/clocks.qml b/examples/quick/demos/clocks/clocks.qml
new file mode 100644
index 0000000000..020fe32908
--- /dev/null
+++ b/examples/quick/demos/clocks/clocks.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: root
+ width: 640; height: 320
+ color: "#646464"
+
+ ListView {
+ id: clockview
+ anchors.fill: parent
+ orientation: ListView.Horizontal
+ cacheBuffer: 2000
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.ApplyRange
+
+ delegate: Clock { city: cityName; shift: timeShift }
+ model: ListModel {
+ ListElement { cityName: "New York"; timeShift: -4 }
+ ListElement { cityName: "London"; timeShift: 0 }
+ ListElement { cityName: "Oslo"; timeShift: 1 }
+ ListElement { cityName: "Mumbai"; timeShift: 5.5 }
+ ListElement { cityName: "Tokyo"; timeShift: 9 }
+ ListElement { cityName: "Brisbane"; timeShift: 10 }
+ ListElement { cityName: "Los Angeles"; timeShift: -8 }
+ }
+ }
+
+ Image {
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: -90
+ opacity: clockview.atXBeginning ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+
+ Image {
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 10
+ source: "content/arrow.png"
+ rotation: 90
+ opacity: clockview.atXEnd ? 0 : 0.5
+ Behavior on opacity { NumberAnimation { duration: 500 } }
+ }
+}
diff --git a/examples/quick/demos/clocks/content/Clock.qml b/examples/quick/demos/clocks/content/Clock.qml
new file mode 100644
index 0000000000..05317b1151
--- /dev/null
+++ b/examples/quick/demos/clocks/content/Clock.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id : clock
+ width: {
+ if (ListView.view && ListView.view.width >= 200)
+ return ListView.view.width / Math.floor(ListView.view.width / 200.0);
+ else
+ return 200;
+ }
+
+ height: {
+ if (ListView.view && ListView.view.height >= 240)
+ return ListView.view.height;
+ else
+ return 240;
+ }
+
+ property alias city: cityLabel.text
+ property int hours
+ property int minutes
+ property int seconds
+ property real shift
+ property bool night: false
+ property bool internationalTime: true //Unset for local time
+
+ function timeChanged() {
+ var date = new Date;
+ hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours()
+ night = ( hours < 7 || hours > 19 )
+ minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes()
+ seconds = date.getUTCSeconds();
+ }
+
+ Timer {
+ interval: 100; running: true; repeat: true;
+ onTriggered: clock.timeChanged()
+ }
+
+ Item {
+ anchors.centerIn: parent
+ width: 200; height: 240
+
+ Image { id: background; source: "clock.png"; visible: clock.night == false }
+ Image { source: "clock-night.png"; visible: clock.night == true }
+
+
+ Image {
+ x: 92.5; y: 27
+ source: "hour.png"
+ transform: Rotation {
+ id: hourRotation
+ origin.x: 7.5; origin.y: 73;
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 93.5; y: 17
+ source: "minute.png"
+ transform: Rotation {
+ id: minuteRotation
+ origin.x: 6.5; origin.y: 83;
+ angle: clock.minutes * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ x: 97.5; y: 20
+ source: "second.png"
+ transform: Rotation {
+ id: secondRotation
+ origin.x: 2.5; origin.y: 80;
+ angle: clock.seconds * 6
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
+ }
+ }
+ }
+
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel
+ y: 210; anchors.horizontalCenter: parent.horizontalCenter
+ color: "white"
+ font.family: "Helvetica"
+ font.bold: true; font.pixelSize: 16
+ style: Text.Raised; styleColor: "black"
+ }
+ }
+}
diff --git a/examples/quick/demos/clocks/content/arrow.png b/examples/quick/demos/clocks/content/arrow.png
new file mode 100644
index 0000000000..e437312217
--- /dev/null
+++ b/examples/quick/demos/clocks/content/arrow.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/background.png b/examples/quick/demos/clocks/content/background.png
new file mode 100644
index 0000000000..a885950862
--- /dev/null
+++ b/examples/quick/demos/clocks/content/background.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/center.png b/examples/quick/demos/clocks/content/center.png
new file mode 100644
index 0000000000..7fbd802a44
--- /dev/null
+++ b/examples/quick/demos/clocks/content/center.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/clock-night.png b/examples/quick/demos/clocks/content/clock-night.png
new file mode 100644
index 0000000000..cc7151a397
--- /dev/null
+++ b/examples/quick/demos/clocks/content/clock-night.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/clock.png b/examples/quick/demos/clocks/content/clock.png
new file mode 100644
index 0000000000..462edacc0e
--- /dev/null
+++ b/examples/quick/demos/clocks/content/clock.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/hour.png b/examples/quick/demos/clocks/content/hour.png
new file mode 100644
index 0000000000..f8061a1235
--- /dev/null
+++ b/examples/quick/demos/clocks/content/hour.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/minute.png b/examples/quick/demos/clocks/content/minute.png
new file mode 100644
index 0000000000..1297ec7c2b
--- /dev/null
+++ b/examples/quick/demos/clocks/content/minute.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/quit.png b/examples/quick/demos/clocks/content/quit.png
new file mode 100644
index 0000000000..b822057d4e
--- /dev/null
+++ b/examples/quick/demos/clocks/content/quit.png
Binary files differ
diff --git a/examples/quick/demos/clocks/content/second.png b/examples/quick/demos/clocks/content/second.png
new file mode 100644
index 0000000000..4aa9fb5e8e
--- /dev/null
+++ b/examples/quick/demos/clocks/content/second.png
Binary files differ
diff --git a/examples/quick/demos/demos.pro b/examples/quick/demos/demos.pro
new file mode 100644
index 0000000000..474b5b1bc0
--- /dev/null
+++ b/examples/quick/demos/demos.pro
@@ -0,0 +1,11 @@
+TEMPLATE = subdirs
+SUBDIRS = samegame \
+ calqlatr \
+ tweetsearch \
+ maroon \
+ stocqt
+
+EXAMPLE_FILES = \
+ clocks \
+ photoviewer \
+ rssnews
diff --git a/examples/quick/demos/maroon/content/BuildButton.qml b/examples/quick/demos/maroon/content/BuildButton.qml
new file mode 100644
index 0000000000..49641fcecc
--- /dev/null
+++ b/examples/quick/demos/maroon/content/BuildButton.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "logic.js" as Logic
+
+Item {
+ id: container
+ width: 64
+ height: 64
+ property alias source: img.source
+ property int index
+ property int row: 0
+ property int col: 0
+ property int towerType
+ property bool canBuild: true
+ property Item gameCanvas: parent.parent.parent
+ signal clicked()
+
+ Image {
+ id: img
+ opacity: (canBuild && gameCanvas.coins >= Logic.towerData[towerType-1].cost) ? 1.0 : 0.4
+ }
+ Text {
+ anchors.right: parent.right
+ font.pointSize: 14
+ font.bold: true
+ color: "#ffffff"
+ text: Logic.towerData[towerType - 1].cost
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Logic.buildTower(towerType, col, row)
+ container.clicked()
+ }
+ }
+ Image {
+ visible: col == index && row != 0
+ source: "gfx/dialog-pointer.png"
+ anchors.top: parent.bottom
+ anchors.topMargin: 4
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Image {
+ visible: col == index && row == 0
+ source: "gfx/dialog-pointer.png"
+ rotation: 180
+ anchors.bottom: parent.top
+ anchors.bottomMargin: 6
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+}
diff --git a/examples/quick/demos/maroon/content/GameCanvas.qml b/examples/quick/demos/maroon/content/GameCanvas.qml
new file mode 100644
index 0000000000..5e6e963e84
--- /dev/null
+++ b/examples/quick/demos/maroon/content/GameCanvas.qml
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "logic.js" as Logic
+import "towers" as Towers
+
+Item {
+ id: grid
+
+ property int squareSize: 64
+ property int rows: 6
+ property int cols: 4
+ property Item canvas: grid
+ property int score: 0
+ property int coins: 100
+ property int lives: 3
+ property int waveNumber: 0
+ property int waveProgress: 0
+ property var towers
+ property var mobs
+ property bool gameRunning: false
+ property bool gameOver: false
+ property bool errored: false
+ property string errorString: ""
+
+ width: cols * squareSize
+ height: rows * squareSize
+
+ function freshState() {
+ lives = 3
+ coins = 100
+ score = 0
+ waveNumber = 0
+ waveProgress = 0
+ gameOver = false
+ gameRunning = false
+ towerMenu.shown = false
+ helpButton.comeBack();
+ }
+
+ Text {
+ id: errorText // Mostly for debug purposes
+ text: errorString
+ visible: errored
+ color: "red"
+ font.pixelSize: 18
+ wrapMode: Text.WordWrap
+ width: parent.width / 1.2
+ height: parent.height / 1.2
+ anchors.centerIn: parent
+ z: 1000
+ }
+
+ Timer {
+ interval: 16
+ running: true
+ repeat: true
+ onTriggered: Logic.tick()
+ }
+
+ MouseArea {
+ id: ma
+ anchors.fill: parent
+ onClicked: {
+ if (towerMenu.visible)
+ towerMenu.finish()
+ else
+ towerMenu.open(mouse.x, mouse.y)
+ }
+ }
+
+ Image {
+ id: towerMenu
+ visible: false
+ z: 1500
+ scale: 0.9
+ opacity: 0.7
+ property int dragDistance: 16
+ property int targetRow: 0
+ property int targetCol: 0
+ property bool shown: false
+ property bool towerExists: false
+
+ function finish() {
+ shown = false
+ }
+
+ function open(xp,yp) {
+ if (!grid.gameRunning)
+ return
+ targetRow = Logic.row(yp)
+ targetCol = Logic.col(xp)
+ if (targetRow == 0)
+ towerMenu.y = (targetRow + 1) * grid.squareSize
+ else
+ towerMenu.y = (targetRow - 1) * grid.squareSize
+ towerExists = (grid.towers[Logic.towerIdx(targetCol, targetRow)] != null)
+ shown = true
+ helpButton.goAway();
+ }
+
+ states: State {
+ name: "shown"; when: towerMenu.shown && !grid.gameOver
+ PropertyChanges { target: towerMenu; visible: true; scale: 1; opacity: 1 }
+ }
+
+ transitions: Transition {
+ PropertyAction { property: "visible" }
+ NumberAnimation { properties: "opacity,scale"; duration: 500; easing.type: Easing.OutElastic }
+ }
+
+ x: -32
+ source: "gfx/dialog.png"
+ Row {
+ id: buttonRow
+ height: 100
+ anchors.centerIn: parent
+ spacing: 8
+ BuildButton {
+ row: towerMenu.targetRow; col: towerMenu.targetCol
+ anchors.verticalCenter: parent.verticalCenter
+ towerType: 1; index: 0
+ canBuild: !towerMenu.towerExists
+ source: "gfx/dialog-melee.png"
+ onClicked: towerMenu.finish()
+ }
+ BuildButton {
+ row: towerMenu.targetRow; col: towerMenu.targetCol
+ anchors.verticalCenter: parent.verticalCenter
+ towerType: 2; index: 1
+ canBuild: !towerMenu.towerExists
+ source: "gfx/dialog-shooter.png"
+ onClicked: towerMenu.finish()
+ }
+ BuildButton {
+ row: towerMenu.targetRow; col: towerMenu.targetCol
+ anchors.verticalCenter: parent.verticalCenter
+ towerType: 3; index: 2
+ canBuild: !towerMenu.towerExists
+ source: "gfx/dialog-bomb.png"
+ onClicked: towerMenu.finish()
+ }
+ BuildButton {
+ row: towerMenu.targetRow; col: towerMenu.targetCol
+ anchors.verticalCenter: parent.verticalCenter
+ towerType: 4; index: 3
+ canBuild: !towerMenu.towerExists
+ source: "gfx/dialog-factory.png"
+ onClicked: towerMenu.finish()
+ }
+ }
+ }
+
+
+ Keys.onPressed: { // Cheat Codes while Testing
+ if (event.key == Qt.Key_Up && (event.modifiers & Qt.ShiftModifier))
+ grid.coins += 10;
+ if (event.key == Qt.Key_Left && (event.modifiers & Qt.ShiftModifier))
+ grid.lives += 1;
+ if (event.key == Qt.Key_Down && (event.modifiers & Qt.ShiftModifier))
+ Logic.gameState.waveProgress += 1000;
+ if (event.key == Qt.Key_Right && (event.modifiers & Qt.ShiftModifier))
+ Logic.endGame();
+ }
+
+ Image {
+ id: helpButton
+ z: 1010
+ source: "gfx/button-help.png"
+ function goAway() {
+ helpMA.enabled = false;
+ helpButton.opacity = 0;
+ }
+ function comeBack() {
+ helpMA.enabled = true;
+ helpButton.opacity = 1;
+ }
+ Behavior on opacity { NumberAnimation {} }
+ MouseArea {
+ id: helpMA
+ anchors.fill: parent
+ onClicked: {helpImage.visible = true; helpButton.visible = false;}
+ }
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 0
+ }
+
+ Image {
+ id: helpImage
+ z: 1010
+ source: "gfx/help.png"
+ anchors.fill: parent
+ visible: false
+ MouseArea {
+ anchors.fill: parent
+ onClicked: helpImage.visible = false;
+ }
+ }
+
+}
diff --git a/examples/quick/demos/maroon/content/GameOverScreen.qml b/examples/quick/demos/maroon/content/GameOverScreen.qml
new file mode 100644
index 0000000000..dfb439fbb9
--- /dev/null
+++ b/examples/quick/demos/maroon/content/GameOverScreen.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "logic.js" as Logic
+
+Item {
+ id: gameOverScreen
+ width: 320
+ height: 400
+ property GameCanvas gameCanvas
+
+ Image {
+ id: img
+ source: "gfx/text-gameover.png"
+ anchors.centerIn: parent
+ }
+
+ ParticleSystem {
+ anchors.fill: parent
+ ImageParticle {
+ id: cloud
+ source: "gfx/cloud.png"
+ alphaVariation: 0.25
+ opacity: 0.25
+ }
+
+ Wander {
+ xVariance: 100;
+ pace: 1;
+ }
+
+ Emitter {
+ id: cloudLeft
+ width: 160
+ height: 160
+ anchors.right: parent.left
+ emitRate: 0.5
+ lifeSpan: 12000
+ velocity: PointDirection{ x: 64; xVariation: 2; yVariation: 2 }
+ size: 160
+ }
+
+ Emitter {
+ id: cloudRight
+ width: 160
+ height: 160
+ anchors.left: parent.right
+ emitRate: 0.5
+ lifeSpan: 12000
+ velocity: PointDirection{ x: -64; xVariation: 2; yVariation: 2 }
+ size: 160
+ }
+ }
+
+
+ Text {
+ visible: gameCanvas != undefined
+ text: "You saved " + gameCanvas.score + " fishes!"
+ anchors.top: img.bottom
+ anchors.topMargin: 12
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.bold: true
+ color: "#000000"
+ opacity: 0.5
+ }
+
+ Image {
+ source: "gfx/button-play.png"
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 0
+ MouseArea {
+ anchors.fill: parent
+ onClicked: gameCanvas.gameOver = false//This will actually trigger the state change in main.qml
+ }
+ }
+}
diff --git a/examples/quick/demos/maroon/content/InfoBar.qml b/examples/quick/demos/maroon/content/InfoBar.qml
new file mode 100644
index 0000000000..36303fc4fe
--- /dev/null
+++ b/examples/quick/demos/maroon/content/InfoBar.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ height: childrenRect.height
+
+ // Display the number of lives
+ Row {
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ spacing: 5
+ Repeater {
+ id: rep
+ model: Math.min(10, canvas.lives)
+ delegate: Image { source: "gfx/lifes.png" }
+ }
+ }
+
+ // Display the number of fishes saved
+ Row {
+ anchors.right: points.left
+ anchors.rightMargin: 20
+ spacing: 5
+ Image { source: "gfx/scores.png" }
+ Text {
+ text: canvas.score
+ font.bold: true
+ }
+ }
+
+ // Display the number of coins
+ Row {
+ id: points
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ spacing: 5
+ Image { source: "gfx/points.png" }
+ Text {
+ id: pointsLabel
+ text: canvas.coins
+ font.bold: true
+ }
+ }
+}
+
diff --git a/examples/quick/demos/maroon/content/NewGameScreen.qml b/examples/quick/demos/maroon/content/NewGameScreen.qml
new file mode 100644
index 0000000000..495e3aaa8e
--- /dev/null
+++ b/examples/quick/demos/maroon/content/NewGameScreen.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// This is the first screen.
+// It shows the logo and emit a startButtonClicked signal
+// when the user press the "PLAY" button.
+
+Item {
+ id: newGameScreen
+ width: 320
+ height: 480
+
+ signal startButtonClicked
+
+ Image {
+ source: "gfx/logo.png"
+ anchors.top: parent.top
+ anchors.topMargin: 60
+ }
+
+ Image {
+ source: "gfx/logo-fish.png"
+ anchors.top: parent.top
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x + 148; to: x + 25; duration: 2000; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x + 25; to: x + 148; duration: 1600; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on anchors.topMargin {
+ loops: Animation.Infinite
+ NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ Image {
+ source: "gfx/logo-bubble.png"
+ anchors.top: parent.top
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x + 140; to: x + 40; duration: 2000; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x + 40; to: x + 140; duration: 1600; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on anchors.topMargin {
+ loops: Animation.Infinite
+ NumberAnimation { from: 100; to: 60; duration: 1600; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: 60; to: 100; duration: 2000; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation { from: 140; to: 160; duration: 1000; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: 160; to: 140; duration: 800; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation { from: 150; to: 140; duration: 800; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: 140; to: 150; duration: 1000; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ Image {
+ source: "gfx/button-play.png"
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 60
+ MouseArea {
+ anchors.fill: parent
+ onClicked: newGameScreen.startButtonClicked()
+ }
+ }
+}
diff --git a/examples/quick/demos/maroon/content/SoundEffect.qml b/examples/quick/demos/maroon/content/SoundEffect.qml
new file mode 100644
index 0000000000..d286a397c1
--- /dev/null
+++ b/examples/quick/demos/maroon/content/SoundEffect.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+//Proxies a SoundEffect if QtMultimedia is installed
+Item {
+ id: container
+ property QtObject effect: Qt.createQmlObject("import QtMultimedia 5.0; SoundEffect{ source: '" + container.source + "' }", container);
+ property url source: ""
+ onSourceChanged: if (effect != null) effect.source = source;
+ function play() {
+ if (effect != null)
+ effect.play();
+ }
+
+}
diff --git a/examples/quick/demos/maroon/content/audio/bomb-action.wav b/examples/quick/demos/maroon/content/audio/bomb-action.wav
new file mode 100644
index 0000000000..b334dc1e5b
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/bomb-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/catch-action.wav b/examples/quick/demos/maroon/content/audio/catch-action.wav
new file mode 100644
index 0000000000..3e22124abf
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/catch-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/catch.wav b/examples/quick/demos/maroon/content/audio/catch.wav
new file mode 100644
index 0000000000..d3eade87f8
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/catch.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/currency.wav b/examples/quick/demos/maroon/content/audio/currency.wav
new file mode 100644
index 0000000000..0d9ef2c200
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/currency.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/factory-action.wav b/examples/quick/demos/maroon/content/audio/factory-action.wav
new file mode 100644
index 0000000000..a2ace6c221
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/factory-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/melee-action.wav b/examples/quick/demos/maroon/content/audio/melee-action.wav
new file mode 100644
index 0000000000..d325af4700
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/melee-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/projectile-action.wav b/examples/quick/demos/maroon/content/audio/projectile-action.wav
new file mode 100644
index 0000000000..4e2284fceb
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/projectile-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/audio/shooter-action.wav b/examples/quick/demos/maroon/content/audio/shooter-action.wav
new file mode 100644
index 0000000000..3e12b9419a
--- /dev/null
+++ b/examples/quick/demos/maroon/content/audio/shooter-action.wav
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/background.png b/examples/quick/demos/maroon/content/gfx/background.png
new file mode 100644
index 0000000000..d548b9314e
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/background.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb-action.png b/examples/quick/demos/maroon/content/gfx/bomb-action.png
new file mode 100644
index 0000000000..42da5d789f
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/bomb-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb-idle.png b/examples/quick/demos/maroon/content/gfx/bomb-idle.png
new file mode 100644
index 0000000000..3bd62e261d
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/bomb-idle.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/bomb.png b/examples/quick/demos/maroon/content/gfx/bomb.png
new file mode 100644
index 0000000000..380da7d1a5
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/bomb.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/button-help.png b/examples/quick/demos/maroon/content/gfx/button-help.png
new file mode 100644
index 0000000000..aecebc1275
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/button-help.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/button-play.png b/examples/quick/demos/maroon/content/gfx/button-play.png
new file mode 100644
index 0000000000..6cdad6c845
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/button-play.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/catch-action.png b/examples/quick/demos/maroon/content/gfx/catch-action.png
new file mode 100644
index 0000000000..78ca9fe1cc
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/catch-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/catch.png b/examples/quick/demos/maroon/content/gfx/catch.png
new file mode 100644
index 0000000000..b7620fe3de
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/catch.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/cloud.png b/examples/quick/demos/maroon/content/gfx/cloud.png
new file mode 100644
index 0000000000..d7c35f8555
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/cloud.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/currency.png b/examples/quick/demos/maroon/content/gfx/currency.png
new file mode 100644
index 0000000000..1571341f6c
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/currency.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-bomb.png b/examples/quick/demos/maroon/content/gfx/dialog-bomb.png
new file mode 100644
index 0000000000..708d916ad7
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog-bomb.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-factory.png b/examples/quick/demos/maroon/content/gfx/dialog-factory.png
new file mode 100644
index 0000000000..d2e2a48e31
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog-factory.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-melee.png b/examples/quick/demos/maroon/content/gfx/dialog-melee.png
new file mode 100644
index 0000000000..069d18d477
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog-melee.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-pointer.png b/examples/quick/demos/maroon/content/gfx/dialog-pointer.png
new file mode 100644
index 0000000000..9b51a090f9
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog-pointer.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog-shooter.png b/examples/quick/demos/maroon/content/gfx/dialog-shooter.png
new file mode 100644
index 0000000000..af980caabd
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog-shooter.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/dialog.png b/examples/quick/demos/maroon/content/gfx/dialog.png
new file mode 100644
index 0000000000..d528ba78d1
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/dialog.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory-action.png b/examples/quick/demos/maroon/content/gfx/factory-action.png
new file mode 100644
index 0000000000..8981678267
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/factory-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory-idle.png b/examples/quick/demos/maroon/content/gfx/factory-idle.png
new file mode 100644
index 0000000000..a145582c8f
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/factory-idle.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/factory.png b/examples/quick/demos/maroon/content/gfx/factory.png
new file mode 100644
index 0000000000..bfb9f3fb79
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/factory.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/grid.png b/examples/quick/demos/maroon/content/gfx/grid.png
new file mode 100644
index 0000000000..b59555247a
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/grid.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/help.png b/examples/quick/demos/maroon/content/gfx/help.png
new file mode 100644
index 0000000000..4654e4c69b
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/help.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/lifes.png b/examples/quick/demos/maroon/content/gfx/lifes.png
new file mode 100644
index 0000000000..135310b38c
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/lifes.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo-bubble.png b/examples/quick/demos/maroon/content/gfx/logo-bubble.png
new file mode 100644
index 0000000000..136151caff
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/logo-bubble.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo-fish.png b/examples/quick/demos/maroon/content/gfx/logo-fish.png
new file mode 100644
index 0000000000..c41833a0c9
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/logo-fish.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/logo.png b/examples/quick/demos/maroon/content/gfx/logo.png
new file mode 100644
index 0000000000..787ac99ce8
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/logo.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee-action.png b/examples/quick/demos/maroon/content/gfx/melee-action.png
new file mode 100644
index 0000000000..c53873bfcc
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/melee-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee-idle.png b/examples/quick/demos/maroon/content/gfx/melee-idle.png
new file mode 100644
index 0000000000..621d9dff54
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/melee-idle.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/melee.png b/examples/quick/demos/maroon/content/gfx/melee.png
new file mode 100644
index 0000000000..ab240151f3
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/melee.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/mob-idle.png b/examples/quick/demos/maroon/content/gfx/mob-idle.png
new file mode 100644
index 0000000000..dedacc7866
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/mob-idle.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/mob.png b/examples/quick/demos/maroon/content/gfx/mob.png
new file mode 100644
index 0000000000..7569c3525a
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/mob.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/points.png b/examples/quick/demos/maroon/content/gfx/points.png
new file mode 100644
index 0000000000..1d2386dbe7
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/points.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/projectile-action.png b/examples/quick/demos/maroon/content/gfx/projectile-action.png
new file mode 100644
index 0000000000..aa2e650aeb
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/projectile-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/projectile.png b/examples/quick/demos/maroon/content/gfx/projectile.png
new file mode 100644
index 0000000000..c25a0c3890
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/projectile.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/scores.png b/examples/quick/demos/maroon/content/gfx/scores.png
new file mode 100644
index 0000000000..af757fe64a
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/scores.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter-action.png b/examples/quick/demos/maroon/content/gfx/shooter-action.png
new file mode 100644
index 0000000000..08e7e300ca
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/shooter-action.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter-idle.png b/examples/quick/demos/maroon/content/gfx/shooter-idle.png
new file mode 100644
index 0000000000..663098d3b0
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/shooter-idle.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/shooter.png b/examples/quick/demos/maroon/content/gfx/shooter.png
new file mode 100644
index 0000000000..d44401e055
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/shooter.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/sunlight.png b/examples/quick/demos/maroon/content/gfx/sunlight.png
new file mode 100644
index 0000000000..d1c7042117
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/sunlight.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-1.png b/examples/quick/demos/maroon/content/gfx/text-1.png
new file mode 100644
index 0000000000..3ea399cc90
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-1.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-2.png b/examples/quick/demos/maroon/content/gfx/text-2.png
new file mode 100644
index 0000000000..934a481f3b
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-2.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-3.png b/examples/quick/demos/maroon/content/gfx/text-3.png
new file mode 100644
index 0000000000..47523f55b8
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-3.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-blank.png b/examples/quick/demos/maroon/content/gfx/text-blank.png
new file mode 100644
index 0000000000..4a687b24dc
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-blank.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-gameover.png b/examples/quick/demos/maroon/content/gfx/text-gameover.png
new file mode 100644
index 0000000000..4f53ef0b29
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-gameover.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/text-go.png b/examples/quick/demos/maroon/content/gfx/text-go.png
new file mode 100644
index 0000000000..bfc26f71fc
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/text-go.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/gfx/wave.png b/examples/quick/demos/maroon/content/gfx/wave.png
new file mode 100644
index 0000000000..f97426c4e7
--- /dev/null
+++ b/examples/quick/demos/maroon/content/gfx/wave.png
Binary files differ
diff --git a/examples/quick/demos/maroon/content/logic.js b/examples/quick/demos/maroon/content/logic.js
new file mode 100644
index 0000000000..dd76b7e073
--- /dev/null
+++ b/examples/quick/demos/maroon/content/logic.js
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library // Shared game state
+.import QtQuick 2.0 as QQ
+
+// Game Stuff
+var gameState // Local reference
+function getGameState() { return gameState; }
+
+var towerData = [ // Name and cost, stats are in the delegate per instance
+ { "name": "Melee", "cost": 20 },
+ { "name": "Ranged", "cost": 50 },
+ { "name": "Bomb", "cost": 75 },
+ { "name": "Factory", "cost": 25 }
+]
+
+var waveBaseData = [300, 290, 280, 270, 220, 180, 160, 80, 80, 80, 30, 30, 30, 30];
+var waveData = [];
+
+var towerComponents = new Array(towerData.length);
+var mobComponent = Qt.createComponent("mobs/MobBase.qml");
+
+function endGame()
+{
+ gameState.gameRunning = false;
+ gameState.gameOver = true;
+ for (var i = 0; i < gameState.cols; i++) {
+ for (var j = 0; j < gameState.rows; j++) {
+ if (gameState.towers[towerIdx(i, j)]) {
+ gameState.towers[towerIdx(i, j)].destroy();
+ gameState.towers[towerIdx(i, j)] = null;
+ }
+ }
+ for (var j in gameState.mobs[i])
+ gameState.mobs[i][j].destroy();
+ gameState.mobs[i].splice(0,gameState.mobs[i].length); //Leaves queue reusable
+ }
+}
+
+function startGame(gameCanvas)
+{
+ waveData = new Array();
+ for (var i in waveBaseData)
+ waveData[i] = waveBaseData[i];
+ gameState.freshState();
+ for (var i = 0; i < gameCanvas.cols; i++) {
+ for (var j = 0; j < gameCanvas.rows; j++)
+ gameState.towers[towerIdx(i, j)] = null;
+ gameState.mobs[i] = new Array();
+ }
+ gameState.towers[towerIdx(0, 0)] = newTower(3, 0, 0);//Start with a starfish in the corner
+ gameState.gameRunning = true;
+ gameState.gameOver = false;
+}
+
+function newGameState(gameCanvas)
+{
+ for (var i = 0; i < towerComponents.length; i++) {
+ towerComponents[i] = Qt.createComponent("towers/" + towerData[i].name + ".qml");
+ if (towerComponents[i].status == QQ.Component.Error) {
+ gameCanvas.errored = true;
+ gameCanvas.errorString += "Loading Tower " + towerData[i].name + "\n" + (towerComponents[i].errorString());
+ console.log(towerComponents[i].errorString());
+ }
+ }
+ gameState = gameCanvas;
+ gameState.freshState();
+ gameState.towers = new Array(gameCanvas.rows * gameCanvas.cols);
+ gameState.mobs = new Array(gameCanvas.cols);
+ return gameState;
+}
+
+function row(y)
+{
+ return Math.floor(y / gameState.squareSize);
+}
+
+function col(x)
+{
+ return Math.floor(x / gameState.squareSize);
+}
+
+function towerIdx(x, y)
+{
+ return y + (x * gameState.rows);
+}
+
+function newMob(col)
+{
+ var ret = mobComponent.createObject(gameState.canvas,
+ { "col" : col,
+ "speed" : (Math.min(2.0, 0.10 * (gameState.waveNumber + 1))),
+ "y" : gameState.canvas.height });
+ gameState.mobs[col].push(ret);
+ return ret;
+}
+
+function newTower(type, row, col)
+{
+ var ret = towerComponents[type].createObject(gameState.canvas);
+ ret.row = row;
+ ret.col = col;
+ ret.fireCounter = ret.rof;
+ ret.spawn();
+ return ret;
+}
+
+function buildTower(type, x, y)
+{
+ if (gameState.towers[towerIdx(x,y)] != null) {
+ if (type <= 0) {
+ gameState.towers[towerIdx(x,y)].sell();
+ gameState.towers[towerIdx(x,y)] = null;
+ }
+ } else {
+ if (gameState.coins < towerData[type - 1].cost)
+ return;
+ gameState.towers[towerIdx(x, y)] = newTower(type - 1, y, x);
+ gameState.coins -= towerData[type - 1].cost;
+ }
+}
+
+function killMob(col, mob)
+{
+ if (!mob)
+ return;
+ var idx = gameState.mobs[col].indexOf(mob);
+ if (idx == -1 || !mob.hp)
+ return;
+ mob.hp = 0;
+ mob.die();
+ gameState.mobs[col].splice(idx,1);
+}
+
+function killTower(row, col)
+{
+ var tower = gameState.towers[towerIdx(col, row)];
+ if (!tower)
+ return;
+ tower.hp = 0;
+ tower.die();
+ gameState.towers[towerIdx(col, row)] = null;
+}
+
+function tick()
+{
+ if (!gameState.gameRunning)
+ return;
+
+ // Spawn
+ gameState.waveProgress += 1;
+ var i = gameState.waveProgress;
+ var j = 0;
+ while (i > 0 && j < waveData.length)
+ i -= waveData[j++];
+ if ( i == 0 ) // Spawn a mob
+ newMob(Math.floor(Math.random() * gameState.cols));
+ if ( j == waveData.length ) { // Next Wave
+ gameState.waveNumber += 1;
+ gameState.waveProgress = 0;
+ var waveModifier = 10; // Constant governing how much faster the next wave is to spawn (not fish speed)
+ for (var k in waveData ) // Slightly faster
+ if (waveData[k] > waveModifier)
+ waveData[k] -= waveModifier;
+ }
+
+ // Towers Attack
+ for (var j in gameState.towers) {
+ var tower = gameState.towers[j];
+ if (tower == null)
+ continue;
+ if (tower.fireCounter > 0) {
+ tower.fireCounter -= 1;
+ continue;
+ }
+ var column = tower.col;
+ for (var k in gameState.mobs[column]) {
+ var conflict = gameState.mobs[column][k];
+ if (conflict.y <= gameState.canvas.height && conflict.y + conflict.height > tower.y
+ && conflict.y - ((tower.row + 1) * gameState.squareSize) < gameState.squareSize * tower.range) { // In Range
+ tower.fire();
+ tower.fireCounter = tower.rof;
+ conflict.hit(tower.damage);
+ }
+ }
+
+ // Income
+ if (tower.income) {
+ gameState.coins += tower.income;
+ tower.fire();
+ tower.fireCounter = tower.rof;
+ }
+ }
+
+ // Mobs move
+ for (var i = 0; i < gameState.cols; i++) {
+ for (var j = 0; j < gameState.mobs[i].length; j++) {
+ var mob = gameState.mobs[i][j];
+ var newPos = gameState.mobs[i][j].y - gameState.mobs[i][j].speed;
+ if (newPos < 0) {
+ gameState.lives -= 1;
+ killMob(i, mob);
+ if (gameState.lives <= 0)
+ endGame();
+ continue;
+ }
+ var conflict = gameState.towers[towerIdx(i, row(newPos))];
+ if (conflict != null) {
+ if (mob.y < conflict.y + gameState.squareSize)
+ gameState.mobs[i][j].y += gameState.mobs[i][j].speed * 10; // Moved inside tower, now hurry back out
+ if (mob.fireCounter > 0) {
+ mob.fireCounter--;
+ } else {
+ gameState.mobs[i][j].fire();
+ conflict.hp -= mob.damage;
+ if (conflict.hp <= 0)
+ killTower(conflict.row, conflict.col);
+ mob.fireCounter = mob.rof;
+ }
+ } else {
+ gameState.mobs[i][j].y = newPos;
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/demos/maroon/content/mobs/MobBase.qml b/examples/quick/demos/maroon/content/mobs/MobBase.qml
new file mode 100644
index 0000000000..d4ece660ed
--- /dev/null
+++ b/examples/quick/demos/maroon/content/mobs/MobBase.qml
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../logic.js" as Logic
+import ".."
+
+Item {
+ id: container
+ property string name: "Fish"
+ property int col: 0
+ property real hp: 3
+ property real damage: 1
+ property real speed: 0.25
+ property int rof: 30 //In ticks
+ property int fireCounter: 0
+ property bool dying: false
+ width: parent ? parent.squareSize : 0
+ height: parent ? parent.squareSize : 0
+ x: col * width
+ z: 1001
+ function fire() { }
+
+ function die() {
+ if (dying)
+ return;
+ dying = true;
+ bubble.jumpTo("burst");
+ if (fishSprite.currentSprite == "front")
+ fishSprite.jumpTo(Math.random() > 0.5 ? "left" : "right" );
+ fishSwim.start();
+ Logic.gameState.score += 1;
+ killedSound.play();
+ bubble.scale = 0.9
+ destroy(350);
+ }
+
+ function inked() {
+ if (hp > 0)
+ ink.jumpTo("dirty");
+ }
+
+ function hit(dmg) {
+ hp -= dmg;
+
+ if (hp <= 0)
+ Logic.killMob(col, container);
+ }
+
+ Component.onCompleted: spawnSound.play()
+
+ SoundEffect {
+ id: spawnSound
+ source: "../audio/catch.wav"
+ }
+ SoundEffect {
+ id: killedSound
+ source: "../audio/catch-action.wav"
+ }
+
+ SpriteSequence {
+ id: fishSprite
+ width: 64
+ height: 64
+ interpolate: false
+ goalSprite: ""
+
+ Sprite {
+ name: "left"
+ source: "../gfx/mob-idle.png"
+ frameWidth: 64
+ frameHeight: 64
+ frameCount: 1
+ frameDuration: 800
+ frameDurationVariation: 400
+ to: { "front" : 1 }
+ }
+
+ Sprite {
+ name: "front"
+ source: "../gfx/mob-idle.png"
+ frameCount: 1
+ frameX: 64
+ frameWidth: 64
+ frameHeight: 64
+ frameDuration: 800
+ frameDurationVariation: 400
+ to: { "left" : 1, "right" : 1 }
+ }
+
+ Sprite {
+ name: "right"
+ source: "../gfx/mob-idle.png"
+ frameCount: 1
+ frameX: 128
+ frameWidth: 64
+ frameHeight: 64
+ frameDuration: 800
+ frameDurationVariation: 400
+ to: { "front" : 1 }
+ }
+
+
+ Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
+ name: "dummy"
+ source: "../gfx/melee-idle.png"
+ frameCount: 8
+ frameWidth: 64
+ frameHeight: 64
+ frameX: 0
+ frameDuration: 200
+ }
+
+ NumberAnimation on x {
+ id: fishSwim
+ running: false
+ property bool goingLeft: fishSprite.currentSprite == "right"
+ to: goingLeft ? -360 : 360
+ duration: 300
+ }
+ }
+
+ SpriteSequence {
+ id: bubble
+ width: 64
+ height: 64
+ scale: 0.4 + (0.2 * hp)
+ interpolate: false
+ goalSprite: ""
+
+ Behavior on scale {
+ NumberAnimation { duration: 150; easing.type: Easing.OutBack }
+ }
+
+ Sprite {
+ name: "big"
+ source: "../gfx/catch.png"
+ frameCount: 1
+ to: { "burst" : 0 }
+ }
+
+ Sprite {
+ name: "burst"
+ source: "../gfx/catch-action.png"
+ frameCount: 3
+ frameX: 64
+ frameDuration: 200
+ }
+
+ Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
+ name: "dummy"
+ source: "../gfx/melee-idle.png"
+ frameCount: 8
+ frameWidth: 64
+ frameHeight: 64
+ frameX: 0
+ frameDuration: 200
+ }
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ SpriteSequence {
+ id: ink
+ width: 64
+ height: 64
+ scale: bubble.scale
+ goalSprite: ""
+
+ Sprite {
+ name: "clean"
+ source: "../gfx/projectile-action.png"
+ frameCount: 1
+ frameX: 0
+ frameWidth: 64
+ frameHeight: 64
+ }
+ Sprite {
+ name: "dirty"
+ source: "../gfx/projectile-action.png"
+ frameCount: 3
+ frameX: 64
+ frameWidth: 64
+ frameHeight: 64
+ frameDuration: 150
+ to: {"clean":1}
+ }
+
+ Sprite { //WORKAROUND: This prevents the triggering of a rendering error which is currently under investigation.
+ name: "dummy"
+ source: "../gfx/melee-idle.png"
+ frameCount: 8
+ frameWidth: 64
+ frameHeight: 64
+ frameX: 0
+ frameDuration: 200
+ }
+ SequentialAnimation on width {
+ loops: Animation.Infinite
+ NumberAnimation { from: width * 1; to: width * 1.1; duration: 800; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: width * 1.1; to: width * 1; duration: 1000; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on height {
+ loops: Animation.Infinite
+ NumberAnimation { from: height * 1; to: height * 1.15; duration: 1200; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: height * 1.15; to: height * 1; duration: 1000; easing.type: Easing.InOutQuad }
+ }
+
+ }
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x; to: x - 5; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x - 5; to: x; duration: 900; easing.type: Easing.InOutQuad }
+ }
+}
+
diff --git a/examples/quick/demos/maroon/content/towers/Bomb.qml b/examples/quick/demos/maroon/content/towers/Bomb.qml
new file mode 100644
index 0000000000..00437f468f
--- /dev/null
+++ b/examples/quick/demos/maroon/content/towers/Bomb.qml
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../logic.js" as Logic
+import ".."
+
+TowerBase {
+ id: container
+ hp: 10
+ range: 0.4
+ rof: 10
+ property real detonationRange: 2.5
+
+ function fire() {
+ sound.play()
+ sprite.jumpTo("shoot")
+ animDelay.start()
+ }
+
+ function finishFire() {
+ var sCol = Math.max(0, col - 1)
+ var eCol = Math.min(Logic.gameState.cols - 1, col + 1)
+ var killList = new Array()
+ for (var i = sCol; i <= eCol; i++) {
+ for (var j = 0; j < Logic.gameState.mobs[i].length; j++)
+ if (Math.abs(Logic.gameState.mobs[i][j].y - container.y) < Logic.gameState.squareSize * detonationRange)
+ killList.push(Logic.gameState.mobs[i][j])
+ while (killList.length > 0)
+ Logic.killMob(i, killList.pop())
+ }
+ Logic.killTower(row, col);
+ }
+
+ Timer {
+ id: animDelay
+ running: false
+ interval: shootState.frameCount * shootState.frameDuration
+ onTriggered: finishFire()
+ }
+
+ function die()
+ {
+ destroy() // No blink, because we usually meant to die
+ }
+
+ SoundEffect {
+ id: sound
+ source: "../audio/bomb-action.wav"
+ }
+
+ SpriteSequence {
+ id: sprite
+ width: 64
+ height: 64
+ interpolate: false
+ goalSprite: ""
+
+ Sprite {
+ name: "idle"
+ source: "../gfx/bomb-idle.png"
+ frameCount: 4
+ frameDuration: 800
+ }
+
+ Sprite {
+ id: shootState
+ name: "shoot"
+ source: "../gfx/bomb-action.png"
+ frameCount: 6
+ frameDuration: 155
+ to: { "dying" : 1 } // So that if it takes a frame to clean up, it is on the last frame of the explosion
+ }
+
+ Sprite {
+ name: "dying"
+ source: "../gfx/bomb-action.png"
+ frameCount: 1
+ frameX: 64 * 5
+ frameWidth: 64
+ frameHeight: 64
+ frameDuration: 155
+ }
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+ NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad }
+ }
+ }
+}
diff --git a/examples/quick/demos/maroon/content/towers/Factory.qml b/examples/quick/demos/maroon/content/towers/Factory.qml
new file mode 100644
index 0000000000..b34a18498a
--- /dev/null
+++ b/examples/quick/demos/maroon/content/towers/Factory.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../logic.js" as Logic
+import ".."
+
+TowerBase {
+ id: container
+ rof: 160
+ income: 5
+ SpriteSequence {
+ id: sprite
+ width: 64
+ height: 64
+ interpolate: false
+ goalSprite: ""
+
+ Sprite {
+ name: "idle"
+ source: "../gfx/factory-idle.png"
+ frameCount: 4
+ frameDuration: 200
+ }
+
+ Sprite {
+ name: "action"
+ source: "../gfx/factory-action.png"
+ frameCount: 4
+ frameDuration: 90
+ to: { "idle" : 1 }
+ }
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x; to: x + 4; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x + 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
+ }
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+ NumberAnimation { from: y; to: y - 4; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: y - 4; to: y; duration: 900; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ SoundEffect {
+ id: actionSound
+ source: "../audio/factory-action.wav"
+ }
+
+ function fire() {
+ actionSound.play()
+ sprite.jumpTo("action")
+ coinLaunch.start()
+ }
+
+ function spawn() {
+ coin.target = Logic.gameState.mapToItem(container, 240, -32)
+ }
+
+ Image {
+ id: coin
+ property var target: { "x" : 0, "y" : 0 }
+ source: "../gfx/currency.png"
+ visible: false
+ }
+
+ SequentialAnimation {
+ id: coinLaunch
+ PropertyAction { target: coin; property: "visible"; value: true }
+ ParallelAnimation {
+ NumberAnimation { target: coin; property: "x"; from: 16; to: coin.target.x }
+ NumberAnimation { target: coin; property: "y"; from: 16; to: coin.target.y }
+ }
+ PropertyAction { target: coin; property: "visible"; value: false }
+ }
+}
diff --git a/examples/quick/demos/maroon/content/towers/Melee.qml b/examples/quick/demos/maroon/content/towers/Melee.qml
new file mode 100644
index 0000000000..1b49a455aa
--- /dev/null
+++ b/examples/quick/demos/maroon/content/towers/Melee.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import ".."
+
+TowerBase {
+ hp: 4
+ range: 0.1
+ damage: 1
+ rof: 40
+ income: 0
+
+ SpriteSequence {
+ id: sprite
+ width: 64
+ height: 64
+ interpolate: false
+ goalSprite: ""
+
+ Sprite {
+ name: "idle"
+ source: "../gfx/melee-idle.png"
+ frameCount: 8
+ frameDuration: 250
+ }
+
+ Sprite {
+ name: "shoot"
+ source: "../gfx/melee-action.png"
+ frameCount: 2
+ frameDuration: 200
+ to: { "idle" : 1 }
+ }
+ }
+
+ function fire() {
+ shootSound.play()
+ sprite.jumpTo("shoot")
+ }
+
+ SoundEffect {
+ id: shootSound
+ source: "../audio/melee-action.wav"
+ }
+}
diff --git a/examples/quick/demos/maroon/content/towers/Ranged.qml b/examples/quick/demos/maroon/content/towers/Ranged.qml
new file mode 100644
index 0000000000..33f3354fb6
--- /dev/null
+++ b/examples/quick/demos/maroon/content/towers/Ranged.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../logic.js" as Logic
+import ".."
+
+TowerBase {
+ id: container
+ hp: 2
+ range: 6
+ damage: 0 // By projectile
+ rof: 40
+ income: 0
+ property var targetMob
+ property real realDamage: 1
+ function fire() {
+ proj.x = 32 - proj.width / 2
+ proj.y = 0
+ targetMob = Logic.gameState.mobs[col][0]
+ projAnim.to = targetMob.y - container.y -10
+ projAnim.start()
+ shootSound.play()
+ sprite.jumpTo("shoot")
+ }
+
+ Image {
+ id: proj
+ y: 1000
+ SequentialAnimation on y {
+ id: projAnim
+ running: false
+ property real to: 1000
+ SmoothedAnimation {
+ to: projAnim.to
+ velocity: 400
+ }
+ ScriptAction {
+ script: {
+ if (targetMob && targetMob.hit) {
+ targetMob.hit(realDamage)
+ targetMob.inked()
+ projSound.play()
+ }
+ }
+ }
+ PropertyAction {
+ value: 1000;
+ }
+ }
+ source: "../gfx/projectile.png"
+ }
+
+ SoundEffect {
+ id: shootSound
+ source: "../audio/shooter-action.wav"
+ }
+ SoundEffect {
+ id: projSound
+ source: "../audio/projectile-action.wav"
+ }
+
+ SpriteSequence {
+ id: sprite
+ width: 64
+ height: 64
+ interpolate: false
+ goalSprite: ""
+
+ Sprite {
+ name: "idle"
+ source: "../gfx/shooter-idle.png"
+ frameCount: 4
+ frameDuration: 250
+ }
+
+ Sprite {
+ name: "shoot"
+ source: "../gfx/shooter-action.png"
+ frameCount: 5
+ frameDuration: 90
+ to: { "idle" : 1 }
+ }
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ NumberAnimation { from: x; to: x - 4; duration: 900; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: x - 4; to: x; duration: 900; easing.type: Easing.InOutQuad }
+ }
+ }
+}
diff --git a/examples/quick/demos/maroon/content/towers/TowerBase.qml b/examples/quick/demos/maroon/content/towers/TowerBase.qml
new file mode 100644
index 0000000000..5c71cb051f
--- /dev/null
+++ b/examples/quick/demos/maroon/content/towers/TowerBase.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property real hp: 1
+ property real range: 0
+ property real damage: 0
+ property int rof: 100
+ property int fireCounter: 0
+ property int income: 0
+ property int row: 0
+ property int col: 0
+
+ width: parent ? parent.squareSize : 0
+ height: parent ? parent.squareSize : 0
+ //This is how it is placed on the gameboard, do not modify/animate the X/Y/Z of a TowerBase please
+ x: col * width
+ y: row * height
+ z: 1000
+
+ function fire() { }
+ function spawn() { } //After all game properties are set
+ function die() { stdDeath.start(); destroy(1000); }
+ function sell() { destroy(); }
+
+ SequentialAnimation on opacity {
+ id: stdDeath
+ running: false
+ loops: 2
+ NumberAnimation { from: 1; to: 0; }
+ NumberAnimation { from: 0; to: 1; }
+ }
+}
diff --git a/examples/quick/demos/maroon/main.cpp b/examples/quick/demos/maroon/main.cpp
new file mode 100644
index 0000000000..da2343e444
--- /dev/null
+++ b/examples/quick/demos/maroon/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(maroon)
diff --git a/examples/quick/demos/maroon/maroon.pro b/examples/quick/demos/maroon/maroon.pro
new file mode 100644
index 0000000000..e193927e72
--- /dev/null
+++ b/examples/quick/demos/maroon/maroon.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/maroon
+qml.files = maroon.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/maroon
+INSTALLS += target qml
diff --git a/examples/quick/demos/maroon/maroon.qml b/examples/quick/demos/maroon/maroon.qml
new file mode 100644
index 0000000000..d7bfcb6a66
--- /dev/null
+++ b/examples/quick/demos/maroon/maroon.qml
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content"
+import "content/logic.js" as Logic
+
+Item {
+ id: root
+ width: 320
+ height: 480
+ property var gameState: Logic.newGameState(canvas);
+ property bool passedSplash: false
+
+ Image {
+ source:"content/gfx/background.png"
+ anchors.bottom: view.bottom
+
+ ParticleSystem {
+ id: particles
+ anchors.fill: parent
+
+ ImageParticle {
+ id: bubble
+ anchors.fill: parent
+ source: "content/gfx/catch.png"
+ opacity: 0.25
+ }
+
+ Wander {
+ xVariance: 25;
+ pace: 25;
+ }
+
+ Emitter {
+ width: parent.width
+ height: 150
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 3
+ startTime: 15000
+
+ emitRate: 2
+ lifeSpan: 15000
+
+ acceleration: PointDirection{ y: -6; xVariation: 2; yVariation: 2 }
+
+ size: 24
+ sizeVariation: 16
+ }
+ }
+ }
+
+ Column {
+ id: view
+ y: -(height - 480)
+ width: 320
+
+ GameOverScreen { gameCanvas: canvas }
+
+ Item {
+ id: canvasArea
+ width: 320
+ height: 480
+
+ Row {
+ height: childrenRect.height
+ Image {
+ id: wave
+ y: 30
+ source:"content/gfx/wave.png"
+ }
+ Image {
+ y: 30
+ source:"content/gfx/wave.png"
+ }
+ NumberAnimation on x { from: 0; to: -(wave.width); duration: 16000; loops: Animation.Infinite }
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+ NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ Row {
+ opacity: 0.5
+ Image {
+ id: wave2
+ y: 25
+ source: "content/gfx/wave.png"
+ }
+ Image {
+ y: 25
+ source: "content/gfx/wave.png"
+ }
+ NumberAnimation on x { from: -(wave2.width); to: 0; duration: 32000; loops: Animation.Infinite }
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+ NumberAnimation { from: y + 2; to: y - 2; duration: 1600; easing.type: Easing.InOutQuad }
+ NumberAnimation { from: y - 2; to: y + 2; duration: 1600; easing.type: Easing.InOutQuad }
+ }
+ }
+
+ Image {
+ source: "content/gfx/sunlight.png"
+ opacity: 0.02
+ y: 0
+ anchors.horizontalCenter: parent.horizontalCenter
+ transformOrigin: Item.Top
+ SequentialAnimation on rotation {
+ loops: Animation.Infinite
+ NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
+ NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
+ }
+ }
+
+ Image {
+ source: "content/gfx/sunlight.png"
+ opacity: 0.04
+ y: 20
+ anchors.horizontalCenter: parent.horizontalCenter
+ transformOrigin: Item.Top
+ SequentialAnimation on rotation {
+ loops: Animation.Infinite
+ NumberAnimation { from: 10; to: -10; duration: 8000; easing.type: Easing.InOutSine }
+ NumberAnimation { from: -10; to: 10; duration: 8000; easing.type: Easing.InOutSine }
+ }
+ }
+
+ Image {
+ source: "content/gfx/grid.png"
+ opacity: 0.5
+ }
+
+ GameCanvas {
+ id: canvas
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 20
+ x: 32
+ focus: true
+ }
+
+ InfoBar { anchors.bottom: canvas.top; anchors.bottomMargin: 6; width: parent.width }
+
+ //3..2..1..go
+ Timer {
+ id: countdownTimer
+ interval: 1000
+ running: root.countdown < 5
+ repeat: true
+ onTriggered: root.countdown++
+ }
+ Repeater {
+ model: ["content/gfx/text-blank.png", "content/gfx/text-3.png", "content/gfx/text-2.png", "content/gfx/text-1.png", "content/gfx/text-go.png"]
+ delegate: Image {
+ visible: root.countdown <= index
+ opacity: root.countdown == index ? 0.5 : 0.1
+ scale: root.countdown >= index ? 1.0 : 0.0
+ source: modelData
+ Behavior on opacity { NumberAnimation {} }
+ Behavior on scale { NumberAnimation {} }
+ }
+ }
+ }
+
+ NewGameScreen {
+ onStartButtonClicked: root.passedSplash = true
+ }
+ }
+
+ property int countdown: 10
+ Timer {
+ id: gameStarter
+ interval: 4000
+ running: false
+ repeat: false
+ onTriggered: Logic.startGame(canvas);
+ }
+
+ states: [
+ State {
+ name: "gameOn"; when: gameState.gameOver == false && passedSplash
+ PropertyChanges { target: view; y: -(height - 960) }
+ StateChangeScript { script: root.countdown = 0; }
+ PropertyChanges { target: gameStarter; running: true }
+ },
+ State {
+ name: "gameOver"; when: gameState.gameOver == true
+ PropertyChanges { target: view; y: 0 }
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { properties: "x,y"; duration: 1200; easing.type: Easing.OutQuad }
+ }
+}
diff --git a/examples/quick/demos/maroon/maroon.qmlproject b/examples/quick/demos/maroon/maroon.qmlproject
new file mode 100644
index 0000000000..752666114f
--- /dev/null
+++ b/examples/quick/demos/maroon/maroon.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "maroon.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
new file mode 100644
index 0000000000..12902c0413
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Component {
+ id: albumDelegate
+ Package {
+
+ Item {
+ Package.name: 'browser'
+ GridView {
+ id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21
+ x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false
+ onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain)
+ }
+ }
+
+ Item {
+ Package.name: 'fullscreen'
+ ListView {
+ id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal
+ width: mainWindow.width; height: mainWindow.height; interactive: false
+ onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain)
+ highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem
+ }
+ }
+
+ Item {
+ Package.name: 'album'
+ id: albumWrapper; width: 210; height: 220
+
+ VisualDataModel {
+ id: visualModel; delegate: PhotoDelegate { }
+ model: RssModel { id: rssModel; tags: tag }
+ }
+
+ BusyIndicator {
+ id: busyIndicator
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ on: rssModel.status != XmlListModel.Ready
+ }
+
+ PathView {
+ id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5
+ visible: !busyIndicator.visible
+ anchors.centerIn: parent; anchors.verticalCenterOffset: -30
+ path: Path {
+ PathAttribute { name: 'z'; value: 9999.0 }
+ PathLine { x: 1; y: 1 }
+ PathAttribute { name: 'z'; value: 0.0 }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid'
+ }
+
+ Tag {
+ anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 }
+ frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode
+ onTagChanged: rssModel.tags = tag
+ onBackClicked: if (mainWindow.editMode) photosModel.remove(index);
+ }
+
+ states: [
+ State {
+ name: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: true }
+ PropertyChanges { target: albumsShade; opacity: 1 }
+ PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 }
+ },
+ State {
+ name: 'fullscreen'; extend: 'inGrid'
+ PropertyChanges { target: photosGridView; interactive: false }
+ PropertyChanges { target: photosListView; interactive: true }
+ PropertyChanges { target: photosShade; opacity: 1 }
+ PropertyChanges { target: backButton; y: -backButton.height - 8 }
+ }
+ ]
+
+ GridView.onAdd: NumberAnimation {
+ target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad
+ }
+ GridView.onRemove: SequentialAnimation {
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true }
+ NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad }
+ PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false }
+ }
+
+ transitions: [
+ Transition {
+ from: '*'; to: 'inGrid'
+ SequentialAnimation {
+ NumberAnimation { properties: 'opacity'; duration: 250 }
+ PauseAnimation { duration: 350 }
+ NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: '*'
+ NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
new file mode 100644
index 0000000000..fc832eaed8
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+ NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml
new file mode 100644
index 0000000000..6571470e2f
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/Button.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property alias label: labelText.text
+ property color tint: "transparent"
+ signal clicked
+
+ width: labelText.width + 70 ; height: labelText.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png'
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; antialiasing: true }
+
+ Rectangle {
+ anchors.fill: container; color: container.tint; visible: container.tint != ""
+ opacity: 0.25
+ }
+
+ Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: container.clicked()
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml
new file mode 100644
index 0000000000..8543bee157
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property string label
+ signal clicked
+
+ width: textInput.width + 70 ; height: textInput.height + 18
+
+ BorderImage {
+ anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 }
+ source: 'images/box-shadow.png';
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+
+ Image { anchors.fill: parent; source: "images/cardboard.png"; antialiasing: true }
+
+ TextInput {
+ id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent
+ Keys.onReturnPressed: {
+ container.label = textInput.text
+ container.focus = true
+ }
+ Keys.onEnterPressed: {
+ container.label = textInput.text
+ container.focus = true
+ }
+ Keys.onEscapePressed: {
+ textInput.text = container.label
+ container.focus = true
+ }
+ }
+
+ Rectangle {
+ anchors.fill: container; border.color: "steelblue"; border.width: 4
+ color: "transparent"; visible: textInput.focus; antialiasing: true
+ }
+
+ MouseArea {
+ anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
+ onClicked: { textInput.forceActiveFocus(); Qt.inputMethod.show(); }
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
new file mode 100644
index 0000000000..e14a1da266
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "script/script.js" as Script
+
+Package {
+ Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z }
+ Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 }
+ Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 }
+
+ Item {
+ width: 160; height: 153
+
+ Item {
+ id: photoWrapper
+
+ property double randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property double randomAngle2: Math.random() * (2 * 6 + 1) - 6
+
+ x: 0; y: 0; width: 140; height: 133
+ z: stackItem.PathView.z; rotation: photoWrapper.randomAngle
+
+ BorderImage {
+ anchors {
+ fill: originalImage.status == Image.Ready ? border : placeHolder
+ leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8
+ }
+ source: 'images/box-shadow.png'
+ border.left: 10; border.top: 10; border.right: 10; border.bottom: 10
+ }
+ Rectangle {
+ id: placeHolder
+
+ property int w: Script.getWidth(content)
+ property int h: Script.getHeight(content)
+ property double s: Script.calculateScale(w, h, photoWrapper.width)
+
+ color: 'white'; anchors.centerIn: parent; antialiasing: true
+ width: w * s; height: h * s; visible: originalImage.status != Image.Ready
+ Rectangle {
+ color: "#878787"; antialiasing: true
+ anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 }
+ }
+ }
+ Rectangle {
+ id: border; color: 'white'; anchors.centerIn: parent; antialiasing: true
+ width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6
+ visible: !placeHolder.visible
+ }
+ BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready }
+ Image {
+ id: originalImage; antialiasing: true;
+ source: "http://" + Script.getImagePath(content); cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Image {
+ id: hqImage; antialiasing: true; source: ""; visible: false; cache: false
+ fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height
+ }
+ Binding {
+ target: mainWindow; property: "downloadProgress"; value: hqImage.progress
+ when: listItem.ListView.isCurrentItem
+ }
+ Binding {
+ target: mainWindow; property: "imageLoading"
+ value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem
+ }
+ MouseArea {
+ width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage
+ onClicked: {
+ if (albumWrapper.state == 'inGrid') {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'fullscreen'
+ } else {
+ gridItem.GridView.view.currentIndex = index;
+ albumWrapper.state = 'inGrid'
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: 'stacked'; when: albumWrapper.state == ''
+ ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 }
+ PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 }
+ },
+ State {
+ name: 'inGrid'; when: albumWrapper.state == 'inGrid'
+ ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 }
+ },
+ State {
+ name: 'fullscreen'; when: albumWrapper.state == 'fullscreen'
+ ParentChange {
+ target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0
+ width: mainWindow.width; height: mainWindow.height
+ }
+ PropertyChanges { target: border; opacity: 0 }
+ PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ from: 'stacked'; to: 'inGrid'
+ SequentialAnimation {
+ PauseAnimation { duration: 10 * index }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'stacked'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' }
+ }
+ },
+ Transition {
+ from: 'inGrid'; to: 'fullscreen'
+ SequentialAnimation {
+ PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 }
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,opacity,rotation'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ },
+ Transition {
+ from: 'fullscreen'; to: 'inGrid'
+ ParentAnimation {
+ target: photoWrapper; via: foreground
+ NumberAnimation {
+ targets: [ photoWrapper, border ]
+ properties: 'x,y,width,height,rotation,opacity'
+ duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart'
+ }
+ }
+ }
+ ]
+ }
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
new file mode 100644
index 0000000000..d2f915887f
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/ProgressBar.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property real progress: 0
+
+ Behavior on opacity { NumberAnimation { duration: 600 } }
+
+ Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 }
+
+ Rectangle {
+ id: fill; color: "white"; height: container.height
+ width: container.width * container.progress
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml
new file mode 100644
index 0000000000..98fcd931dd
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/RssModel.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+XmlListModel {
+ property string tags : ""
+
+ function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
+
+ source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")
+ query: "/feed/entry"
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml
new file mode 100644
index 0000000000..eeb8c355e3
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/Tag.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Flipable {
+ id: flipable
+
+ property alias frontLabel: frontButton.label
+ property alias backLabel: backButton.label
+
+ property int angle: 0
+ property int randomAngle: Math.random() * (2 * 6 + 1) - 6
+ property bool flipped: false
+
+ signal frontClicked
+ signal backClicked
+ signal tagChanged(string tag)
+
+ front: EditableButton {
+ id: frontButton; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.frontClicked()
+ onLabelChanged: flipable.tagChanged(label)
+ }
+
+ back: Button {
+ id: backButton; tint: "red"; rotation: flipable.randomAngle
+ anchors { centerIn: parent; verticalCenterOffset: -20 }
+ onClicked: flipable.backClicked()
+ }
+
+ transform: Rotation {
+ origin.x: flipable.width / 2; origin.y: flipable.height / 2
+ axis.x: 0; axis.y: 1; axis.z: 0
+ angle: flipable.angle
+ }
+
+ states: State {
+ name: "back"; when: flipable.flipped
+ PropertyChanges { target: flipable; angle: 180 }
+ }
+
+ transitions: Transition {
+ ParallelAnimation {
+ NumberAnimation { properties: "angle"; duration: 400 }
+ SequentialAnimation {
+ NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 }
+ NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 }
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
new file mode 100644
index 0000000000..431af8545d
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/images/box-shadow.png
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/images/busy.png
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png
new file mode 100644
index 0000000000..1847ab528d
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/images/cardboard.png
Binary files differ
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir b/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir
new file mode 100644
index 0000000000..d3c247f21a
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/qmldir
@@ -0,0 +1,8 @@
+AlbumDelegate AlbumDelegate.qml
+PhotoDelegate PhotoDelegate.qml
+ProgressBar ProgressBar.qml
+RssModel RssModel.qml
+BusyIndicator BusyIndicator.qml
+EditableButton EditableButton.qml
+Button Button.qml
+Tag Tag.qml
diff --git a/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js b/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js
new file mode 100644
index 0000000000..e8ef93a847
--- /dev/null
+++ b/examples/quick/demos/photoviewer/PhotoViewerCore/script/script.js
@@ -0,0 +1,27 @@
+.pragma library
+
+function getWidth(string) {
+ return (string.match(/width=\"([0-9]+)\"/))[1]
+}
+
+function getHeight(string) {
+ return (string.match(/height=\"([0-9]+)\"/))[1]
+}
+
+function getImagePath(string) {
+ var pattern = /src=\"http:\/\/(\S+)\"/
+ return (string.match(pattern))[1]
+}
+
+function calculateScale(width, height, cellSize) {
+ var widthScale = (cellSize * 1.0) / width
+ var heightScale = (cellSize * 1.0) / height
+ var scale = 0
+
+ if (widthScale <= heightScale) {
+ scale = widthScale;
+ } else if (heightScale < widthScale) {
+ scale = heightScale;
+ }
+ return scale;
+}
diff --git a/examples/quick/demos/photoviewer/i18n/base.ts b/examples/quick/demos/photoviewer/i18n/base.ts
new file mode 100644
index 0000000000..1accfd2f90
--- /dev/null
+++ b/examples/quick/demos/photoviewer/i18n/base.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.qm b/examples/quick/demos/photoviewer/i18n/qml_fr.qm
new file mode 100644
index 0000000000..c24fcbc46c
--- /dev/null
+++ b/examples/quick/demos/photoviewer/i18n/qml_fr.qm
Binary files differ
diff --git a/examples/quick/demos/photoviewer/i18n/qml_fr.ts b/examples/quick/demos/photoviewer/i18n/qml_fr.ts
new file mode 100644
index 0000000000..9f892db616
--- /dev/null
+++ b/examples/quick/demos/photoviewer/i18n/qml_fr.ts
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="fr_FR">
+<context>
+ <name>AlbumDelegate</name>
+ <message>
+ <location filename="../PhotoViewerCore/AlbumDelegate.qml" line="59"/>
+ <source>Remove</source>
+ <translation>Supprimer</translation>
+ </message>
+</context>
+<context>
+ <name>photoviewer</name>
+ <message>
+ <location filename="../photoviewer.qml" line="30"/>
+ <source>Add</source>
+ <translation>Ajouter</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="39"/>
+ <source>Edit</source>
+ <translation>Éditer</translation>
+ </message>
+ <message>
+ <location filename="../photoviewer.qml" line="52"/>
+ <source>Back</source>
+ <translation>Retour</translation>
+ </message>
+</context>
+</TS>
diff --git a/examples/quick/demos/photoviewer/photoviewer.qml b/examples/quick/demos/photoviewer/photoviewer.qml
new file mode 100644
index 0000000000..caeade4594
--- /dev/null
+++ b/examples/quick/demos/photoviewer/photoviewer.qml
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "PhotoViewerCore"
+
+Rectangle {
+ id: mainWindow
+
+ property real downloadProgress: 0
+ property bool imageLoading: false
+ property bool editMode: false
+
+ width: 800; height: 480; color: "#d5d6d8"
+
+ ListModel {
+ id: photosModel
+ ListElement { tag: "Flowers" }
+ ListElement { tag: "Wildlife" }
+ ListElement { tag: "Prague" }
+ }
+
+ VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} }
+
+ GridView {
+ id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220
+ model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0
+ }
+
+ Column {
+ spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 }
+ Button {
+ id: newButton; label: qsTr("Add"); rotation: 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ onClicked: {
+ mainWindow.editMode = false
+ photosModel.append( { tag: "" } )
+ albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain)
+ }
+ }
+ Button {
+ id: deleteButton; label: qsTr("Edit"); rotation: -2;
+ onClicked: mainWindow.editMode = !mainWindow.editMode
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ Button {
+ id: quitButton; label: qsTr("Quit"); rotation: -2;
+ onClicked: Qt.quit()
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Rectangle {
+ id: albumsShade; color: mainWindow.color
+ width: parent.width; height: parent.height; opacity: 0.0
+ }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false }
+
+ Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 }
+
+ Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 }
+
+ ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false }
+
+ Item { id: foreground; anchors.fill: parent }
+
+ ProgressBar {
+ progress: mainWindow.downloadProgress; width: parent.width; height: 4
+ anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0
+ }
+}
diff --git a/examples/quick/demos/photoviewer/photoviewer.qmlproject b/examples/quick/demos/photoviewer/photoviewer.qmlproject
new file mode 100644
index 0000000000..600bdb10f4
--- /dev/null
+++ b/examples/quick/demos/photoviewer/photoviewer.qmlproject
@@ -0,0 +1,20 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "photoviewer.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ Files {
+ filter: "*.ts"
+ directory: "i18n"
+ }
+}
diff --git a/examples/quick/demos/rssnews/content/BusyIndicator.qml b/examples/quick/demos/rssnews/content/BusyIndicator.qml
new file mode 100644
index 0000000000..20ac08f612
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/BusyIndicator.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+
+ NumberAnimation on rotation {
+ running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ }
+}
diff --git a/examples/quick/demos/rssnews/content/CategoryDelegate.qml b/examples/quick/demos/rssnews/content/CategoryDelegate.qml
new file mode 100644
index 0000000000..a6fea432f8
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/CategoryDelegate.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+
+ width: delegate.ListView.view.width; height: 60
+
+ Text {
+ text: name
+ color: delegate.ListView.isCurrentItem ? "white" : "black"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ BusyIndicator {
+ scale: 0.6
+ on: delegate.ListView.isCurrentItem && window.loading
+ anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
+ }
+
+ Rectangle {
+ width: delegate.width; height: 1; color: "#cccccc"
+ anchors.bottom: delegate.bottom
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+ Rectangle {
+ width: delegate.width; height: 1; color: "white"
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+
+ MouseArea {
+ anchors.fill: delegate
+ onClicked: {
+ delegate.ListView.view.currentIndex = index
+ window.currentFeed = feed
+ }
+ }
+}
diff --git a/examples/quick/demos/rssnews/content/NewsDelegate.qml b/examples/quick/demos/rssnews/content/NewsDelegate.qml
new file mode 100644
index 0000000000..fe481a0eb0
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/NewsDelegate.qml
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+ height: column.height + 40
+ width: delegate.ListView.view.width
+
+ Column {
+ id: column
+ x: 20; y: 20
+ width: parent.width - 40
+
+ Text {
+ id: titleText
+ text: title; width: parent.width; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pointSize: 16 }
+ }
+
+ Text {
+ id: descriptionText
+ width: parent.width; text: description
+ wrapMode: Text.WordWrap; font.family: "Helvetica"
+ }
+ }
+
+ Rectangle {
+ width: parent.width; height: 1; color: "#cccccc"
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/examples/quick/demos/rssnews/content/RssFeeds.qml b/examples/quick/demos/rssnews/content/RssFeeds.qml
new file mode 100644
index 0000000000..9a31d2be3e
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/RssFeeds.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id: rssFeeds
+
+ ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" }
+ ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
+ ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" }
+ ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
+ ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
+ ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" }
+ ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" }
+ ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" }
+ ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" }
+ ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" }
+ ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" }
+ ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" }
+}
diff --git a/examples/quick/demos/rssnews/content/ScrollBar.qml b/examples/quick/demos/rssnews/content/ScrollBar.qml
new file mode 100644
index 0000000000..2752b7c56d
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/ScrollBar.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2) return ny; else return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else return nh + ny;
+ }
+
+ Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
+
+ BorderImage {
+ source: "images/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ }
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
diff --git a/examples/quick/demos/rssnews/content/images/busy.png b/examples/quick/demos/rssnews/content/images/busy.png
new file mode 100644
index 0000000000..664c2b1491
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/busy.png
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/scrollbar.png b/examples/quick/demos/rssnews/content/images/scrollbar.png
new file mode 100644
index 0000000000..0228dcf9eb
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/scrollbar.png
Binary files differ
diff --git a/examples/quick/demos/rssnews/rssnews.qml b/examples/quick/demos/rssnews/rssnews.qml
new file mode 100644
index 0000000000..72c7170c93
--- /dev/null
+++ b/examples/quick/demos/rssnews/rssnews.qml
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "content"
+
+Rectangle {
+ id: window
+ width: 800; height: 480
+
+ property string currentFeed: "rss.news.yahoo.com/rss/topstories"
+ property bool loading: feedModel.status == XmlListModel.Loading
+
+ RssFeeds { id: rssFeeds }
+
+ XmlListModel {
+ id: feedModel
+ source: "http://" + window.currentFeed
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+ }
+
+ Row {
+ Rectangle {
+ width: 220; height: window.height
+ color: "#efefef"
+
+ ListView {
+ focus: true
+ id: categories
+ anchors.fill: parent
+ model: rssFeeds
+ footer: quitButtonDelegate
+ delegate: CategoryDelegate {}
+ highlight: Rectangle { color: "steelblue" }
+ highlightMoveVelocity: 9999999
+ }
+ ScrollBar {
+ scrollArea: categories; height: categories.height; width: 8
+ anchors.right: categories.right
+ }
+ }
+ ListView {
+ id: list
+ width: window.width - 220; height: window.height
+ model: feedModel
+ delegate: NewsDelegate {}
+ }
+ }
+ Component {
+ id: quitButtonDelegate
+ Item {
+ width: categories.width; height: 60
+ Text {
+ text: "Quit"
+ font { family: "Helvetica"; pixelSize: 16; bold: true }
+ anchors {
+ left: parent.left; leftMargin: 15
+ verticalCenter: parent.verticalCenter
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+ }
+ }
+ }
+ ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
+ Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
+}
diff --git a/examples/quick/demos/rssnews/rssnews.qmlproject b/examples/quick/demos/rssnews/rssnews.qmlproject
new file mode 100644
index 0000000000..5becbdaed0
--- /dev/null
+++ b/examples/quick/demos/rssnews/rssnews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "rssnews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/demos/samegame/content/Block.qml b/examples/quick/demos/samegame/content/Block.qml
new file mode 100644
index 0000000000..85f2e27d2a
--- /dev/null
+++ b/examples/quick/demos/samegame/content/Block.qml
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red.png";
+ } else if (type == 1) {
+ "gfx/blue.png";
+ } else if (type == 2) {
+ "gfx/green.png";
+ } else {
+ "gfx/yellow.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ //Paint particles on the background
+ PaintEmitter {
+ id: particles2
+ system: particleSystem
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/quick/demos/samegame/content/BlockEmitter.qml b/examples/quick/demos/samegame/content/BlockEmitter.qml
new file mode 100644
index 0000000000..7dad509dfd
--- /dev/null
+++ b/examples/quick/demos/samegame/content/BlockEmitter.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+import "../settings.js" as Settings
+
+Emitter {
+ property Item block: parent
+ velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40}
+ acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;}
+ shape: EllipseShape{fill:true}
+ enabled: false;
+ lifeSpan: 700; lifeSpanVariation: 100
+ emitRate: 1000
+ maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number)
+ size: Settings.blockSize * 0.85
+ endSize: Settings.blockSize * 0.85 /2
+}
diff --git a/examples/quick/demos/samegame/content/Button.qml b/examples/quick/demos/samegame/content/Button.qml
new file mode 100644
index 0000000000..aab21ec8c6
--- /dev/null
+++ b/examples/quick/demos/samegame/content/Button.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ property alias imgSrc: image.source
+ property alias system: emitter.system
+ property alias group: emitter.group
+ signal clicked
+ property bool rotatedButton: false
+
+ width: image.width
+ height: image.sourceSize.height
+ Image {
+ id: image
+ height: parent.height
+ width: height/sourceSize.height * sourceSize.width
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
+ MenuEmitter {
+ id: emitter
+ anchors.fill: parent
+ //shape: MaskShape {source: image.source}
+ }
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {parent.clicked(); emitter.burst(400);}
+ }
+}
diff --git a/examples/quick/demos/samegame/content/GameArea.qml b/examples/quick/demos/samegame/content/GameArea.qml
new file mode 100644
index 0000000000..f3ca98d80e
--- /dev/null
+++ b/examples/quick/demos/samegame/content/GameArea.qml
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "samegame.js" as Logic
+
+Item {
+ id: gameCanvas
+ property bool gameOver: true
+ property int score: 0
+ property int highScore: 0
+ property int moves: 0
+ property string mode: ""
+ property ParticleSystem ps: particleSystem
+ //For easy theming
+ property alias backgroundVisible: bg.visible
+ property string background: "gfx/background.png"
+ property string blockFile: "Block.qml"
+ onBlockFileChanged: Logic.changeBlock(blockFile);
+ property alias particlePack: auxLoader.source
+ //For multiplayer
+ property int score2: 0
+ property int curTurn: 1
+ property bool autoTurnChange: false
+ signal swapPlayers
+ property bool swapping: false
+ //onSwapPlayers: if (autoTurnChange) Logic.turnChange();//Now implemented below
+ //For puzzle
+ property url level
+ property bool puzzleWon: false
+ signal puzzleLost //Since root is tracking the puzzle progress
+ function showPuzzleEnd (won) {
+ if (won) {
+ smokeParticle.color = Qt.rgba(0,1,0,0);
+ puzzleWin.play();
+ } else {
+ smokeParticle.color = Qt.rgba(1,0,0,0);
+ puzzleFail.play();
+ puzzleLost();
+ }
+ }
+ function showPuzzleGoal (str) {
+ puzzleTextBubble.opacity = 1;
+ puzzleTextLabel.text = str;
+ }
+ Image {
+ id: bg
+ z: -1
+ anchors.fill: parent
+ source: background;
+ fillMode: Image.PreserveAspectCrop
+ }
+
+ MouseArea {
+ anchors.fill: parent; onClicked: {
+ if (puzzleTextBubble.opacity == 1) {
+ puzzleTextBubble.opacity = 0;
+ Logic.finishLoadingMap();
+ } else if (!swapping) {
+ Logic.handleClick(mouse.x,mouse.y);
+ }
+ }
+ }
+
+ Image {
+ id: highScoreTextBubble
+ opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
+ Behavior on opacity { NumberAnimation {} }
+ anchors.centerIn: parent
+ z: 10
+ source: "gfx/bubble-highscore.png"
+ Image {
+ anchors.centerIn: parent
+ source: "gfx/text-highscore-new.png"
+ rotation: -10
+ }
+ }
+
+ Image {
+ id: puzzleTextBubble
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ source: "gfx/bubble-puzzle.png"
+ Connections {
+ target: gameCanvas
+ onModeChanged: if (mode != "puzzle" && puzzleTextBubble.opacity > 0) puzzleTextBubble.opacity = 0;
+ }
+ Text {
+ id: puzzleTextLabel
+ width: parent.width - 24
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignHCenter
+ color: "white"
+ font.pixelSize: 24
+ font.bold: true
+ wrapMode: Text.WordWrap
+ }
+ }
+ onModeChanged: {
+ p1WonImg.opacity = 0;
+ p2WonImg.opacity = 0;
+ }
+ SmokeText { id: puzzleWin; source: "gfx/icon-ok.png"; system: particleSystem }
+ SmokeText { id: puzzleFail; source: "gfx/icon-fail.png"; system: particleSystem }
+
+ onSwapPlayers: {
+ smokeParticle.color = "yellow"
+ Logic.turnChange();
+ if (curTurn == 1) {
+ p1Text.play();
+ } else {
+ p2Text.play();
+ }
+ clickDelay.running = true;
+ }
+ SequentialAnimation {
+ id: clickDelay
+ ScriptAction { script: gameCanvas.swapping = true; }
+ PauseAnimation { duration: 750 }
+ ScriptAction { script: gameCanvas.swapping = false; }
+ }
+
+ SmokeText {
+ id: p1Text; source: "gfx/text-p1-go.png";
+ system: particleSystem; playerNum: 1
+ opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+ }
+
+ SmokeText {
+ id: p2Text; source: "gfx/text-p2-go.png";
+ system: particleSystem; playerNum: 2
+ opacity: p1WonImg.opacity + p2WonImg.opacity > 0 ? 0 : 1
+ }
+
+ onGameOverChanged: {
+ if (gameCanvas.mode == "multiplayer") {
+ if (gameCanvas.score >= gameCanvas.score2) {
+ p1WonImg.opacity = 1;
+ } else {
+ p2WonImg.opacity = 1;
+ }
+ }
+ }
+ Image {
+ id: p1WonImg
+ source: "gfx/text-p1-won.png"
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ }
+ Image {
+ id: p2WonImg
+ source: "gfx/text-p2-won.png"
+ anchors.centerIn: parent
+ opacity: 0
+ Behavior on opacity { NumberAnimation {} }
+ z: 10
+ }
+
+ ParticleSystem{
+ id: particleSystem;
+ anchors.fill: parent
+ z: 5
+ ImageParticle {
+ id: smokeParticle
+ groups: ["smoke"]
+ source: "gfx/particle-smoke.png"
+ alpha: 0.1
+ alphaVariation: 0.1
+ color: "yellow"
+ }
+ Loader {
+ id: auxLoader
+ anchors.fill: parent
+ source: "PrimaryPack.qml"
+ onItemChanged: {
+ if (item && "particleSystem" in item)
+ item.particleSystem = particleSystem
+ if (item && "gameArea" in item)
+ item.gameArea = gameCanvas
+ }
+ }
+ }
+}
+
diff --git a/examples/quick/demos/samegame/content/LogoAnimation.qml b/examples/quick/demos/samegame/content/LogoAnimation.qml
new file mode 100644
index 0000000000..c879893e92
--- /dev/null
+++ b/examples/quick/demos/samegame/content/LogoAnimation.qml
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container //Positioned where the 48x48 S/G should be
+ property alias running: mainAnim.running
+ property ParticleSystem particleSystem
+ property int dur: 500
+ signal boomTime
+ Image {
+ id: s1
+ source: "gfx/logo-s.png"
+ y: 0
+ }
+ Image {
+ id: g1
+ source: "gfx/logo-g.png"
+ y: -128
+ }
+ Column {
+ Repeater {
+ model: 2
+ Item {
+ width: 48
+ height: 48
+ BlockEmitter {
+ id: emitter
+ anchors.fill: parent
+ group: "red"
+ system: particleSystem
+ Connections {
+ target: container
+ onBoomTime: emitter.pulse(100);
+ }
+ }
+ }
+ }
+ }
+ SequentialAnimation {
+ id: mainAnim
+ running: true
+ loops: -1
+ PropertyAction { target: g1; property: "y"; value: -128}
+ PropertyAction { target: g1; property: "opacity"; value: 1}
+ PropertyAction { target: s1; property: "y"; value: 0}
+ PropertyAction { target: s1; property: "opacity"; value: 1}
+ NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur}
+ ParallelAnimation {
+ NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur}
+ NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur }
+ }
+ PauseAnimation { duration: dur }
+ ScriptAction { script: container.boomTime(); }
+ ParallelAnimation {
+ NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur }
+ NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur }
+ }
+ PropertyAction { target: s1; property: "y"; value: -128}
+ PropertyAction { target: s1; property: "opacity"; value: 1}
+ NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2}
+ }
+}
diff --git a/examples/quick/demos/samegame/content/MenuEmitter.qml b/examples/quick/demos/samegame/content/MenuEmitter.qml
new file mode 100644
index 0000000000..16c766068c
--- /dev/null
+++ b/examples/quick/demos/samegame/content/MenuEmitter.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Emitter {
+ anchors.fill: parent
+ velocity: AngleDirection{angleVariation: 360; magnitude: 140; magnitudeVariation: 40}
+ enabled: false;
+ lifeSpan: 500;
+ emitRate: 1
+ size: 28
+ endSize: 14
+ group: "yellow"
+}
diff --git a/examples/quick/demos/samegame/content/PaintEmitter.qml b/examples/quick/demos/samegame/content/PaintEmitter.qml
new file mode 100644
index 0000000000..4a67c4a2d2
--- /dev/null
+++ b/examples/quick/demos/samegame/content/PaintEmitter.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "../settings.js" as Settings
+
+Emitter {
+ property Item block: parent
+ anchors.fill: parent
+ shape: EllipseShape { fill: true }
+ group: {
+ if (block.type == 0){
+ "redspots";
+ } else if (block.type == 1) {
+ "bluespots";
+ } else if (block.type == 2) {
+ "greenspots";
+ } else {
+ "yellowspots";
+ }
+ }
+ size: Settings.blockSize * 2
+ endSize: Settings.blockSize/2
+ lifeSpan: 30000
+ enabled: false
+ emitRate: 60
+ maximumEmitted: 60
+ velocity: PointDirection{ y: 4; yVariation: 4 }
+ /* Possibly better, but dependent on gerrit change,28212
+ property real mainIntensity: 0.8
+ property real subIntensity: 0.1
+ property real colorVariation: 0.005
+ onEmitParticles: {//One group, many colors, for better stacking
+ for (var i=0; i<particles.length; i++) {
+ var particle = particles[i];
+ if (block.type == 0) {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 1) {
+ particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 2) {
+ particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else if (block.type == 3) {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ } else {
+ particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
+ }
+ }
+ }
+ */
+}
diff --git a/examples/quick/demos/samegame/content/PrimaryPack.qml b/examples/quick/demos/samegame/content/PrimaryPack.qml
new file mode 100644
index 0000000000..278ed0eae1
--- /dev/null
+++ b/examples/quick/demos/samegame/content/PrimaryPack.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: container
+ property ParticleSystem particleSystem
+ property GameArea gameArea
+ onGameAreaChanged: bgstacker.parent = gameArea;//Move to direct child of game canvas
+ Item {
+ id: bgstacker
+ z: 0
+ ImageParticle {
+ groups: ["yellowspots"]
+ color: Qt.darker("yellow");//Actually want desaturated...
+ system: particleSystem
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["redspots"]
+ system: particleSystem
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["greenspots"]
+ system: particleSystem
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ ImageParticle {
+ groups: ["bluespots"]
+ system: particleSystem
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "gfx/particle-paint.png"
+ colorVariation: 0.2
+ alpha: 0.2
+ entryEffect: ImageParticle.None
+ }
+ }
+ ImageParticle {
+ groups: ["yellow"]
+ system: particleSystem
+ color: Qt.darker("yellow");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["red"]
+ system: particleSystem
+ color: Qt.darker("red");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["green"]
+ system: particleSystem
+ color: Qt.darker("green");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+ ImageParticle {
+ groups: ["blue"]
+ system: particleSystem
+ color: Qt.darker("blue");//Actually want desaturated...
+ source: "gfx/particle-brick.png"
+ colorVariation: 0.4
+ alpha: 0.1
+ }
+}
diff --git a/examples/quick/demos/samegame/content/PuzzleBlock.qml b/examples/quick/demos/samegame/content/PuzzleBlock.qml
new file mode 100644
index 0000000000..8a0e725b16
--- /dev/null
+++ b/examples/quick/demos/samegame/content/PuzzleBlock.qml
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ NumberAnimation{ easing.type: Easing.OutBounce }
+ }
+ Behavior on y {
+ NumberAnimation{ easing.type: Easing.InQuad }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red-puzzle.png";
+ } else if (type == 1) {
+ "gfx/blue-puzzle.png";
+ } else if (type == 2) {
+ "gfx/green-puzzle.png";
+ } else {
+ "gfx/yellow-puzzle.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -4
+ anchors.horizontalCenterOffset: 4
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ PropertyChanges { target: img; scale: 2 }
+ StateChangeScript { script: particles.pulse(200); }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/quick/demos/samegame/content/SamegameText.qml b/examples/quick/demos/samegame/content/SamegameText.qml
new file mode 100644
index 0000000000..28c85f9486
--- /dev/null
+++ b/examples/quick/demos/samegame/content/SamegameText.qml
@@ -0,0 +1,49 @@
+/***************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../settings.js" as Settings
+
+Text {
+ font.pixelSize: Settings.fontPixelSize;
+ color: "white";
+ textFormat: Text.StyledText;
+ Behavior on opacity { NumberAnimation {} }
+}
diff --git a/examples/quick/demos/samegame/content/SimpleBlock.qml b/examples/quick/demos/samegame/content/SimpleBlock.qml
new file mode 100644
index 0000000000..22a1fa3225
--- /dev/null
+++ b/examples/quick/demos/samegame/content/SimpleBlock.qml
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ id: block
+ property bool dying: false
+ property bool spawned: false
+ property int type: 0
+ property ParticleSystem particleSystem
+
+ Behavior on x {
+ enabled: spawned;
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+ Behavior on y {
+ SpringAnimation{ spring: 2; damping: 0.2 }
+ }
+
+ Image {
+ id: img
+ source: {
+ if (type == 0){
+ "gfx/red.png";
+ } else if (type == 1) {
+ "gfx/blue.png";
+ } else if (type == 2) {
+ "gfx/green.png";
+ } else {
+ "gfx/yellow.png";
+ }
+ }
+ opacity: 0
+ Behavior on opacity { NumberAnimation { duration: 200 } }
+ anchors.fill: parent
+ }
+
+ //Foreground particles
+ BlockEmitter {
+ id: particles
+ system: particleSystem
+ group: {
+ if (type == 0){
+ "red";
+ } else if (type == 1) {
+ "blue";
+ } else if (type == 2) {
+ "green";
+ } else {
+ "yellow";
+ }
+ }
+ anchors.fill: parent
+ }
+
+ states: [
+ State {
+ name: "AliveState"; when: spawned == true && dying == false
+ PropertyChanges { target: img; opacity: 1 }
+ },
+
+ State {
+ name: "DeathState"; when: dying == true
+ StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); } }
+ PropertyChanges { target: img; opacity: 0 }
+ StateChangeScript { script: block.destroy(1000); }
+ }
+ ]
+}
diff --git a/examples/quick/demos/samegame/content/SmokeText.qml b/examples/quick/demos/samegame/content/SmokeText.qml
new file mode 100644
index 0000000000..73d9ae42da
--- /dev/null
+++ b/examples/quick/demos/samegame/content/SmokeText.qml
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+
+Item {
+ z: 10
+ property alias source: img.source
+ property alias system: emitter.system
+ property int playerNum: 1
+ function play() {
+ anim.running = true;
+ }
+ anchors.centerIn: parent
+ Image {
+ opacity: 0
+ id: img
+ anchors.centerIn: parent
+ rotation: playerNum == 1 ? -8 : -5
+ Emitter {
+ id: emitter
+ group: "smoke"
+ anchors.fill: parent
+ shape: MaskShape { source: img.source }
+ enabled: false
+ emitRate: 1000
+ lifeSpan: 600
+ size: 64
+ endSize: 32
+ velocity: AngleDirection { angleVariation: 360; magnitudeVariation: 160 }
+ }
+ }
+ SequentialAnimation {
+ id: anim
+ running: false
+ PauseAnimation { duration: 500}
+ ParallelAnimation {
+ NumberAnimation { target: img; property: "opacity"; from: 0.1; to: 1.0 }
+ NumberAnimation { target: img; property: "scale"; from: 0.1; to: 1.0 }
+ }
+ PauseAnimation { duration: 250}
+ ScriptAction { script: emitter.pulse(100); }
+ NumberAnimation { target: img; property: "opacity"; from: 1.0; to: 0.0 }
+ }
+}
diff --git a/examples/quick/demos/samegame/content/gfx/background-puzzle.png b/examples/quick/demos/samegame/content/gfx/background-puzzle.png
new file mode 100644
index 0000000000..c2eca5f5dc
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/background-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/background.png b/examples/quick/demos/samegame/content/gfx/background.png
new file mode 100644
index 0000000000..60f57b650f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/background.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bar.png b/examples/quick/demos/samegame/content/gfx/bar.png
new file mode 100644
index 0000000000..4953cd6221
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/bar.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/blue-puzzle.png b/examples/quick/demos/samegame/content/gfx/blue-puzzle.png
new file mode 100644
index 0000000000..e550d5935b
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/blue-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/blue.png b/examples/quick/demos/samegame/content/gfx/blue.png
new file mode 100644
index 0000000000..b8161c0f70
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/blue.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bubble-highscore.png b/examples/quick/demos/samegame/content/gfx/bubble-highscore.png
new file mode 100644
index 0000000000..c4e38df824
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/bubble-highscore.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png b/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png
new file mode 100644
index 0000000000..278556bc8d
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/bubble-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-1.png b/examples/quick/demos/samegame/content/gfx/but-game-1.png
new file mode 100644
index 0000000000..3343b7ff13
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-game-1.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-2.png b/examples/quick/demos/samegame/content/gfx/but-game-2.png
new file mode 100644
index 0000000000..afba106962
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-game-2.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-3.png b/examples/quick/demos/samegame/content/gfx/but-game-3.png
new file mode 100644
index 0000000000..adea77a687
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-game-3.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-4.png b/examples/quick/demos/samegame/content/gfx/but-game-4.png
new file mode 100644
index 0000000000..18c922ba45
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-game-4.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-game-new.png b/examples/quick/demos/samegame/content/gfx/but-game-new.png
new file mode 100644
index 0000000000..257e182585
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-game-new.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-menu.png b/examples/quick/demos/samegame/content/gfx/but-menu.png
new file mode 100644
index 0000000000..8440e87759
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-menu.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png b/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png
new file mode 100644
index 0000000000..7e3ed417d0
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-puzzle-next.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/but-quit.png b/examples/quick/demos/samegame/content/gfx/but-quit.png
new file mode 100644
index 0000000000..95c77ced94
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/but-quit.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/green-puzzle.png b/examples/quick/demos/samegame/content/gfx/green-puzzle.png
new file mode 100644
index 0000000000..581f76fd8d
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/green-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/green.png b/examples/quick/demos/samegame/content/gfx/green.png
new file mode 100644
index 0000000000..da4cca5e7f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/green.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-fail.png b/examples/quick/demos/samegame/content/gfx/icon-fail.png
new file mode 100644
index 0000000000..40726118a9
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/icon-fail.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-ok.png b/examples/quick/demos/samegame/content/gfx/icon-ok.png
new file mode 100644
index 0000000000..15a8442e94
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/icon-ok.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/icon-time.png b/examples/quick/demos/samegame/content/gfx/icon-time.png
new file mode 100644
index 0000000000..9490e49e90
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/icon-time.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-a.png b/examples/quick/demos/samegame/content/gfx/logo-a.png
new file mode 100644
index 0000000000..20c20ba480
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo-a.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-e.png b/examples/quick/demos/samegame/content/gfx/logo-e.png
new file mode 100644
index 0000000000..dd663f114a
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo-e.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-g.png b/examples/quick/demos/samegame/content/gfx/logo-g.png
new file mode 100644
index 0000000000..a319bf9ffa
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo-g.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-m.png b/examples/quick/demos/samegame/content/gfx/logo-m.png
new file mode 100644
index 0000000000..6a029b3267
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo-m.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo-s.png b/examples/quick/demos/samegame/content/gfx/logo-s.png
new file mode 100644
index 0000000000..963b17546a
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo-s.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/logo.png b/examples/quick/demos/samegame/content/gfx/logo.png
new file mode 100644
index 0000000000..e900eddb2f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/logo.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-brick.png b/examples/quick/demos/samegame/content/gfx/particle-brick.png
new file mode 100644
index 0000000000..5c83896d22
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/particle-brick.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-paint.png b/examples/quick/demos/samegame/content/gfx/particle-paint.png
new file mode 100644
index 0000000000..9bd0a2a13f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/particle-paint.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/particle-smoke.png b/examples/quick/demos/samegame/content/gfx/particle-smoke.png
new file mode 100644
index 0000000000..b27f954a79
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/particle-smoke.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/red-puzzle.png b/examples/quick/demos/samegame/content/gfx/red-puzzle.png
new file mode 100644
index 0000000000..9ceb17e4d0
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/red-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/red.png b/examples/quick/demos/samegame/content/gfx/red.png
new file mode 100644
index 0000000000..681810fe3b
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/red.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-highscore-new.png b/examples/quick/demos/samegame/content/gfx/text-highscore-new.png
new file mode 100644
index 0000000000..50f7fcd0f6
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-highscore-new.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-highscore.png b/examples/quick/demos/samegame/content/gfx/text-highscore.png
new file mode 100644
index 0000000000..7198c277b8
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-highscore.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-no-winner.png b/examples/quick/demos/samegame/content/gfx/text-no-winner.png
new file mode 100644
index 0000000000..b4a6685111
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-no-winner.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1-go.png b/examples/quick/demos/samegame/content/gfx/text-p1-go.png
new file mode 100644
index 0000000000..c7bd2a5e75
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p1-go.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1-won.png b/examples/quick/demos/samegame/content/gfx/text-p1-won.png
new file mode 100644
index 0000000000..41c2eb7c98
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p1-won.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p1.png b/examples/quick/demos/samegame/content/gfx/text-p1.png
new file mode 100644
index 0000000000..b59c87b977
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p1.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2-go.png b/examples/quick/demos/samegame/content/gfx/text-p2-go.png
new file mode 100644
index 0000000000..f03cd93afa
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p2-go.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2-won.png b/examples/quick/demos/samegame/content/gfx/text-p2-won.png
new file mode 100644
index 0000000000..116b7f2e7a
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p2-won.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/text-p2.png b/examples/quick/demos/samegame/content/gfx/text-p2.png
new file mode 100644
index 0000000000..d4f2bc7335
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/text-p2.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png b/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png
new file mode 100644
index 0000000000..66044c81b4
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/yellow-puzzle.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/gfx/yellow.png b/examples/quick/demos/samegame/content/gfx/yellow.png
new file mode 100644
index 0000000000..6bc5d385e3
--- /dev/null
+++ b/examples/quick/demos/samegame/content/gfx/yellow.png
Binary files differ
diff --git a/examples/quick/demos/samegame/content/levels/TemplateBase.qml b/examples/quick/demos/samegame/content/levels/TemplateBase.qml
new file mode 100644
index 0000000000..f0832d447f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/TemplateBase.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle{
+ id: control
+ property int scoreTarget: -1
+ property int timeTarget: -1
+ property int moveTarget: -1
+ property bool mustClear: true
+ property string goalText: "Clear the level..."
+
+ property var startingGrid //If this isn't an array of ints, we will refuse to load the level.
+ /* Ints are 0-4. If not enough ints are there it will be prepadded with 0s to fill the grid
+ (which ruins everything if you have the wrong number of rows).
+ 0 - No block
+ 1 - Red
+ 2 - Blue
+ 3 - Green
+ 4 - Yellow
+ Ideas for future colors, but not supported in this version:
+ 5 - Purple
+ 6 - Cyan
+ 7 - Gray
+ 8 - Black
+ 9 - White
+ */
+
+ width: 320
+ height: 416
+ color: "white" //TODO: Theme support for both setting themes per level, and seeing it in the control!
+}
diff --git a/examples/quick/demos/samegame/content/levels/level0.qml b/examples/quick/demos/samegame/content/levels/level0.qml
new file mode 100644
index 0000000000..5d2fa4faf5
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level0.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 3
+ goalText: "1 of 10<br><br>Clear in three moves..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 ,
+ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 2 , 1 , 1 ,
+ 0 , 0 , 0 , 1 , 1 , 3 , 3 , 3 , 3 , 3 ,
+ 0 , 1 , 1 , 3 , 3 , 3 , 1 , 3 , 1 , 1 ,
+ 1 , 2 , 3 , 3 , 1 , 1 , 3 , 3 , 3 , 3 ,
+ 1 , 3 , 3 , 2 , 3 , 3 , 3 , 3 , 1 , 1 ,
+ 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level1.qml b/examples/quick/demos/samegame/content/levels/level1.qml
new file mode 100644
index 0000000000..4bb15cbe6a
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level1.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ timeTarget: 10
+ goalText: "2 of 10<br><br>Clear in 10 seconds..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 1 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 2 ,
+ 1 , 2 , 3 , 3 , 3 , 1 , 1 , 1 , 1 , 2 ,
+ 2 , 2 , 1 , 3 , 3 , 3 , 1 , 1 , 1 , 2 ,
+ 2 , 1 , 1 , 1 , 3 , 3 , 3 , 1 , 2 , 2 ,
+ 1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 2 , 1 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level2.qml b/examples/quick/demos/samegame/content/levels/level2.qml
new file mode 100644
index 0000000000..a319479a60
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level2.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 1200
+ timeTarget: 60
+ goalText: "3 of 10<br><br>Score over 1200 points in one minute..."
+ mustClear: false
+ startingGrid: [ 3 , 1 , 2 , 1 , 1 , 2 , 1 , 1 , 3 , 3 ,
+ 1 , 3 , 3 , 2 , 3 , 3 , 1 , 1 , 3 , 1 ,
+ 3 , 1 , 3 , 3 , 2 , 3 , 3 , 3 , 1 , 2 ,
+ 3 , 2 , 2 , 1 , 3 , 3 , 2 , 1 , 1 , 2 ,
+ 3 , 1 , 2 , 2 , 2 , 2 , 2 , 1 , 3 , 1 ,
+ 2 , 3 , 1 , 2 , 2 , 3 , 3 , 1 , 3 , 2 ,
+ 3 , 2 , 1 , 1 , 3 , 3 , 3 , 2 , 2 , 1 ,
+ 1 , 2 , 2 , 3 , 2 , 3 , 3 , 3 , 1 , 1 ,
+ 1 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 1 ,
+ 3 , 3 , 2 , 1 , 2 , 2 , 1 , 1 , 1 , 3 ,
+ 2 , 1 , 3 , 2 , 3 , 2 , 3 , 2 , 2 , 1 ,
+ 1 , 3 , 1 , 2 , 1 , 2 , 3 , 1 , 2 , 2 ,
+ 1 , 2 , 2 , 2 , 1 , 1 , 2 , 3 , 1 , 2 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level3.qml b/examples/quick/demos/samegame/content/levels/level3.qml
new file mode 100644
index 0000000000..43e82d7694
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level3.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 3000
+ timeTarget: 60
+ goalText: "4 of 10<br>Clear the board with over 3000 points in under a minute..."
+ startingGrid: [ 3 , 3 , 1 , 1 , 1 , 2 , 2 , 4 , 3 , 3 ,
+ 4 , 3 , 1 , 4 , 2 , 2 , 2 , 4 , 3 , 4 ,
+ 4 , 3 , 3 , 4 , 1 , 1 , 3 , 3 , 4 , 4 ,
+ 3 , 3 , 3 , 3 , 3 , 1 , 3 , 2 , 2 , 4 ,
+ 4 , 4 , 3 , 4 , 3 , 1 , 4 , 4 , 4 , 4 ,
+ 4 , 4 , 3 , 4 , 1 , 1 , 4 , 4 , 3 , 3 ,
+ 4 , 2 , 2 , 2 , 2 , 2 , 4 , 4 , 4 , 1 ,
+ 4 , 4 , 2 , 4 , 2 , 2 , 1 , 1 , 1 , 1 ,
+ 4 , 4 , 2 , 4 , 2 , 2 , 1 , 4 , 4 , 1 ,
+ 4 , 1 , 1 , 4 , 3 , 3 , 4 , 2 , 4 , 1 ,
+ 4 , 1 , 1 , 2 , 3 , 3 , 4 , 2 , 2 , 1 ,
+ 1 , 1 , 2 , 2 , 2 , 3 , 3 , 3 , 2 , 1 ,
+ 4 , 1 , 1 , 2 , 2 , 3 , 4 , 3 , 4 , 4 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level4.qml b/examples/quick/demos/samegame/content/levels/level4.qml
new file mode 100644
index 0000000000..46ad42f709
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level4.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ goalText: "5 of 10<br><br>Clear the level..."
+ startingGrid: [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
+ 1 , 3 , 2 , 1 , 1 , 1 , 1 , 3 , 2 , 3 ,
+ 1 , 2 , 3 , 1 , 3 , 2 , 2 , 1 , 1 , 2 ,
+ 3 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 3 , 3 ,
+ 2 , 1 , 1 , 3 , 2 , 1 , 1 , 2 , 1 , 3 ,
+ 1 , 3 , 3 , 1 , 2 , 1 , 2 , 1 , 3 , 3 ,
+ 1 , 3 , 2 , 2 , 2 , 1 , 1 , 3 , 2 , 3 ,
+ 1 , 1 , 3 , 2 , 3 , 3 , 2 , 1 , 1 , 1 ,
+ 1 , 2 , 2 , 3 , 2 , 2 , 1 , 3 , 1 , 3 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level5.qml b/examples/quick/demos/samegame/content/levels/level5.qml
new file mode 100644
index 0000000000..3716264993
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level5.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 4
+ goalText: "6 of 10<br><br>Clear in four or less moves..."
+ startingGrid: [ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+ 4 , 2 , 4 , 4 , 4 , 3 , 2 , 3 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 3 , 3 , 4 , 4 ,
+ 4 , 4 , 4 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+ 4 , 2 , 2 , 2 , 4 , 3 , 4 , 3 , 4 , 4 ,
+ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 3 , 3 , 3 , 4 , 2 , 4 , 4 , 4 , 3 ,
+ 4 , 3 , 3 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 4 , 4 , 4 , 4 ,
+ 4 , 3 , 4 , 3 , 4 , 2 , 2 , 2 , 4 , 3 ,
+ 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level6.qml b/examples/quick/demos/samegame/content/levels/level6.qml
new file mode 100644
index 0000000000..4547b75a37
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level6.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ moveTarget: 20
+ timeTarget: 40
+ goalText: "7 of 10<br><br>Clear with 20 moves in 40 seconds (or better)."
+ startingGrid: [ 1 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 2 , 2 ,
+ 2 , 1 , 2 , 3 , 3 , 1 , 3 , 1 , 1 , 3 ,
+ 3 , 1 , 1 , 1 , 2 , 2 , 3 , 2 , 3 , 1 ,
+ 1 , 3 , 1 , 1 , 3 , 1 , 1 , 1 , 2 , 3 ,
+ 2 , 1 , 1 , 1 , 3 , 2 , 3 , 3 , 2 , 3 ,
+ 3 , 3 , 3 , 3 , 2 , 2 , 3 , 1 , 3 , 2 ,
+ 2 , 2 , 3 , 2 , 2 , 3 , 2 , 2 , 2 , 2 ,
+ 1 , 2 , 1 , 2 , 1 , 3 , 2 , 3 , 2 , 3 ,
+ 1 , 1 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 2 ,
+ 3 , 3 , 2 , 2 , 2 , 2 , 3 , 1 , 3 , 1 ,
+ 1 , 2 , 3 , 3 , 3 , 1 , 3 , 2 , 1 , 2 ,
+ 1 , 2 , 1 , 1 , 2 , 3 , 1 , 2 , 1 , 3 ,
+ 3 , 1 , 2 , 2 , 1 , 3 , 3 , 1 , 3 , 2 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level7.qml b/examples/quick/demos/samegame/content/levels/level7.qml
new file mode 100644
index 0000000000..5d71d7cb51
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level7.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ goalText: "8 of 10<br><br>Clear the grid."
+ startingGrid: [ 2 , 4 , 3 , 2 , 3 , 2 , 3 , 3 , 4 , 3 ,
+ 2 , 2 , 3 , 3 , 1 , 4 , 3 , 3 , 3 , 2 ,
+ 1 , 4 , 2 , 3 , 4 , 3 , 3 , 1 , 1 , 1 ,
+ 2 , 1 , 2 , 4 , 4 , 2 , 2 , 3 , 2 , 1 ,
+ 3 , 4 , 4 , 1 , 3 , 2 , 4 , 2 , 1 , 1 ,
+ 2 , 2 , 3 , 1 , 2 , 4 , 1 , 2 , 1 , 2 ,
+ 1 , 2 , 3 , 2 , 4 , 4 , 3 , 1 , 1 , 2 ,
+ 4 , 4 , 2 , 1 , 2 , 4 , 2 , 2 , 4 , 3 ,
+ 4 , 2 , 4 , 1 , 3 , 4 , 1 , 4 , 2 , 4 ,
+ 4 , 3 , 4 , 1 , 4 , 3 , 1 , 3 , 1 , 1 ,
+ 3 , 3 , 2 , 3 , 2 , 4 , 1 , 2 , 4 , 4 ,
+ 3 , 4 , 2 , 2 , 4 , 3 , 4 , 1 , 3 , 2 ,
+ 4 , 3 , 3 , 4 , 2 , 4 , 1 , 2 , 3 , 2 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level8.qml b/examples/quick/demos/samegame/content/levels/level8.qml
new file mode 100644
index 0000000000..9dbb8c2d5f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level8.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 1000
+ goalText: "9 of 10<br><br>Score over 1000 points"
+ startingGrid: [ 1 , 4 , 4 , 3 , 2 , 1 , 4 , 2 , 4 , 2 ,
+ 2 , 3 , 4 , 4 , 1 , 1 , 1 , 4 , 4 , 4 ,
+ 1 , 3 , 1 , 2 , 2 , 1 , 2 , 1 , 4 , 2 ,
+ 4 , 3 , 4 , 2 , 1 , 4 , 1 , 2 , 2 , 3 ,
+ 3 , 4 , 2 , 4 , 4 , 3 , 2 , 2 , 2 , 1 ,
+ 4 , 4 , 3 , 2 , 4 , 4 , 2 , 1 , 1 , 1 ,
+ 1 , 2 , 1 , 3 , 4 , 1 , 1 , 3 , 2 , 3 ,
+ 3 , 4 , 2 , 2 , 1 , 3 , 2 , 2 , 4 , 2 ,
+ 2 , 4 , 1 , 2 , 2 , 4 , 3 , 3 , 3 , 1 ,
+ 1 , 2 , 2 , 4 , 1 , 2 , 2 , 3 , 3 , 3 ,
+ 4 , 4 , 1 , 4 , 3 , 1 , 3 , 3 , 3 , 4 ,
+ 1 , 2 , 4 , 1 , 2 , 1 , 1 , 4 , 2 , 1 ,
+ 1 , 2 , 3 , 4 , 2 , 4 , 4 , 2 , 1 , 3 ]
+}
diff --git a/examples/quick/demos/samegame/content/levels/level9.qml b/examples/quick/demos/samegame/content/levels/level9.qml
new file mode 100644
index 0000000000..4e8bf19e26
--- /dev/null
+++ b/examples/quick/demos/samegame/content/levels/level9.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+TemplateBase{
+ scoreTarget: 2000
+ timeTarget: 60
+ moveTarget: 20
+ mustClear: false
+ goalText: "10 of 10<br><br>Score 2000 in one minute with less than 20 moves!"
+ startingGrid: [ 3 , 2 , 3 , 1 , 3 , 3 , 4 , 1 , 3 , 3 ,
+ 2 , 3 , 2 , 1 , 1 , 2 , 2 , 2 , 4 , 1 ,
+ 2 , 4 , 4 , 4 , 3 , 1 , 4 , 4 , 4 , 1 ,
+ 3 , 1 , 3 , 4 , 4 , 2 , 2 , 2 , 2 , 3 ,
+ 2 , 1 , 4 , 4 , 3 , 3 , 1 , 1 , 3 , 2 ,
+ 3 , 2 , 1 , 4 , 3 , 4 , 1 , 3 , 4 , 2 ,
+ 3 , 3 , 1 , 4 , 4 , 4 , 2 , 1 , 2 , 3 ,
+ 2 , 3 , 4 , 3 , 4 , 1 , 1 , 3 , 2 , 4 ,
+ 4 , 4 , 1 , 2 , 4 , 3 , 2 , 2 , 2 , 4 ,
+ 1 , 4 , 2 , 2 , 1 , 1 , 2 , 1 , 1 , 4 ,
+ 1 , 4 , 3 , 3 , 3 , 1 , 3 , 4 , 4 , 2 ,
+ 3 , 4 , 1 , 1 , 2 , 2 , 2 , 3 , 2 , 1 ,
+ 3 , 3 , 4 , 3 , 1 , 1 , 1 , 4 , 4 , 3 ]
+}
diff --git a/examples/quick/demos/samegame/content/samegame.js b/examples/quick/demos/samegame/content/samegame.js
new file mode 100755
index 0000000000..7b226cb42f
--- /dev/null
+++ b/examples/quick/demos/samegame/content/samegame.js
@@ -0,0 +1,581 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/* This script file handles the game logic */
+.pragma library
+.import QtQuick.LocalStorage 2.0 as Sql
+.import "../settings.js" as Settings
+
+var maxColumn = 10;
+var maxRow = 13;
+var types = 3;
+var maxIndex = maxColumn*maxRow;
+var board = new Array(maxIndex);
+var blockSrc = "Block.qml";
+var gameDuration;
+var component = Qt.createComponent(blockSrc);
+var gameCanvas;
+var betweenTurns = false;
+
+var puzzleLevel = null;
+var puzzlePath = "";
+
+var gameMode = "arcade"; //Set in new game, then tweaks behaviour of other functions
+var gameOver = false;
+
+function changeBlock(src)
+{
+ blockSrc = src;
+ component = Qt.createComponent(blockSrc);
+}
+
+// Index function used instead of a 2D array
+function index(column, row)
+{
+ return column + row * maxColumn;
+}
+
+function timeStr(msecs)
+{
+ var secs = Math.floor(msecs/1000);
+ var m = Math.floor(secs/60);
+ var ret = "" + m + "m " + (secs%60) + "s";
+ return ret;
+}
+
+function cleanUp()
+{
+ if (gameCanvas == undefined)
+ return;
+ // Delete blocks from previous game
+ for (var i = 0; i < maxIndex; i++) {
+ if (board[i] != null)
+ board[i].destroy();
+ board[i] = null;
+ }
+ if (puzzleLevel != null){
+ puzzleLevel.destroy();
+ puzzleLevel = null;
+ }
+ gameCanvas.mode = ""
+}
+
+function startNewGame(gc, mode, map)
+{
+ gameCanvas = gc;
+ if (mode == undefined)
+ gameMode = "arcade";
+ else
+ gameMode = mode;
+ gameOver = false;
+
+ cleanUp();
+
+ gc.gameOver = false;
+ gc.mode = gameMode;
+ // Calculate board size
+ maxColumn = Math.floor(gameCanvas.width/Settings.blockSize);
+ maxRow = Math.floor(gameCanvas.height/Settings.blockSize);
+ maxIndex = maxRow * maxColumn;
+ if (gameMode == "arcade") //Needs to be after board sizing
+ getHighScore();
+
+
+ // Initialize Board
+ board = new Array(maxIndex);
+ gameCanvas.score = 0;
+ gameCanvas.score2 = 0;
+ gameCanvas.moves = 0;
+ gameCanvas.curTurn = 1;
+ if (gameMode == "puzzle")
+ loadMap(map);
+ else//Note that we load them in reverse order for correct visual stacking
+ for (var column = maxColumn - 1; column >= 0; column--)
+ for (var row = maxRow - 1; row >= 0; row--)
+ createBlock(column, row);
+ if (gameMode == "puzzle")
+ getLevelHistory();//Needs to be after map load
+ gameDuration = new Date();
+}
+
+var fillFound; // Set after a floodFill call to the number of blocks found
+var floodBoard; // Set to 1 if the floodFill reaches off that node
+
+// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+function handleClick(x,y)
+{
+ if (betweenTurns || gameOver || gameCanvas == undefined)
+ return;
+ var column = Math.floor(x/Settings.blockSize);
+ var row = Math.floor(y/Settings.blockSize);
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (board[index(column, row)] == null)
+ return;
+ // If it's a valid block, remove it and all connected (does nothing if it's not connected)
+ floodFill(column,row, -1);
+ if (fillFound <= 0)
+ return;
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ gameCanvas.score2 += (fillFound - 1) * (fillFound - 1);
+ else
+ gameCanvas.score += (fillFound - 1) * (fillFound - 1);
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ shuffleUp();
+ else
+ shuffleDown();
+ gameCanvas.moves += 1;
+ if (gameMode == "endless")
+ refill();
+ else if (gameMode != "multiplayer")
+ victoryCheck();
+ if (gameMode == "multiplayer" && !gc.gameOver){
+ betweenTurns = true;
+ gameCanvas.swapPlayers();//signal, animate and call turnChange() when ready
+ }
+}
+
+function floodFill(column,row,type)
+{
+ if (board[index(column, row)] == null)
+ return;
+ var first = false;
+ if (type == -1) {
+ first = true;
+ type = board[index(column,row)].type;
+
+ // Flood fill initialization
+ fillFound = 0;
+ floodBoard = new Array(maxIndex);
+ }
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return;
+ if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
+ return;
+ floodBoard[index(column, row)] = 1;
+ floodFill(column + 1, row, type);
+ floodFill(column - 1, row, type);
+ floodFill(column, row + 1, type);
+ floodFill(column, row - 1, type);
+ if (first == true && fillFound == 0)
+ return; // Can't remove single blocks
+ board[index(column, row)].dying = true;
+ board[index(column, row)] = null;
+ fillFound += 1;
+}
+
+function shuffleDown()
+{
+ // Fall down
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = maxRow - 1; row >= 0; row--) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row + fallDist) * Settings.blockSize;
+ board[index(column, row + fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, maxRow - 1)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * Settings.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+
+function shuffleUp()
+{
+ // Fall up
+ for (var column = 0; column < maxColumn; column++) {
+ var fallDist = 0;
+ for (var row = 0; row < maxRow; row++) {
+ if (board[index(column,row)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ var obj = board[index(column, row)];
+ obj.y = (row - fallDist) * Settings.blockSize;
+ board[index(column, row - fallDist)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+ // Fall to the left (or should it be right, so as to be left for P2?)
+ fallDist = 0;
+ for (column = 0; column < maxColumn; column++) {
+ if (board[index(column, 0)] == null) {
+ fallDist += 1;
+ } else {
+ if (fallDist > 0) {
+ for (row = 0; row < maxRow; row++) {
+ obj = board[index(column, row)];
+ if (obj == null)
+ continue;
+ obj.x = (column - fallDist) * Settings.blockSize;
+ board[index(column - fallDist,row)] = obj;
+ board[index(column, row)] = null;
+ }
+ }
+ }
+ }
+}
+
+function turnChange()//called by ui outside
+{
+ betweenTurns = false;
+ if (gameCanvas.curTurn == 1){
+ shuffleUp();
+ gameCanvas.curTurn = 2;
+ victoryCheck();
+ }else{
+ shuffleDown();
+ gameCanvas.curTurn = 1;
+ victoryCheck();
+ }
+}
+
+function refill()
+{
+ for (var column = 0; column < maxColumn; column++) {
+ for (var row = 0; row < maxRow; row++) {
+ if (board[index(column, row)] == null)
+ createBlock(column, row);
+ }
+ }
+}
+
+function victoryCheck()
+{
+ // Awards bonuses for no blocks left
+ var deservesBonus = true;
+ if (board[index(0,maxRow - 1)] != null || board[index(0,0)] != null)
+ deservesBonus = false;
+ // Checks for game over
+ if (deservesBonus){
+ if (gameCanvas.curTurn = 1)
+ gameCanvas.score += 1000;
+ else
+ gameCanvas.score2 += 1000;
+ }
+ gameOver = deservesBonus;
+ if (gameCanvas.curTurn == 1){
+ if (!(floodMoveCheck(0, maxRow - 1, -1)))
+ gameOver = true;
+ }else{
+ if (!(floodMoveCheck(0, 0, -1, true)))
+ gameOver = true;
+ }
+ if (gameMode == "puzzle"){
+ puzzleVictoryCheck(deservesBonus);//Takes it from here
+ return;
+ }
+ if (gameOver) {
+ var winnerScore = Math.max(gameCanvas.score, gameCanvas.score2);
+ if (gameMode == "multiplayer"){
+ gameCanvas.score = winnerScore;
+ saveHighScore(gameCanvas.score2);
+ }
+ saveHighScore(gameCanvas.score);
+ gameDuration = new Date() - gameDuration;
+ gameCanvas.gameOver = true;
+ }
+}
+
+// Only floods up and right, to see if it can find adjacent same-typed blocks
+function floodMoveCheck(column, row, type, goDownInstead)
+{
+ if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
+ return false;
+ if (board[index(column, row)] == null)
+ return false;
+ var myType = board[index(column, row)].type;
+ if (type == myType)
+ return true;
+ if (goDownInstead)
+ return floodMoveCheck(column + 1, row, myType, goDownInstead) ||
+ floodMoveCheck(column, row + 1, myType, goDownInstead);
+ else
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, myType);
+}
+
+function createBlock(column,row,type)
+{
+ // Note that we don't wait for the component to become ready. This will
+ // only work if the block QML is a local file. Otherwise the component will
+ // not be ready immediately. There is a statusChanged signal on the
+ // component you could use if you want to wait to load remote files.
+ if (component.status == 1){
+ if (type == undefined)
+ type = Math.floor(Math.random() * types);
+ if (type < 0 || type > 4) {
+ console.log("Invalid type requested");//TODO: Is this triggered by custom levels much?
+ return;
+ }
+ var dynamicObject = component.createObject(gameCanvas,
+ {"type": type,
+ "x": column*Settings.blockSize,
+ "y": -1*Settings.blockSize,
+ "width": Settings.blockSize,
+ "height": Settings.blockSize,
+ "particleSystem": gameCanvas.ps});
+ if (dynamicObject == null){
+ console.log("error creating block");
+ console.log(component.errorString());
+ return false;
+ }
+ dynamicObject.y = row*Settings.blockSize;
+ dynamicObject.spawned = true;
+
+ board[index(column,row)] = dynamicObject;
+ }else{
+ console.log("error loading block component");
+ console.log(component.errorString());
+ return false;
+ }
+ return true;
+}
+
+function showPuzzleError(str)
+{
+ //TODO: Nice user visible UI?
+ console.log(str);
+}
+
+function loadMap(map)
+{
+ puzzlePath = map;
+ var levelComp = Qt.createComponent(puzzlePath);
+ if (levelComp.status != 1){
+ console.log("Error loading level");
+ showPuzzleError(levelComp.errorString());
+ return;
+ }
+ puzzleLevel = levelComp.createObject();
+ if (puzzleLevel == null || !puzzleLevel.startingGrid instanceof Array) {
+ showPuzzleError("Bugger!");
+ return;
+ }
+ gameCanvas.showPuzzleGoal(puzzleLevel.goalText);
+ //showPuzzleGoal should call finishLoadingMap as the next thing it does, before handling more events
+}
+
+function finishLoadingMap()
+{
+ for (var i in puzzleLevel.startingGrid)
+ if (! (puzzleLevel.startingGrid[i] >= 0 && puzzleLevel.startingGrid[i] <= 9) )
+ puzzleLevel.startingGrid[i] = 0;
+ //TODO: Don't allow loading larger levels, leads to cheating
+ while (puzzleLevel.startingGrid.length > maxIndex) puzzleLevel.startingGrid.shift();
+ while (puzzleLevel.startingGrid.length < maxIndex) puzzleLevel.startingGrid.unshift(0);
+ for (var i in puzzleLevel.startingGrid)
+ if (puzzleLevel.startingGrid[i] > 0)
+ createBlock(i % maxColumn, Math.floor(i / maxColumn), puzzleLevel.startingGrid[i] - 1);
+
+ //### Experimental feature - allow levels to contain arbitrary QML scenes as well!
+ //while (puzzleLevel.children.length)
+ // puzzleLevel.children[0].parent = gameCanvas;
+ gameDuration = new Date(); //Don't start until we finish loading
+}
+
+function puzzleVictoryCheck(clearedAll)//gameOver has also been set if no more moves
+{
+ var won = true;
+ var soFar = new Date() - gameDuration;
+ if (puzzleLevel.scoreTarget != -1 && gameCanvas.score < puzzleLevel.scoreTarget){
+ won = false;
+ } if (puzzleLevel.scoreTarget != -1 && gameCanvas.score >= puzzleLevel.scoreTarget && !puzzleLevel.mustClear){
+ gameOver = true;
+ } if (puzzleLevel.timeTarget != -1 && soFar/1000.0 > puzzleLevel.timeTarget){
+ gameOver = true;
+ } if (puzzleLevel.moveTarget != -1 && gameCanvas.moves >= puzzleLevel.moveTarget){
+ gameOver = true;
+ } if (puzzleLevel.mustClear && gameOver && !clearedAll) {
+ won = false;
+ }
+
+ if (gameOver) {
+ gameCanvas.gameOver = true;
+ gameCanvas.showPuzzleEnd(won);
+
+ if (won) {
+ // Store progress
+ saveLevelHistory();
+ }
+ }
+}
+
+function getHighScore()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ // Only show results for the current grid size
+ var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'
+ + maxColumn + "x" + maxRow + '" AND game = "' + gameMode + '" ORDER BY score desc');
+ if (rs.rows.length > 0)
+ gameCanvas.highScore = rs.rows.item(0).score;
+ else
+ gameCanvas.highScore = 0;
+ }
+ );
+}
+
+function saveHighScore(score)
+{
+ // Offline storage
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
+ var data = [
+ gameMode,
+ score,
+ maxColumn + "x" + maxRow,
+ Math.floor(gameDuration / 1000)
+ ];
+ if (score >= gameCanvas.highScore)//Update UI field
+ gameCanvas.highScore = score;
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(game TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
+ tx.executeSql(dataStr, data);
+ }
+ );
+}
+
+function getLevelHistory()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+ var rs = tx.executeSql('SELECT * FROM Puzzle WHERE level = "' + puzzlePath + '" ORDER BY score desc');
+ if (rs.rows.length > 0) {
+ gameCanvas.puzzleWon = true;
+ gameCanvas.highScore = rs.rows.item(0).score;
+ } else {
+ gameCanvas.puzzleWon = false;
+ gameCanvas.highScore = 0;
+ }
+ }
+ );
+}
+
+function saveLevelHistory()
+{
+ var db = Sql.LocalStorage.openDatabaseSync(
+ "SameGame",
+ "2.0",
+ "SameGame Local Data",
+ 100
+ );
+ var dataStr = "INSERT INTO Puzzle VALUES(?, ?, ?, ?)";
+ var data = [
+ puzzlePath,
+ gameCanvas.score,
+ gameCanvas.moves,
+ Math.floor(gameDuration / 1000)
+ ];
+ gameCanvas.puzzleWon = true;
+
+ db.transaction(
+ function(tx) {
+ tx.executeSql('CREATE TABLE IF NOT EXISTS Puzzle(level TEXT, score NUMBER, moves NUMBER, time NUMBER)');
+ tx.executeSql(dataStr, data);
+ }
+ );
+}
+
+function nuke() //For "Debug mode"
+{
+ for (var row = 1; row <= 5; row++) {
+ for (var col = 0; col < 5; col++) {
+ if (board[index(col, maxRow - row)] != null) {
+ board[index(col, maxRow - row)].dying = true;
+ board[index(col, maxRow - row)] = null;
+ }
+ }
+ }
+ if (gameMode == "multiplayer" && gameCanvas.curTurn == 2)
+ shuffleUp();
+ else
+ shuffleDown();
+ if (gameMode == "endless")
+ refill();
+ else
+ victoryCheck();
+}
diff --git a/examples/quick/demos/samegame/main.cpp b/examples/quick/demos/samegame/main.cpp
new file mode 100644
index 0000000000..20bf7fad18
--- /dev/null
+++ b/examples/quick/demos/samegame/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(samegame)
diff --git a/examples/quick/demos/samegame/samegame.pro b/examples/quick/demos/samegame/samegame.pro
new file mode 100644
index 0000000000..fec2e53018
--- /dev/null
+++ b/examples/quick/demos/samegame/samegame.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/samegame
+qml.files = samegame.qml content settings.js
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/samegame
+INSTALLS += target qml
diff --git a/examples/quick/demos/samegame/samegame.qml b/examples/quick/demos/samegame/samegame.qml
new file mode 100644
index 0000000000..2b0b82a37c
--- /dev/null
+++ b/examples/quick/demos/samegame/samegame.qml
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Particles 2.0
+import "content/samegame.js" as Logic
+import "settings.js" as Settings
+import "content"
+
+Rectangle {
+ id: root
+ width: 320; height: 480
+ property int acc: 0
+
+
+ function loadPuzzle() {
+ if (gameCanvas.mode != "")
+ Logic.cleanUp();
+ Logic.startNewGame(gameCanvas,"puzzle","levels/level"+acc+".qml")
+ }
+ function nextPuzzle() {
+ acc = (acc + 1) % 10;
+ loadPuzzle();
+ }
+ Timer {
+ id: gameOverTimer
+ interval: 1500
+ running : gameCanvas.gameOver && gameCanvas.mode == "puzzle" //mode will be reset by cleanUp();
+ repeat : false
+ onTriggered: {
+ Logic.cleanUp();
+ nextPuzzle();
+ }
+ }
+
+ Image {
+ source: "content/gfx/background.png"
+ anchors.fill: parent
+ }
+
+ GameArea {
+ id: gameCanvas
+ z: 1
+ y: Settings.headerHeight
+
+ width: parent.width
+ height: parent.height - Settings.headerHeight - Settings.footerHeight
+
+ backgroundVisible: root.state == "in-game"
+ onModeChanged: if (gameCanvas.mode != "puzzle") puzzleWon = false; //UI has stricter constraints on this variable than the game does
+ Age {
+ groups: ["redspots", "greenspots", "bluespots", "yellowspots"]
+ enabled: root.state == ""
+ system: gameCanvas.ps
+ }
+
+ onPuzzleLost: acc--;//So that nextPuzzle() reloads the current one
+
+ }
+
+ Item {
+ id: menu
+ z: 2
+ width: parent.width;
+ anchors.top: parent.top
+ anchors.bottom: bottomBar.top
+
+ LogoAnimation {
+ x: 64
+ y: Settings.headerHeight
+ particleSystem: gameCanvas.ps
+ running: root.state == ""
+ }
+ Row {
+ x: 112
+ y: 20
+ Image { source: "content/gfx/logo-a.png" }
+ Image { source: "content/gfx/logo-m.png" }
+ Image { source: "content/gfx/logo-e.png" }
+ }
+
+ Column {
+ y: 100 + 40
+ spacing: Settings.menuButtonSpacing
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-1.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return //Prevent double clicking
+ root.state = "in-game"
+ gameCanvas.blockFile = "Block.qml"
+ gameCanvas.background = "gfx/background.png"
+ arcadeTimer.start();
+ }
+ //Emitted particles don't fade out, because ImageParticle is on the GameArea
+ system: gameCanvas.ps
+ group: "green"
+ Timer {
+ id: arcadeTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas)
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-2.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "Block.qml"
+ gameCanvas.background = "gfx/background.png"
+ twopTimer.start();
+ }
+ system: gameCanvas.ps
+ group: "green"
+ Timer {
+ id: twopTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas, "multiplayer")
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-3.png"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "SimpleBlock.qml"
+ gameCanvas.background = "gfx/background.png"
+ endlessTimer.start();
+ }
+ system: gameCanvas.ps
+ group: "blue"
+ Timer {
+ id: endlessTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: Logic.startNewGame(gameCanvas, "endless")
+ }
+ }
+
+ Button {
+ width: root.width
+ rotatedButton: true
+ imgSrc: "content/gfx/but-game-4.png"
+ group: "yellow"
+ onClicked: {
+ if (root.state == "in-game")
+ return
+ root.state = "in-game"
+ gameCanvas.blockFile = "PuzzleBlock.qml"
+ gameCanvas.background = "gfx/background.png"
+ puzzleTimer.start();
+ }
+ Timer {
+ id: puzzleTimer
+ interval: Settings.menuDelay
+ running : false
+ repeat : false
+ onTriggered: loadPuzzle();
+ }
+ system: gameCanvas.ps
+ }
+ }
+ }
+
+ Image {
+ id: scoreBar
+ source: "content/gfx/bar.png"
+ width: parent.width
+ z: 6
+ y: -Settings.headerHeight
+ height: Settings.headerHeight
+ Behavior on opacity { NumberAnimation {} }
+ SamegameText {
+ id: arcadeScore
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+ font.pixelSize: Settings.fontPixelSize
+ textFormat: Text.StyledText
+ color: "white"
+ opacity: gameCanvas.mode == "arcade" ? 1 : 0
+ Behavior on opacity { NumberAnimation {} }
+ }
+ SamegameText {
+ id: arcadeHighScore
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Highscore:</font> ' + gameCanvas.highScore
+ opacity: gameCanvas.mode == "arcade" ? 1 : 0
+ }
+ SamegameText {
+ id: p1Score
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P1:</font> ' + gameCanvas.score
+ opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+ }
+ SamegameText {
+ id: p2Score
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">P2:</font> ' + gameCanvas.score2
+ opacity: gameCanvas.mode == "multiplayer" ? 1 : 0
+ rotation: 180
+ }
+ SamegameText {
+ id: puzzleMoves
+ anchors { left: parent.left; topMargin: 3; leftMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Moves:</font> ' + gameCanvas.moves
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ }
+ SamegameText {
+ Image {
+ source: "content/gfx/icon-time.png"
+ x: -20
+ }
+ id: puzzleTime
+ anchors { topMargin: 3; top: parent.top; horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 20}
+ text: "00:00"
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ Timer {
+ interval: 1000
+ repeat: true
+ running: gameCanvas.mode == "puzzle" && !gameCanvas.gameOver
+ onTriggered: {
+ var elapsed = Math.floor((new Date() - Logic.gameDuration)/ 1000.0);
+ var mins = Math.floor(elapsed/60.0);
+ var secs = (elapsed % 60);
+ puzzleTime.text = (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs;
+ }
+ }
+ }
+ SamegameText {
+ id: puzzleScore
+ anchors { right: parent.right; topMargin: 3; rightMargin: 11; top: parent.top}
+ text: '<font color="#f7d303">Score:</font> ' + gameCanvas.score
+ opacity: gameCanvas.mode == "puzzle" ? 1 : 0
+ }
+ }
+
+ Image {
+ id: bottomBar
+ width: parent.width
+ height: Settings.footerHeight
+ source: "content/gfx/bar.png"
+ y: parent.height - Settings.footerHeight;
+ z: 2
+ Button {
+ id: quitButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-quit.png"
+ onClicked: {Qt.quit(); }
+ anchors { left: parent.left; verticalCenter: parent.verticalCenter; leftMargin: 11 }
+ }
+ Button {
+ id: menuButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-menu.png"
+ visible: (root.state == "in-game");
+ onClicked: {root.state = ""; Logic.cleanUp(); gameCanvas.mode = ""}
+ anchors { left: quitButton.right; verticalCenter: parent.verticalCenter; leftMargin: 0 }
+ }
+ Button {
+ id: againButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-game-new.png"
+ visible: (root.state == "in-game");
+ opacity: gameCanvas.gameOver && (gameCanvas.mode == "arcade" || gameCanvas.mode == "multiplayer")
+ Behavior on opacity{ NumberAnimation {} }
+ onClicked: {if (gameCanvas.gameOver) { Logic.startNewGame(gameCanvas, gameCanvas.mode);}}
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+ }
+ Button {
+ id: nextButton
+ height: Settings.toolButtonHeight
+ imgSrc: "content/gfx/but-puzzle-next.png"
+ visible: (root.state == "in-game") && gameCanvas.mode == "puzzle" && gameCanvas.puzzleWon
+ opacity: gameCanvas.puzzleWon ? 1 : 0
+ Behavior on opacity{ NumberAnimation {} }
+ onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();}
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
+ }
+ }
+
+ Connections {
+ target: root
+ onStateChanged: stateChangeAnim.running = true
+ }
+ SequentialAnimation {
+ id: stateChangeAnim
+ ParallelAnimation {
+ NumberAnimation { target: bottomBar; property: "y"; to: root.height; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
+ NumberAnimation { target: scoreBar; property: "y"; to: -Settings.headerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutQuad }
+ }
+ ParallelAnimation {
+ NumberAnimation { target: bottomBar; property: "y"; to: root.height - Settings.footerHeight; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
+ NumberAnimation { target: scoreBar; property: "y"; to: root.state == "" ? -Settings.headerHeight : 0; duration: Settings.menuDelay/2; easing.type: Easing.OutBounce}
+ }
+ }
+
+ states: [
+ State {
+ name: "in-game"
+ PropertyChanges {
+ target: menu
+ opacity: 0
+ visible: false
+ }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ NumberAnimation {properties: "x,y,opacity"}
+ }
+ ]
+
+ //"Debug mode"
+ focus: true
+ Keys.onAsteriskPressed: Logic.nuke();
+ Keys.onSpacePressed: gameCanvas.puzzleWon = true;
+}
diff --git a/examples/quick/demos/samegame/samegame.qmlproject b/examples/quick/demos/samegame/samegame.qmlproject
new file mode 100644
index 0000000000..42ffacf4f8
--- /dev/null
+++ b/examples/quick/demos/samegame/samegame.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "samegame.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/demos/samegame/settings.js b/examples/quick/demos/samegame/settings.js
new file mode 100644
index 0000000000..e09dee9af3
--- /dev/null
+++ b/examples/quick/demos/samegame/settings.js
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+
+//This should be switched over once a proper QML settings API exists
+
+var menuDelay = 500
+
+var headerHeight = 20 // 70 on BB10
+var footerHeight = 44 // 100 on BB10
+
+var fontPixelSize = 14 // 55 on BB10
+
+var blockSize = 32 // 64 on BB10
+
+var toolButtonHeight = 32 // 64 on BB10
+
+var menuButtonSpacing = 0 // 15 on BB10
diff --git a/examples/quick/demos/stocqt/content/Button.qml b/examples/quick/demos/stocqt/content/Button.qml
new file mode 100644
index 0000000000..0e99c52c51
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/Button.qml
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:button
+ property bool buttonEnabled:true
+ radius:5
+ width:25
+ height:25
+ color:buttonEnabled ? "steelblue" : "gray"
+ MouseArea {
+ anchors.fill:parent
+ onClicked: {
+ if (buttonEnabled)
+ buttonEnabled = false;
+ else
+ buttonEnabled = true;
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/DatePicker.qml b/examples/quick/demos/stocqt/content/DatePicker.qml
new file mode 100644
index 0000000000..82d8788bd9
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/DatePicker.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ color:"transparent"
+ width:300
+ height:45
+ property var _monthNames : [ "JAN", "FEB", "MAR", "APR", "MAY", "JUN","JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ];
+ property var date:new Date()
+
+ onDateChanged: {
+ month.text = root._monthNames[root.date.getMonth()]
+ day.text = date.getDate();
+ year.text = date.getFullYear();
+ }
+ Row {
+ spacing:20
+ anchors.fill:parent
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:month
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root._monthNames[root.date.getMonth()]
+ onAccepted : {
+ for (var i = 0; i < 12; i++) {
+ if (text === root._monthNames[i]) {
+ root.date.setMonth(i);
+ root.date = root.date;
+ return;
+ }
+ }
+ root.date = root.date;
+ }
+ }
+ }
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:day
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root.date.getDate()
+ validator:IntValidator {bottom:1; top:31}
+ onAccepted: { root.date.setDate(text); root.date = root.date;}
+ }
+ }
+
+ Rectangle {
+ height:root.height
+ width:root.width/3 - 20
+ color:"#272822"
+ radius:5
+
+ TextInput {
+ id:year
+ anchors.centerIn:parent
+ color:"#ecc089"
+ font.pointSize:25
+ font.bold:true
+ text:root.date.getFullYear()
+ validator:IntValidator {bottom:1995; top:(new Date()).getFullYear()}
+ onAccepted:{ root.date.setFullYear(text); root.date = root.date;}
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml
new file mode 100644
index 0000000000..c7411679bb
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockChart.qml
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Rectangle {
+ id:chart
+ width:320
+ height:320
+ color:"transparent"
+ property var _months : [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
+ property var stockModel:null
+ property var startDate
+ property var endDate
+ property var settings
+
+ function update() {
+ if (settings.chartType === "year")
+ chart.startDate = new Date(chart.endDate.getFullYear() - 1, chart.endDate.getMonth(), chart.endDate.getDate());
+ else if (settings.chartType === "month")
+ chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth() -1, chart.endDate.getDate())
+ else if (settings.chartType === "week")
+ chart.startDate = new Date(chart.endDate.getFullYear() , chart.endDate.getMonth(), chart.endDate.getDate() - 7)
+ else
+ chart.startDate = new Date(1995, 3, 25)
+
+ canvas.requestPaint();
+ }
+
+
+ Text {
+ id:fromDate
+ color:"#6a5b44"
+ width:50
+ font.pointSize: 10
+ wrapMode: Text.WordWrap
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top:parent.top
+ text:_months[startDate.getMonth()] + "\n" + startDate.getFullYear()
+ }
+
+ Text {
+ id:toDate
+ color:"#6a5b44"
+ font.pointSize: 10
+ width:50
+ wrapMode: Text.WordWrap
+ anchors.right: parent.right
+ anchors.leftMargin: 20
+ anchors.top:parent.top
+ text:_months[endDate.getMonth()] + "\n" + endDate.getFullYear()
+ }
+
+ Canvas {
+ id:canvas
+ anchors.top : toDate.bottom
+ width:parent.width
+ anchors.bottom: parent.bottom
+
+ renderTarget: Canvas.FramebufferObject
+ property int frames:first
+ property int mouseX:0;
+ property int mouseY:0;
+ property int mousePressedX:0;
+ property int mousePressedY:0;
+ property int movedY:0
+ property real scaleX:1.0;
+ property real scaleY:1.0;
+ property int first:0;
+ property int last:0;
+
+// MouseArea {
+// anchors.fill: parent
+
+// onPositionChanged: {
+// if (mouse.modifiers & Qt.ControlModifier) {
+// if (canvas.mouseX == 0 && canvas.mouseY == 0) {
+// canvas.mouseX = mouse.x;
+// canvas.mouseY = mouse.y;
+// }
+// } else{
+// var w = (view.width/view.count)*canvas.scaleX;
+
+// //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2);
+
+// var movedX = Math.round((canvas.mousePressedX - mouse.x)/w);
+// if (movedX != 0 || canvas.movedY != 0) {
+// if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) {
+// canvas.first += movedX;
+// canvas.last += movedX;
+// }
+// canvas.requestPaint();
+// }
+// }
+// }
+
+// onPressed: {
+// canvas.mousePressedX = mouse.x;
+// canvas.mousePressedY = mouse.y;
+// }
+
+// onReleased : {
+// if (mouse.modifiers & Qt.ControlModifier) {
+// var sx = mouse.x - canvas.mouseX;
+// var sy = canvas.mouseY - mouse.y;
+
+// if (Math.abs(sx) < 50) sx = 0;
+// if (Math.abs(sy) < 50) sy = 0;
+
+// if (sx > 0)
+// canvas.scaleX *= sx/100 +1;
+// else
+// canvas.scaleX *= 1/(-sx/100 + 1);
+
+// if (sy > 0)
+// canvas.scaleY *= sy/100 +1;
+// else
+// canvas.scaleY *= 1/(-sy/100 + 1);
+
+// if (canvas.scaleX < 1)
+// canvas.scaleX = 1;
+
+// //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY);
+
+// canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX);
+// canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX);
+
+// canvas.mouseX = 0;
+// canvas.mouseY = 0;
+// canvas.mousePressedX = 0;
+// canvas.mousePressedY = 0;
+// canvas.requestPaint();
+// }
+// }
+// }
+
+ function drawBackground(ctx) {
+ ctx.save();
+ ctx.fillStyle = "#272822"
+ ctx.fillRect(0, 0, canvas.width, canvas.height)
+ ctx.strokeStyle = "#423a2f"
+ ctx.beginPath();
+ for (var i = 0; i < 10; i++) {
+ ctx.moveTo(0, i * (canvas.height/10.0));
+ ctx.lineTo(canvas.width, i * (canvas.height/10.0));
+ }
+
+ for (i = 0; i < 12; i++) {
+ ctx.moveTo(i * (canvas.width/12.0), 0);
+ ctx.lineTo(i * (canvas.width/12.0), canvas.height);
+ }
+ ctx.stroke();
+
+ ctx.strokeStyle = "#5c7a37"
+ ctx.beginPath();
+ ctx.moveTo(8 * (canvas.width/12.0), 0);
+ ctx.lineTo(8 * (canvas.width/12.0), canvas.height);
+ ctx.stroke();
+
+ ctx.restore();
+ }
+
+ function drawPrice(ctx, from, to, color, price, points, highest)
+ {
+ ctx.save();
+ ctx.globalAlpha = 0.7;
+ ctx.strokeStyle = color;
+ ctx.lineWidth = 1;
+ ctx.beginPath();
+
+ var w = canvas.width/points.length;
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * y/highest;
+ if (i == 0) {
+ ctx.moveTo(x+w/2, y);
+ } else {
+ ctx.lineTo(x+w/2, y);
+ }
+ }
+ ctx.stroke();
+ ctx.restore();
+ }
+
+ function drawKLine(ctx, from, to, points, highest)
+ {
+ ctx.save();
+ ctx.globalAlpha = 0.4;
+ ctx.lineWidth = 2;
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var open = canvas.height * points[i].open/highest - canvas.movedY;
+ var close = canvas.height * points[i].close/highest - canvas.movedY;
+ var high = canvas.height * points[i].high/highest - canvas.movedY;
+ var low = canvas.height * points[i].low/highest - canvas.movedY;
+
+ var top, bottom;
+ if (close <= open) {
+ ctx.fillStyle = Qt.rgba(1, 0, 0, 1);
+ ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
+ top = close;
+ bottom = open;
+ } else {
+ ctx.fillStyle = Qt.rgba(0, 1, 0, 1);
+ ctx.strokeStyle = Qt.rgba(0, 1, 0, 1);
+ top = open;
+ bottom = close;
+ }
+
+ var w1, w2;
+ w1 = canvas.width/points.length;
+ w2 = w1 > 10 ? w1/2 : w1;
+
+ ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top);
+ ctx.beginPath();
+ ctx.moveTo(x+w1/2, high);
+ ctx.lineTo(x+w1/2, low);
+ ctx.stroke();
+ }
+ ctx.restore();
+ }
+
+ function drawVolume(ctx, from, to, color, price, points, highest)
+ {
+ ctx.save();
+ ctx.fillStyle = color;
+ ctx.globalAlpha = 0.6;
+ ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1);
+ ctx.lineWidth = 1;
+
+ var end = points.length;
+ for (var i = 0; i < end; i++) {
+ var x = points[i].x;
+ var y = points[i][price];
+ y = canvas.height * (1 - y/highest);
+ ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y);
+ }
+ ctx.restore();
+ }
+
+ onPaint: {
+ var ctx = canvas.getContext("2d");
+
+ ctx.globalCompositeOperation = "source-over";
+ ctx.lineWidth = 1;
+
+ drawBackground(ctx);
+ if (!stockModel.ready)
+ return;
+
+ last = stockModel.indexOf(chart.endDate)
+ first = last - (chart.endDate.getTime() - chart.startDate.getTime())/86400000;
+ console.log("painting... first:" + first + ", last:" + last);
+
+ var highestPrice = stockModel.highestPrice;
+ var highestVolume = stockModel.highestVolume;
+ console.log("highest price:" + highestPrice + ", highest volume:" + highestVolume)
+ var points = [];
+ for (var i = 0; i <= last - first; i++) {
+ var price = stockModel.get(i + first);
+ points.push({
+ x: i*canvas.width/(last-first+1),
+ open: price.open,
+ close: price.close,
+ high:price.high,
+ low:price.low,
+ volume:price.volume
+ });
+ }
+ if (settings.drawHighPrice)
+ drawPrice(ctx, first, last, settings.highColor,"high", points, highestPrice);
+ if (settings.drawLowPrice)
+ drawPrice(ctx, first, last, settings.lowColor,"low", points, highestPrice);
+ if (settings.drawOpenPrice)
+ drawPrice(ctx, first, last,settings.openColor,"open", points, highestPrice);
+ if (settings.drawClosePrice)
+ drawPrice(ctx, first, last, settings.closeColor,"close", points, highestPrice);
+ if (settings.drawVolume)
+ drawVolume(ctx, first, last, settings.volumeColor,"volume", points, highestVolume);
+ if (settings.drawKLine)
+ drawKLine(ctx, first, last, points, highestPrice);
+ }
+}
+}
diff --git a/examples/quick/demos/stocqt/content/StockListModel.qml b/examples/quick/demos/stocqt/content/StockListModel.qml
new file mode 100644
index 0000000000..b1e0706a3a
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockListModel.qml
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:stocks
+ //Data from : http://en.wikipedia.org/wiki/NASDAQ-100
+
+ ListElement {name:"Activision Blizzard"; stockId:"ATVI"}
+ ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"}
+ ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"}
+ ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"}
+ ListElement {name:"Altera Corporation"; stockId:"ALTR"}
+ ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"}
+ ListElement {name:"Amgen Inc."; stockId:"AMGN"}
+ ListElement {name:"Apollo Group, Inc."; stockId:"APOL"}
+ ListElement {name:"Apple Inc."; stockId:"AAPL"}
+ ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"}
+ ListElement {name:"Autodesk, Inc."; stockId:"ADSK"}
+ ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"}
+ ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"}
+ ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"}
+ ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"}
+ ListElement {name:"BMC Software, Inc."; stockId:"BMC"}
+ ListElement {name:"Broadcom Corporation"; stockId:"BRCM"}
+ ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"}
+ ListElement {name:"CA, Inc."; stockId:"CA"}
+ ListElement {name:"Celgene Corporation"; stockId:"CELG"}
+ ListElement {name:"Cephalon, Inc."; stockId:"CEPH"}
+ ListElement {name:"Cerner Corporation"; stockId:"CERN"}
+ ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"}
+ ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"}
+ ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"}
+ ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"}
+ ListElement {name:"Comcast Corporation"; stockId:"CMCSA"}
+ ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"}
+ ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"}
+ ListElement {name:"Dell Inc."; stockId:"DELL"}
+ ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"}
+ ListElement {name:"DirecTV"; stockId:"DTV"}
+ ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"}
+ ListElement {name:"eBay Inc."; stockId:"EBAY"}
+ ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"}
+ ListElement {name:"Expedia, Inc."; stockId:"EXPE"}
+ ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"}
+ ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"}
+ ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"}
+ ListElement {name:"Fastenal Company"; stockId:"FAST"}
+ ListElement {name:"First Solar, Inc."; stockId:"FSLR"}
+ ListElement {name:"Fiserv, Inc."; stockId:"FISV"}
+ ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"}
+ ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"}
+ ListElement {name:"Garmin Ltd."; stockId:"GRMN"}
+ ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"}
+ ListElement {name:"Google Inc."; stockId:"GOOG"}
+ ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"}
+ ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"}
+ ListElement {name:"Illumina, Inc."; stockId:"ILMN"}
+ ListElement {name:"Infosys Technologies"; stockId:"INFY"}
+ ListElement {name:"Intel Corporation"; stockId:"INTC"}
+ ListElement {name:"Intuit, Inc."; stockId:"INTU"}
+ ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"}
+ ListElement {name:"Joy Global Inc."; stockId:"JOYG"}
+ ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"}
+ ListElement {name:"Lam Research Corporation"; stockId:"LRCX"}
+ ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"}
+ ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"}
+ ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"}
+ ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"}
+ ListElement {name:"Mattel, Inc."; stockId:"MAT"}
+ ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"}
+ ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"}
+ ListElement {name:"Micron Technology, Inc."; stockId:"MU"}
+ ListElement {name:"Microsoft Corporation"; stockId:"MSFT"}
+ ListElement {name:"Mylan, Inc."; stockId:"MYL"}
+ ListElement {name:"NetApp, Inc."; stockId:"NTAP"}
+ ListElement {name:"Netflix, Inc."; stockId:"NFLX"}
+ ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"}
+ ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"}
+ ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"}
+ ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"}
+ ListElement {name:"Oracle Corporation"; stockId:"ORCL"}
+ ListElement {name:"PACCAR Inc."; stockId:"PCAR"}
+ ListElement {name:"Paychex, Inc."; stockId:"PAYX"}
+ ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"}
+ ListElement {name:"Qiagen N.V."; stockId:"QGEN"}
+ ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"}
+ ListElement {name:"Research in Motion Limited"; stockId:"RIMM"}
+ ListElement {name:"Ross Stores Inc."; stockId:"ROST"}
+ ListElement {name:"SanDisk Corporation"; stockId:"SNDK"}
+ ListElement {name:"Seagate Technology Holdings"; stockId:"STX"}
+ ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"}
+ ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"}
+ ListElement {name:"Staples Inc."; stockId:"SPLS"}
+ ListElement {name:"Starbucks Corporation"; stockId:"SBUX"}
+ ListElement {name:"Stericycle, Inc"; stockId:"SRCL"}
+ ListElement {name:"Symantec Corporation"; stockId:"SYMC"}
+ ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"}
+ ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"}
+ ListElement {name:"VeriSign, Inc."; stockId:"VRSN"}
+ ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"}
+ ListElement {name:"Virgin Media, Inc."; stockId:"VMED"}
+ ListElement {name:"Vodafone Group, plc."; stockId:"VOD"}
+ ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"}
+ ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"}
+ ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"}
+ ListElement {name:"Xilinx, Inc."; stockId:"XLNX"}
+ ListElement {name:"Yahoo! Inc."; stockId:"YHOO"}
+}
diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml
new file mode 100644
index 0000000000..c241efb54c
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockListView.qml
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+
+ property string currentStockId:""
+ property string currentStockName:""
+
+ ListView {
+ id:view
+ anchors.fill:parent
+ keyNavigationWraps:true
+ focus:true
+ snapMode: ListView.SnapToItem
+ model:StockListModel{}
+
+ onCurrentIndexChanged: {
+ root.currentStockId = model.get(currentIndex).stockId
+ root.currentStockName = model.get(currentIndex).name
+ console.log("current stock:" + root.currentStockId + " - " + root.currentStockName)
+ }
+
+ delegate:Rectangle {
+ height:30
+ width:parent.width
+ color:"transparent"
+ MouseArea {
+ anchors.fill: parent
+ onClicked:view.currentIndex = index
+ }
+
+ Text {
+ anchors.verticalCenter : parent.top
+ anchors.verticalCenterOffset : 15
+ color:index == view.currentIndex ? "#ECC089" : "#A58963"
+ font.pointSize:12
+ font.bold:true
+ text:" " + stockId + " - " + name
+ }
+ }
+
+ highlight:Image {height:30; width:parent.width; source:"images/stock-selected.png"}
+ }
+} \ No newline at end of file
diff --git a/examples/quick/demos/stocqt/content/StockModel.qml b/examples/quick/demos/stocqt/content/StockModel.qml
new file mode 100644
index 0000000000..b5a78548e4
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockModel.qml
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id:model
+ property string stockId:""
+ property string stockName:""
+ property var startDate
+ property var endDate
+ property string stockDataCycle:"d"
+ property bool ready:false
+ property real stockPrice:0.0
+ property real stockPriceChanged:0.0
+ property real highestPrice:0
+ property real highestVolume:0
+
+ signal dataReady
+
+ function indexOf(date) {
+ var end = new Date(model.get(0).date)
+ var start = new Date(model.get(model.count - 1).date)
+ if (end <= date)
+ return model.count -1;
+
+ if (start >= date)
+ return 0;
+
+ for (var i = 0; i < model.count; i++) {
+ var d = new Date(model.get(i).date)
+ if ( d === date)
+ return i;
+ }
+ return -1;
+ }
+
+ function requestUrl() {
+ if (stockId === "")
+ return;
+
+ if (startDate === undefined)
+ startDate = new Date(1995, 3, 25) //default: 25 April 1995
+
+ if (endDate === undefined)
+ endDate = new Date(); //today
+
+ if (stockDataCycle !== "d" && stockDataCycle !== "w" && stockDataCycle !== "m")
+ stockDataCycle = "d";
+
+ /*
+ Fetch stock data from yahoo finance:
+ url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv
+ s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962
+ d:end day, e:end month, f:end year, default:today (data only available 3 days before today)
+ g:data cycle(d daily, w weekly, m monthly, v Dividend)
+ */
+ var request = "http://ichart.finance.yahoo.com/table.csv?";
+ request += "s=" + stockId;
+ request += "&a=" + startDate.getDate();
+ request += "&b=" + startDate.getMonth();
+ request += "&c=" + startDate.getFullYear();
+ request += "&d=" + endDate.getDate();
+ request += "&e=" + endDate.getMonth();
+ request += "&f=" + endDate.getFullYear();
+ request += "&g=" + stockDataCycle;
+ request += "&ignore=.csv";
+ return request;
+ }
+
+ function createStockPrice(r) {
+ if (highestPrice < r[2])
+ highestPrice = r[2];
+ if (highestVolume < r[5])
+ highestVolume = r[5];
+ return {
+ "date": r[0],
+ "open":r[1],
+ "high":r[2],
+ "low":r[3],
+ "close":r[4],
+ "volume":r[5],
+ "adjusted":r[6]
+ };
+ }
+
+ function updateStock() {
+ var xhr = new XMLHttpRequest;
+
+ var req = requestUrl();
+ console.log("getting " + req + " .....");
+
+ xhr.open("GET", req);
+
+
+ model.ready = false;
+ model.clear();
+ var i = 1; //skip the first line
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === XMLHttpRequest.LOADING || xhr.readyState === XMLHttpRequest.DONE) {
+ var records = xhr.responseText.split('\n');
+ console.log("Updating:" + (records.length - i) + " records for " + model.stockId + " from:" + model.startDate + " to " + model.endDate)
+
+ for (;i < records.length; i++ ) {
+ var r = records[i].split(',');
+ if (r.length === 7)
+ model.append(createStockPrice(r));
+ }
+
+ if (xhr.readyState === XMLHttpRequest.DONE) {
+ if (model.count > 0) {
+ console.log("done, total:" + model.count);
+ model.ready = true;
+ model.stockPrice = model.get(0).adjusted
+ model.stockPriceChanged = Math.round((model.stockPrice - model.get(2).adjusted) * 100) / 100
+ model.dataReady(); //emit signal
+ }
+ }
+ }
+ }
+ xhr.send()
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockSettings.qml b/examples/quick/demos/stocqt/content/StockSettings.qml
new file mode 100644
index 0000000000..600747b969
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockSettings.qml
@@ -0,0 +1,317 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+ property var startDate : startDatePicker.date;
+ property var endDate : endDatePicker.date;
+
+ property bool drawHighPrice:highButton.buttonEnabled
+ property bool drawLowPrice:lowButton.buttonEnabled
+ property bool drawOpenPrice:openButton.buttonEnabled
+ property bool drawClosePrice:closeButton.buttonEnabled
+ property bool drawVolume:volumeButton.buttonEnabled
+ property bool drawKLine:klineButton.buttonEnabled
+
+ property color highColor:Qt.rgba(1, 0, 0, 1)
+ property color lowColor:Qt.rgba(0, 1, 0, 1)
+ property color openColor:Qt.rgba(0, 0, 1, 1)
+ property color closeColor:"#ecc088"
+ property color volumeColor:Qt.rgba(0.3, 0.5, 0.7, 1)
+
+ property string chartType:"year"
+ Image {
+ id:logo
+ source:"images/logo.png"
+ anchors.horizontalCenter : parent.horizontalCenter
+ anchors.top:parent.top
+ anchors.topMargin:15
+ }
+
+ Text {
+ id:startDateText
+ text:"START DATE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:logo.bottom
+ anchors.topMargin:20
+ }
+
+ DatePicker {
+ id:startDatePicker
+ anchors.left:parent.left
+ anchors.leftMargin:30
+ anchors.top:startDateText.bottom
+ anchors.topMargin:15
+ date : new Date(1995, 3, 25)
+ }
+
+ Text {
+ id:endDateText
+ text:"END DATE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:startDatePicker.bottom
+ anchors.topMargin:20
+ }
+
+ DatePicker {
+ id:endDatePicker
+ anchors.left:parent.left
+ anchors.leftMargin:30
+ anchors.top:endDateText.bottom
+ anchors.topMargin:15
+ }
+
+ Text {
+ id:drawOptionsText
+ text:"DRAW OPTIONS:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:endDatePicker.bottom
+ anchors.topMargin:20
+ }
+ Column {
+ id:drawOptions
+ anchors.top:drawOptionsText.bottom
+ anchors.topMargin: 20
+ anchors.left: parent.left
+ anchors.leftMargin: 30
+ spacing:2
+ Row{
+ spacing:10
+ Text {
+ text:"High "
+ color:"#76644A"
+ font.pointSize:15
+ }
+
+ Button {
+ id:highButton
+ buttonEnabled:false
+ }
+
+ Text {
+ text:"Low "
+ color:"#76644A"
+ font.pointSize:15
+ }
+
+ Button {
+ id:lowButton
+ buttonEnabled:false
+ }
+
+ Text {
+ text:"Open "
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:openButton
+ buttonEnabled:false
+ }
+ }
+ Row{
+ spacing:10
+ Text {
+ text:"Close "
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:closeButton
+ buttonEnabled:true
+ }
+ Text {
+ text:"Volume"
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:volumeButton
+ buttonEnabled:true
+ }
+ Text {
+ text:"K Line"
+ color:"#76644A"
+ font.pointSize:15
+ }
+ Button {
+ id:klineButton
+ buttonEnabled:false
+ }
+ }
+ }
+
+
+ Text {
+ id:chartTypeText
+ text:"CHART TYPE:"
+ color:"#76644A"
+ font.pointSize:15
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:drawOptions.bottom
+ anchors.topMargin:20
+ }
+ Row {
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ anchors.top : chartTypeText.bottom
+ anchors.topMargin: 20
+ spacing:10
+ Rectangle {
+ id:yearView
+ width:70
+ height:30
+ radius:10
+ color:"steelblue"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.fill: parent
+ font.pointSize: 15
+ text:"YEAR"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "year") {
+ root.chartType = "year";
+ yearView.color = "steelblue"
+ monthView.color = "gray"
+ weekView.color = "gray"
+ allView.color = "gray"
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:monthView
+ width:70
+ radius:10
+ height:30
+ color:"gray"
+ Text {
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"MONTH"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "month") {
+ root.chartType = "month";
+ yearView.color = "gray"
+ monthView.color = "steelblue"
+ weekView.color = "gray"
+ allView.color = "gray"
+ }
+ }
+ }
+
+ }
+ Rectangle {
+ id:weekView
+ height:30
+ width:70
+ radius:10
+ color:"gray"
+ Text {
+ anchors.fill: parent
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"WEEK"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "week") {
+ root.chartType = "week";
+ yearView.color = "gray"
+ monthView.color = "gray"
+ weekView.color = "steelblue"
+ allView.color = "gray"
+ }
+ }
+ }
+ }
+ Rectangle {
+ id:allView
+ width:70
+ radius:10
+ height:30
+ color:"gray"
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.fill: parent
+ font.pointSize: 15
+ color:"#ecc089"
+ text:"ALL"
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (root.chartType != "all") {
+ root.chartType = "all";
+ yearView.color = "gray"
+ monthView.color = "gray"
+ weekView.color = "gray"
+ allView.color = "steelblue"
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml
new file mode 100644
index 0000000000..49e6c98622
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/StockView.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+Rectangle {
+ id:root
+ width:320
+ height:480
+ color:"#423A2F"
+ property var stock:null
+ property var stocklist:null
+ property var settings:null
+ signal listViewClicked
+ signal settingsClicked
+
+ function update() {
+ chart.endDate = settings.endDate
+ chart.update()
+ }
+
+ Rectangle {
+ color:"#272822"
+ anchors.fill:parent
+ radius:20
+
+ Image {
+ source:"images/icon-items.png"
+ anchors.left:parent.left
+ anchors.leftMargin:10
+ anchors.top:parent.top
+ anchors.topMargin:10
+ MouseArea {
+ anchors.fill:parent
+ onClicked:listViewClicked()
+ }
+ }
+ Image {
+ source:"images/icon-settings.png"
+ anchors.right:parent.right
+ anchors.rightMargin:10
+ anchors.top:parent.top
+ anchors.topMargin:10
+ MouseArea {
+ anchors.fill:parent
+ onClicked:settingsClicked()
+ }
+ }
+
+ Text {
+ id:desc
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:parent.top
+ anchors.topMargin:40
+ color:"#564c3A"
+ font.pointSize:15
+ text:root.stock.stockId + " - " + root.stock.stockName
+ }
+
+ Text {
+ id:price
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:desc.bottom
+ anchors.topMargin:5
+ color:"#ECC089"
+ font.pointSize:30
+ text:root.stock.stockPrice
+ }
+
+ Text {
+ id:priceChange
+ anchors.left:parent.left
+ anchors.leftMargin:20
+ anchors.top:price.bottom
+ anchors.topMargin:5
+ color: root.stock.stockPriceChanged < 0 ? "#A43D3D" : "#679B3A"
+ font.pointSize:25
+ text: root.stock.stockPriceChanged + " (" + Math.abs(Math.round(root.stock.stockPriceChanged/(root.stock.stockPrice - root.stock.stockPriceChanged) * 100))/100 +"%)"
+ }
+
+ StockChart {
+ id:chart
+ anchors.bottom: parent.bottom
+ anchors.top : priceChange.bottom
+ anchors.topMargin: 30
+ width:parent.width
+ stockModel:root.stock
+ settings:root.settings
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png b/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
new file mode 100644
index 0000000000..c5164d5183
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-calendar-anim.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-calendar.png b/examples/quick/demos/stocqt/content/images/icon-calendar.png
new file mode 100644
index 0000000000..bd2857470b
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-calendar.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-items.png b/examples/quick/demos/stocqt/content/images/icon-items.png
new file mode 100644
index 0000000000..f951aa5009
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-items.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/icon-settings.png b/examples/quick/demos/stocqt/content/images/icon-settings.png
new file mode 100644
index 0000000000..222d998289
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/icon-settings.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/logo.png b/examples/quick/demos/stocqt/content/images/logo.png
new file mode 100644
index 0000000000..90c7c3ba3d
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/logo.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/stock-selected.png b/examples/quick/demos/stocqt/content/images/stock-selected.png
new file mode 100644
index 0000000000..5629796b9c
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/stock-selected.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel-touch.png b/examples/quick/demos/stocqt/content/images/wheel-touch.png
new file mode 100644
index 0000000000..11c8120ada
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/wheel-touch.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/content/images/wheel.png b/examples/quick/demos/stocqt/content/images/wheel.png
new file mode 100644
index 0000000000..470a675b35
--- /dev/null
+++ b/examples/quick/demos/stocqt/content/images/wheel.png
Binary files differ
diff --git a/examples/quick/demos/stocqt/main.cpp b/examples/quick/demos/stocqt/main.cpp
new file mode 100644
index 0000000000..779d204a24
--- /dev/null
+++ b/examples/quick/demos/stocqt/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(stocqt)
diff --git a/examples/quick/demos/stocqt/stocqt.pro b/examples/quick/demos/stocqt/stocqt.pro
new file mode 100644
index 0000000000..f33c4aee01
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += qml quick
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
+qml.files = stocqt.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/stocqt
+INSTALLS += target qml
diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml
new file mode 100644
index 0000000000..3f8a84a810
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.qml
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "./content"
+
+ListView {
+ id:root
+ width:320
+ height:480
+ snapMode:ListView.SnapOneItem
+ focus:false
+ orientation : ListView.Horizontal
+ boundsBehavior : Flickable.StopAtBounds
+ currentIndex : 1
+
+ StockModel {
+ id:stock
+ stockId:listView.currentStockId
+ stockName: listView.currentStockName
+ startDate: settings.startDate
+ endDate:settings.endDate
+ onStockIdChanged: updateStock()
+ onStartDateChanged: updateStock()
+ onEndDateChanged: updateStock()
+ onDataReady: {
+ root.currentIndex = 1
+ stockView.update()
+ }
+ }
+
+ model: VisualItemModel {
+ StockListView {
+ id:listView
+ width:root.width
+ height:root.height
+ }
+
+ StockView {
+ id:stockView
+ width:root.width
+ height:root.height
+ stocklist : listView
+ settings : settings
+ stock: stock
+
+ onListViewClicked:root.currentIndex = 0
+ onSettingsClicked:root.currentIndex = 2
+ }
+
+ StockSettings {
+ id:settings
+ width:root.width
+ height:root.height
+ onDrawHighPriceChanged: stockView.update()
+ onDrawLowPriceChanged: stockView.update()
+ onDrawOpenPriceChanged: stockView.update()
+ onDrawClosePriceChanged: stockView.update()
+ onDrawVolumeChanged: stockView.update()
+ onDrawKLineChanged: stockView.update()
+ onChartTypeChanged: stockView.update()
+ }
+ }
+}
diff --git a/examples/quick/demos/stocqt/stocqt.qmlproject b/examples/quick/demos/stocqt/stocqt.qmlproject
new file mode 100644
index 0000000000..11ab78418a
--- /dev/null
+++ b/examples/quick/demos/stocqt/stocqt.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "stocqt.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/FlipBar.qml b/examples/quick/demos/tweetsearch/content/FlipBar.qml
new file mode 100644
index 0000000000..06aebcacb1
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/FlipBar.qml
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+ property int animDuration: 300
+ property Item front: Item {}
+ property Item back: Item {}
+ property real factor: 0.1 // amount the edges fold in for the 3D effect
+ property alias delta: effect.delta
+ property Item cur: frontShown ? front : back
+ property Item noncur: frontShown ? back : front
+
+ function swap() {
+ var tmp = front;
+ front = back;
+ back = tmp;
+ resync();
+ }
+
+ width: cur.width
+ height: cur.height
+ onFrontChanged: resync();
+ onBackChanged: resync();
+
+ function resync() {//TODO: Are the items ever actually visible?
+ back.parent = container;
+ front.parent = container;
+ frontShown ? back.visible = false : front.visible = false;
+ }
+
+ property bool frontShown: true
+
+ onFrontShownChanged: {
+ back.visible = !frontShown
+ front.visible = frontShown
+ }
+
+ function flipUp(start) {
+ effect.visible = true;
+ effect.sourceA = effect.source1
+ effect.sourceB = effect.source2
+ if (start == undefined)
+ start = 1.0;
+ deltaAnim.from = start;
+ deltaAnim.to = 0.0
+ dAnim.start();
+ frontShown = false;
+ }
+
+ function flipDown(start) {
+ effect.visible = true;
+ effect.sourceA = effect.source1
+ effect.sourceB = effect.source2
+ if (start == undefined)
+ start = 0.0;
+ deltaAnim.from = start;
+ deltaAnim.to = 1.0
+ dAnim.start();
+ frontShown = true;
+ }
+
+ ShaderEffect {
+ id: effect
+ width: cur.width
+ height: cur.height
+ property real factor: container.factor * width
+ property real delta: 1.0
+
+ mesh: GridMesh { resolution: Qt.size(8,2) }
+
+ SequentialAnimation on delta {
+ id: dAnim
+ running: false
+ NumberAnimation {
+ id: deltaAnim
+ duration: animDuration//expose anim
+ }
+ }
+
+ property variant sourceA: source1
+ property variant sourceB: source1
+ property variant source1: ShaderEffectSource {
+ sourceItem: front
+ hideSource: effect.visible
+ }
+
+ property variant source2: ShaderEffectSource {
+ sourceItem: back
+ hideSource: effect.visible
+ }
+
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D sourceA;
+ uniform sampler2D sourceB;
+ uniform highp float delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ highp vec4 tex = vec4(qt_TexCoord0.x, qt_TexCoord0.y * 2.0, qt_TexCoord0.x, (qt_TexCoord0.y-0.5) * 2.0);
+ highp float shade = clamp(delta*2.0, 0.5, 1.0);
+ highp vec4 col;
+ if (qt_TexCoord0.y < 0.5) {
+ col = texture2D(sourceA, tex.xy) * (shade);
+ } else {
+ col = texture2D(sourceB, tex.zw) * (1.5 - shade);
+ col.w = 1.0;
+ }
+ gl_FragColor = col * qt_Opacity;
+ }
+ "
+ property real h: height
+ vertexShader: "
+ uniform highp float delta;
+ uniform highp float factor;
+ uniform highp float h;
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ highp vec4 pos = qt_Vertex;
+ if (qt_MultiTexCoord0.y == 0.0)
+ pos.x += factor * (1. - delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
+ else if (qt_MultiTexCoord0.y == 1.0)
+ pos.x += factor * (delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
+ else
+ pos.y = delta * h;
+ gl_Position = qt_Matrix * pos;
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ }"
+
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/LineInput.qml b/examples/quick/demos/tweetsearch/content/LineInput.qml
new file mode 100644
index 0000000000..368293e961
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/LineInput.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: wrapper
+
+ property alias text: input.text
+ property alias hint: hint.text
+ property alias prefix: prefix.text
+
+ signal accepted
+
+ Rectangle {
+ anchors.fill: parent
+ border.color: "#707070"
+ color: "#c1c1c1"
+ radius: 4
+
+ Text {
+ id: hint
+ anchors { fill: parent; leftMargin: 14 }
+ verticalAlignment: Text.AlignVCenter
+ text: "Enter word"
+ font.pixelSize: 18
+ color: "#707070"
+ opacity: input.length ? 0 : 1
+ }
+
+ Text {
+ id: prefix
+ anchors { left: parent.left; leftMargin: 14; verticalCenter: parent.verticalCenter }
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 18
+ color: "#707070"
+ opacity: !hint.opacity
+ }
+
+ TextInput {
+ id: input
+ focus: true
+ anchors { left: prefix.right; right: parent.right; top: parent.top; bottom: parent.bottom }
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 18
+ color: "#707070"
+ onAccepted: wrapper.accepted()
+ }
+
+ Image {
+ source: "resources/icon-search.png"
+ anchors.right: parent.right
+ anchors.rightMargin: 12
+ anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors { fill: parent; margins: -10 }
+ onClicked: wrapper.accepted()
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/ListFooter.qml b/examples/quick/demos/tweetsearch/content/ListFooter.qml
new file mode 100644
index 0000000000..91c1c8b331
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/ListFooter.qml
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "#d6d6d6"
+ width: parent.width
+ height: childrenRect.height
+ z: 2
+ Connections {
+ target: mainListView
+ onAutoSearch: {
+ if (type == 'tag') {
+ tagSearch.open()
+ tagSearch.searchText = str
+ } else if (type == 'user'){
+ userSearch.open()
+ userSearch.searchText = str
+ } else {
+ wordSearch.open()
+ wordSearch.searchText = str
+ }
+ }
+ }
+
+ Column {
+ width: parent.width
+
+ SearchDelegate {
+ id: wordSearch
+ label: "Search word..."
+ placeHolder: "Enter word"
+ onHasOpened: {
+ tagSearch.close()
+ userSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.from = ""
+ tweetsModel.phrase = searchText
+ }
+ }
+
+ SearchDelegate {
+ id: userSearch
+ label: "From user..."
+ placeHolder: "@username"
+ prefix: "@"
+ onHasOpened:{
+ tagSearch.close()
+ wordSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.phrase = ""
+ tweetsModel.from = searchText
+ }
+ }
+
+ SearchDelegate {
+ id: tagSearch
+ label: "Search hashtag..."
+ placeHolder: "#hashtag"
+ prefix: "#"
+ onHasOpened:{
+ userSearch.close()
+ wordSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.from = ""
+ tweetsModel.phrase = "#" + searchText
+ }
+ }
+
+ SpriteSequence {
+ id: sprite
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: 320
+ height: 300
+ running: true
+ interpolate: false
+ Sprite {
+ name: "bird"
+ source: "resources/bird-anim-sprites.png"
+ frameCount: 1
+ frameRate: 1
+ frameWidth: 320
+ frameHeight: 300
+ to: { "bird":10, "trill":1, "blink":1 }
+ }
+ Sprite {
+ name: "trill"
+ source: "resources/bird-anim-sprites.png"
+ frameCount: 5
+ frameRate: 3
+ frameWidth: 320
+ frameHeight: 300
+ to: {"bird":1}
+ }
+ Sprite {
+ name: "blink"
+ source: "resources/bird-anim-sprites.png"
+ frameCount: 1
+ frameRate: 3
+ frameWidth: 320
+ frameHeight: 300
+ frameX: 1600
+ to: {"bird":1}
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/ListHeader.qml b/examples/quick/demos/tweetsearch/content/ListHeader.qml
new file mode 100644
index 0000000000..2fb673dc7c
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/ListHeader.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ height: 60
+ width: parent.width
+
+ property bool refresh: state == "pulled" ? true : false
+
+ Row {
+ spacing: 6
+ height: childrenRect.height
+ anchors.centerIn: parent
+
+ Image {
+ id: arrow
+ source: "resources/icon-refresh.png"
+ transformOrigin: Item.Center
+ Behavior on rotation { NumberAnimation { duration: 200 } }
+ }
+
+ Text {
+ id: label
+ anchors.verticalCenter: arrow.verticalCenter
+ text: "Pull to refresh... "
+ font.pixelSize: 18
+ color: "#999999"
+ }
+ }
+
+ states: [
+ State {
+ name: "base"; when: mainListView.contentY >= -120
+ PropertyChanges { target: arrow; rotation: 180 }
+ },
+ State {
+ name: "pulled"; when: mainListView.contentY < -120
+ PropertyChanges { target: label; text: "Release to refresh..." }
+ PropertyChanges { target: arrow; rotation: 0 }
+ }
+ ]
+}
diff --git a/examples/quick/demos/tweetsearch/content/SearchDelegate.qml b/examples/quick/demos/tweetsearch/content/SearchDelegate.qml
new file mode 100644
index 0000000000..fc0ee0b655
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/SearchDelegate.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FlipBar {
+ id: flipBar
+ animDuration: 250
+ property string label: ""
+ property string placeHolder: ""
+ property alias searchText: lineInput.text
+ property alias prefix: lineInput.prefix
+ property bool opened: false
+ signal ok
+ signal hasOpened
+
+ height: 60
+ width: parent.width
+
+ function open() {
+ flipBar.flipUp()
+ flipBar.opened = true
+ lineInput.forceActiveFocus()
+ flipBar.hasOpened()
+ }
+
+ function close() {
+ if (opened) {
+ flipBar.flipDown()
+ flipBar.opened = false
+ }
+ }
+
+ front: Rectangle {
+ height: 60
+ width: parent.width
+ color: "#999999"
+
+ Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
+ Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (!flipBar.opened)
+ open()
+ else if (!lineInput.activeFocus)
+ lineInput.forceActiveFocus()
+ else
+ close()
+ }
+ }
+
+ Text {
+ text: flipBar.label
+ anchors { left: parent.left; leftMargin: 20 }
+ anchors.verticalCenter: parent.verticalCenter
+ font.pixelSize: 18
+ color: "#ffffff"
+ }
+ }
+
+ back: FocusScope {
+ height: 60
+ width: parent.width
+ Rectangle {
+ anchors.fill: parent
+ color: "#999999"
+
+ Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
+ Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ LineInput {
+ id: lineInput
+ hint: flipBar.placeHolder
+ focus: flipBar.opened
+ anchors { fill: parent; margins: 6 }
+ onAccepted: flipBar.ok()
+ }
+ }
+ }
+
+}
diff --git a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
new file mode 100644
index 0000000000..c336ae6f8a
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "tweetsearch.js" as Helper
+
+Item {
+ id: container
+ property real hm: 1.0
+ property int appear: -1
+ property real startRotation: 1
+
+ onAppearChanged: {
+ container.startRotation = 0.5
+ flipBar.animDuration = appear;
+ delayedAnim.start();
+ }
+
+ SequentialAnimation {
+ id: delayedAnim
+ PauseAnimation { duration: 50 }
+ ScriptAction { script: flipBar.flipDown(startRotation); }
+ }
+
+ width: 320
+ height: flipBar.height * hm
+
+ FlipBar {
+ id: flipBar
+
+ property bool flipped: false
+ delta: startRotation
+
+ anchors.bottom: parent.bottom
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+
+ front: Rectangle {
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+ color: "#2699bf"
+
+ Rectangle { color: "#33ccff"; width: parent.width; height: 1 }
+ Rectangle { color: "#1a6680"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ Image {
+ id: placeHolder
+ source: "resources/anonymous.png"
+ x: 10; y: 9
+ visible: avatar.status != Image.Ready
+ }
+
+ Image {
+ id: avatar
+ source: model.userImage
+ anchors.fill: placeHolder
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ flipBar.flipUp()
+ flipBar.flipped = true
+ }
+ }
+ }
+
+ Text {
+ id: name
+ text: Helper.realName(model.name)
+ anchors { left: avatar.right; leftMargin: 10; top: avatar.top; topMargin: -3 }
+ font.pixelSize: 12
+ font.bold: true
+ color: "white"
+ linkColor: "white"
+ }
+
+ Text {
+ id: tweet
+ text: model.statusText
+ anchors { left: avatar.right; leftMargin: 10; top: name.bottom; topMargin: 0; right: parent.right; rightMargin: 10 }
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ font.bold: false
+ color: "#adebff"
+ linkColor: "white"
+ onLinkActivated: {
+ var tag = link.split("http://search.twitter.com/search?q=%23")
+ var user = link.split("https://twitter.com/")
+ if (tag[1] != undefined) {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ mainListView.autoSearch('tag', tag[1])
+ tweetsModel.from = ""
+ tweetsModel.phrase = "#" + tag[1]
+ } else if (user[1] != undefined) {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ mainListView.autoSearch('user', user[1])
+ tweetsModel.phrase = ""
+ tweetsModel.from = user[1]
+ } else
+ Qt.openUrlExternally(link)
+ }
+ }
+ }
+
+ back: Rectangle {
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+ color: "#be4a25"
+
+ Rectangle { color: "#ff6633"; width: parent.width; height: 1 }
+ Rectangle { color: "#80341a"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ Image {
+ id: avatar2
+ source: model.userImage
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ y: 9
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ flipBar.flipDown()
+ flipBar.flipped = false
+ }
+ }
+ }
+
+ Text {
+ id: username
+ text: Helper.twitterName(model.name)
+ x: 10; anchors { top: avatar2.top; topMargin: -3 }
+ font.pixelSize: 12
+ font.bold: true
+ color: "white"
+ linkColor: "white"
+ }
+
+ Text {
+ text: model.source + "<br>" + Helper.formatDate(model.published) + "<br>" + model.uri
+ x: 10; anchors { top: username.bottom; topMargin: 0 }
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ font.bold: false
+ color: "#ffc2ad"
+ linkColor: "white"
+ onLinkActivated: Qt.openUrlExternally(link);
+ }
+ }
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/TweetsModel.qml b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
new file mode 100644
index 0000000000..df6ecdcd7f
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/TweetsModel.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Item {
+ id: wrapper
+
+ property variant model: xmlModel
+ property string from : ""
+ property string phrase : ""
+
+ property string mode : "everyone"
+ property int status: xmlModel.status
+
+ function reload() { xmlModel.reload(); }
+
+ property bool isLoading: status == XmlListModel.Loading
+ property bool wasLoading: false
+ signal isLoaded
+
+ XmlListModel {
+ id: xmlModel
+
+ onStatusChanged: {
+ if (status == XmlListModel.Ready && wasLoading == true)
+ wrapper.isLoaded()
+ if (status == XmlListModel.Loading)
+ wasLoading = true;
+ else
+ wasLoading = false;
+ }
+
+ function encodePhrase(x) { return encodeURIComponent(x); }
+
+ source: (from == "" && phrase == "") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&rpp=10&phrase="+encodePhrase(phrase)
+
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "id"; query: "id/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "published"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "uri"; query: "author/uri/string()" }
+ XmlRole { name: "image"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/content/resources/anonymous.png b/examples/quick/demos/tweetsearch/content/resources/anonymous.png
new file mode 100644
index 0000000000..88fba26e90
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/anonymous.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png b/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png
new file mode 100644
index 0000000000..4e8d7e6116
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-clear.png b/examples/quick/demos/tweetsearch/content/resources/icon-clear.png
new file mode 100644
index 0000000000..75672f64c7
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/icon-clear.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-loading.png b/examples/quick/demos/tweetsearch/content/resources/icon-loading.png
new file mode 100644
index 0000000000..8dbff8b70f
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/icon-loading.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png b/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png
new file mode 100644
index 0000000000..b639a638fe
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-search.png b/examples/quick/demos/tweetsearch/content/resources/icon-search.png
new file mode 100644
index 0000000000..e41935a6c1
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/resources/icon-search.png
Binary files differ
diff --git a/examples/quick/demos/tweetsearch/content/tweetsearch.js b/examples/quick/demos/tweetsearch/content/tweetsearch.js
new file mode 100644
index 0000000000..9b8638f69e
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/content/tweetsearch.js
@@ -0,0 +1,19 @@
+.pragma library
+
+function twitterName(str)
+{
+ var s = str.split("(")
+ return s[0]
+}
+
+function realName(str)
+{
+ var s = str.split("(")
+ return s[1].substring(0, s[1].length-1)
+}
+
+function formatDate(date)
+{
+ var da = new Date(date)
+ return da.toDateString()
+}
diff --git a/examples/quick/demos/tweetsearch/main.cpp b/examples/quick/demos/tweetsearch/main.cpp
new file mode 100644
index 0000000000..8b1d59679c
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(tweetsearch)
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.pro b/examples/quick/demos/tweetsearch/tweetsearch.pro
new file mode 100644
index 0000000000..887c05af88
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/tweetsearch.pro
@@ -0,0 +1,9 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch
+qml.files = tweetsearch.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch
+INSTALLS += target qml
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qml b/examples/quick/demos/tweetsearch/tweetsearch.qml
new file mode 100644
index 0000000000..961ffce36b
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/tweetsearch.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: main
+ width: 320
+ height: 480
+ color: "#d6d6d6"
+
+ property string searchTerms: ""
+ property int inAnimDur: 250
+ property int counter: 0
+ property alias isLoading: tweetsModel.isLoading
+ property var idx
+ property var ids
+
+ Component.onCompleted: ids = new Array()
+
+ function idInModel(id)
+ {
+ for (var j = 0; j < ids.length; j++)
+ if (ids[j] === id)
+ return 1
+ return 0
+ }
+
+ TweetsModel {
+ id: tweetsModel
+ onIsLoaded: {
+ console.debug("Reload")
+ idx = new Array()
+ for (var i = 0; i < tweetsModel.model.count; i++) {
+ var id = tweetsModel.model.get(i).id
+ if (!idInModel(id))
+ idx.push(i)
+ }
+ console.debug(idx.length + " new tweets")
+ main.counter = idx.length
+ }
+ }
+
+ Timer {
+ id: timer
+ interval: 500; running: main.counter; repeat: true
+ onTriggered: {
+ main.counter--;
+ var id = tweetsModel.model.get(idx[main.counter]).id
+ mainListView.add( { "statusText": tweetsModel.model.get(main.counter).content,
+ "name": tweetsModel.model.get(main.counter).name,
+ "userImage": tweetsModel.model.get(main.counter).image,
+ "source": tweetsModel.model.get(main.counter).source,
+ "id": id,
+ "uri": tweetsModel.model.get(main.counter).uri,
+ "published": tweetsModel.model.get(main.counter).published } );
+ ids.push(id)
+ }
+ }
+
+ ListView {
+ id: mainListView
+ anchors.fill: parent
+ delegate: TweetDelegate { }
+ model: ListModel { id: finalModel }
+
+ add: Transition {
+ NumberAnimation { property: "hm"; from: 0; to: 1.0; duration: 300; easing.type: Easing.OutQuad }
+ PropertyAction { property: "appear"; value: 250 }
+ }
+
+ onDragEnded: if (header.refresh) { tweetsModel.model.reload() }
+
+ ListHeader {
+ id: header
+ y: -mainListView.contentY - height
+ }
+
+ footer: ListFooter { }
+
+ function clear() {
+ ids = new Array()
+ model.clear()
+ }
+
+ function add(obj) {
+ model.insert(0, obj)
+ }
+
+ signal autoSearch(string type, string str) // To communicate with Footer instance
+ }
+}
diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qmlproject b/examples/quick/demos/tweetsearch/tweetsearch.qmlproject
new file mode 100644
index 0000000000..5a0f31117b
--- /dev/null
+++ b/examples/quick/demos/tweetsearch/tweetsearch.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "tweetsearch.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}