From 3978b7d5064e12c413b0938b5ebe7b3fe0e00c87 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Thu, 3 Mar 2011 16:27:38 +0100 Subject: Added 4 mobile demos. Added links and descriptions for them. Reviewed-by: David Boddie --- demos/demos.pro | 12 +- demos/mobile/guitartuner/guitartuner.pro | 89 + demos/mobile/guitartuner/guitartuner.pro.user | 558 ++++++ demos/mobile/guitartuner/guitartuner.qrc | 75 + demos/mobile/guitartuner/images/guitartab.svg | 174 ++ .../mobile/guitartuner/images/guitartuner_icon.svg | 247 +++ demos/mobile/guitartuner/images/inputMode.svg | 161 ++ demos/mobile/guitartuner/images/note.svg | 101 ++ demos/mobile/guitartuner/images/noteNo.svg | 105 ++ demos/mobile/guitartuner/src/application.qml | 321 ++++ demos/mobile/guitartuner/src/constants.h | 47 + .../guitartuner/src/fastfouriertransformer.cpp | 177 ++ .../guitartuner/src/fastfouriertransformer.h | 60 + demos/mobile/guitartuner/src/fftpack.c | 1399 +++++++++++++++ demos/mobile/guitartuner/src/guitartuner.cpp | 352 ++++ demos/mobile/guitartuner/src/guitartuner.h | 88 + demos/mobile/guitartuner/src/guitartuner.rc | 23 + demos/mobile/guitartuner/src/guitartuner.ui | 178 ++ demos/mobile/guitartuner/src/guitartunerui.cpp | 334 ++++ demos/mobile/guitartuner/src/guitartunerui.h | 104 ++ demos/mobile/guitartuner/src/guitartunerui.ui | 178 ++ demos/mobile/guitartuner/src/main.cpp | 53 + .../guitartuner/src/mycomponents/adjustbars.js | 82 + .../guitartuner/src/mycomponents/adjuster.qml | 124 ++ .../guitartuner/src/mycomponents/images/big_a.png | Bin 0 -> 575 bytes .../guitartuner/src/mycomponents/images/big_b.png | Bin 0 -> 599 bytes .../guitartuner/src/mycomponents/images/big_d.png | Bin 0 -> 465 bytes .../guitartuner/src/mycomponents/images/big_e.png | Bin 0 -> 327 bytes .../guitartuner/src/mycomponents/images/big_g.png | Bin 0 -> 610 bytes .../src/mycomponents/images/glowing_a.png | Bin 0 -> 2978 bytes .../src/mycomponents/images/glowing_b.png | Bin 0 -> 3084 bytes .../src/mycomponents/images/glowing_d.png | Bin 0 -> 2940 bytes .../src/mycomponents/images/glowing_e.png | Bin 0 -> 2696 bytes .../src/mycomponents/images/glowing_g.png | Bin 0 -> 3046 bytes .../src/mycomponents/images/guitartuner_malli.png | Bin 0 -> 143243 bytes .../src/mycomponents/images/guitartuner_skin.png | Bin 0 -> 129068 bytes .../src/mycomponents/images/lcdFrame.png | Bin 0 -> 176107 bytes .../src/mycomponents/images/meterBG.png | Bin 0 -> 8378 bytes .../guitartuner/src/mycomponents/images/mute.png | Bin 0 -> 3630 bytes .../src/mycomponents/images/pointer.png | Bin 0 -> 965 bytes .../src/mycomponents/images/pointerShadow.png | Bin 0 -> 1694 bytes .../guitartuner/src/mycomponents/images/power.png | Bin 0 -> 3190 bytes .../guitartuner/src/mycomponents/images/quit.png | Bin 0 -> 1363 bytes .../src/mycomponents/images/sensitivity.png | Bin 0 -> 835 bytes .../src/mycomponents/images/tuner_a.png | Bin 0 -> 3233 bytes .../src/mycomponents/images/tuner_a_on.png | Bin 0 -> 3068 bytes .../src/mycomponents/images/tuner_auto.png | Bin 0 -> 3619 bytes .../src/mycomponents/images/tuner_auto_on.png | Bin 0 -> 3281 bytes .../src/mycomponents/images/tuner_b.png | Bin 0 -> 3324 bytes .../src/mycomponents/images/tuner_b_on.png | Bin 0 -> 3132 bytes .../src/mycomponents/images/tuner_d.png | Bin 0 -> 3266 bytes .../src/mycomponents/images/tuner_d_on.png | Bin 0 -> 3009 bytes .../src/mycomponents/images/tuner_e.png | Bin 0 -> 3171 bytes .../src/mycomponents/images/tuner_e_on.png | Bin 0 -> 2955 bytes .../src/mycomponents/images/tuner_g.png | Bin 0 -> 3292 bytes .../src/mycomponents/images/tuner_g_on.png | Bin 0 -> 3089 bytes .../src/mycomponents/images/voicemode_off.png | Bin 0 -> 3775 bytes .../src/mycomponents/images/voicemode_on.png | Bin 0 -> 3484 bytes .../guitartuner/src/mycomponents/images/volume.png | Bin 0 -> 351 bytes .../src/mycomponents/images/volume_off.png | Bin 0 -> 2235 bytes .../mobile/guitartuner/src/mycomponents/meter.qml | 105 ++ .../src/mycomponents/notebuttonview.qml | 77 + .../guitartuner/src/mycomponents/notesmodel.qml | 102 ++ demos/mobile/guitartuner/src/mycomponents/qmldir | 44 + .../guitartuner/src/mycomponents/togglebutton.qml | 103 ++ demos/mobile/guitartuner/src/voiceanalyzer.cpp | 288 ++++ demos/mobile/guitartuner/src/voiceanalyzer.h | 86 + demos/mobile/guitartuner/src/voicegenerator.cpp | 239 +++ demos/mobile/guitartuner/src/voicegenerator.h | 79 + demos/mobile/guitartuner/ui_guitartunerui.h | 181 ++ demos/mobile/qcamera/businesscardhandling.cpp | 145 ++ demos/mobile/qcamera/businesscardhandling.h | 80 + demos/mobile/qcamera/button.cpp | 107 ++ demos/mobile/qcamera/button.h | 69 + demos/mobile/qcamera/cameraexample.cpp | 514 ++++++ demos/mobile/qcamera/cameraexample.h | 154 ++ demos/mobile/qcamera/contactsdlg.cpp | 156 ++ demos/mobile/qcamera/contactsdlg.h | 47 + demos/mobile/qcamera/icons/camera.png | Bin 0 -> 15868 bytes demos/mobile/qcamera/icons/cameramms_icon.svg | 255 +++ demos/mobile/qcamera/icons/exit.png | Bin 0 -> 14026 bytes demos/mobile/qcamera/icons/mms.png | Bin 0 -> 12281 bytes demos/mobile/qcamera/main.cpp | 124 ++ demos/mobile/qcamera/messagehandling.cpp | 180 ++ demos/mobile/qcamera/messagehandling.h | 89 + demos/mobile/qcamera/qcamera.pro | 62 + demos/mobile/qcamera/qcamera.pro.user | 582 +++++++ demos/mobile/qcamera/resources.qrc | 7 + demos/mobile/qtbubblelevel/accelerometerfilter.cpp | 78 + demos/mobile/qtbubblelevel/accelerometerfilter.h | 62 + demos/mobile/qtbubblelevel/debian/changelog | 19 + demos/mobile/qtbubblelevel/debian/compat | 1 + demos/mobile/qtbubblelevel/debian/control | 12 + demos/mobile/qtbubblelevel/debian/copyright | 36 + demos/mobile/qtbubblelevel/debian/dirs | 2 + demos/mobile/qtbubblelevel/debian/files | 1 + demos/mobile/qtbubblelevel/debian/postinst | 5 + demos/mobile/qtbubblelevel/debian/rules | 91 + .../qtbubblelevel/icons/26x26/qtbubblelevel.png | Bin 0 -> 1113 bytes .../qtbubblelevel/icons/40x40/qtbubblelevel.png | Bin 0 -> 2048 bytes .../qtbubblelevel/icons/64x64/qtbubblelevel.png | Bin 0 -> 4154 bytes demos/mobile/qtbubblelevel/icons/bubblelevel.svg | 264 +++ demos/mobile/qtbubblelevel/icons/qtbl_icon.png | Bin 0 -> 11181 bytes .../qtbubblelevel/icons/xpm/qtbubblelevel.xpm | 1783 ++++++++++++++++++++ demos/mobile/qtbubblelevel/main.cpp | 128 ++ demos/mobile/qtbubblelevel/qml/BubbleLevel.qml | 218 +++ demos/mobile/qtbubblelevel/qml/Button.qml | 64 + demos/mobile/qtbubblelevel/qml/Tube.qml | 79 + demos/mobile/qtbubblelevel/qml/images/board.png | Bin 0 -> 520721 bytes demos/mobile/qtbubblelevel/qml/images/bubble.png | Bin 0 -> 4951 bytes .../qtbubblelevel/qml/images/calibbutton.png | Bin 0 -> 4881 bytes demos/mobile/qtbubblelevel/qml/images/exit.png | Bin 0 -> 2308 bytes .../mobile/qtbubblelevel/qml/images/reflection.png | Bin 0 -> 1306 bytes demos/mobile/qtbubblelevel/qml/images/scale.png | Bin 0 -> 271 bytes .../mobile/qtbubblelevel/qml/images/signblank.png | Bin 0 -> 41230 bytes .../qtbubblelevel/qml/images/signwithtext.png | Bin 0 -> 47648 bytes .../qtbubblelevel/qml/images/taskswitcher.png | Bin 0 -> 767 bytes demos/mobile/qtbubblelevel/qtbubblelevel.desktop | 12 + demos/mobile/qtbubblelevel/qtbubblelevel.pro | 61 + demos/mobile/qtbubblelevel/qtbubblelevel.pro.user | 382 +++++ demos/mobile/qtbubblelevel/qtbubblelevel.zip | Bin 0 -> 1283530 bytes demos/mobile/qtbubblelevel/resources.qrc | 16 + demos/mobile/qtbubblelevel/settings.h | 59 + demos/mobile/qtbubblelevel/taskswitcher.cpp | 25 + demos/mobile/qtbubblelevel/taskswitcher.h | 47 + demos/mobile/quickhit/Game.js | 173 ++ demos/mobile/quickhit/InvSounds.cpp | 182 ++ demos/mobile/quickhit/InvSounds.h | 84 + demos/mobile/quickhit/QuickHit.pro.user | 382 +++++ demos/mobile/quickhit/button.qml | 79 + demos/mobile/quickhit/debian/changelog | 11 + demos/mobile/quickhit/debian/compat | 1 + demos/mobile/quickhit/debian/control | 11 + demos/mobile/quickhit/debian/copyright | 8 + demos/mobile/quickhit/debian/dirs | 2 + demos/mobile/quickhit/debian/postinst | 5 + demos/mobile/quickhit/debian/rules | 91 + demos/mobile/quickhit/freesound.org.licence.txt | 24 + demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp | 383 +++++ demos/mobile/quickhit/ga_src/GEAudioBuffer.h | 130 ++ demos/mobile/quickhit/ga_src/GEAudioOut.cpp | 137 ++ demos/mobile/quickhit/ga_src/GEAudioOut.h | 82 + demos/mobile/quickhit/ga_src/GEInterfaces.cpp | 170 ++ demos/mobile/quickhit/ga_src/GEInterfaces.h | 81 + demos/mobile/quickhit/game.qml | 432 +++++ demos/mobile/quickhit/gameengine.cpp | 585 +++++++ demos/mobile/quickhit/gameengine.h | 141 ++ demos/mobile/quickhit/gfx/back.png | Bin 0 -> 2234 bytes demos/mobile/quickhit/gfx/background2.png | Bin 0 -> 113110 bytes demos/mobile/quickhit/gfx/bigship.png | Bin 0 -> 98253 bytes demos/mobile/quickhit/gfx/exit.png | Bin 0 -> 2810 bytes demos/mobile/quickhit/gfx/pause.png | Bin 0 -> 1986 bytes demos/mobile/quickhit/gfx/quickhit_logo.png | Bin 0 -> 8974 bytes demos/mobile/quickhit/gfx/soundOff.png | Bin 0 -> 3122 bytes demos/mobile/quickhit/gfx/soundOn.png | Bin 0 -> 2420 bytes demos/mobile/quickhit/icon.svg | 305 ++++ demos/mobile/quickhit/main.cpp | 94 ++ demos/mobile/quickhit/mainwindow.cpp | 241 +++ demos/mobile/quickhit/mainwindow.h | 78 + demos/mobile/quickhit/menu.qml | 156 ++ demos/mobile/quickhit/menuitem.qml | 96 ++ demos/mobile/quickhit/message.qml | 140 ++ demos/mobile/quickhit/missile.qml | 136 ++ demos/mobile/quickhit/myeventfilter.cpp | 60 + demos/mobile/quickhit/myeventfilter.h | 56 + demos/mobile/quickhit/myship.qml | 177 ++ demos/mobile/quickhit/plugins/LevelOne/Level.qml | 207 +++ .../quickhit/plugins/LevelOne/debian/changelog | 11 + .../mobile/quickhit/plugins/LevelOne/debian/compat | 1 + .../quickhit/plugins/LevelOne/debian/control | 11 + .../quickhit/plugins/LevelOne/debian/copyright | 8 + demos/mobile/quickhit/plugins/LevelOne/debian/dirs | 2 + .../quickhit/plugins/LevelOne/debian/postinst | 5 + .../mobile/quickhit/plugins/LevelOne/debian/rules | 91 + .../quickhit/plugins/LevelOne/gfx/background3.png | Bin 0 -> 113110 bytes .../quickhit/plugins/LevelOne/gfx/enemy1.png | Bin 0 -> 4508 bytes .../quickhit/plugins/LevelOne/gfx/enemy2.png | Bin 0 -> 4344 bytes .../plugins/LevelOne/gfx/enemy_missile2.png | Bin 0 -> 452 bytes .../mobile/quickhit/plugins/LevelOne/gfx/fire.png | Bin 0 -> 1036 bytes .../mobile/quickhit/plugins/LevelOne/gfx/fire2.png | Bin 0 -> 2558 bytes .../quickhit/plugins/LevelOne/gfx/missile2.png | Bin 0 -> 392 bytes .../quickhit/plugins/LevelOne/gfx/red_fire.png | Bin 0 -> 4737 bytes .../mobile/quickhit/plugins/LevelOne/gfx/ship.png | Bin 0 -> 5408 bytes .../mobile/quickhit/plugins/LevelOne/gfx/star3.png | Bin 0 -> 409 bytes .../quickhit/plugins/LevelOne/gfx/transparent.png | Bin 0 -> 1000 bytes .../mobile/quickhit/plugins/LevelOne/levelone.cpp | 113 ++ demos/mobile/quickhit/plugins/LevelOne/levelone.h | 84 + .../mobile/quickhit/plugins/LevelOne/levelone.pro | 100 ++ .../quickhit/plugins/LevelOne/sound/crash.wav | Bin 0 -> 963020 bytes .../plugins/LevelOne/sound/levelonestart.wav | Bin 0 -> 500528 bytes .../quickhit/plugins/LevelOne/sound/rocket.wav | Bin 0 -> 41336 bytes .../plugins/LevelOne/sound/rocket_explosion.wav | Bin 0 -> 289420 bytes .../plugins/LevelTemplate/debian/changelog | 11 + .../quickhit/plugins/LevelTemplate/debian/compat | 1 + .../quickhit/plugins/LevelTemplate/debian/control | 11 + .../plugins/LevelTemplate/debian/copyright | 8 + .../quickhit/plugins/LevelTemplate/debian/dirs | 2 + .../plugins/LevelTemplate/debian/levelone.tarlist | 41 + .../quickhit/plugins/LevelTemplate/debian/postinst | 5 + .../quickhit/plugins/LevelTemplate/debian/rules | 91 + .../plugins/LevelTemplate/gfx/blue_fire.png | Bin 0 -> 38263 bytes .../quickhit/plugins/LevelTemplate/gfx/enemy1.png | Bin 0 -> 4508 bytes .../quickhit/plugins/LevelTemplate/gfx/enemy2.png | Bin 0 -> 4344 bytes .../plugins/LevelTemplate/gfx/enemy_missile2.png | Bin 0 -> 452 bytes .../plugins/LevelTemplate/gfx/missile2.png | Bin 0 -> 392 bytes .../quickhit/plugins/LevelTemplate/gfx/ship.png | Bin 0 -> 5408 bytes .../plugins/LevelTemplate/gfx/transparent.png | Bin 0 -> 1000 bytes .../plugins/LevelTemplate/leveltemplate.cpp | 119 ++ .../quickhit/plugins/LevelTemplate/leveltemplate.h | 88 + .../plugins/LevelTemplate/leveltemplate.pro | 103 ++ .../quickhit/plugins/LevelTemplate/qml/Enemy.qml | 54 + .../quickhit/plugins/LevelTemplate/qml/Level.js | 35 + .../quickhit/plugins/LevelTemplate/qml/Level.qml | 96 ++ .../quickhit/plugins/LevelTemplate/sound/crash.wav | Bin 0 -> 963020 bytes .../plugins/LevelTemplate/sound/enableship.wav | Bin 0 -> 78380 bytes .../LevelTemplate/sound/enemy_explosion.wav | Bin 0 -> 219642 bytes .../quickhit/plugins/LevelTemplate/sound/laser.wav | Bin 0 -> 46764 bytes .../plugins/LevelTemplate/sound/level2.wav | Bin 0 -> 84034 bytes .../LevelTemplate/sound/myship_explosion.wav | Bin 0 -> 120474 bytes .../plugins/LevelTemplate/sound/rocket.wav | Bin 0 -> 41336 bytes .../LevelTemplate/sound/rocket_explosion.wav | Bin 0 -> 289420 bytes .../quickhit/plugins/LevelTwo/debian/changelog | 11 + .../mobile/quickhit/plugins/LevelTwo/debian/compat | 1 + .../quickhit/plugins/LevelTwo/debian/control | 11 + .../quickhit/plugins/LevelTwo/debian/copyright | 8 + demos/mobile/quickhit/plugins/LevelTwo/debian/dirs | 2 + .../plugins/LevelTwo/debian/levelone.tarlist | 41 + .../quickhit/plugins/LevelTwo/debian/postinst | 5 + .../mobile/quickhit/plugins/LevelTwo/debian/rules | 91 + .../quickhit/plugins/LevelTwo/gfx/background2.png | Bin 0 -> 149307 bytes .../plugins/LevelTwo/gfx/background_loop.png | Bin 0 -> 163319 bytes .../quickhit/plugins/LevelTwo/gfx/blue_fire.png | Bin 0 -> 38263 bytes .../quickhit/plugins/LevelTwo/gfx/enemy1.png | Bin 0 -> 4508 bytes .../plugins/LevelTwo/gfx/enemy_missile2.png | Bin 0 -> 370 bytes .../mobile/quickhit/plugins/LevelTwo/gfx/fire.png | Bin 0 -> 1036 bytes .../mobile/quickhit/plugins/LevelTwo/gfx/fire2.png | Bin 0 -> 2558 bytes .../quickhit/plugins/LevelTwo/gfx/missile.png | Bin 0 -> 289 bytes .../quickhit/plugins/LevelTwo/gfx/missile2.png | Bin 0 -> 392 bytes .../mobile/quickhit/plugins/LevelTwo/gfx/ship.png | Bin 0 -> 5408 bytes .../mobile/quickhit/plugins/LevelTwo/gfx/star3.png | Bin 0 -> 1288 bytes .../quickhit/plugins/LevelTwo/gfx/transparent.png | Bin 0 -> 1000 bytes .../mobile/quickhit/plugins/LevelTwo/leveltwo.cpp | 115 ++ demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h | 84 + .../mobile/quickhit/plugins/LevelTwo/leveltwo.pro | 108 ++ .../mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml | 77 + .../mobile/quickhit/plugins/LevelTwo/qml/Level.js | 35 + .../mobile/quickhit/plugins/LevelTwo/qml/Level.qml | 221 +++ .../quickhit/plugins/LevelTwo/sound/crash.wav | Bin 0 -> 963020 bytes .../quickhit/plugins/LevelTwo/sound/enableship.wav | Bin 0 -> 78380 bytes .../plugins/LevelTwo/sound/enemy_explosion.wav | Bin 0 -> 219642 bytes .../quickhit/plugins/LevelTwo/sound/laser.wav | Bin 0 -> 46764 bytes .../quickhit/plugins/LevelTwo/sound/level2.wav | Bin 0 -> 84034 bytes .../plugins/LevelTwo/sound/myship_explosion.wav | Bin 0 -> 120474 bytes .../quickhit/plugins/LevelTwo/sound/rocket.wav | Bin 0 -> 41336 bytes .../plugins/LevelTwo/sound/rocket_explosion.wav | Bin 0 -> 289420 bytes .../mobile/quickhit/plugins/levelplugininterface.h | 79 + demos/mobile/quickhit/qmldir | 46 + demos/mobile/quickhit/quickhit.png | Bin 0 -> 4511 bytes demos/mobile/quickhit/quickhit.pro | 91 + demos/mobile/quickhit/resources.qrc | 25 + demos/mobile/quickhit/sound/gameover.wav | Bin 0 -> 46868 bytes demos/mobile/quickhit/sound/gamestart.wav | Bin 0 -> 573486 bytes demos/mobile/quickhit/sound/menu1.wav | Bin 0 -> 22444 bytes demos/mobile/quickhit/sound/menu2.wav | Bin 0 -> 25644 bytes demos/mobile/quickhit/sound/youwin.wav | Bin 0 -> 458554 bytes doc/src/demos/mobiledemos.qdoc | 67 + doc/src/getting-started/demos.qdoc | 11 + doc/src/howtos/developmentsteps.qdoc | 6 +- doc/src/index.qdoc | 87 +- doc/src/mainpage.qdoc | 52 +- doc/src/qt-webpages.qdoc | 143 +- 271 files changed, 19680 insertions(+), 130 deletions(-) create mode 100755 demos/mobile/guitartuner/guitartuner.pro create mode 100644 demos/mobile/guitartuner/guitartuner.pro.user create mode 100755 demos/mobile/guitartuner/guitartuner.qrc create mode 100755 demos/mobile/guitartuner/images/guitartab.svg create mode 100755 demos/mobile/guitartuner/images/guitartuner_icon.svg create mode 100755 demos/mobile/guitartuner/images/inputMode.svg create mode 100755 demos/mobile/guitartuner/images/note.svg create mode 100755 demos/mobile/guitartuner/images/noteNo.svg create mode 100755 demos/mobile/guitartuner/src/application.qml create mode 100755 demos/mobile/guitartuner/src/constants.h create mode 100755 demos/mobile/guitartuner/src/fastfouriertransformer.cpp create mode 100755 demos/mobile/guitartuner/src/fastfouriertransformer.h create mode 100755 demos/mobile/guitartuner/src/fftpack.c create mode 100755 demos/mobile/guitartuner/src/guitartuner.cpp create mode 100755 demos/mobile/guitartuner/src/guitartuner.h create mode 100755 demos/mobile/guitartuner/src/guitartuner.rc create mode 100755 demos/mobile/guitartuner/src/guitartuner.ui create mode 100755 demos/mobile/guitartuner/src/guitartunerui.cpp create mode 100755 demos/mobile/guitartuner/src/guitartunerui.h create mode 100755 demos/mobile/guitartuner/src/guitartunerui.ui create mode 100755 demos/mobile/guitartuner/src/main.cpp create mode 100755 demos/mobile/guitartuner/src/mycomponents/adjustbars.js create mode 100755 demos/mobile/guitartuner/src/mycomponents/adjuster.qml create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/big_a.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/big_b.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/big_d.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/big_e.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/big_g.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/meterBG.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/mute.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/pointer.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/power.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/quit.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/volume.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/images/volume_off.png create mode 100755 demos/mobile/guitartuner/src/mycomponents/meter.qml create mode 100755 demos/mobile/guitartuner/src/mycomponents/notebuttonview.qml create mode 100755 demos/mobile/guitartuner/src/mycomponents/notesmodel.qml create mode 100644 demos/mobile/guitartuner/src/mycomponents/qmldir create mode 100755 demos/mobile/guitartuner/src/mycomponents/togglebutton.qml create mode 100755 demos/mobile/guitartuner/src/voiceanalyzer.cpp create mode 100755 demos/mobile/guitartuner/src/voiceanalyzer.h create mode 100755 demos/mobile/guitartuner/src/voicegenerator.cpp create mode 100755 demos/mobile/guitartuner/src/voicegenerator.h create mode 100644 demos/mobile/guitartuner/ui_guitartunerui.h create mode 100755 demos/mobile/qcamera/businesscardhandling.cpp create mode 100755 demos/mobile/qcamera/businesscardhandling.h create mode 100755 demos/mobile/qcamera/button.cpp create mode 100755 demos/mobile/qcamera/button.h create mode 100755 demos/mobile/qcamera/cameraexample.cpp create mode 100755 demos/mobile/qcamera/cameraexample.h create mode 100755 demos/mobile/qcamera/contactsdlg.cpp create mode 100755 demos/mobile/qcamera/contactsdlg.h create mode 100755 demos/mobile/qcamera/icons/camera.png create mode 100755 demos/mobile/qcamera/icons/cameramms_icon.svg create mode 100755 demos/mobile/qcamera/icons/exit.png create mode 100755 demos/mobile/qcamera/icons/mms.png create mode 100755 demos/mobile/qcamera/main.cpp create mode 100755 demos/mobile/qcamera/messagehandling.cpp create mode 100755 demos/mobile/qcamera/messagehandling.h create mode 100755 demos/mobile/qcamera/qcamera.pro create mode 100644 demos/mobile/qcamera/qcamera.pro.user create mode 100755 demos/mobile/qcamera/resources.qrc create mode 100644 demos/mobile/qtbubblelevel/accelerometerfilter.cpp create mode 100644 demos/mobile/qtbubblelevel/accelerometerfilter.h create mode 100644 demos/mobile/qtbubblelevel/debian/changelog create mode 100644 demos/mobile/qtbubblelevel/debian/compat create mode 100644 demos/mobile/qtbubblelevel/debian/control create mode 100644 demos/mobile/qtbubblelevel/debian/copyright create mode 100644 demos/mobile/qtbubblelevel/debian/dirs create mode 100644 demos/mobile/qtbubblelevel/debian/files create mode 100644 demos/mobile/qtbubblelevel/debian/postinst create mode 100644 demos/mobile/qtbubblelevel/debian/rules create mode 100644 demos/mobile/qtbubblelevel/icons/26x26/qtbubblelevel.png create mode 100644 demos/mobile/qtbubblelevel/icons/40x40/qtbubblelevel.png create mode 100644 demos/mobile/qtbubblelevel/icons/64x64/qtbubblelevel.png create mode 100644 demos/mobile/qtbubblelevel/icons/bubblelevel.svg create mode 100644 demos/mobile/qtbubblelevel/icons/qtbl_icon.png create mode 100644 demos/mobile/qtbubblelevel/icons/xpm/qtbubblelevel.xpm create mode 100644 demos/mobile/qtbubblelevel/main.cpp create mode 100644 demos/mobile/qtbubblelevel/qml/BubbleLevel.qml create mode 100644 demos/mobile/qtbubblelevel/qml/Button.qml create mode 100644 demos/mobile/qtbubblelevel/qml/Tube.qml create mode 100644 demos/mobile/qtbubblelevel/qml/images/board.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/bubble.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/calibbutton.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/exit.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/reflection.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/scale.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/signblank.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/signwithtext.png create mode 100644 demos/mobile/qtbubblelevel/qml/images/taskswitcher.png create mode 100644 demos/mobile/qtbubblelevel/qtbubblelevel.desktop create mode 100644 demos/mobile/qtbubblelevel/qtbubblelevel.pro create mode 100644 demos/mobile/qtbubblelevel/qtbubblelevel.pro.user create mode 100644 demos/mobile/qtbubblelevel/qtbubblelevel.zip create mode 100644 demos/mobile/qtbubblelevel/resources.qrc create mode 100644 demos/mobile/qtbubblelevel/settings.h create mode 100644 demos/mobile/qtbubblelevel/taskswitcher.cpp create mode 100644 demos/mobile/qtbubblelevel/taskswitcher.h create mode 100755 demos/mobile/quickhit/Game.js create mode 100755 demos/mobile/quickhit/InvSounds.cpp create mode 100755 demos/mobile/quickhit/InvSounds.h create mode 100644 demos/mobile/quickhit/QuickHit.pro.user create mode 100755 demos/mobile/quickhit/button.qml create mode 100755 demos/mobile/quickhit/debian/changelog create mode 100755 demos/mobile/quickhit/debian/compat create mode 100755 demos/mobile/quickhit/debian/control create mode 100755 demos/mobile/quickhit/debian/copyright create mode 100755 demos/mobile/quickhit/debian/dirs create mode 100755 demos/mobile/quickhit/debian/postinst create mode 100755 demos/mobile/quickhit/debian/rules create mode 100755 demos/mobile/quickhit/freesound.org.licence.txt create mode 100755 demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp create mode 100755 demos/mobile/quickhit/ga_src/GEAudioBuffer.h create mode 100755 demos/mobile/quickhit/ga_src/GEAudioOut.cpp create mode 100755 demos/mobile/quickhit/ga_src/GEAudioOut.h create mode 100755 demos/mobile/quickhit/ga_src/GEInterfaces.cpp create mode 100755 demos/mobile/quickhit/ga_src/GEInterfaces.h create mode 100755 demos/mobile/quickhit/game.qml create mode 100755 demos/mobile/quickhit/gameengine.cpp create mode 100755 demos/mobile/quickhit/gameengine.h create mode 100755 demos/mobile/quickhit/gfx/back.png create mode 100755 demos/mobile/quickhit/gfx/background2.png create mode 100755 demos/mobile/quickhit/gfx/bigship.png create mode 100755 demos/mobile/quickhit/gfx/exit.png create mode 100755 demos/mobile/quickhit/gfx/pause.png create mode 100755 demos/mobile/quickhit/gfx/quickhit_logo.png create mode 100755 demos/mobile/quickhit/gfx/soundOff.png create mode 100755 demos/mobile/quickhit/gfx/soundOn.png create mode 100755 demos/mobile/quickhit/icon.svg create mode 100755 demos/mobile/quickhit/main.cpp create mode 100755 demos/mobile/quickhit/mainwindow.cpp create mode 100755 demos/mobile/quickhit/mainwindow.h create mode 100755 demos/mobile/quickhit/menu.qml create mode 100755 demos/mobile/quickhit/menuitem.qml create mode 100755 demos/mobile/quickhit/message.qml create mode 100755 demos/mobile/quickhit/missile.qml create mode 100755 demos/mobile/quickhit/myeventfilter.cpp create mode 100755 demos/mobile/quickhit/myeventfilter.h create mode 100755 demos/mobile/quickhit/myship.qml create mode 100755 demos/mobile/quickhit/plugins/LevelOne/Level.qml create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/changelog create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/compat create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/control create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/copyright create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/dirs create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/postinst create mode 100755 demos/mobile/quickhit/plugins/LevelOne/debian/rules create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png create mode 100755 demos/mobile/quickhit/plugins/LevelOne/levelone.cpp create mode 100755 demos/mobile/quickhit/plugins/LevelOne/levelone.h create mode 100755 demos/mobile/quickhit/plugins/LevelOne/levelone.pro create mode 100755 demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav create mode 100755 demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav create mode 100755 demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav create mode 100755 demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/compat create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/control create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/debian/rules create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/changelog create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/compat create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/control create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/copyright create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/dirs create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/postinst create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/debian/rules create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/crash.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/enableship.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/enemy_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/laser.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/level2.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/myship_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/rocket.wav create mode 100755 demos/mobile/quickhit/plugins/LevelTwo/sound/rocket_explosion.wav create mode 100755 demos/mobile/quickhit/plugins/levelplugininterface.h create mode 100644 demos/mobile/quickhit/qmldir create mode 100755 demos/mobile/quickhit/quickhit.png create mode 100755 demos/mobile/quickhit/quickhit.pro create mode 100755 demos/mobile/quickhit/resources.qrc create mode 100755 demos/mobile/quickhit/sound/gameover.wav create mode 100755 demos/mobile/quickhit/sound/gamestart.wav create mode 100755 demos/mobile/quickhit/sound/menu1.wav create mode 100755 demos/mobile/quickhit/sound/menu2.wav create mode 100755 demos/mobile/quickhit/sound/youwin.wav create mode 100644 doc/src/demos/mobiledemos.qdoc diff --git a/demos/demos.pro b/demos/demos.pro index fdc1e4c..7f85499 100644 --- a/demos/demos.pro +++ b/demos/demos.pro @@ -21,7 +21,11 @@ SUBDIRS = \ symbian: SUBDIRS = \ demos_shared \ demos_deform \ - demos_pathstroke + demos_pathstroke \ + demos_guitartuner \ + demos_qcamera \ + demos_qtbubblelevel \ + demos_quickhit wince*: SUBDIRS = \ demos_shared \ @@ -91,6 +95,12 @@ demos_qtdemo.subdir = qtdemo demos_mediaplayer.subdir = qmediaplayer demos_declarative.subdir = declarative +#mobile demos +demos_guitartuner = mobile/guitartuner +demos_qcamera = mobile/qcamera +demos_qtbubblelevel = mobile/qtbubblelevel +demos_quickhit = mobile/quickhit + demos_browser.subdir = browser demos_boxes.subdir = boxes diff --git a/demos/mobile/guitartuner/guitartuner.pro b/demos/mobile/guitartuner/guitartuner.pro new file mode 100755 index 0000000..9caa60d --- /dev/null +++ b/demos/mobile/guitartuner/guitartuner.pro @@ -0,0 +1,89 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-10-22T14:28:56 +# +#------------------------------------------------- + +QT += core gui + +TARGET = guitartuner +TEMPLATE = app + +ICON = images/guitartuner_icon.svg + +SOURCES += src/main.cpp\ + src/guitartuner.cpp \ + src/voicegenerator.cpp \ + src/voiceanalyzer.cpp \ + src/guitartunerui.cpp \ + src/fastfouriertransformer.cpp + +HEADERS += src/guitartuner.h \ + src/voicegenerator.h \ + src/voiceanalyzer.h \ + src/constants.h \ + src/guitartunerui.h \ + src/fastfouriertransformer.h + +FORMS += src/guitartunerui.ui + +VERSION = 1.2.0 + +symbian { + INCLUDEPATH += /epoc32/include/mmf/common + INCLUDEPATH += /epoc32/include/mmf/server + LIBS += -lmmfdevsound + TARGET.UID3 = 0xEC46D2C8 + # TARGET.CAPABILITY += + # TARGET.EPOCSTACKSIZE = 0x14000 + # TARGET.EPOCHEAPSIZE = 0x020000 0x1000000 +} + +RESOURCES += \ + guitartuner.qrc + +# Avoid auto screen rotation +DEFINES += ORIENTATIONLOCK + +symbian { + contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -leiksrv -lcone +} + + +# Add mobility into Qt's CONFIG, and add multimedia into MOBILITY. + +win32 { + QT += multimedia + RC_FILE = src/guitartuner.rc +} +else { + CONFIG += mobility + MOBILITY = multimedia +} + +symbian { + TARGET.CAPABILITY = UserEnvironment +} + +# Add declarative module +QT += declarative + +OTHER_FILES += \ + src/application.qml \ + src/mycomponents/Adjuster.qml \ + src/mycomponents/adjustbars.js \ + src/mycomponents/ToggleButton.qml + +OTHER_FILES += \ + src/mycomponents/NotesModel.qml \ + src/mycomponents/NoteButtonView.qml \ + src/mycomponents/Meter.qml + +unix:!symbian { + maemo5 { + target.path = /opt/usr/bin + } else { + target.path = /usr/local/bin + } + INSTALLS += target +} diff --git a/demos/mobile/guitartuner/guitartuner.pro.user b/demos/mobile/guitartuner/guitartuner.pro.user new file mode 100644 index 0000000..45f9d55 --- /dev/null +++ b/demos/mobile/guitartuner/guitartuner.pro.user @@ -0,0 +1,558 @@ + + + + ProjectExplorer.Project.ActiveTarget + 2 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 2 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner + 2 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner + 2 + 0 + false + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Desktop Qt for GCC (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-desktop + 4 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Desktop Qt for GCC (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-desktop + 4 + 0 + true + + 4 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + guitartuner + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + guitartuner.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + Remote Compiler + Remote Compiler + Qt4ProjectManager.Target.WccCompilerTarget + 0 + 0 + 0 + + + + + + Qt4ProjectManager.WccBuildStep + + + + 1 + 1 + 4_7_0_m1_0_2 + 1 + maemo5 + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-remote + 7 + 12 + true + + + + + + + Qt4ProjectManager.WccBuildStep + + + + 0 + 1 + + 1 + + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-remote + 7 + 12 + true + + + + + + + Qt4ProjectManager.WccBuildStep + + + + 1 + 1 + 4_7_0_m1_0_2 + 1 + maemo5 + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-remote + 7 + 12 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + Remote Compiler - Empty Run Configuration + Qt4ProjectManager.WccRunConfiguration + guitartuner.pro + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.2 + + Qt Simulator + Qt Simulator + Qt4ProjectManager.Target.QtSimulatorTarget + 0 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/declarative/guitartuner-build-simulator + 6 + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + guitartuner + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + guitartuner.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7d0e1b67-5eac-4464-8506-ed03165c2662} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/demos/mobile/guitartuner/guitartuner.qrc b/demos/mobile/guitartuner/guitartuner.qrc new file mode 100755 index 0000000..b230433 --- /dev/null +++ b/demos/mobile/guitartuner/guitartuner.qrc @@ -0,0 +1,75 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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$ + * + *****************************************************************************/ + + + src/application.qml + src/mycomponents/adjustbars.js + src/mycomponents/adjuster.qml + src/mycomponents/meter.qml + src/mycomponents/notebuttonview.qml + src/mycomponents/notesmodel.qml + src/mycomponents/togglebutton.qml + src/mycomponents/images/meterBG.png + src/mycomponents/images/pointerShadow.png + src/mycomponents/images/sensitivity.png + src/mycomponents/images/tuner_a.png + src/mycomponents/images/tuner_a_on.png + src/mycomponents/images/tuner_b.png + src/mycomponents/images/tuner_b_on.png + src/mycomponents/images/tuner_d.png + src/mycomponents/images/tuner_d_on.png + src/mycomponents/images/tuner_e.png + src/mycomponents/images/tuner_e_on.png + src/mycomponents/images/tuner_g.png + src/mycomponents/images/tuner_g_on.png + src/mycomponents/images/voicemode_off.png + src/mycomponents/images/voicemode_on.png + src/mycomponents/images/volume.png + src/mycomponents/images/volume_off.png + src/mycomponents/images/guitartuner_skin.png + src/mycomponents/images/power.png + src/mycomponents/images/tuner_auto.png + src/mycomponents/images/tuner_auto_on.png + src/mycomponents/images/big_a.png + src/mycomponents/images/big_b.png + src/mycomponents/images/big_d.png + src/mycomponents/images/big_e.png + src/mycomponents/images/big_g.png + src/mycomponents/images/glowing_a.png + src/mycomponents/images/glowing_b.png + src/mycomponents/images/glowing_d.png + src/mycomponents/images/glowing_e.png + src/mycomponents/images/glowing_g.png + src/mycomponents/images/pointer.png + + diff --git a/demos/mobile/guitartuner/images/guitartab.svg b/demos/mobile/guitartuner/images/guitartab.svg new file mode 100755 index 0000000..9d88d5d --- /dev/null +++ b/demos/mobile/guitartuner/images/guitartab.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/images/guitartuner_icon.svg b/demos/mobile/guitartuner/images/guitartuner_icon.svg new file mode 100755 index 0000000..de7ebe0 --- /dev/null +++ b/demos/mobile/guitartuner/images/guitartuner_icon.svg @@ -0,0 +1,247 @@ + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/images/inputMode.svg b/demos/mobile/guitartuner/images/inputMode.svg new file mode 100755 index 0000000..f95991a --- /dev/null +++ b/demos/mobile/guitartuner/images/inputMode.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/images/note.svg b/demos/mobile/guitartuner/images/note.svg new file mode 100755 index 0000000..c1f1771 --- /dev/null +++ b/demos/mobile/guitartuner/images/note.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/images/noteNo.svg b/demos/mobile/guitartuner/images/noteNo.svg new file mode 100755 index 0000000..888d230 --- /dev/null +++ b/demos/mobile/guitartuner/images/noteNo.svg @@ -0,0 +1,105 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/src/application.qml b/demos/mobile/guitartuner/src/application.qml new file mode 100755 index 0000000..5d253d2 --- /dev/null +++ b/demos/mobile/guitartuner/src/application.qml @@ -0,0 +1,321 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 1.0 +import "mycomponents" + +/* The base canvas for all QML drawing. */ +Rectangle { + id: application + + property int targetNoteIndex: 0 + property alias frequency: noteChooser.currentFrequency + //Data provided to C++. + property bool isInput: true + property bool isMuted: false + property bool isAuto: true + property alias maxVoiceDifference: voiceDifferenceMeter.maxValue + property real volume: 0.5 + property real sensitivity: 0.5 + + //Signals to C++. + signal volumeChanged(real volume) + signal microphoneSensitivityChanged(real sensitivity) + signal targetFrequencyChanged(real frequency) + signal modeChanged(bool isInput) + signal muteStateChanged(bool isMuted) + + //Slots for signals coming from C++. + function voiceDifferenceChanged(difference) { + if (isAuto) timer.running = true; + voiceDifferenceMeter.valueChanged(difference); + noteImage.glowing = false + } + function correctFrequencyObtained() { + noteImage.glowing = true + } + function lowVoice() { + noteImage.glowing = false + } + + //Private function for changing the target frequency automatically. + function calculateTargetFrequency(difference) { + var tempDifference = Math.abs(difference); + var tempIndex = targetNoteIndex + while (!(difference < 0 && tempIndex == 0) && + tempDifference >= notes.get(tempIndex-(difference<0)).interval/2) { + tempDifference -= notes.get(tempIndex-(difference<0)).interval; + tempIndex += difference/Math.abs(difference); + } + if (tempIndex != targetNoteIndex) { + targetNoteIndex = tempIndex + noteChooser.currentFrequency = notes.get(targetNoteIndex).frequency; + targetFrequencyChanged(frequency); + } + } + + width: 360; height: 640 + color: "black" + + //Provides data for functions. + NotesModel {id: notes} + + /* A timer for changing the target frequency automatically. + * This is needed for avoiding recursion. */ + Timer { + id: timer + + interval: 1 + onTriggered: calculateTargetFrequency(voiceDifferenceMeter.value) + } + + //A meter for showing the difference between current and target frequency. + Meter { + id: voiceDifferenceMeter + + maxValue: 12 + minValue: -maxValue + height: imageSize.height/background.sourceSize.height*parent.height + width: imageSize.width/background.sourceSize.width*parent.width + anchors { + topMargin: 100/background.sourceSize.height*parent.height + horizontalCenter: parent.horizontalCenter + top: parent.top + } + } + + Image { + id: background + + anchors.fill: parent + smooth: true + source: "./mycomponents/images/guitartuner_skin.png" + } + + //A button for quitting the application. + Image { + id: quitButton + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + source: "./mycomponents/images/power.png" + smooth: true + KeyNavigation.up: volumeAdjuster + KeyNavigation.down: modeButton + Keys.onEnterPressed: Qt.quit() + anchors{ + leftMargin: 297/background.sourceSize.width*parent.width + left: parent.left; + topMargin: 17/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + //An image for showing the target note. + Image { + id: noteImage + + property bool glowing: false + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + source: glowing ? notes.get(targetNoteIndex).glowSource : notes.get(targetNoteIndex).bigSource + + anchors { + topMargin: 273/background.sourceSize.height*parent.height + top: parent.top + horizontalCenter: parent.horizontalCenter + } + } + + //A button for choosing the input/output mode. + Image { + id: modeButton + + function buttonPressed() { + isInput = !isInput + modeChanged(isInput) + if (isInput) { + soundIcons.source = "./mycomponents/images/sensitivity.png" + source = "./mycomponents/images/voicemode_off.png" + volumeAdjuster.setValue(sensitivity) + } + else { + //Change off from "auto" mode + if (isAuto) { + noteChooser.pushButton(targetNoteIndex) + } + if (isMuted) { + soundIcons.source = "./mycomponents/images/volume_off.png"; + } + else + soundIcons.source = "./mycomponents/images/volume.png" + source = "./mycomponents/images/voicemode_on.png" + volumeAdjuster.setValue(volume) + } + } + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + smooth: true + source: "./mycomponents/images/voicemode_off.png" + KeyNavigation.up: quitButton + KeyNavigation.down: noteChooser + Keys.onEnterPressed: buttonPressed() + anchors { + leftMargin: 16/background.sourceSize.width*parent.width + left: parent.left + topMargin: 353/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onPressed: { + parent.focus = true + parent.scale = 0.95 + } + onReleased: { + parent.scale = 1/0.95 + } + onClicked: parent.buttonPressed() + } + } + + //Buttons for choosing the target note. + NoteButtonView { + id: noteChooser + + width: parent.width*0.95; height: width/model.count + onNoteSelected: { + if (note == "Auto") { + if (!isAuto) { + isAuto = true + } + if (!isInput) { + modeButton.buttonPressed() + } + } + else { + timer.running = false; + isAuto = false + targetNoteIndex = index + targetFrequencyChanged(frequency) + } + focus = true + } + KeyNavigation.up: modeButton + KeyNavigation.down: soundIcons + anchors { + horizontalCenter: parent.horizontalCenter + topMargin: 454/background.sourceSize.height*parent.height + top: parent.top + } + } + + //An element for showing the mode and changing the mute state. + Image { + id: soundIcons + + function stateChanged() { + isMuted = !isMuted + muteStateChanged(isMuted) + if (isMuted) { + source = "qrc:/src/mycomponents/images/volume_off.png" + } + else { + source = "qrc:/src/mycomponents/images/volume.png" + } + } + + width: sourceSize.width/background.sourceSize.width*parent.width + height: sourceSize.height/background.sourceSize.height*parent.height + smooth: true + source: "./mycomponents/images/sensitivity.png" + Keys.onEnterPressed: stateChanged() + KeyNavigation.up: noteChooser + KeyNavigation.down: quitButton + KeyNavigation.left: volumeAdjuster + KeyNavigation.right: volumeAdjuster + anchors { + leftMargin: 42/background.sourceSize.width*parent.width + left: parent.left + topMargin: 565/background.sourceSize.height*parent.height + top: parent.top + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (!isInput) { + parent.stateChanged() + } + parent.focus = true + } + } + } + + //An element for adjusting volume. + Adjuster { + id: volumeAdjuster + + max: 1 + value: 0.5 + width: 222/background.sourceSize.width*parent.width + height: parent.height*0.1 + onFocusChangedByClick: focus = true + onArrowPressedWhenValueOverLimits: soundIcons.focus = true + KeyNavigation.up: modeButton + KeyNavigation.down: quitButton + anchors { + leftMargin: 98/background.sourceSize.width*parent.width + left: parent.left + verticalCenter: soundIcons.verticalCenter + } + onValueChanged: { + if (isInput) { + sensitivity = value; + microphoneSensitivityChanged(1-sensitivity) + } + else { + volume = value + volumeChanged(volume) + } + } + } +} diff --git a/demos/mobile/guitartuner/src/constants.h b/demos/mobile/guitartuner/src/constants.h new file mode 100755 index 0000000..dde2f33 --- /dev/null +++ b/demos/mobile/guitartuner/src/constants.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef CONSTANTS_H +#define CONSTANTS_H + +#define M_MAX_AMPLITUDE_8BIT_SIGNED 127 +#define M_MAX_AMPLITUDE_8BIT_UNSIGNED 255 +#define M_MAX_AMPLITUDE_16BIT_SIGNED 32767 +#define M_MAX_AMPLITUDE_16BIT_UNSIGNED 65535 + +#define M_TWELTH_ROOT_OF_2 1.05946309435930000000 + +// M_SAMPLE_COUNT_MULTIPLIER is 2/(M_TWELTH_ROOT_OF_2 - 1) +#define M_SAMPLE_COUNT_MULTIPLIER 33.63430749021150000000 + +#endif // CONSTANTS_H diff --git a/demos/mobile/guitartuner/src/fastfouriertransformer.cpp b/demos/mobile/guitartuner/src/fastfouriertransformer.cpp new file mode 100755 index 0000000..705e483 --- /dev/null +++ b/demos/mobile/guitartuner/src/fastfouriertransformer.cpp @@ -0,0 +1,177 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "fastfouriertransformer.h" +#include "math.h" + +#define STIN inline +#define __STATIC + +#include "fftpack.c" + +// called by __ogg_fdrffti +__STATIC void drfti1(int n, float *wa, int *ifac); +void __ogg_fdrffti(int n, float *wsave, int *ifac); +void __ogg_fdcosqi(int n, float *wsave, int *ifac); +// called by drftf1 +STIN void dradf2(int ido,int l1,float *cc,float *ch,float *wa1); +// called by drftf1 +STIN void dradf4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3); +// called by drftf1 +STIN void dradfg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa); +// called by drftf1 +STIN void drftf1(int n,float *c,float *ch,float *wa,int *ifac); +void __ogg_fdrfftf(int n,float *r,float *wsave,int *ifac); +STIN void dcsqf1(int n,float *x,float *w,float *xh,int *ifac); +void __ogg_fdcosqf(int n,float *x,float *wsave,int *ifac); +STIN void dradb2(int ido,int l1,float *cc,float *ch,float *wa1); +STIN void dradb3(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2); +STIN void dradb4(int ido,int l1,float *cc,float *ch,float *wa1, + float *wa2,float *wa3); +STIN void dradbg(int ido,int ip,int l1,int idl1,float *cc,float *c1, + float *c2,float *ch,float *ch2,float *wa); +STIN void drftb1(int n, float *c, float *ch, float *wa, int *ifac); +void __ogg_fdrfftb(int n, float *r, float *wsave, int *ifac); +STIN void dcsqb1(int n,float *x,float *w,float *xh,int *ifac); +void __ogg_fdcosqb(int n,float *x,float *wsave,int *ifac); + +FastFourierTransformer::FastFourierTransformer(QObject *parent) : + QObject(parent), + m_waveFloat(0), + m_workingArray(0), + m_ifac(0), + m_last_n(-1) +{ +} + +FastFourierTransformer::~FastFourierTransformer() +{ + if (m_waveFloat != 0) { + delete [] m_waveFloat; + } + if (m_workingArray != 0) { + delete [] m_workingArray; + } + if (m_ifac != 0) { + delete [] m_ifac; + } +} + +/** + * Prepares the arrays to be of length n. + */ +void FastFourierTransformer::reserve(int n) +{ + Q_ASSERT(n>0); + if (m_waveFloat != 0) { + delete [] m_waveFloat; + } + if (m_workingArray != 0) { + delete [] m_workingArray; + } + if (m_ifac != 0) { + delete [] m_ifac; + } + m_workingArray = new float[2*n+15]; + m_waveFloat = new float[n]; + m_ifac = new int[n]; + __ogg_fdrffti(n, m_workingArray, m_ifac); + m_last_n = n; +} + +/** + * Calculates the Fast Fourier Transformation (FFT). + */ +void FastFourierTransformer::calculateFFT(QList wave) +{ + const int n = wave.size(); + if (m_last_n != n) { + reserve(n); + } + for (int i = 0; i < n; i++) { + m_waveFloat[i] = (float) wave.at(i); + } + + __ogg_fdrfftf(n, m_waveFloat, m_workingArray, m_ifac); + +} + +/** + * Returns the index which corresponds to the maximum density + * of the FFT. + */ +int FastFourierTransformer::getMaximumDensityIndex() +{ + const int halfN = m_last_n / 2; + float maxDensity = 0; + int maxDensityIndex = 0; + float densitySquared = 0.f; + for (int k = 1; k < halfN; k++) { + // Here, we calculate the frequency k/N. + // k=1, the wave oscillation time is N, and the frequency + // is 1/sample. + // k=2, the wave oscillation time is N/2, and the frequency + // is 2/sample. + // k=3, the wave oscillation time is N/3, and the frequency + // is 3/sample. + // Note, that the documentation is for Fortran, so indexes in the + // documentation does not match. + // The sine and cosine coefficients are obtained thus as follows: + const float cosCoefficient = qAbs(m_waveFloat[2*k-1]); + const float sinCoefficient = qAbs(m_waveFloat[2*k]); + + densitySquared = sinCoefficient*sinCoefficient + cosCoefficient*cosCoefficient; + if (densitySquared > maxDensity) { + maxDensity = densitySquared; + maxDensityIndex = k; + } + } + + if (m_cutOffForDensitySquared < maxDensity) { + return maxDensityIndex; + } + else { + return -1; + } +} + +/** + * Sets the cutoff density. + */ +void FastFourierTransformer::setCutOffForDensity(float cutoff) +{ + m_cutOffForDensitySquared = cutoff*cutoff; +} diff --git a/demos/mobile/guitartuner/src/fastfouriertransformer.h b/demos/mobile/guitartuner/src/fastfouriertransformer.h new file mode 100755 index 0000000..7e01db3 --- /dev/null +++ b/demos/mobile/guitartuner/src/fastfouriertransformer.h @@ -0,0 +1,60 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef FASTFOURIERTRANSFORM_H +#define FASTFOURIERTRANSFORM_H + +#include +#include + +class FastFourierTransformer : public QObject +{ + Q_OBJECT + +public: + FastFourierTransformer(QObject *parent = 0); + ~FastFourierTransformer(); + void reserve(int n); + void calculateFFT(QList wave); + int getMaximumDensityIndex(); + void setCutOffForDensity(float cutoff); + +private: + float *m_waveFloat; + float *m_workingArray; + int *m_ifac; + int m_last_n; + float m_cutOffForDensitySquared; +}; + +#endif // FASTFOURIERTRANSFORM_H diff --git a/demos/mobile/guitartuner/src/fftpack.c b/demos/mobile/guitartuner/src/fftpack.c new file mode 100755 index 0000000..05a7917 --- /dev/null +++ b/demos/mobile/guitartuner/src/fftpack.c @@ -0,0 +1,1399 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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$ + * + *****************************************************************************/ + +/******************************************************************** + + The routines in this file are from http://www.netlib.org/fftpack/. + According to the comments in the original file (which are provided below) + and according to the wikipedia article about the FFTPACK[1], + they are released as public domain. + + For information about the author of the original, Fortran routines, + and the author of the C translation these routines, + see the comments below. + + [1] http://en.wikipedia.org/wiki/FFTPACK, referenced 2010-12-21. + + ********************************************************************/ + +/******************************************************************** + + file: fft.c + function: Fast discrete Fourier and cosine transforms and inverses + author: Monty + modifications by: Monty + last modification date: Jul 1 1996 + + ********************************************************************/ + +/* These Fourier routines were originally based on the Fourier + routines of the same names from the NETLIB bihar and fftpack + fortran libraries developed by Paul N. Swarztrauber at the National + Center for Atmospheric Research in Boulder, CO USA. They have been + reimplemented in C and optimized in a few ways for OggSquish. */ + +/* As the original fortran libraries are public domain, the C Fourier + routines in this file are hereby released to the public domain as + well. The C routines here produce output exactly equivalent to the + original fortran routines. Of particular interest are the facts + that (like the original fortran), these routines can work on + arbitrary length vectors that need not be powers of two in + length. */ + +#include + +__STATIC void drfti1(int n, float *wa, int *ifac){ + static int ntryh[4] = { 4,2,3,5 }; + static float tpi = 6.28318530717958647692528676655900577; + float arg,argh,argld,fi; + int ntry=0,i,j=-1; + int k1, l1, l2, ib; + int ld, ii, ip, is, nq, nr; + int ido, ipm, nfm1; + int nl=n; + int nf=0; + + L101: + j++; + if (j < 4) + ntry=ntryh[j]; + else + ntry+=2; + + L104: + nq=nl/ntry; + nr=nl-ntry*nq; + if (nr!=0) goto L101; + + nf++; + ifac[nf+1]=ntry; + nl=nq; + if (ntry!=2) goto L107; + if (nf==1) goto L107; + + for (i=1;i>1; + ipp2=ip; + idp2=ido; + nbd=(ido-1)>>1; + t0=l1*ido; + t10=ip*ido; + + if (ido==1) goto L119; + for (ik=0;ikl1){ + for (j=1;j>1; + np2=n; + + kc=np2; + for (k=1;k>1; + ipp2=ip; + ipph=(ip+1)>>1; + if (idol1) goto L139; + + is= -ido-1; + t1=0; + for (j=1;j>1; + np2=n; + + for (i=2;i 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 "guitartuner.h" + +#ifdef Q_OS_SYMBIAN +#include +#endif // Q_OS_SYMBIAN + +#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) +#include +#include +#include +#include +#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK + +GuitarTuner::GuitarTuner(QWidget *parent) : + QMainWindow(parent) +{ + + // Set up the QML. + m_guitarTunerUI = new QDeclarativeView(QUrl("qrc:/src/application.qml"), this); + setCentralWidget(m_guitarTunerUI); + m_guitarTunerUI->setResizeMode(QDeclarativeView::SizeRootObjectToView); + qmlObject = m_guitarTunerUI->rootObject(); + + // Init audio output and input. + initAudioOutput(); + initAudioInput(); + + // Connect the quit signal of m_guitarTunerUI + // into the close slot of this. + connect(m_guitarTunerUI->engine(), SIGNAL(quit()), SLOT(close())); + + // Connect the signals from qmlObject into proper slots + // of this and m_voicegenerator. + connect(qmlObject, SIGNAL(muteStateChanged(bool)), + SLOT(muteStateChanged(bool))); + connect(qmlObject, SIGNAL(volumeChanged(qreal)), + m_voicegenerator, SLOT(setAmplitude(qreal))); + connect(qmlObject, SIGNAL(volumeChanged(qreal)), + SLOT(setMaxVolumeLevel(qreal))); + + // Connect the modeChanged signal from qmlObject + // into modeChanged slot of this class. + connect(qmlObject, SIGNAL(modeChanged(bool)), + SLOT(modeChanged(bool))); + + // Connect the microphoneSensitivityChanged signal from + // m_guitarTunerUI into setCutOffPercentage slot of m_analyzer class. + connect(qmlObject, SIGNAL(microphoneSensitivityChanged(qreal)), + m_analyzer, SLOT(setCutOffPercentage(qreal))); + + // Connect the signals from m_analyzer into slots of qmlObject. + connect(m_analyzer, SIGNAL(lowVoice()), + qmlObject, SLOT(lowVoice())); + connect(m_analyzer, SIGNAL(correctFrequency()), + qmlObject, SLOT(correctFrequencyObtained())); + connect(m_analyzer, SIGNAL(voiceDifference(QVariant)), + qmlObject, SLOT(voiceDifferenceChanged(QVariant))); + + // Initialise the MaximumVoiceDifference + // value of qmlObject with the value obtained from m_analyzer. + qmlObject->setProperty("maxVoiceDifference", + m_analyzer->getMaximumVoiceDifference()); + + // Connect the targetFrequencyChanged signal of qmlObject + // into targetFrequencyChanged slot of this class. + connect(qmlObject, SIGNAL(targetFrequencyChanged(qreal)), + SLOT(targetFrequencyChanged(qreal))); + + // Start voice output or input by using the modeChanged function, + // depending of the current mode. + modeChanged(qmlObject->property("isInput").toBool()); + +} + +/** + * Inits audio output. + */ +void GuitarTuner::initAudioOutput() +{ + // Set up the output format. + m_format_output.setFrequency(DataFrequencyHzOutput); + m_format_output.setCodec("audio/pcm"); + m_format_output.setSampleSize(16); + m_format_output.setChannels(1); + m_format_output.setByteOrder(QAudioFormat::LittleEndian); + m_format_output.setSampleType(QAudioFormat::SignedInt); + + // Obtain a default output device, and if the format is not + // supported, find the nearest format available. + QAudioDeviceInfo outputDeviceInfo( + QAudioDeviceInfo::defaultOutputDevice()); + if (!outputDeviceInfo.isFormatSupported(m_format_output)) { + m_format_output = outputDeviceInfo.nearestFormat(m_format_output); + } + + // Create new QAudioOutput and VoiceGenerator instances, and store + // them in m_audioOutput and m_voicegenerator, respectively. + m_audioOutput = new QAudioOutput(outputDeviceInfo, + m_format_output, this); + m_voicegenerator = new VoiceGenerator(m_format_output, + qmlObject->property("frequency").toReal(), + qmlObject->property("volume").toReal(), + this); + + // Connect m_audioOutput stateChanged signal to outputStateChanged. + connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), + SLOT(outputStateChanged(QAudio::State))); +} + +/** + * Inits audio input. + */ +void GuitarTuner::initAudioInput() +{ + // Set up the input format. + m_format_input.setFrequency(DataFrequencyHzInput); + m_format_input.setCodec("audio/pcm"); + m_format_input.setSampleSize(16); + m_format_input.setChannels(1); + m_format_input.setByteOrder(QAudioFormat::LittleEndian); + m_format_input.setSampleType(QAudioFormat::SignedInt); + + // Obtain a default input device, and if the format is not + // supported, find the nearest format available. + QAudioDeviceInfo inputDeviceInfo( + QAudioDeviceInfo::defaultInputDevice()); + if (!inputDeviceInfo.isFormatSupported(m_format_input)) { + m_format_input = inputDeviceInfo.nearestFormat(m_format_input); + } + + // Create new QAudioInput and VoiceAnalyzer instances, and store + // them in m_audioInput and m_analyzer, respectively. + // Remember to set the cut-off percentage for voice analyzer. + m_audioInput = new QAudioInput(inputDeviceInfo, m_format_input, this); + m_analyzer = new VoiceAnalyzer(m_format_input, this); + m_analyzer->setCutOffPercentage(qmlObject->property("sensitivity").toReal()); + +} + +/** + * Receives a mode changed signal. + */ +void GuitarTuner::modeChanged(bool isInput) +{ + + + + // If the mode must be changed to input mode: + if (isInput) { + + // Stop audio output and audio generator. + m_audioOutput->stop(); + m_voicegenerator->stop(); + // Start the audio analyzer and then the audio input. + m_analyzer->start(qmlObject->property("frequency").toReal()); + m_audioInput->start(m_analyzer); + + } + // Else: + else { + + // Stop audio input and audio analyzer. + m_audioInput->stop(); + m_analyzer->stop(); + + // Set up the audio output. + + // If the current frequency of voice generator + // is not the same as the target frequency selected in the UI, + // update voice generator's frequency. + if (m_voicegenerator->frequency() != qmlObject->property("frequency").toReal()) { + m_voicegenerator->setFrequency(qmlObject->property("frequency").toReal()); + } + + // Start the voice generator and then the audio output. + m_voicegenerator->start(); + m_audioOutput->start(m_voicegenerator); + // Call setMaxVolumeLevel(1) to set the maximum volume louder. + setMaxVolumeLevel(qmlObject->property("volume").toReal()); + + // If the voice is muted, the voice is suspended + // in the outputStateChanged slot. + + } +} + +/** + * Receives a output state changed signal. + * Suspends the audio output, if the state is ActiveState + * and the voice is muted. + */ +void GuitarTuner::outputStateChanged(QAudio::State state) +{ + if (QAudio::ActiveState == state && qmlObject->property("isMuted").toBool()) { + // If the voice is muted, suspend the voice. + m_audioOutput->suspend(); + } +} + +/** + * Receives a mute state changed signal. + * Suspends the audio output or resumes it, depending of the + * isMuted parameter. + */ +void GuitarTuner::muteStateChanged(bool isMuted) +{ + if (isMuted) { + m_audioOutput->suspend(); + } + else { + m_audioOutput->resume(); + } +} + +/** + * Receives a target frequency signal. + */ +void GuitarTuner::targetFrequencyChanged(qreal targetFrequency) +{ + // If the output mode is active: + if (!qmlObject->property("isInput").toBool()) { + // Stop the audio output and voice generator. + m_audioOutput->stop(); + m_voicegenerator->stop(); + // Set the voice generator's frequency to the target frequency. + m_voicegenerator->setFrequency(targetFrequency); + // Start the voice generator and audio output. + m_voicegenerator->start(); + m_audioOutput->start(m_voicegenerator); + // Call setMaxVolumeLevel(1) to set the maximum volume louder. + setMaxVolumeLevel(qmlObject->property("volume").toReal()); + + // If the voice is muted, the voice is suspended + // in the outputStateChanged slot. + + } + // Else: + else { + + // Stop the audio input and voice analyzer. + m_audioInput->stop(); + m_analyzer->stop(); + // Start the voice analyzer with new frequency and audio input. + m_analyzer->start(targetFrequency); + m_audioInput->start(m_analyzer); + + } +} + +/** + * This method provides a hack to set the maximum volume level in + * Symbian. + */ +void GuitarTuner::setMaxVolumeLevel(qreal percent) +{ + if (percent >= 1.0) { + percent = 1.0; + } + else if (percent <= 0.0) { + percent = 0.0; + } + percent = percent*0.5 + 0.5; + // Warning! This is a hack, which can break when the QtMobility + // changes. Use at your own risk. +#ifdef Q_OS_SYMBIAN + unsigned int *pointer_to_abstract_audio + = (unsigned int*)( (unsigned char*)m_audioOutput + 8 ); + unsigned int *dev_sound_wrapper + = (unsigned int*)(*pointer_to_abstract_audio) + 16; + unsigned int *temp + = ((unsigned int*)(*dev_sound_wrapper) + 6); + CMMFDevSound *dev_sound = (CMMFDevSound*)(*temp); + dev_sound->SetVolume((unsigned int) + (percent*(float)dev_sound->MaxVolume())); +#endif +} + +/** + * A function used to lock the orientation. + */ +void GuitarTuner::setOrientation(Orientation orientation) +{ +#ifdef Q_OS_SYMBIAN + if (orientation != Auto) { +#if defined(ORIENTATIONLOCK) + const CAknAppUiBase::TAppUiOrientation uiOrientation = + (orientation == LockPortrait) + ? CAknAppUi::EAppUiOrientationPortrait + : CAknAppUi::EAppUiOrientationLandscape; + CAknAppUi* appUi = dynamic_cast + (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); +#else // ORIENTATIONLOCK + qWarning(QString("'ORIENTATIONLOCK' needs to be defined on") + +QString(" Symbian when locking the orientation.")); +#endif // ORIENTATIONLOCK + } +#elif defined(Q_WS_MAEMO_5) + Qt::WidgetAttribute attribute; + switch (orientation) { + case LockPortrait: + attribute = Qt::WA_Maemo5PortraitOrientation; + break; + case LockLandscape: + attribute = Qt::WA_Maemo5LandscapeOrientation; + break; + case Auto: + default: + attribute = Qt::WA_Maemo5AutoOrientation; + break; + } + setAttribute(attribute, true); +#else // Q_OS_SYMBIAN + Q_UNUSED(orientation); +#endif // Q_OS_SYMBIAN +} diff --git a/demos/mobile/guitartuner/src/guitartuner.h b/demos/mobile/guitartuner/src/guitartuner.h new file mode 100755 index 0000000..c5a2d69 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include "voicegenerator.h" +#include "voiceanalyzer.h" + +const int DataFrequencyHzOutput = 44100; +const int DataFrequencyHzInput = 48000; + +#define MAX_INPUT_VALUE 50 +#define MIN_INPUT_VALUE -50 + +class GuitarTuner : public QMainWindow +{ + Q_OBJECT +public: + enum Orientation { + LockPortrait, + LockLandscape, + Auto + }; + explicit GuitarTuner(QWidget *parent = 0); + qreal getVolume(); + qreal getMicrophoneSensitivity(); + bool getMuteState(); + void setOrientation(Orientation orientation); + +signals: + +public slots: + void modeChanged(bool isInput); + void muteStateChanged(bool isMuted); + void targetFrequencyChanged(qreal targetFrequency); + void outputStateChanged(QAudio::State state); + void setMaxVolumeLevel(qreal); + +private: + void initAudioOutput(); + void initAudioInput(); + VoiceGenerator *m_voicegenerator; + VoiceAnalyzer *m_analyzer; + QObject *qmlObject; + QAudioOutput *m_audioOutput; + QAudioInput *m_audioInput; + QAudioFormat m_format_output; + QAudioFormat m_format_input; + QDeclarativeView *m_guitarTunerUI; +}; + +#endif // MAINWINDOW_H diff --git a/demos/mobile/guitartuner/src/guitartuner.rc b/demos/mobile/guitartuner/src/guitartuner.rc new file mode 100755 index 0000000..85cee0b --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.rc @@ -0,0 +1,23 @@ +IDI_ICON1 ICON DISCARDABLE "/../images/guitartuner_icon.ico" + +1 VERSIONINFO +FILEVERSION 1,2,0,0 +PRODUCTVERSION 1,2,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "Nokia Corporation\0" + VALUE "FileDescription", "Qt Quick example application.\0" + VALUE "FileVersion", "1.2.0\0" + VALUE "LegalCopyright", "Copyright 2011 Nokia Corporation. All rights reserved.\0" + VALUE "ProductName", "Guitar Tuner\0" + VALUE "ProductVersion", "1.2.0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END \ No newline at end of file diff --git a/demos/mobile/guitartuner/src/guitartuner.ui b/demos/mobile/guitartuner/src/guitartuner.ui new file mode 100755 index 0000000..36ee1bd --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartuner.ui @@ -0,0 +1,178 @@ + + + GuitarTuner + + + + 0 + 0 + 187 + 279 + + + + GuitarTuner + + + + + + + + + :/images/guitartab.svg + + + Qt::AlignCenter + + + + + + + false + + + false + + + -50 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 50 + + + + + + + + + + 0 + 0 + + + + ... + + + Qt::LeftArrow + + + + + + + A + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + ... + + + false + + + Qt::RightArrow + + + + + + + + + Change mode + + + + + + + Qt::Horizontal + + + + + + + + + 65 + + + Qt::Vertical + + + + + + + ... + + + + :/images/note.svg + :/images/noteNo.svg + :/images/noteNo.svg:/images/note.svg + + + + 30 + 30 + + + + true + + + true + + + + + + + + 0 + 0 + + + + microphone +sensitivity + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/src/guitartunerui.cpp b/demos/mobile/guitartuner/src/guitartunerui.cpp new file mode 100755 index 0000000..fa69f8c --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.cpp @@ -0,0 +1,334 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include + +#include "guitartunerui.h" +#include "ui_guitartunerui.h" + +GuitarTunerUI::GuitarTunerUI(QWidget *parent) : + QWidget(parent), + ui(new Ui::GuitarTunerUI), + m_maximumPrecision(0) +{ + ui->setupUi(this); + + // Set up the class attributes to proper values. + m_outputActive = false; + m_muted = false; + m_outputVolumeLevel = getVolumeFromSoundSlider(); + m_inputVolumeLevel = 1.0 - m_outputVolumeLevel; + + // Set up the current tone, the frequency, and the name for it. + m_currentToneIndex = 5; + updateFrequencyByToneIndex(m_currentToneIndex); + + // Connect the signals from UI into proper slots. + connect(ui->soundSlider, SIGNAL(valueChanged(int)), + SLOT(changeVolume())); + connect(ui->soundButton, SIGNAL(toggled(bool)), + SLOT(toggleSound(bool))); + connect(ui->modeButton, SIGNAL(clicked()), + SLOT(toggleInputOrOutput())); + connect(ui->buttonNext, SIGNAL(clicked()), SLOT(next())); + connect(ui->buttonPrev, SIGNAL(clicked()), SLOT(prev())); + + // Initialise up the UI by calling toggleInputOrOutput + // for the first time. + toggleInputOrOutput(); +} + +GuitarTunerUI::~GuitarTunerUI() +{ + delete ui; +} + +void GuitarTunerUI::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +/** + * Returns a value from 0 to 1, representing the volume. + */ +qreal GuitarTunerUI::getVolumeFromSoundSlider() const +{ + qreal value = ui->soundSlider->value(); + return value/ui->soundSlider->maximum(); +} + +/** + * Updates the m_currentToneFrequency and m_currentToneString, + * according to the given index. Also updates the UI. + */ +void GuitarTunerUI::updateFrequencyByToneIndex(int index) +{ + + switch (index) { + case 0: { + m_currentToneFrequency = FrequencyE; + m_currentToneString = "E"; + break; + } + case 1: { + m_currentToneFrequency = FrequencyA; + m_currentToneString = "A"; + break; + } + case 2: { + m_currentToneFrequency = FrequencyD; + m_currentToneString = "D"; + break; + } + case 3: { + m_currentToneFrequency = FrequencyG; + m_currentToneString = "G"; + break; + } + case 4: { + m_currentToneFrequency = FrequencyB; + m_currentToneString = "B"; + break; + } + case 5: { + m_currentToneFrequency = FrequencyE2; + m_currentToneString = "e"; + break; + } + default: { + qDebug() << "invalid index!" << index; + } + } + // Set the noteLabel text according to the current tone. + ui->noteLabel->setText(m_currentToneString); +} + +/** + * Returns the volume. + */ +qreal GuitarTunerUI::getVolume() const +{ + return m_outputVolumeLevel; +} + +/** + * Returns true if the sound is muted. + */ +bool GuitarTunerUI::getMuteState() const +{ + return m_muted; +} + + +/** + * Returns the microphone sensitivity. + */ +qreal GuitarTunerUI::getMicrophoneSensitivity() const +{ + return m_inputVolumeLevel; +} + +/** + * Returns whether the input mode is active. + */ +bool GuitarTunerUI::isInputModeActive() const +{ + return !m_outputActive; +} + +/** + * Returns the current target frequency. + */ +qreal GuitarTunerUI::getFrequency() const +{ + return m_currentToneFrequency; +} + +/** + * Toggles the sound according to the parameter. + * Has no effect if output is not active. + */ +void GuitarTunerUI::toggleSound(bool noSound) +{ + if (!m_outputActive) { + return; + } + m_muted = noSound; + emit muteChanged(m_muted); +} + +/** + * Changes the volume or microphone sensitivity. + */ +void GuitarTunerUI::changeVolume() +{ + qreal resultingAmplitude = getVolumeFromSoundSlider(); + qDebug() << "resultingAmplitude" << resultingAmplitude; + if (m_outputActive) { + m_outputVolumeLevel = resultingAmplitude; + emit volumeChanged(resultingAmplitude); + } + else { + m_inputVolumeLevel = resultingAmplitude; + emit microphoneSensitivityChanged(1.0-resultingAmplitude); + } +} + +/** + * Toggles input or output, depending of the current state. + */ +void GuitarTunerUI::toggleInputOrOutput() +{ + // If output mode is active: + if (m_outputActive) { + // Change UI to correspond to the input mode. + m_outputActive = false; + ui->soundSlider->setValue(m_inputVolumeLevel*100); + ui->soundButton->setDisabled(true); + ui->soundButton->hide(); + ui->micSensitivityLabel->show(); + emit modeChanged(true); + ui->modeButton->setText("To tone mode"); + } + // Else: + else { + // Change UI to correspond to the output mode. + m_outputActive = true; + ui->soundSlider->setValue(m_outputVolumeLevel*100); + ui->soundButton->setDisabled(false); + ui->micSensitivityLabel->hide(); + ui->soundButton->show(); + emit modeChanged(false); + ui->modeButton->setText("To listen mode"); + } +} + +/** + * Receives the low voice signal. + */ +void GuitarTunerUI::lowVoice() +{ + if (ui->noteLabel->font().bold()) { + QFont font; + font.setBold(false); + font.setUnderline(false); + ui->noteLabel->setFont(font); + } +} + +/** + * Receives the voice difference signal. + * The difference is qreal, where increase of 1 corresponds + * to increase of 1 tone to the target frequency. + */ +void GuitarTunerUI::voiceDifference(qreal difference) +{ + if (ui->noteLabel->font().bold()) { + QFont font; + font.setBold(false); + font.setUnderline(false); + ui->noteLabel->setFont(font); + } + ui->correctSoundSlider->setValue(difference*m_maximumPrecision); +} + +/** + * Receives the correct frequency signal. + * Makes the UI to visualize correct frequency event. + */ +void GuitarTunerUI::correctFrequencyObtained() +{ + qDebug() << "CORRECT FREQUENCY"; + QFont font; + font.setBold(true); + font.setUnderline(true); + ui->noteLabel->setFont(font); +} + +/** + * Sets up the maximum voice difference. + */ +void GuitarTunerUI::setMaximumVoiceDifference(int max) +{ + // Assert that the maximum precision is known. + Q_ASSERT(m_maximumPrecision != 0); + // Set the maximum and minimum values of the correctSoundSlider + // to the +- max*m_maximumPrecision, and set the tick interval + // to be m_maximumPrecision. + ui->correctSoundSlider->setMaximum(max*m_maximumPrecision); + ui->correctSoundSlider->setMinimum(-max*m_maximumPrecision); + ui->correctSoundSlider->setTickInterval(max*m_maximumPrecision); +} + +/** + * Stores the maximum precision per note. Used to setup the + * correct sound slider. + */ +void GuitarTunerUI::setMaximumPrecisionPerNote(int max) +{ + m_maximumPrecision = max; +} + +/** + * Changes the tone to the next value. + */ +void GuitarTunerUI::next() +{ + changeTone((m_currentToneIndex + 1) % 6); +} + +/** + * Changes the tone to the previous value. + */ +void GuitarTunerUI::prev() +{ + changeTone((m_currentToneIndex + 5) % 6); +} + +/** + * Changes the tone according to the new index. + */ +void GuitarTunerUI::changeTone(int newIndex) +{ + m_currentToneIndex = newIndex; + updateFrequencyByToneIndex(m_currentToneIndex); + qDebug() << "targetFrequencyChanged" << m_currentToneFrequency; + emit targetFrequencyChanged(m_currentToneFrequency); +} diff --git a/demos/mobile/guitartuner/src/guitartunerui.h b/demos/mobile/guitartuner/src/guitartunerui.h new file mode 100755 index 0000000..72f8d44 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.h @@ -0,0 +1,104 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef GUITARTUNERUI_H +#define GUITARTUNERUI_H + +#include +#include + +namespace Ui { + class GuitarTunerUI; +} + +const qreal FrequencyE = 82.407; +const qreal FrequencyA = 110.00; +const qreal FrequencyD = 146.83; +const qreal FrequencyG = 196.00; +const qreal FrequencyB = 246.94; +const qreal FrequencyE2 = 329.63; + +class GuitarTunerUI : public QWidget +{ + Q_OBJECT + +public: + explicit GuitarTunerUI(QWidget *parent = 0); + ~GuitarTunerUI(); + + qreal getVolume() const; + bool getMuteState() const; + qreal getMicrophoneSensitivity() const; + bool isInputModeActive() const; + qreal getFrequency() const; + int getScaleMaximumValue() const; + void setMaximumVoiceDifference(int max); + void setMaximumPrecisionPerNote(int max); + +public slots: + void toggleSound(bool off); + void next(); + void prev(); + void changeVolume(); + void toggleInputOrOutput(); + + void lowVoice(); + void voiceDifference(qreal difference); + void correctFrequencyObtained(); + +signals: + void modeChanged(bool isInput); + void volumeChanged(qreal volume); + void microphoneSensitivityChanged(qreal sensitivity); + void muteChanged(bool isMuted); + void targetFrequencyChanged(qreal targetFrequency); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::GuitarTunerUI *ui; + void changeTone(int newIndex); + qreal getVolumeFromSoundSlider() const; + int m_currentToneIndex; + QString m_currentToneString; + qreal m_currentToneFrequency; + void updateFrequencyByToneIndex(int index); + bool m_outputActive; + bool m_muted; + qreal m_outputVolumeLevel; + qreal m_inputVolumeLevel; + int m_maximumPrecision; +}; + +#endif // GUITARTUNERUI_H diff --git a/demos/mobile/guitartuner/src/guitartunerui.ui b/demos/mobile/guitartuner/src/guitartunerui.ui new file mode 100755 index 0000000..af7b585 --- /dev/null +++ b/demos/mobile/guitartuner/src/guitartunerui.ui @@ -0,0 +1,178 @@ + + + GuitarTunerUI + + + + 0 + 0 + 187 + 279 + + + + GuitarTunerUI + + + + + + + + + :/images/guitartab.svg + + + Qt::AlignCenter + + + + + + + false + + + false + + + -50 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + 50 + + + + + + + + + + 0 + 0 + + + + ... + + + Qt::LeftArrow + + + + + + + A + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + ... + + + false + + + Qt::RightArrow + + + + + + + + + Change mode + + + + + + + Qt::Horizontal + + + + + + + + + 65 + + + Qt::Vertical + + + + + + + ... + + + + :/images/note.svg + :/images/noteNo.svg + :/images/noteNo.svg:/images/note.svg + + + + 30 + 30 + + + + true + + + true + + + + + + + + 0 + 0 + + + + microphone +sensitivity + + + + + + + + + + + + + diff --git a/demos/mobile/guitartuner/src/main.cpp b/demos/mobile/guitartuner/src/main.cpp new file mode 100755 index 0000000..00fd3cb --- /dev/null +++ b/demos/mobile/guitartuner/src/main.cpp @@ -0,0 +1,53 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include "guitartuner.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + GuitarTuner w; + w.setOrientation(GuitarTuner::LockPortrait); + +#ifdef Q_OS_SYMBIAN + w.showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + w.showMaximized(); +#else + w.show(); +#endif + + return a.exec(); +} + diff --git a/demos/mobile/guitartuner/src/mycomponents/adjustbars.js b/demos/mobile/guitartuner/src/mycomponents/adjustbars.js new file mode 100755 index 0000000..e962dcd --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/adjustbars.js @@ -0,0 +1,82 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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$ + * + *****************************************************************************/ + +/* JavaScript functions for creating, handling and + * destroying the bars of the adjuster component. */ + +var maxBars = 10; +var firstBarHeight = 5; +var bars = new Array(maxBars); +var colors = new Array(maxBars); +var barWidthFactor = 2.3; + +function createBars() { + var barWidth = adjuster.width/maxBars/barWidthFactor; + for (var i = 1; i <= maxBars; i++) { + //Create, configure and store the bars. + var bar = Qt.createQmlObject('import QtQuick 1.0; Rectangle {smooth: true}', adjuster, "dynamicBar"); + bar.width = barWidth; + bar.height = firstBarHeight+(i/maxBars)*(adjuster.height*0.8-firstBarHeight); + bar.radius = bar.width/2; + bar.x = (i-1)*(barWidthFactor*barWidth); + bar.y = adjuster.height/2 - bar.height/2; + bars[i-1] = bar; + + //Calculate and store the colors + if (i < maxBars/2) { + colors[i-1] = Qt.rgba(1-i/(maxBars/2), 1, 1-i/(maxBars/2), i); + } + else { + colors[i-1] = Qt.rgba((i-(maxBars/2))/(maxBars/2), 1-((i-(maxBars/2))/(maxBars/2)), 0, i); + } + } +} + +function destroyBars() { + for (var i = 0; i < maxBars; i++) { + bars[i].color = "transparent" //Colors must be set to transparent or otherwise the bars will stay appeared. + bars[i].destroy(); + } +} + +function fillBars(barNumber) { + //Set the color for the bars (transparent from the selected bar to the end). + for (var i = 0; i < maxBars; i++) { + if (i < barNumber) { + bars[i].color = colors[i]; + } + else { + bars[i].color = "black"; + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/adjuster.qml b/demos/mobile/guitartuner/src/mycomponents/adjuster.qml new file mode 100755 index 0000000..8f43740 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/adjuster.qml @@ -0,0 +1,124 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 1.0 +import "adjustbars.js" as AdjustBars + +/* A barchart-like adjuster component. */ +Rectangle { + id: adjuster + + property real max: 100 + property real value: 0 + property bool created: false + + signal valueChanged(real value) + signal focusChangedByClick() + signal arrowPressedWhenValueOverLimits() + + function setValue(pValue) { + value = pValue; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + + height: 60; width: 300 + color: "transparent" + Keys.onRightPressed: { + var val = value+max/AdjustBars.maxBars; + if (val <= max) { + value = val; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + else { + arrowPressedWhenValueOverLimits() + } + } + Keys.onLeftPressed: { + var val = value-max/AdjustBars.maxBars; + if (0 <= val) { + value = val; + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + valueChanged(value); + } + else { + arrowPressedWhenValueOverLimits() + } + } + Component.onCompleted: { + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + created = true; + } + Component.onDestruction: { + AdjustBars.destroyBars; + } + //Dynamic objects have to be recreated when the window size changes. + onWidthChanged: { + if (created) { + AdjustBars.destroyBars(); + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + } + } + onHeightChanged: { + if (created) { + AdjustBars.destroyBars(); + AdjustBars.createBars(); + AdjustBars.fillBars(value/max*AdjustBars.maxBars); + } + } + + MouseArea { + anchors.fill: parent + onPositionChanged: { + focusChangedByClick(); + var val = mouse.x/parent.width*parent.max; + if (0 < val && val < max) { + parent.value = val; + AdjustBars.fillBars(parent.value/parent.max*AdjustBars.maxBars); + valueChanged(parent.value); + } + } + onClicked: { + focusChangedByClick(); + var val = mouse.x/parent.width*parent.max; + if (0 < val && val < max) { + parent.value = val; + AdjustBars.fillBars(parent.value/parent.max*AdjustBars.maxBars); + valueChanged(parent.value); + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_a.png b/demos/mobile/guitartuner/src/mycomponents/images/big_a.png new file mode 100755 index 0000000..3838e76 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/big_a.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_b.png b/demos/mobile/guitartuner/src/mycomponents/images/big_b.png new file mode 100755 index 0000000..114b32d Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/big_b.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_d.png b/demos/mobile/guitartuner/src/mycomponents/images/big_d.png new file mode 100755 index 0000000..3ede9f0 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/big_d.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_e.png b/demos/mobile/guitartuner/src/mycomponents/images/big_e.png new file mode 100755 index 0000000..cc1f488 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/big_e.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/big_g.png b/demos/mobile/guitartuner/src/mycomponents/images/big_g.png new file mode 100755 index 0000000..804177b Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/big_g.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png new file mode 100755 index 0000000..b6fd0e2 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/glowing_a.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png new file mode 100755 index 0000000..b5fa016 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/glowing_b.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png new file mode 100755 index 0000000..32f1a29 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/glowing_d.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png new file mode 100755 index 0000000..4be9f2a Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/glowing_e.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png b/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png new file mode 100755 index 0000000..4216d82 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/glowing_g.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png new file mode 100755 index 0000000..dbe3fc7 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_malli.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png new file mode 100755 index 0000000..5d53df9 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/guitartuner_skin.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png b/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png new file mode 100755 index 0000000..ff8dffc Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/lcdFrame.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png b/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png new file mode 100755 index 0000000..4046355 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/meterBG.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/mute.png b/demos/mobile/guitartuner/src/mycomponents/images/mute.png new file mode 100755 index 0000000..382e6047 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/mute.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/pointer.png b/demos/mobile/guitartuner/src/mycomponents/images/pointer.png new file mode 100755 index 0000000..d0cb21b Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/pointer.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png b/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png new file mode 100755 index 0000000..a708639 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/pointerShadow.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/power.png b/demos/mobile/guitartuner/src/mycomponents/images/power.png new file mode 100755 index 0000000..8ec0c5c Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/power.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/quit.png b/demos/mobile/guitartuner/src/mycomponents/images/quit.png new file mode 100755 index 0000000..2a9443e Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/quit.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png b/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png new file mode 100755 index 0000000..c3d2ea3 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/sensitivity.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png new file mode 100755 index 0000000..a1823e5 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png new file mode 100755 index 0000000..7c78cbd Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_a_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png new file mode 100755 index 0000000..b9e494b Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png new file mode 100755 index 0000000..d5608d8 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_auto_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png new file mode 100755 index 0000000..94977f8 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png new file mode 100755 index 0000000..78841dc Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_b_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png new file mode 100755 index 0000000..293ee55 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png new file mode 100755 index 0000000..705de41 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_d_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png new file mode 100755 index 0000000..569d2c6 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png new file mode 100755 index 0000000..1342a91 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_e_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png new file mode 100755 index 0000000..a8f0de5 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png new file mode 100755 index 0000000..6fdca41 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/tuner_g_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png new file mode 100755 index 0000000..0701dd3 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_off.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png new file mode 100755 index 0000000..986d589 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/voicemode_on.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/volume.png b/demos/mobile/guitartuner/src/mycomponents/images/volume.png new file mode 100755 index 0000000..46fdb7f Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/volume.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png b/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png new file mode 100755 index 0000000..a97e422 Binary files /dev/null and b/demos/mobile/guitartuner/src/mycomponents/images/volume_off.png differ diff --git a/demos/mobile/guitartuner/src/mycomponents/meter.qml b/demos/mobile/guitartuner/src/mycomponents/meter.qml new file mode 100755 index 0000000..151c62f --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/meter.qml @@ -0,0 +1,105 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 1.0 + +/* A meter component. */ +Rectangle { + id: meter + + property real value: 0 + property real minValue: -1 + property real maxValue: 1 + property alias imageSize: meterImage.sourceSize + + function valueChanged(pValue) { + value = pValue; + scaleValueToAngle(); + } + function scaleValueToAngle() { + pointer.angle = (((value-minValue)/(maxValue-minValue))* + (pointer.angleMax-pointer.angleMin))+ + pointer.angleMin; + } + + color: "transparent" + + Image { + id: meterImage + + smooth: true + source: "./images/meterBG.png" + anchors.fill: parent + } + + Image { + id:pointerShadow + + x: pointer.x - 2 + y: pointer.y - 2 + height: pointer.height + smooth: true + source: "./images/pointerShadow.png" + transform: Rotation { + origin.x: 2 + origin.y: height + angle: -pointer.angle + } + } + + Image { + id: pointer + + property real angle: 0 + property real angleMax: -45 + property real angleMin: 45 + + height: parent.height*0.92 + transformOrigin: "Bottom" + rotation: -angle + smooth: true + source: "./images/pointer.png" + anchors { + bottomMargin: 2 + bottom: parent.bottom; + horizontalCenter: parent.horizontalCenter + } + + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: 0.15 + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/notebuttonview.qml b/demos/mobile/guitartuner/src/mycomponents/notebuttonview.qml new file mode 100755 index 0000000..8e68c43 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/notebuttonview.qml @@ -0,0 +1,77 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 1.0 + +/* A view component for buttons for choosing notes. */ +ListView { + id: noteChooser + + property real currentFrequency: 82.407 + + signal noteSelected(string note, real frequency, int index) + + //Press down the button corresponding to the given note. + function pushButton(index) { + currentIndex = index; + } + + width: 50*model.count + spacing*(model.count-1); height: 50 + orientation: ListView.Horizontal + model: NotesModel {} + delegate: notesDelegate + keyNavigationWraps: true + boundsBehavior: Flickable.StopAtBounds + + Component { + id: notesDelegate + + ToggleButton { + id: noteButton + + width: height; height: noteChooser.height + offImageSource: offSource + onImageSource: onSource + state: noteButton.ListView.isCurrentItem ? "pressed" : "unPressed" + onSelected: { + noteChooser.noteSelected(note, frequency, index) + if (note != "Auto") { + currentFrequency = frequency + } + } + onPushed: { + noteButton.ListView.view.currentIndex = index + } + } + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/notesmodel.qml b/demos/mobile/guitartuner/src/mycomponents/notesmodel.qml new file mode 100755 index 0000000..297adb9 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/notesmodel.qml @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import QtQuick 1.0 + +/* The model component for the NoteButtonView. */ +ListModel { + ListElement { + note: "E" + offSource: "./images/tuner_e.png" + onSource: "./images/tuner_e_on.png" + bigSource: "./mycomponents/images/big_e.png" + glowSource: "./mycomponents/images/glowing_e.png" + frequency: "82.407" + interval: "5" + } + ListElement { + note: "A" + offSource: "./images/tuner_a.png" + onSource: "./images/tuner_a_on.png" + bigSource: "./mycomponents/images/big_a.png" + glowSource: "./mycomponents/images/glowing_a.png" + frequency: "110.00" + interval: "5" + } + ListElement { + note: "D" + offSource: "./images/tuner_d.png" + onSource: "./images/tuner_d_on.png" + bigSource: "./mycomponents/images/big_d.png" + glowSource: "./mycomponents/images/glowing_d.png" + frequency: "146.83" + interval: "5" + } + ListElement { + note: "G" + offSource: "./images/tuner_g.png" + onSource: "./images/tuner_g_on.png" + bigSource: "./mycomponents/images/big_g.png" + glowSource: "./mycomponents/images/glowing_g.png" + frequency: "196.00" + interval: "4" + } + ListElement { + note: "B" + offSource: "./images/tuner_b.png" + onSource: "./images/tuner_b_on.png" + bigSource: "./mycomponents/images/big_b.png" + glowSource: "./mycomponents/images/glowing_b.png" + frequency: "246.94" + interval: "5" + } + ListElement { + note: "e" + offSource: "./images/tuner_e.png" + onSource: "./images/tuner_e_on.png" + bigSource: "./mycomponents/images/big_e.png" + glowSource: "./mycomponents/images/glowing_e.png" + frequency: "329.63" + interval: "9999" //Big enough that we can't move over this note + } + ListElement { + note: "Auto" + offSource: "./images/tuner_auto.png" + onSource: "./images/tuner_auto_on.png" + frequency: "82.407" + } +} diff --git a/demos/mobile/guitartuner/src/mycomponents/qmldir b/demos/mobile/guitartuner/src/mycomponents/qmldir new file mode 100644 index 0000000..cad46c4 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/qmldir @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module 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 Nokia Corporation 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$ +** +****************************************************************************/ +NotesModel ./notesmodel.qml +Adjuster ./adjuster.qml +Meter ./meter.qml +NoteButtonView ./notebuttonview.qml +ToggleButton ./togglebutton.qml diff --git a/demos/mobile/guitartuner/src/mycomponents/togglebutton.qml b/demos/mobile/guitartuner/src/mycomponents/togglebutton.qml new file mode 100755 index 0000000..47e4d41 --- /dev/null +++ b/demos/mobile/guitartuner/src/mycomponents/togglebutton.qml @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 1.0 + +/* A toggle button component. */ +Rectangle { + id: toggleButton + + property url offImageSource: "" + property url onImageSource: "" + property alias imageSource: buttonImage.source + + signal selected() + signal pushed() + + color: "transparent" + state: "unPressed" + onStateChanged: { + if (state == "pressed") { + selected() + } + } + + Image { + id: buttonImage + + smooth: true + anchors.fill: parent + } + MouseArea { + id: mouseArea + + anchors.fill: parent + onPressed: { + if (parent.state == "unPressed") { + pushed() + } + } + } + + states: [ + State { + name: "pressed" + PropertyChanges { + target: toggleButton + scale: 0.95 + imageSource: onImageSource + } + }, + State { + name: "unPressed" + PropertyChanges { + target: toggleButton + scale: 1/0.95 + imageSource: offImageSource + } + } + ] + + transitions: [ + Transition { + from: "unPressed" + to: "pressed" + reversible: true + PropertyAnimation { + target: toggleButton + properties: "scale" + duration: 100 + } + } + ] +} diff --git a/demos/mobile/guitartuner/src/voiceanalyzer.cpp b/demos/mobile/guitartuner/src/voiceanalyzer.cpp new file mode 100755 index 0000000..e8cd72f --- /dev/null +++ b/demos/mobile/guitartuner/src/voiceanalyzer.cpp @@ -0,0 +1,288 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "voiceanalyzer.h" + +/** + * Constant used to scale the cut-off density for the fft helper. + */ +const static float CutOffScaler = 0.05; + +/** + * Force the precision to be "1/PrecisionPerNote" notes + * near the target frequency. + */ +const static int PrecisionPerNote = 4; + +/** + * TargetFrequencyParameter is a constant which implies the index at + * which corresponds to the target frequency. + * 0.5 * N * 1/TargetFrequencyParameter is (about) the index which + * corresponds to the given target frequency. + * Effectively TargetFrequencyParameter = 2^z, and the z*TargetFrequency + * is the maximum frequency that can be noticed. + */ +const static int TargetFrequencyParameter = 4; + + +VoiceAnalyzer::VoiceAnalyzer(const QAudioFormat &format, QObject *parent): + QIODevice(parent), + m_format(format), + m_frequency(0), + m_position(0), + m_fftHelper(new FastFourierTransformer(this)) +{ + Q_ASSERT(qFuzzyCompare(M_SAMPLE_COUNT_MULTIPLIER, + float(2)/(M_TWELTH_ROOT_OF_2 -1.0))); + m_totalSampleCount = qRound(qreal(PrecisionPerNote) + *TargetFrequencyParameter + *M_SAMPLE_COUNT_MULTIPLIER); + m_samples.reserve(m_totalSampleCount); + int i = 2; + int j = 1; + for (; i < TargetFrequencyParameter; i *= 2) { + j++; + } + m_maximumVoiceDifference = j*12; + + setCutOffPercentage(CutOffScaler); +} + +/** + * Opens the parent QIODevice. Sets up the analysation parameters. + */ +void VoiceAnalyzer::start(qreal frequency) +{ + m_stepSize = (qreal) 1.0 * m_format.sampleRate() + / (TargetFrequencyParameter*2*frequency); + m_frequency = frequency; + open(QIODevice::WriteOnly); +} + +/** + * Closes the parent QIODevice, thus the voice is not analysed anymore. + * Resets the m_samples QList. + */ +void VoiceAnalyzer::stop() +{ + m_samples.clear(); + m_samples.reserve(m_totalSampleCount); + close(); +} + +/** + * Called when data is obtained. Stores each m_stepSize sample + * into a QList to be analysed. + */ +qint64 VoiceAnalyzer::writeData(const char *data, qint64 maxlen) +{ + const int channelBytes = m_format.sampleSize() / 8; + int sampleSize = m_format.channels() * channelBytes; + int m_stepSizeInBytes = m_stepSize*sampleSize; + // assert that each sample fits fully into the data + Q_ASSERT((m_position % sampleSize)==0); + const uchar *ptr = reinterpret_cast(data); + while (m_position < maxlen) { + if (m_samples.size() < m_totalSampleCount) { + m_samples.append(getValueInt16(ptr+m_position)); + } + else { + analyzeVoice(); + m_samples.clear(); + m_samples.reserve(m_totalSampleCount); + // fast forward position to the first position after maxlen or to the maxlen + m_position += ((m_stepSizeInBytes - 1 + maxlen - m_position) / + m_stepSizeInBytes) * m_stepSizeInBytes; + break; + } + m_position += m_stepSizeInBytes; + } + m_position -= maxlen; + return maxlen; +} + +/** + * Interprets ptr as a pointer to int value and returns it. + */ +qint16 VoiceAnalyzer::getValueInt16(const uchar *ptr) +{ + qint16 realValue = 0; + if (m_format.sampleSize() == 8) + { + const qint16 value = *reinterpret_cast(ptr); + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + realValue = value - M_MAX_AMPLITUDE_8BIT_SIGNED - 1; + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + realValue = value; + } + } else if (m_format.sampleSize() == 16) { + qint16 value = 0; + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + value = qFromLittleEndian(ptr); + else + value = qFromBigEndian(ptr); + + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + realValue = value - M_MAX_AMPLITUDE_16BIT_SIGNED; + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + realValue = value; + } + } + return realValue; +} + +/** + * Takes a number between 0 and 1, scales it with CutOffScaler, + * multiplies it with maximum density, and then gives it + * to the fft helper. + */ +void VoiceAnalyzer::setCutOffPercentage(qreal cutoff) +{ + cutoff = CutOffScaler*cutoff; + if (m_format.sampleSize() == 8) { + float t = cutoff*m_totalSampleCount*M_MAX_AMPLITUDE_8BIT_SIGNED; + m_fftHelper->setCutOffForDensity(t); + } + else if (m_format.sampleSize() == 16) { + float t = cutoff*m_totalSampleCount*M_MAX_AMPLITUDE_16BIT_SIGNED; + m_fftHelper->setCutOffForDensity(t); + } +} + +/** + * Returns the current target frequency. + */ +qreal VoiceAnalyzer::frequency() +{ + return m_frequency; +} + +/** + * Returns the maximum absolute value sent by + * the voiceDifference() signal. + */ +int VoiceAnalyzer::getMaximumVoiceDifference() +{ + return m_maximumVoiceDifference; +} + +/** + * Returns the maximum precision per note + * near the target frequency. + */ +int VoiceAnalyzer::getMaximumPrecisionPerNote() +{ + return PrecisionPerNote; +} + +/** + * Analyzes the voice frequency and emits appropriate signals. + */ +void VoiceAnalyzer::analyzeVoice() +{ + m_fftHelper->calculateFFT(m_samples); + int index = m_fftHelper->getMaximumDensityIndex(); + + // If index == -1 + if (index == -1) { + // The voice is to be filtered away. + // Emit the lowVoice signal and return. + emit lowVoice(); + qDebug() << "low voice"; + return; + } + // Else, continue + + // Let the correctIndex to be + // the nearest index corresponding to the correct frequency. + qreal stepSizeInFrequency = (qreal)m_format.sampleRate() + / (m_totalSampleCount * m_stepSize); + qreal newFrequency = qreal(index) * stepSizeInFrequency; + // Calculate the nearest index corresponding to the correct frequency. + int correctIndex = qRound(m_frequency / stepSizeInFrequency); + qreal value = 0; + + // If the obtained frequency is more than + // log_2(TargetFrequencyParameter) octaves less than the m_frequency: + + // Note: + // Instead of m_frequency/TargetFrequencyParameter > newFrequency, + // the comparison is done without a div instructions by + // m_frequency > newFrequency * TargetFrequencyParameter. + + if (m_frequency > newFrequency * TargetFrequencyParameter) { + // Set the difference value to be -m_maximumVoiceDifference. + qDebug() << "compare" << "low" << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + value = -m_maximumVoiceDifference; + } + // Else, if the obtained frequency is more than + // log_2(TargetFrequencyParameter) octaves more than the m_frequency: + else if (m_frequency*TargetFrequencyParameter < newFrequency) { + // Set the difference value to be m_maximumVoiceDifference. + qDebug() << "compare" << "high" << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + value = m_maximumVoiceDifference; + } + // Else: + else { + // Calculate the difference between the obtained and the correct + // frequency in tones. + // Use stepSizeInFrequency * correctIndex instead of + // m_frequency so that the value is zero when there is correct + // voice obtained. Set the difference value to be + // log(frequency / target frequency) * 12 / log(2). + value = log(newFrequency / (stepSizeInFrequency * correctIndex)) + * 12 / M_LN2; + qDebug() << "compare" << value << newFrequency << m_frequency - stepSizeInFrequency * correctIndex << (m_frequency - stepSizeInFrequency * correctIndex) / stepSizeInFrequency; + } + + // Emit voiceDifference signal. + QVariant valueVar(value); //Has to be QVariant for QML + emit voiceDifference(valueVar); + + // If the correctIndex is index, emit the correctFrequency signal. + if (correctIndex == index) { + emit(correctFrequency()); + } +} + +/** + * Empty implementation for readData, since no data is provided + * by the VoiceAnalyzer class. + */ +qint64 VoiceAnalyzer::readData(char *data, qint64 maxlen) +{ + Q_UNUSED(data); + Q_UNUSED(maxlen); + + return 0; +} diff --git a/demos/mobile/guitartuner/src/voiceanalyzer.h b/demos/mobile/guitartuner/src/voiceanalyzer.h new file mode 100755 index 0000000..41c42f8 --- /dev/null +++ b/demos/mobile/guitartuner/src/voiceanalyzer.h @@ -0,0 +1,86 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef VOICEANALYZER_H +#define VOICEANALYZER_H + +#include +#include +#include +#include +#include +#include + +#include "constants.h" +#include "fastfouriertransformer.h" +#include "math.h" + +class VoiceAnalyzer : public QIODevice +{ + Q_OBJECT +public: + VoiceAnalyzer(const QAudioFormat &format, QObject *parent = 0); + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 maxlen); + void start(qreal frequency); + void stop(); + qreal frequency(); + int getMaximumVoiceDifference(); + int getMaximumPrecisionPerNote(); + +public slots: + void setCutOffPercentage(qreal cutoff); + +private: + const QAudioFormat m_format; + QList m_samples; + int m_totalSampleCount; + int m_maximumVoiceDifference; + + qint16 getValueInt16(const uchar *ptr); + int m_stepSize; + qreal m_frequency; + qint64 m_position; + FastFourierTransformer *m_fftHelper; + void analyzeVoice(); +signals: + void voiceDifference(QVariant frequency); + void correctFrequency(); + void lowVoice(); + +public slots: + +}; + + +#endif // VOICEANALYZER_H diff --git a/demos/mobile/guitartuner/src/voicegenerator.cpp b/demos/mobile/guitartuner/src/voicegenerator.cpp new file mode 100755 index 0000000..bbe7c1c --- /dev/null +++ b/demos/mobile/guitartuner/src/voicegenerator.cpp @@ -0,0 +1,239 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "voicegenerator.h" + +const int BufferSizeMilliseconds = 100; + +VoiceGenerator::VoiceGenerator(const QAudioFormat &format, + qreal frequency, qreal amplitude, + QObject *parent) : + QIODevice(parent), + m_format(format), + m_amplitude(0.5) +{ + Q_ASSERT(m_format.sampleSize() % 8 == 0); + int sampleBytes = m_format.channels() * (m_format.sampleSize() / 8); + // + 1 to round up, just to be sure that all samples fit. + qint64 samplesInBuffer = m_format.sampleRate() + * BufferSizeMilliseconds / 1000 + 1; + qint64 length = samplesInBuffer * sampleBytes; + m_buffer.resize(length); + m_max_position = 0; + m_position = 0; + m_amplitude = amplitude; + setFrequency(frequency); +} + +VoiceGenerator::~VoiceGenerator() +{ +} + +/** + * Opens the parent QIODevice. + */ +void VoiceGenerator::start() +{ + open(QIODevice::ReadOnly); +} + +/** + * Closes the parent QIODevice. Resets the m_position to zero. + */ +void VoiceGenerator::stop() +{ + close(); + m_position = 0; +} + +/** + * Sets the frequency to new frequency. + */ +void VoiceGenerator::setFrequency(qreal frequency) +{ + Q_ASSERT(1 / frequency < BufferSizeMilliseconds); + this->m_frequency = frequency; + refreshData(); +} + +/** + * Sets the amplitude for the voice. + */ +void VoiceGenerator::setAmplitude(qreal amplitude) +{ + Q_ASSERT(amplitude >= 0); + m_amplitude = amplitude; + refreshData(); +} + +/** + * Returns the current frequency. + */ +qreal VoiceGenerator::frequency() +{ + return m_frequency; +} + +/** + * Generates voice data corresponding a sine voice with target frequency. + * The number of data generated is calculated + * and stored to m_max_position. + */ +void VoiceGenerator::refreshData() +{ + const int channelBytes = m_format.sampleSize() / 8; + const int sampleSize = m_format.channels() * channelBytes; + const qint64 voiceOscillationsInBuffer = BufferSizeMilliseconds + * m_frequency / 1000; + const qint64 voiceSamplesInBuffer = voiceOscillationsInBuffer + * m_format.sampleRate() / m_frequency; + m_max_position = voiceSamplesInBuffer * sampleSize; + qint64 dataGenerationLength = m_buffer.size(); + + + Q_ASSERT(m_max_position % (sampleSize) == 0); + Q_ASSERT(dataGenerationLength <= m_buffer.size()); + + short *t = (short*)m_buffer.data(); + + +/* + int te ; + static float fpos = 0.0f; + //dataGenerationLength>>=1; // in words + for (int f=0; f(m_buffer.data()); + int sampleIndex = 0; + while (dataGenerationLength > 0) { + qreal realValue = 0; + if (sampleIndex < voiceSamplesInBuffer) { + realValue = m_amplitude + *qSin(2.0f * M_PI * m_frequency + * qreal(sampleIndex % m_format.sampleRate()) + / m_format.sampleRate()); + } + for (int i=0; i( + qRound((1.0 + realValue) / 2 + * M_MAX_AMPLITUDE_8BIT_UNSIGNED)); + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + value = static_cast( + qRound(realValue + * M_MAX_AMPLITUDE_8BIT_SIGNED)); + } + *reinterpret_cast(ptr) = value; + } else if (m_format.sampleSize() == 16) { + quint16 value = 0; + if (m_format.sampleType() == QAudioFormat::UnSignedInt) { + value = static_cast( + qRound((1.0 + realValue) / 2 + * M_MAX_AMPLITUDE_16BIT_UNSIGNED)); + } else if (m_format.sampleType() == QAudioFormat::SignedInt) { + value = static_cast( + qRound(realValue + * M_MAX_AMPLITUDE_16BIT_SIGNED)); + } + if (m_format.byteOrder() == QAudioFormat::LittleEndian) + qToLittleEndian(value, ptr); + else + qToBigEndian(value, ptr); + } +} + +qint64 VoiceGenerator::bytesAvailable() const +{ + return m_max_position + QIODevice::bytesAvailable(); +} + +/** + * Called by the QIODevice. Puts maxlen amount of voice + * samples into the data array. + */ +qint64 VoiceGenerator::readData(char *data, qint64 maxlen) +{ + qint64 total = 0; + qint64 chunk = 0; + while (total < maxlen) { + if (maxlen - total >= m_max_position - m_position) { + // the needed buffer is longer than the currently + // available buffer from m_position to the m_max_position + chunk = m_max_position - m_position; + memcpy(data, m_buffer.constData() + m_position, chunk); + m_position = 0; + } + else { + // we can copy the needed data directly, and the loop will end + chunk = maxlen - total; + memcpy(data, m_buffer.constData() + m_position, chunk); + m_position = (m_position + chunk) % m_max_position; + } + data += chunk; + total += chunk; + } + return total; +} + +/** + * Empty implementation for writeData, since no data is provided + * for the VoiceGenerator class. + */ +qint64 VoiceGenerator::writeData(const char *data, qint64 maxlen) +{ + Q_UNUSED(data); + Q_UNUSED(maxlen); + + return 0; +} diff --git a/demos/mobile/guitartuner/src/voicegenerator.h b/demos/mobile/guitartuner/src/voicegenerator.h new file mode 100755 index 0000000..cf8c172 --- /dev/null +++ b/demos/mobile/guitartuner/src/voicegenerator.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef VOICEGENERATOR_H +#define VOICEGENERATOR_H + +#include +#include +#include +#include +#include +#include + +#include "constants.h" + + +class VoiceGenerator : public QIODevice +{ + Q_OBJECT +public: + VoiceGenerator(const QAudioFormat &format, qreal frequency, qreal amplitude, QObject *parent = 0); + ~VoiceGenerator(); + void setFrequency(qreal frequency); + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 maxlen); + qint64 bytesAvailable() const; + qreal frequency(); +signals: + +public slots: + void setAmplitude(qreal amplitude); + void start(); + void stop(); + +private: + void setValue(uchar *ptr, qreal realValue); + void refreshData(); + const QAudioFormat m_format; + // buffer to store the data + QByteArray m_buffer; + // current position in buffer + qint64 m_position; + // max position depends on the sample rate of format and the frequency of voice + qint64 m_max_position; + qreal m_amplitude; + qreal m_frequency; +}; + +#endif // VOICEGENERATOR_H diff --git a/demos/mobile/guitartuner/ui_guitartunerui.h b/demos/mobile/guitartuner/ui_guitartunerui.h new file mode 100644 index 0000000..3a698aa --- /dev/null +++ b/demos/mobile/guitartuner/ui_guitartunerui.h @@ -0,0 +1,181 @@ +/******************************************************************************** +** Form generated from reading UI file 'guitartunerui.ui' +** +** Created: Wed Mar 2 14:59:33 2011 +** by: Qt User Interface Compiler version 4.7.2 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_GUITARTUNERUI_H +#define UI_GUITARTUNERUI_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Ui_GuitarTunerUI +{ +public: + QVBoxLayout *verticalLayout_2; + QLabel *tabulatorIcon; + QSlider *correctSoundSlider; + QHBoxLayout *horizontalLayout; + QToolButton *buttonPrev; + QLabel *noteLabel; + QToolButton *buttonNext; + QPushButton *modeButton; + QFrame *line; + QHBoxLayout *horizontalLayout_2; + QSlider *soundSlider; + QToolButton *soundButton; + QLabel *micSensitivityLabel; + + void setupUi(QWidget *GuitarTunerUI) + { + if (GuitarTunerUI->objectName().isEmpty()) + GuitarTunerUI->setObjectName(QString::fromUtf8("GuitarTunerUI")); + GuitarTunerUI->resize(187, 279); + verticalLayout_2 = new QVBoxLayout(GuitarTunerUI); + verticalLayout_2->setSpacing(6); + verticalLayout_2->setContentsMargins(11, 11, 11, 11); + verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); + tabulatorIcon = new QLabel(GuitarTunerUI); + tabulatorIcon->setObjectName(QString::fromUtf8("tabulatorIcon")); + tabulatorIcon->setText(QString::fromUtf8("")); + tabulatorIcon->setPixmap(QPixmap(QString::fromUtf8(":/images/guitartab.svg"))); + tabulatorIcon->setAlignment(Qt::AlignCenter); + + verticalLayout_2->addWidget(tabulatorIcon); + + correctSoundSlider = new QSlider(GuitarTunerUI); + correctSoundSlider->setObjectName(QString::fromUtf8("correctSoundSlider")); + correctSoundSlider->setEnabled(false); + correctSoundSlider->setAutoFillBackground(false); + correctSoundSlider->setMinimum(-50); + correctSoundSlider->setMaximum(50); + correctSoundSlider->setOrientation(Qt::Horizontal); + correctSoundSlider->setTickPosition(QSlider::TicksAbove); + correctSoundSlider->setTickInterval(50); + + verticalLayout_2->addWidget(correctSoundSlider); + + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setSpacing(6); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + buttonPrev = new QToolButton(GuitarTunerUI); + buttonPrev->setObjectName(QString::fromUtf8("buttonPrev")); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(buttonPrev->sizePolicy().hasHeightForWidth()); + buttonPrev->setSizePolicy(sizePolicy); + buttonPrev->setArrowType(Qt::LeftArrow); + + horizontalLayout->addWidget(buttonPrev); + + noteLabel = new QLabel(GuitarTunerUI); + noteLabel->setObjectName(QString::fromUtf8("noteLabel")); + noteLabel->setAlignment(Qt::AlignCenter); + + horizontalLayout->addWidget(noteLabel); + + buttonNext = new QToolButton(GuitarTunerUI); + buttonNext->setObjectName(QString::fromUtf8("buttonNext")); + sizePolicy.setHeightForWidth(buttonNext->sizePolicy().hasHeightForWidth()); + buttonNext->setSizePolicy(sizePolicy); + buttonNext->setAutoRaise(false); + buttonNext->setArrowType(Qt::RightArrow); + + horizontalLayout->addWidget(buttonNext); + + + verticalLayout_2->addLayout(horizontalLayout); + + modeButton = new QPushButton(GuitarTunerUI); + modeButton->setObjectName(QString::fromUtf8("modeButton")); + + verticalLayout_2->addWidget(modeButton); + + line = new QFrame(GuitarTunerUI); + line->setObjectName(QString::fromUtf8("line")); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + + verticalLayout_2->addWidget(line); + + horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->setSpacing(6); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + soundSlider = new QSlider(GuitarTunerUI); + soundSlider->setObjectName(QString::fromUtf8("soundSlider")); + soundSlider->setValue(65); + soundSlider->setOrientation(Qt::Vertical); + + horizontalLayout_2->addWidget(soundSlider); + + soundButton = new QToolButton(GuitarTunerUI); + soundButton->setObjectName(QString::fromUtf8("soundButton")); + QIcon icon; + icon.addFile(QString::fromUtf8(":/images/note.svg"), QSize(), QIcon::Normal, QIcon::Off); + icon.addFile(QString::fromUtf8(":/images/noteNo.svg"), QSize(), QIcon::Normal, QIcon::On); + icon.addFile(QString::fromUtf8(":/images/noteNo.svg"), QSize(), QIcon::Active, QIcon::On); + soundButton->setIcon(icon); + soundButton->setIconSize(QSize(30, 30)); + soundButton->setCheckable(true); + soundButton->setAutoRaise(true); + + horizontalLayout_2->addWidget(soundButton); + + micSensitivityLabel = new QLabel(GuitarTunerUI); + micSensitivityLabel->setObjectName(QString::fromUtf8("micSensitivityLabel")); + QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Preferred); + sizePolicy1.setHorizontalStretch(0); + sizePolicy1.setVerticalStretch(0); + sizePolicy1.setHeightForWidth(micSensitivityLabel->sizePolicy().hasHeightForWidth()); + micSensitivityLabel->setSizePolicy(sizePolicy1); + + horizontalLayout_2->addWidget(micSensitivityLabel); + + + verticalLayout_2->addLayout(horizontalLayout_2); + + + retranslateUi(GuitarTunerUI); + + QMetaObject::connectSlotsByName(GuitarTunerUI); + } // setupUi + + void retranslateUi(QWidget *GuitarTunerUI) + { + GuitarTunerUI->setWindowTitle(QApplication::translate("GuitarTunerUI", "GuitarTunerUI", 0, QApplication::UnicodeUTF8)); + buttonPrev->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + noteLabel->setText(QApplication::translate("GuitarTunerUI", "A", 0, QApplication::UnicodeUTF8)); + buttonNext->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + modeButton->setText(QApplication::translate("GuitarTunerUI", "Change mode", 0, QApplication::UnicodeUTF8)); + soundButton->setText(QApplication::translate("GuitarTunerUI", "...", 0, QApplication::UnicodeUTF8)); + micSensitivityLabel->setText(QApplication::translate("GuitarTunerUI", "microphone\n" +"sensitivity", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class GuitarTunerUI: public Ui_GuitarTunerUI {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_GUITARTUNERUI_H diff --git a/demos/mobile/qcamera/businesscardhandling.cpp b/demos/mobile/qcamera/businesscardhandling.cpp new file mode 100755 index 0000000..7c3cd81 --- /dev/null +++ b/demos/mobile/qcamera/businesscardhandling.cpp @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "businesscardhandling.h" +#include + +BusinessCardHandling::BusinessCardHandling(QObject *parent) : + QObject(parent) +{ +} + +BusinessCardHandling::~BusinessCardHandling() +{ + delete m_contactManager; +} + +void BusinessCardHandling::createContactManager() +{ +#if defined Q_WS_MAEMO_5 + m_contactManager = new QContactManager("maemo5"); +#elif defined Q_OS_SYMBIAN + m_contactManager = new QContactManager("symbian"); +#endif + + // Use default + if (!m_contactManager) { + m_contactManager = new QContactManager(); + } +} + +void BusinessCardHandling::storeAvatarToContact(QString phoneNumber, QString filename, + QPixmap pixmap) +{ + // Create QContactManager + if (!m_contactManager) { + createContactManager(); + } + + // Search contacts and save avatar + QContact contact; + if (findContact(phoneNumber, contact)) { + saveAvatar(filename, pixmap, contact); + } +} + +bool BusinessCardHandling::findContact(const QString phoneNumber, QContact& c) +{ + // Create QContactManager + if (!m_contactManager) { + createContactManager(); + } + + QContact contact; + QContactDetailFilter phoneFilter; + phoneFilter.setDetailDefinitionName(QContactPhoneNumber::DefinitionName, + QContactPhoneNumber::FieldNumber); + +#if defined Q_WS_MAEMO_5 + // Workaround for Maemo bug http://bugreports.qt.nokia.com/browse/QTMOBILITY-437 + phoneFilter.setValue(phoneNumber.right(7)); + phoneFilter.setMatchFlags(QContactFilter::MatchContains); +#else + phoneFilter.setValue(phoneNumber); + phoneFilter.setMatchFlags(QContactFilter::MatchPhoneNumber); +#endif + + // Find contacts + QList matchingContacts = m_contactManager->contacts(phoneFilter); + if (matchingContacts.size() > 0) { + contact = matchingContacts.at(0); + c = contact; + return true; + } else { + return false; + } +} + +void BusinessCardHandling::saveAvatar(const QString filename, QPixmap p, QContact& contact) +{ + + // Path to store avatar picture + QString path; +#ifdef Q_OS_SYMBIAN + path.append("c:/System/"); +#endif + path.append(filename); + + // Remove same file if exists + QFile file; + if (file.exists(path)) + file.remove(path); + + // Save pixmap into file + bool saveRet = p.save(path); + + if (saveRet) { + // Create avatar + QContactAvatar contactAvatar; + contactAvatar.setImageUrl(QUrl(path)); + bool saveAvatar = contact.saveDetail(&contactAvatar); + + // Save contact + if (saveAvatar) + m_contactManager->saveContact(&contact); + + // NOTE: Do not remove picture, system needs it for showing avatar + // Remove picture file + //bool removeRet = file.remove(path); + } +} + diff --git a/demos/mobile/qcamera/businesscardhandling.h b/demos/mobile/qcamera/businesscardhandling.h new file mode 100755 index 0000000..a4e998d --- /dev/null +++ b/demos/mobile/qcamera/businesscardhandling.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef BUSINESSCARDHANDLING_H +#define BUSINESSCARDHANDLING_H + +#include +#include +#include + +// QtMobility API headers +// Contacts +#include +#include +#include +#include +#include +#include +#include + + +// QtMobility namespace +QTM_USE_NAMESPACE + +class BusinessCardHandling: public QObject +{ +Q_OBJECT + +public: + BusinessCardHandling(QObject *parent = 0); + ~BusinessCardHandling(); + + bool findContact(const QString phoneNumber, QContact& contact); + +public slots: + void storeAvatarToContact(QString, QString, QPixmap); + +private: + void createContactManager(); + void saveAvatar(const QString filename, QPixmap p, QContact& contact); + +private: + QPointer m_contactManager; +}; + +#endif // BUSINESSCARDHANDLING_H diff --git a/demos/mobile/qcamera/button.cpp b/demos/mobile/qcamera/button.cpp new file mode 100755 index 0000000..cc09a11 --- /dev/null +++ b/demos/mobile/qcamera/button.cpp @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "button.h" +#include +#include +#include + +Button::Button(QWidget *parent, Qt::WindowFlags f) : + QLabel(parent, f) +{ + m_downPixmap = 0; + m_disabled = false; +} + +Button::~Button() +{ +} + +void Button::disableBtn(bool b) +{ + m_disabled = b; + if (m_disabled) { + setPixmap(m_downPixmap); + } else { + setPixmap(m_upPixmap); + } +} + +void Button::mousePressEvent(QMouseEvent *event) +{ + if (!m_disabled) { + event->accept(); + setPixmap(m_downPixmap); + repaint(); + // Lift button back to up after 300ms + QTimer::singleShot(300, this, SLOT(backToUp())); + } +} + +void Button::backToUp() +{ + setPixmap(m_upPixmap); + repaint(); + emit pressed(); +} + +void Button::setPixmap(const QPixmap& p) +{ + // Set up and down picture for the button + // Set pixmap + if (!p.isNull()) + QLabel::setPixmap(p); + + // Make down pixmap if it does not exists + if (m_downPixmap.isNull()) { + // Store up pixmap + m_upPixmap = *pixmap(); + + // Create down pixmap + // Make m_downPixmap as a transparent m_upPixmap + QPixmap transparent(m_upPixmap.size()); + transparent.fill(Qt::transparent); + QPainter painter(&transparent); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.drawPixmap(0, 0, m_upPixmap); + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.fillRect(transparent.rect(), QColor(0, 0, 0, 150)); + painter.end(); + m_downPixmap = transparent; + } + +} diff --git a/demos/mobile/qcamera/button.h b/demos/mobile/qcamera/button.h new file mode 100755 index 0000000..e6f295b --- /dev/null +++ b/demos/mobile/qcamera/button.h @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef BUTTON_H +#define BUTTON_H + +#include +#include + +class Button: public QLabel +{ +Q_OBJECT + +public: + Button(QWidget *parent = 0, Qt::WindowFlags f = 0); + ~Button(); + + void mousePressEvent(QMouseEvent *); + void disableBtn(bool); + +public Q_SLOTS: + void setPixmap(const QPixmap &); + void backToUp(); + + signals: + void pressed(); + +private: + QPixmap m_upPixmap; + QPixmap m_downPixmap; + bool m_disabled; + +}; + +#endif // BUTTON_H diff --git a/demos/mobile/qcamera/cameraexample.cpp b/demos/mobile/qcamera/cameraexample.cpp new file mode 100755 index 0000000..9b5c71b --- /dev/null +++ b/demos/mobile/qcamera/cameraexample.cpp @@ -0,0 +1,514 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "cameraexample.h" +#include "messagehandling.h" +#include "contactsdlg.h" +#include "button.h" +#include "businesscardhandling.h" +#include + +/***************************************************************************** +* MyVideoSurface +*/ +MyVideoSurface::MyVideoSurface(QWidget* widget, VideoIF* target, QObject* parent) + : QAbstractVideoSurface(parent) +{ + m_targetWidget = widget; + m_target = target; + m_imageFormat = QImage::Format_Invalid; +} + +MyVideoSurface::~MyVideoSurface() +{ +} + +bool MyVideoSurface::start(const QVideoSurfaceFormat &format) +{ + m_videoFormat = format; + const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat()); + const QSize size = format.frameSize(); + + if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) { + m_imageFormat = imageFormat; + QAbstractVideoSurface::start(format); + return true; + } else { + return false; + } +} + +bool MyVideoSurface::present(const QVideoFrame &frame) +{ + m_frame = frame; + if (surfaceFormat().pixelFormat() != m_frame.pixelFormat() || + surfaceFormat().frameSize() != m_frame.size()) { + stop(); + return false; + } else { + m_target->updateVideo(); + return true; + } +} + +void MyVideoSurface::paint(QPainter *painter) + { + if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) { + QImage image( + m_frame.bits(), + m_frame.width(), + m_frame.height(), + m_frame.bytesPerLine(), + m_imageFormat); + + QRect r = m_targetWidget->rect(); + QPoint centerPic((qAbs(r.size().width() - image.size().width())) / 2, (qAbs( + r.size().height() - image.size().height())) / 2); + + if (!image.isNull()) { + painter->drawImage(centerPic,image); + } + + m_frame.unmap(); + } + } + +QList MyVideoSurface::supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType) const +{ + if (handleType == QAbstractVideoBuffer::NoHandle) { + return QList() + << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_ARGB32_Premultiplied + << QVideoFrame::Format_RGB565 + << QVideoFrame::Format_RGB555; + } else { + return QList(); + } +} + + +/***************************************************************************** +* CameraExample +*/ +CameraExample::CameraExample(QWidget *parent) : + QMainWindow(parent) +{ + setWindowTitle("QCameraExample"); + + // Opitimizations for screen update and drawing qwidget + setAutoFillBackground(false); + + // Prevent to screensaver to activate + m_systemScreenSaver = new QSystemScreenSaver(this); + m_systemScreenSaver->setScreenSaverInhibit(); + + m_myVideoSurface = 0; + pictureCaptured = false; + showViewFinder = false; + m_focusing = false; + + // MMS handling + m_message = new Message(this); + QObject::connect(m_message, SIGNAL(messageStateChanged(int)), this, SLOT(messageStateChanged(int))); + QObject::connect(m_message, SIGNAL(messageReceived(QString,QString,QPixmap)), this, SLOT(messageReceived(QString,QString,QPixmap))); + + // Business card handling (Contact's avatar picture) + m_businessCardHandling = new BusinessCardHandling(this); + + // Black background + QPalette palette = this->palette(); + palette.setColor(QPalette::Background, Qt::black); + setPalette(palette); + + // Main widget & layout + QWidget* mainWidget = new QWidget(this); + mainWidget->setPalette(palette); + + QHBoxLayout* hboxl = new QHBoxLayout; + hboxl->setSpacing(0); + hboxl->setMargin(0); + + // UI stack + m_stackedWidget = new QStackedWidget(); + m_stackedWidget->setPalette(palette); + + // First widget to stack + m_videoWidget = new QWidget(); + m_videoWidget->setPalette(palette); + m_stackedWidget->addWidget(m_videoWidget); + + // Second widget to stack + QWidget* secondWidget = new QWidget(this); + secondWidget->setPalette(palette); + m_stackedWidget->addWidget(secondWidget); + m_stackedWidget->setCurrentIndex(0); + + hboxl->addWidget(m_stackedWidget); + + // Buttons + QSize iconSize(80, 80); + QVBoxLayout* vboxl = new QVBoxLayout; + vboxl->setSpacing(0); + vboxl->setMargin(0); + + // Exit button + m_exit = new Button(this); + QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit())); + QPixmap p = QPixmap(":/icons/exit.png"); + m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + vboxl->addWidget(m_exit); + vboxl->setAlignment(m_exit, Qt::AlignHCenter | Qt::AlignTop); + + // Camera button + m_cameraBtn = new Button(this); + QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock())); + p = QPixmap(":/icons/camera.png"); + m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + vboxl->addWidget(m_cameraBtn); + vboxl->setAlignment(m_cameraBtn, Qt::AlignCenter); + + // Send MMS button + m_mms = new Button(this); + QObject::connect(m_mms, SIGNAL(pressed()), this, SLOT(openContactsDlg())); + p = QPixmap(":/icons/mms.png"); + m_mms->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + vboxl->addWidget(m_mms); + vboxl->setAlignment(m_mms, Qt::AlignHCenter | Qt::AlignBottom); +#ifndef MESSAGING_ENABLED + m_mms->disableBtn(true); + m_mms->setEnabled(false); +#endif + + hboxl->addLayout(vboxl); + mainWidget->setLayout(hboxl); + + setCentralWidget(mainWidget); + + // Enable camera after 1s, so that the application is started + // and widget is created to landscape orientation + QTimer::singleShot(1000,this,SLOT(enableCamera())); +} + +CameraExample::~CameraExample() +{ +if (m_myVideoSurface) + m_myVideoSurface->stop(); + m_camera->stop(); + delete m_stackedWidget; + delete m_stillImageCapture; + delete m_camera; +} + + +void CameraExample::enableCamera() +{ + m_camera = new QCamera(); + m_camera->setCaptureMode(QCamera::CaptureStillImage); + connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(error(QCamera::Error))); + connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)), this, SLOT(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason))); + + // Own video output drawing that shows camera view finder pictures + //! [0] + QMediaService* ms = m_camera->service(); + QVideoRendererControl* vrc = ms->requestControl(); + m_myVideoSurface = new MyVideoSurface(this,this,this); + vrc->setSurface(m_myVideoSurface); +//! [0] + // Image capturer + m_stillImageCapture = new QCameraImageCapture(m_camera); + connect(m_stillImageCapture, SIGNAL(imageCaptured(int,QImage)), this, SLOT(imageCaptured(int,QImage))); + + // Start camera + if (m_camera->state() == QCamera::ActiveState) { + m_camera->stop(); + } + m_videoWidget->show(); + m_camera->start(); + showViewFinder = true; +} + +void CameraExample::mousePressEvent(QMouseEvent *event) +{ + QMainWindow::mousePressEvent(event); + + if (pictureCaptured) { + // Starting view finder + pictureCaptured = false; + m_stackedWidget->setCurrentIndex(0); + if (m_myVideoSurface) { + showViewFinder = true; + } + } +} + +void CameraExample::searchAndLock() +{ + m_focusing = false; + m_focusMessage.clear(); + + if (pictureCaptured) { + // Starting view finder again + pictureCaptured = false; + m_stackedWidget->setCurrentIndex(0); + if (m_myVideoSurface) { + showViewFinder = true; + } + } + else { + // Search and lock picture (=focus) + if (m_camera->supportedLocks() & QCamera::LockFocus) { + m_focusing = true; + m_focusMessage = "Focusing..."; + m_camera->searchAndLock(QCamera::LockFocus); + } else { + // No focus functionality, take picture right away + captureImage(); + } + } +} + +void CameraExample::lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason) +{ + if (status == QCamera::Locked) { + if (reason == QCamera::LockAcquired) { + // Focus locked + m_focusMessage.clear(); + m_focusing = false; + // Capture new image + captureImage(); + // Unlock camera + m_camera->unlock(); + } else { + if (m_focusing) + m_focusMessage = "No focus, try again"; + } + } else if (status == QCamera::Unlocked && m_focusing) { + m_focusMessage = "No focus, try again"; + } +} + +void CameraExample::captureImage() +{ + if (pictureCaptured) { + // Starting view finder again + pictureCaptured = false; + m_stackedWidget->setCurrentIndex(0); + showViewFinder = true; + } + else { + // Capturing image + showViewFinder = false; + // Get picture location where to store captured images + QString path(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); + QDir dir(path); + + // Get next filename + QStringList files = dir.entryList(QStringList() << "camera_*.jpg"); + int lastImage = 0; + foreach ( QString fileName, files ) { + int imgNumber = fileName.mid(7, fileName.size() - 11).toInt(); + lastImage = qMax(lastImage, imgNumber); + } + // Capture image + if (m_stillImageCapture->isReadyForCapture()) { + m_imageName = QString("camera_%1.jpg").arg(lastImage+1); + m_stillImageCapture->capture(m_imageName); + } + } +} + +void CameraExample::imageCaptured(int id, const QImage &preview) +{ + showViewFinder = false; + m_focusing = false; + + // Image captured, show it to the user + m_stackedWidget->setCurrentIndex(1); + + // Get picture location + QString path(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); + m_imageName.prepend(path + "/"); + + m_capturedImage = preview; + + // Set suitable size to the image + QSize s = m_videoWidget->size(); + s = s - QSize(20, 20); + m_capturedImage = m_capturedImage.scaled(s, Qt::KeepAspectRatio, Qt::SmoothTransformation); + + pictureCaptured = true; + update(); +} + +void CameraExample::error(QCamera::Error e) +{ + switch (e) { + case QCamera::NoError: + { + break; + } + case QCamera::CameraError: + { + QMessageBox::warning(this, "QCameraExample", "General Camera error"); + break; + } + case QCamera::InvalidRequestError: + { + QMessageBox::warning(this, "QCameraExample", "Camera invalid request error"); + break; + } + case QCamera::ServiceMissingError: + { + QMessageBox::warning(this, "QCameraExample", "Camera service missing error"); + break; + } + case QCamera::NotSupportedFeatureError : + { + QMessageBox::warning(this, "QCameraExample", "Camera not supported error"); + break; + } + }; +} + +void CameraExample::openContactsDlg() +{ + // Open dialog for showing contacts + if (!m_contactsDialog) { + + if (m_capturedImage.isNull()) { + QMessageBox::information(this, "QCameraExample", "Take picture first"); + return; + } + + // Show dialog + m_contactsDialog = new ContactsDialog(this); + QObject::connect(m_contactsDialog, SIGNAL(contactSelected(QString)), + this, SLOT(contactSelected(QString))); + m_contactsDialog->exec(); + QObject::disconnect(m_contactsDialog, SIGNAL(contactSelected(QString)), + this, SLOT(contactSelected(QString))); + + delete m_contactsDialog; + m_contactsDialog = 0; + } +} + +void CameraExample::contactSelected(QString phoneNumber) +{ + m_phoneNumber = phoneNumber; + QTimer::singleShot(1000,this,SLOT(sendMMS())); +} + +void CameraExample::sendMMS() +{ +#ifdef MESSAGING_ENABLED + m_message->sendMMS(m_imageName, m_phoneNumber); +#endif +} + +void CameraExample::messageStateChanged(int /*error*/) +{ +} + +void CameraExample::updateVideo() +{ + if (showViewFinder) { + repaint(); + } +} + +void CameraExample::paintEvent(QPaintEvent *event) +{ + //QMainWindow::paintEvent(event); + + QPainter painter(this); + QRect r = this->rect(); + + QFont font = painter.font(); + font.setPixelSize(20); + painter.setFont(font); + painter.setPen(Qt::white); + + if (showViewFinder && m_myVideoSurface && m_myVideoSurface->isActive()) { + // Show view finder + m_myVideoSurface->paint(&painter); + + // Paint focus message + if (!m_focusMessage.isEmpty()) + painter.drawText(r, Qt::AlignCenter, m_focusMessage); + + } else { + // Draw black + painter.fillRect(event->rect(), palette().background()); + // Show captured image + if (pictureCaptured) { + // Paint captured image + QPoint centerPic((qAbs(r.size().width() - m_capturedImage.size().width())) / 2, (qAbs( + r.size().height() - m_capturedImage.size().height())) / 2); + + painter.drawImage(centerPic, m_capturedImage); + + // Paint filename + painter.drawText(r, Qt::AlignBottom | Qt::AlignCenter, m_imageName); + } + } + +} + +void CameraExample::messageReceived(QString phoneNumber, QString filename, QPixmap pixmap) +{ +#ifdef MESSAGING_ENABLED + // MMS message received + // Check that is came from some of our contact + QContact contact; + if (m_businessCardHandling->findContact(phoneNumber, contact)) { + // Ask from user to store it as sender avatar picture into contacts + if (QMessageBox::question( + this, + "QCameraExample", + QString( + "MMS picture message received from %1. Do you want to store it as sender avatar picture?").arg( + contact.displayLabel()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + + m_businessCardHandling->storeAvatarToContact(phoneNumber, filename, pixmap); + } + } +#endif +} + diff --git a/demos/mobile/qcamera/cameraexample.h b/demos/mobile/qcamera/cameraexample.h new file mode 100755 index 0000000..77883f9 --- /dev/null +++ b/demos/mobile/qcamera/cameraexample.h @@ -0,0 +1,154 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef QCAMERAEXAMPLE_H +#define QCAMERAEXAMPLE_H + +#include + +// Multimedia API in QtMobility API +// Unlike the other APIs in Qt Mobility, +// the Multimedia API is not in the QtMobility namespace "QTM_USE_NAMESPACE" +#include +#include + +// QtMobility API +#include +QTM_USE_NAMESPACE + + +#include +#include +#include + +/***************************************************************************** +* MyVideoSurface +*/ +class VideoIF +{ +public: + virtual void updateVideo() = 0; +}; +class MyVideoSurface: public QAbstractVideoSurface +{ +Q_OBJECT + +public: + MyVideoSurface(QWidget* widget, VideoIF* target, QObject * parent = 0); + ~MyVideoSurface(); + + bool start(const QVideoSurfaceFormat &format); + + bool present(const QVideoFrame &frame); + + QList supportedPixelFormats( + QAbstractVideoBuffer::HandleType handleType = QAbstractVideoBuffer::NoHandle) const; + + void paint(QPainter*); + +private: + QWidget* m_targetWidget; + VideoIF* m_target; + QVideoFrame m_frame; + QImage::Format m_imageFormat; + QVideoSurfaceFormat m_videoFormat; +}; + + + +/***************************************************************************** +* CameraExample +*/ +class Message; +class ContactsDialog; +class Button; +class BusinessCardHandling; +class CameraExample: public QMainWindow, public VideoIF +{ +Q_OBJECT + +public: + CameraExample(QWidget *parent = 0); + ~CameraExample(); + + void paintEvent(QPaintEvent*); + void mousePressEvent(QMouseEvent *); + + void updateVideo(); + + +public slots: + void enableCamera(); + void lockStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason); + void searchAndLock(); + void captureImage(); + void imageCaptured(int id, const QImage &preview); + void error(QCamera::Error); + + void openContactsDlg(); + void contactSelected(QString phoneNumber); + + void messageStateChanged(int error); + void messageReceived(QString phoneNumber, QString filename, QPixmap pixmap); + + void sendMMS(); + +private: + QWidget* m_videoWidget; + QCamera* m_camera; + QCameraImageCapture* m_stillImageCapture; + + QStackedWidget* m_stackedWidget; + Button* m_exit; + Button* m_cameraBtn; + Button* m_mms; + QImage m_capturedImage; + QString m_imageName; + QString m_focusMessage; + bool m_focusing; + QString m_phoneNumber; + + Message* m_message; + QPointer m_contactsDialog; + BusinessCardHandling* m_businessCardHandling; + bool pictureCaptured; + bool showViewFinder; + MyVideoSurface* m_myVideoSurface; + QSystemScreenSaver* m_systemScreenSaver; +}; + +#endif // QCAMERA_H diff --git a/demos/mobile/qcamera/contactsdlg.cpp b/demos/mobile/qcamera/contactsdlg.cpp new file mode 100755 index 0000000..fff81fd --- /dev/null +++ b/demos/mobile/qcamera/contactsdlg.cpp @@ -0,0 +1,156 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "contactsdlg.h" +#include +#include +#include +#include +#include + +ContactsDialog::ContactsDialog(QWidget *parent) : + QDialog(parent) +{ + QHBoxLayout* l = new QHBoxLayout; + m_listWidget = new QListWidget(this); + l->addWidget(m_listWidget); + + QVBoxLayout* lv = new QVBoxLayout; + + QPushButton* backBtn = new QPushButton("Back",this); + QObject::connect(backBtn, SIGNAL(pressed()), this, SLOT(close())); + backBtn->setFixedWidth(100); + lv->addWidget(backBtn); + lv->setAlignment(backBtn,Qt::AlignTop); + + QPushButton* okBtn = new QPushButton("Ok",this); + QObject::connect(okBtn, SIGNAL(pressed()), this, SLOT(selectContact())); + okBtn->setFixedWidth(100); + lv->addWidget(okBtn); + lv->setAlignment(okBtn,Qt::AlignBottom); + + l->addLayout(lv); + + setLayout(l); + + // Remove context menu from the all widgets +#ifdef Q_OS_SYMBIAN + QWidgetList widgets = QApplication::allWidgets(); + QWidget* w = 0; + foreach (w,widgets) + { + w->setContextMenuPolicy(Qt::NoContextMenu); + } +#endif + + // Create QContactManager and search contacts + createContactManager(); + searchContact(); + + showFullScreen(); +} + +ContactsDialog::~ContactsDialog() +{ + delete m_contactManager; +} + +void ContactsDialog::createContactManager() +{ +#if defined Q_WS_MAEMO_5 + m_contactManager = new QContactManager("maemo5"); +#elif defined Q_OS_SYMBIAN + m_contactManager = new QContactManager("symbian"); +#endif + + // Use default + if (!m_contactManager) { + m_contactManager = new QContactManager(); + } + +} + +void ContactsDialog::searchContact() +{ + m_listWidget->clear(); + + // Sort contacts by lastname + QContactSortOrder sort; + sort.setDirection(Qt::AscendingOrder); + sort.setDetailDefinitionName(QContactName::DefinitionName, QContactName::FieldLastName); + + // Build QListWidget from the contact list + QList contactIds = m_contactManager->contactIds(sort); + QContact currContact; + foreach (const QContactLocalId& id, contactIds) + { + QListWidgetItem *currItem = new QListWidgetItem; + currContact = m_contactManager->contact(id); + QContactDisplayLabel dl = currContact.detail(QContactDisplayLabel::DefinitionName); + currItem->setData(Qt::DisplayRole, dl.label()); + currItem->setData(Qt::UserRole, currContact.localId()); // also store the id of the contact + m_listWidget->addItem(currItem); + } + + if (m_listWidget->count()>0) { + m_listWidget->setCurrentRow(0); + } +} + +void ContactsDialog::selectContact() +{ + QList items = m_listWidget->selectedItems(); + if (!items.isEmpty()) { + itemClicked(items.first()); + } +} + +void ContactsDialog::itemClicked(QListWidgetItem *item) +{ + QVariant data = item->data(Qt::UserRole); + QContactLocalId id = data.toInt(); + QContact contact = m_contactManager->contact(id); + QContactPhoneNumber cpn = contact.detail (); + + // Emit contact phonenumber + if (!cpn.isEmpty()) { + emit contactSelected(cpn.number()); + // Close dialog + close(); + } +} + diff --git a/demos/mobile/qcamera/contactsdlg.h b/demos/mobile/qcamera/contactsdlg.h new file mode 100755 index 0000000..e9d5c17 --- /dev/null +++ b/demos/mobile/qcamera/contactsdlg.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2011 Nokia Corporation. + */ + +#ifndef CONTACTSDIALOG_H +#define CONTACTSDIALOG_H + +#include +#include +#include + +// QtMobility API headers +// Contacts +#include +#include +#include +#include +#include + +// QtMobility namespace +QTM_USE_NAMESPACE + +class ContactsDialog: public QDialog +{ +Q_OBJECT + +public: + ContactsDialog(QWidget *parent = 0); + ~ContactsDialog(); + +public slots: + void itemClicked(QListWidgetItem *item); + void selectContact(); + +signals: + void contactSelected(QString phoneNumber); + +private: + void createContactManager(); + void searchContact(); + +private: + QPointer m_contactManager; + QListWidget* m_listWidget; +}; + +#endif // CONTACTSDIALOG_H diff --git a/demos/mobile/qcamera/icons/camera.png b/demos/mobile/qcamera/icons/camera.png new file mode 100755 index 0000000..dc4ecbf Binary files /dev/null and b/demos/mobile/qcamera/icons/camera.png differ diff --git a/demos/mobile/qcamera/icons/cameramms_icon.svg b/demos/mobile/qcamera/icons/cameramms_icon.svg new file mode 100755 index 0000000..ae6f354 --- /dev/null +++ b/demos/mobile/qcamera/icons/cameramms_icon.svg @@ -0,0 +1,255 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/demos/mobile/qcamera/icons/exit.png b/demos/mobile/qcamera/icons/exit.png new file mode 100755 index 0000000..dbe586a Binary files /dev/null and b/demos/mobile/qcamera/icons/exit.png differ diff --git a/demos/mobile/qcamera/icons/mms.png b/demos/mobile/qcamera/icons/mms.png new file mode 100755 index 0000000..46a1a73 Binary files /dev/null and b/demos/mobile/qcamera/icons/mms.png differ diff --git a/demos/mobile/qcamera/main.cpp b/demos/mobile/qcamera/main.cpp new file mode 100755 index 0000000..7d46554 --- /dev/null +++ b/demos/mobile/qcamera/main.cpp @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "cameraexample.h" + +#include +#include +#include + +// Lock Symbian orientation +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#include +#endif + + +#ifdef Q_OS_SYMBIAN +#include +#include + +#endif + +static const int KGoomMemoryLowEvent = 0x10282DBF; +static const int KGoomMemoryGoodEvent = 0x20026790; + +class MyApplication : public QApplication +{ +public: + MyApplication( int argc, char** argv ) : QApplication( argc, argv ) {} + +#ifdef Q_OS_SYMBIAN +protected: +//! [0] + bool symbianEventFilter( const QSymbianEvent* symbianEvent ) + { + const TWsEvent *event = symbianEvent->windowServerEvent(); + if ( !event ) { + return false; + } + switch ( event->Type() ) { + // GOOM handling enabled + // http://wiki.forum.nokia.com/index.php/Graphics_memory_handling + case EEventUser: { + TApaSystemEvent* eventData = reinterpret_cast(event->EventData()); + if ((*eventData) == EApaSystemEventShutdown) { + eventData++; + if ((*eventData) == KGoomMemoryLowEvent) { + return true; + } + } + break; + } + default: + break; + }; + + // Always return false so we don't stop + // the event from being processed + return false; + } +//! [0] +#endif +}; + + +int main(int argc, char *argv[]) +{ + // NOTE: set this value before creating MyApplication instance + // http://doc.trolltech.com/qapplication.html#setGraphicsSystem + QApplication::setGraphicsSystem("raster"); // NOTE: Seems that raster have to be enabled with Nokia N8 + + MyApplication a(argc, argv); + + // Lock Symbian orientation +#ifdef Q_OS_SYMBIAN + CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi()); + TRAP_IGNORE( + if (appUi) { + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape); + } + ); +#endif + + CameraExample w; + w.showFullScreen(); + + return a.exec(); +} diff --git a/demos/mobile/qcamera/messagehandling.cpp b/demos/mobile/qcamera/messagehandling.cpp new file mode 100755 index 0000000..04d0139 --- /dev/null +++ b/demos/mobile/qcamera/messagehandling.cpp @@ -0,0 +1,180 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "messagehandling.h" +#include +#include +#include +#include +#include +#include +#include + +Message::Message(QObject *parent) : + QObject(parent) +{ + // QMessageService class provides the interface for requesting messaging service operations + m_service = new QMessageService(this); + //QObject::connect(m_service, SIGNAL(stateChanged(QMessageService::State)), this, SLOT(stateChanged(QMessageService::State))); + QObject::connect(m_service, SIGNAL(messagesFound(const QMessageIdList&)), this, SLOT(messagesFound(const QMessageIdList&))); + + // QMessageManager class represents the main interface for storage and + // retrieval of messages, folders and accounts in the system message store + m_manager = new QMessageManager(this); + + QObject::connect(m_manager, SIGNAL(messageAdded(const QMessageId&,const QMessageManager::NotificationFilterIdSet&)), + this, SLOT(messageAdded(const QMessageId&,const QMessageManager::NotificationFilterIdSet&))); + + // Register MMS in inbox (draft in emulator) folder notificationfilter +#ifdef Q_OS_SYMBIAN +#ifdef __WINS__ + m_notifFilterSet.insert(m_manager->registerNotificationFilter(QMessageFilter::byStandardFolder( + QMessage::DraftsFolder))); +#else + m_notifFilterSet.insert(m_manager->registerNotificationFilter(QMessageFilter::byStandardFolder( + QMessage::InboxFolder))); +#endif +#else + m_notifFilterSet.insert(m_manager->registerNotificationFilter(QMessageFilter::byStandardFolder( + QMessage::InboxFolder))); +#endif + +} + +Message::~Message() +{ +} + +void Message::messageAdded(const QMessageId& id, + const QMessageManager::NotificationFilterIdSet& matchingFilterIds) +{ + if (matchingFilterIds.contains(m_notifFilterSet)) { + processIncomingMMS(id); + } +} + + +void Message::checkMessages() +{ +#ifdef Q_OS_SYMBIAN +#ifdef __WINS__ + QMessageFilter folderFilter(QMessageFilter::byStandardFolder(QMessage::DraftsFolder)); +#else + QMessageFilter folderFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder)); +#endif +#else + QMessageFilter folderFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder)); +#endif + + m_service->queryMessages(folderFilter); + // Message::messagesFound() is called if MMS messages found + +} + +void Message::messagesFound(const QMessageIdList &ids) +{ + foreach (const QMessageId& id, ids) { + processIncomingMMS(id); + } +} + +void Message::processIncomingMMS(const QMessageId& id) +{ + QMessage message = m_manager->message(id); + + // Handle only MMS messages + if (message.type()!=QMessage::Mms) + return; + + + QMessageContentContainerIdList attachments = message.attachmentIds(); + if (!attachments.isEmpty()) { + QMessageContentContainer messageContent = message.find(attachments[0]); + if (messageContent.isContentAvailable() && messageContent.contentType() == "image") { + + // Create QPixmap from the message image attachment + QPixmap pixmap; + pixmap.loadFromData(messageContent.content()); + + QString from = message.from().addressee(); + QString filename = messageContent.suggestedFileName(); + + // Emit received MMS message info + emit messageReceived(from, filename, pixmap); + } + } +} + +bool Message::sendMMS(QString picturePath, QString phoneNumber) +{ + QString tmpFileName = "c:/System/qcamera_mms.jpg"; + + // Create temp image for MMS + // Delete previous temp image + QFile previousFile(tmpFileName); + if (previousFile.exists()) { + previousFile.remove(); + } + // Create new temp image + QImageReader reader; + reader.setFileName(picturePath); + QSize imageSize = reader.size(); + imageSize.scale(QSize(300,300), Qt::KeepAspectRatio); + reader.setScaledSize(imageSize); + QImage image = reader.read(); + image.save(tmpFileName); + + // Use temp mms image + picturePath = tmpFileName; + + // Send MMS + QMessage message; + message.setType(QMessage::Mms); + message.setParentAccountId(QMessageAccount::defaultAccount(QMessage::Mms)); + message.setTo(QMessageAddress(QMessageAddress::Phone, phoneNumber)); + + QStringList paths; + paths << picturePath; + message.appendAttachments(paths); + + return m_service->send(message); +} + +void Message::stateChanged(QMessageService::State s) +{ + emit messageStateChanged(s); +} diff --git a/demos/mobile/qcamera/messagehandling.h b/demos/mobile/qcamera/messagehandling.h new file mode 100755 index 0000000..b83e25f --- /dev/null +++ b/demos/mobile/qcamera/messagehandling.h @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2011 Nokia Corporation. All rights reserved. + * + * Nokia and Nokia Connecting People are registered trademarks of Nokia + * Corporation. Oracle and Java are registered trademarks of Oracle and/or its + * affiliates. Other product and company names mentioned herein may be + * trademarks or trade names of their respective owners. + * + * + * Subject to the conditions below, you may, without charge: + * + * * Use, copy, modify and/or merge copies of this software and associated + * documentation files (the "Software") + * + * * Publish, distribute, sub-licence and/or sell new software derived from + * or incorporating the Software. + * + * + * + * This file, unmodified, shall be included with all copies or substantial + * portions of the Software that are distributed in source code form. + * + * The Software cannot constitute the primary value of any new software derived + * from or incorporating the Software. + * + * Any person dealing with the Software shall not misrepresent the source of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef MESSAGE_H +#define MESSAGE_H + +#include +#include + +// QtMobility API headers +// Messaging +#include +#include +#include + +// Location +#include + +// QtMobility namespace +QTM_USE_NAMESPACE + +class Message: public QObject +{ +Q_OBJECT + +public: + Message(QObject *parent = 0); + ~Message(); + + void checkMessages(); + bool sendMMS(QString picturePath, QString phoneNumber); + +private: + void processIncomingMMS(const QMessageId& id); + +public slots: + // QMessageService + void stateChanged(QMessageService::State s); + void messagesFound(const QMessageIdList &ids); + + // QMessageManager + void messageAdded(const QMessageId &id, const QMessageManager::NotificationFilterIdSet &matchingFilterIds); + +signals: + void messageStateChanged(int); + void messageReceived(QString from, QString filename, QPixmap pixmap); + +private: + QMessageService* m_service; + QMessageManager* m_manager; + QMessageManager::NotificationFilterIdSet m_notifFilterSet; + QMessageId m_messageId; +}; + +#endif // MESSAGE_H diff --git a/demos/mobile/qcamera/qcamera.pro b/demos/mobile/qcamera/qcamera.pro new file mode 100755 index 0000000..4a6dea6 --- /dev/null +++ b/demos/mobile/qcamera/qcamera.pro @@ -0,0 +1,62 @@ + +# Copyright (c) 2011 Nokia Corporation. + +TEMPLATE = app +TARGET = qcamera + +VERSION = 1.1.0 + +QT += network + +HEADERS += contactsdlg.h \ + cameraexample.h \ + messagehandling.h \ + button.h \ + businesscardhandling.h + +SOURCES += contactsdlg.cpp \ + main.cpp \ + cameraexample.cpp \ + messagehandling.cpp \ + button.cpp \ + businesscardhandling.cpp + +CONFIG += mobility +MOBILITY = contacts \ + messaging \ + multimedia \ + location \ + systeminfo + +RESOURCES += resources.qrc + +ICON = icons/cameramms_icon.svg + +symbian: { + # Because landscape orientation lock + LIBS += -lcone -leikcore -lavkon + TARGET.UID3 = 0xEF642F0E + TARGET = QCamera + TARGET.EPOCSTACKSIZE = 0x14000 + TARGET.EPOCHEAPSIZE = 0x20000 0x8000000 + + # Self-signing capabilities + TARGET.CAPABILITY += NetworkServices \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + + # QtMobility Messaging module needs these + #DEFINES += MESSAGING_ENABLED + + contains(DEFINES,MESSAGING_ENABLED) { + # Additional capabilities that needs Open Signed Online signing + TARGET.CAPABILITY += ReadDeviceData WriteDeviceData + } +} + +!contains(DEFINES,MESSAGING_ENABLED) { + warning(Qt Mobility Messaging disabled!) +} + diff --git a/demos/mobile/qcamera/qcamera.pro.user b/demos/mobile/qcamera/qcamera.pro.user new file mode 100644 index 0000000..6ac56bc --- /dev/null +++ b/demos/mobile/qcamera/qcamera.pro.user @@ -0,0 +1,582 @@ + + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 2 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-desktop + 2 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Qt in PATH Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-desktop + 2 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Desktop Qt for GCC (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-desktop + 4 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Desktop Qt for GCC (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-desktop + 4 + 0 + true + + 4 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + qcamera + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qcamera.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + Qt Simulator + Qt Simulator + Qt4ProjectManager.Target.QtSimulatorTarget + 3 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Simulator Qt for GCC (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Simulator Qt for GCC (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-simulator + 6 + 0 + true + + 4 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + qcamera + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qcamera.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.2 + + Remote Compiler + Remote Compiler + Qt4ProjectManager.Target.WccCompilerTarget + 0 + 0 + 0 + + + + + + Qt4ProjectManager.WccBuildStep + + + + 1 + 1 + 4_7_0_m1_0_2 + 1 + maemo5 + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/qt-contributor-team/demos/qcamera-build-remote + 7 + 12 + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + Remote Compiler - Empty Run Configuration + Qt4ProjectManager.WccRunConfiguration + qcamera.pro + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7d0e1b67-5eac-4464-8506-ed03165c2662} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/demos/mobile/qcamera/resources.qrc b/demos/mobile/qcamera/resources.qrc new file mode 100755 index 0000000..833fa99 --- /dev/null +++ b/demos/mobile/qcamera/resources.qrc @@ -0,0 +1,7 @@ + + + icons/camera.png + icons/exit.png + icons/mms.png + + diff --git a/demos/mobile/qtbubblelevel/accelerometerfilter.cpp b/demos/mobile/qtbubblelevel/accelerometerfilter.cpp new file mode 100644 index 0000000..78482ee --- /dev/null +++ b/demos/mobile/qtbubblelevel/accelerometerfilter.cpp @@ -0,0 +1,78 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include "accelerometerfilter.h" + +#define RADIANS_TO_DEGREES 57.2957795 + +AccelerometerFilter::AccelerometerFilter() + : x(0), y(0), z(0) +{ +} + +//! [0] +bool AccelerometerFilter::filter(QAccelerometerReading *reading) +{ + qreal rx = reading->x(); + qreal ry = reading->y(); + qreal rz = reading->z(); + + qreal divider = sqrt(rx * rx + ry * ry + rz * rz); + + // Lowpass factor +#ifdef Q_OS_SYMBIAN + float lowPassFactor = 0.10; +#else + float lowPassFactor = 0.05; +#endif + + // Calculate the axis angles in degrees and reduce the noise in sensor + // readings. + x += (acos(rx / divider) * RADIANS_TO_DEGREES - 90 - x) * lowPassFactor; + y += (acos(ry / divider) * RADIANS_TO_DEGREES - 90 - y) * lowPassFactor; + z += (acos(rz / divider) * RADIANS_TO_DEGREES - 90 - z) * lowPassFactor; + + // The orientations of the accelerometers are different between + // Symbian and Maemo devices so we use the different axes + // depending on the platform. +#if defined(Q_OS_SYMBIAN) + emit rotationChanged(-y); +#else + emit rotationChanged(x); +#endif + + // Don't store the reading in the sensor. + return false; +} +//! [0] diff --git a/demos/mobile/qtbubblelevel/accelerometerfilter.h b/demos/mobile/qtbubblelevel/accelerometerfilter.h new file mode 100644 index 0000000..8e592ad --- /dev/null +++ b/demos/mobile/qtbubblelevel/accelerometerfilter.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef ACCELEROMETERFILTER_H +#define ACCELEROMETERFILTER_H + +//! [0] +#include +#include + +QTM_USE_NAMESPACE + +class AccelerometerFilter + : public QObject, public QAccelerometerFilter +{ + Q_OBJECT + +protected: + qreal x; + qreal y; + qreal z; + +public: + AccelerometerFilter(); + bool filter(QAccelerometerReading *reading); + +signals: + void rotationChanged(const QVariant °); +}; +//! [0] + +#endif // ACCELEROMETERFILTER_H diff --git a/demos/mobile/qtbubblelevel/debian/changelog b/demos/mobile/qtbubblelevel/debian/changelog new file mode 100644 index 0000000..0413145 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/changelog @@ -0,0 +1,19 @@ +qtbubblelevel (1.2.0) stable; urgency=low + + * Improved the usability of the calibration dialog. + + -- Forum Nokia Wed, 16 Feb 2011 12:59:30 +0100 + +qtbubblelevel (1.1.0) stable; urgency=low + + * QtMobility Rotation sensor support + + -- Antonio Aloisio Tue, 15 Jun 2010 9:03:02 +0100 + + +qtbubblelevel (1.0.0) unstable; urgency=low + + * Initial release + + -- Antonio Aloisio Tue, 15 Jun 2010 9:03:02 +0100 + diff --git a/demos/mobile/qtbubblelevel/debian/compat b/demos/mobile/qtbubblelevel/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/qtbubblelevel/debian/control b/demos/mobile/qtbubblelevel/debian/control new file mode 100644 index 0000000..5980327 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/control @@ -0,0 +1,12 @@ +Source: qtbubblelevel +Section: user/games +Priority: extra +Maintainer: Forum Nokia +Build-Depends: debhelper (>= 5), libqt4-dev, libqtm-sensors +Standards-Version: 3.7.3 + +Package: qtbubblelevel +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Qt Bubble Level example + QtQuick example diff --git a/demos/mobile/qtbubblelevel/debian/copyright b/demos/mobile/qtbubblelevel/debian/copyright new file mode 100644 index 0000000..e8dea63 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/copyright @@ -0,0 +1,36 @@ +This package was debianized by unknown on +Tue, 15 Jun 2010 9:03:02 +0100. + +It was downloaded from + +Upstream Author: + +Copyright: + +License: + + This package is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU Lesser General +Public License can be found in `/usr/share/common-licenses/LGPL'. + + +The Debian packaging is (C) 2010, unknown and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. + + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/demos/mobile/qtbubblelevel/debian/dirs b/demos/mobile/qtbubblelevel/debian/dirs new file mode 100644 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/qtbubblelevel/debian/files b/demos/mobile/qtbubblelevel/debian/files new file mode 100644 index 0000000..3d43242 --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/files @@ -0,0 +1 @@ +qtbubblelevel_1.2.0_armel.deb user/games extra diff --git a/demos/mobile/qtbubblelevel/debian/postinst b/demos/mobile/qtbubblelevel/debian/postinst new file mode 100644 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/qtbubblelevel/debian/rules b/demos/mobile/qtbubblelevel/debian/rules new file mode 100644 index 0000000..f18b9cd --- /dev/null +++ b/demos/mobile/qtbubblelevel/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/qtbubblelevel.sgml > qtbubblelevel.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/qtbubblelevel. + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/qtbubblelevel install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link +# dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/qtbubblelevel/icons/26x26/qtbubblelevel.png b/demos/mobile/qtbubblelevel/icons/26x26/qtbubblelevel.png new file mode 100644 index 0000000..ae34ccf Binary files /dev/null and b/demos/mobile/qtbubblelevel/icons/26x26/qtbubblelevel.png differ diff --git a/demos/mobile/qtbubblelevel/icons/40x40/qtbubblelevel.png b/demos/mobile/qtbubblelevel/icons/40x40/qtbubblelevel.png new file mode 100644 index 0000000..6230f55 Binary files /dev/null and b/demos/mobile/qtbubblelevel/icons/40x40/qtbubblelevel.png differ diff --git a/demos/mobile/qtbubblelevel/icons/64x64/qtbubblelevel.png b/demos/mobile/qtbubblelevel/icons/64x64/qtbubblelevel.png new file mode 100644 index 0000000..375326c Binary files /dev/null and b/demos/mobile/qtbubblelevel/icons/64x64/qtbubblelevel.png differ diff --git a/demos/mobile/qtbubblelevel/icons/bubblelevel.svg b/demos/mobile/qtbubblelevel/icons/bubblelevel.svg new file mode 100644 index 0000000..a3c30df --- /dev/null +++ b/demos/mobile/qtbubblelevel/icons/bubblelevel.svg @@ -0,0 +1,264 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/demos/mobile/qtbubblelevel/icons/qtbl_icon.png b/demos/mobile/qtbubblelevel/icons/qtbl_icon.png new file mode 100644 index 0000000..780fbb4 Binary files /dev/null and b/demos/mobile/qtbubblelevel/icons/qtbl_icon.png differ diff --git a/demos/mobile/qtbubblelevel/icons/xpm/qtbubblelevel.xpm b/demos/mobile/qtbubblelevel/icons/xpm/qtbubblelevel.xpm new file mode 100644 index 0000000..19f3c2f --- /dev/null +++ b/demos/mobile/qtbubblelevel/icons/xpm/qtbubblelevel.xpm @@ -0,0 +1,1783 @@ +/* XPM */ +static char * qtbubblelevel_xpm[] = { +"64 64 1716 2", +" c None", +". c #BBD2A8", +"+ c #BBD1A8", +"@ c #BFD3A5", +"# c #C0D2AA", +"$ c #A4B594", +"% c #94A488", +"& c #B2C3A5", +"* c #A5B694", +"= c #A6B893", +"- c #A7B993", +"; c #A8BA93", +"> c #A6B891", +", c #A7B992", +"' c #A7B792", +") c #A7B896", +"! c #A8B997", +"~ c #A9BA98", +"{ c #ABBC99", +"] c #AABB99", +"^ c #AABB98", +"/ c #A8B996", +"( c #A9BA97", +"_ c #ADBC94", +": c #ACBA95", +"< c #ABB895", +"[ c #ADBC9A", +"} c #B6C3A5", +"| c #95A285", +"1 c #A9BA99", +"2 c #BDD4AA", +"3 c #AFC897", +"4 c #AFC898", +"5 c #AFC797", +"6 c #B4C994", +"7 c #B4C799", +"8 c #97A981", +"9 c #839570", +"0 c #8C9E7A", +"a c #7B8C65", +"b c #7E9167", +"c c #7D9268", +"d c #7E9268", +"e c #7E926A", +"f c #82966E", +"g c #859972", +"h c #889B74", +"i c #8CA07A", +"j c #8FA37D", +"k c #91A47E", +"l c #93A680", +"m c #94A881", +"n c #93A781", +"o c #95A983", +"p c #96AA83", +"q c #94A882", +"r c #94A880", +"s c #94A780", +"t c #93A47A", +"u c #90A079", +"v c #8D9C77", +"w c #8B9A78", +"x c #98A787", +"y c #879576", +"z c #9CAE89", +"A c #B1CA9A", +"B c #B1C999", +"C c #A7BF8A", +"D c #A8C18A", +"E c #A8C18B", +"F c #A8C08A", +"G c #ACC286", +"H c #ACC08A", +"I c #93A677", +"J c #7A8C63", +"K c #7A8D62", +"L c #778A5D", +"M c #7C905F", +"N c #799162", +"O c #7A9163", +"P c #799063", +"Q c #7B9363", +"R c #7C9464", +"S c #7C9465", +"T c #819869", +"U c #849C6D", +"V c #89A071", +"W c #8DA478", +"X c #90A77C", +"Y c #94AB80", +"Z c #96AD82", +"` c #97AE83", +" . c #96AE83", +".. c #98AD82", +"+. c #99AF84", +"@. c #9AB085", +"#. c #99B085", +"$. c #98AE83", +"%. c #97AD81", +"&. c #96A97D", +"*. c #91A378", +"=. c #8C9F76", +"-. c #879973", +";. c #879875", +">. c #819271", +",. c #96AA80", +"'. c #AAC38C", +"). c #A9C28C", +"!. c #A7C189", +"~. c #A8C189", +"{. c #A2BB80", +"]. c #A2BB82", +"^. c #A1BA81", +"/. c #A4BD83", +"(. c #A3BD82", +"_. c #A5BC7D", +":. c #A4B980", +"<. c #8CA06F", +"[. c #798B5F", +"}. c #788B5E", +"|. c #7A8D5D", +"1. c #7D935F", +"2. c #7A9661", +"3. c #7C9762", +"4. c #7C9763", +"5. c #819B66", +"6. c #829D68", +"7. c #829D66", +"8. c #819C65", +"9. c #849F68", +"0. c #86A16A", +"a. c #87A26C", +"b. c #8CA674", +"c. c #8FA979", +"d. c #92AD7D", +"e. c #95AF7F", +"f. c #96B080", +"g. c #97B180", +"h. c #98B282", +"i. c #9AB383", +"j. c #9AB483", +"k. c #99B282", +"l. c #97B080", +"m. c #96AF7F", +"n. c #93A879", +"o. c #8DA375", +"p. c #889D72", +"q. c #81966D", +"r. c #7E926B", +"s. c #7B8E6A", +"t. c #94A97C", +"u. c #A4BD84", +"v. c #A3BC82", +"w. c #A1BA82", +"x. c #A2BB83", +"y. c #A3BB84", +"z. c #A5BD86", +"A. c #A5BD85", +"B. c #A6BC7F", +"C. c #A5BA83", +"D. c #90A274", +"E. c #7D9165", +"F. c #7E9266", +"G. c #7E9262", +"H. c #809662", +"I. c #7E9C61", +"J. c #819E64", +"K. c #83A166", +"L. c #88A56B", +"M. c #89A76C", +"N. c #89A769", +"O. c #8BA96B", +"P. c #8CAB6B", +"Q. c #8FAD74", +"R. c #92AF79", +"S. c #95B27C", +"T. c #97B57E", +"U. c #98B67E", +"V. c #9AB880", +"W. c #9CB982", +"X. c #9CBA83", +"Y. c #9DBA83", +"Z. c #9BB881", +"`. c #99B67F", +" + c #98B57E", +".+ c #96B27D", +"++ c #93AB79", +"@+ c #8CA574", +"#+ c #879F70", +"$+ c #829A6D", +"%+ c #80976D", +"&+ c #7D946C", +"*+ c #95AC7D", +"=+ c #A4BC85", +"-+ c #A3BA84", +";+ c #A3BC84", +">+ c #A4BC88", +",+ c #A4BC89", +"'+ c #A6BE8B", +")+ c #A5BE8A", +"!+ c #A7BC83", +"~+ c #A8BC88", +"{+ c #94A77B", +"]+ c #85976F", +"^+ c #869870", +"/+ c #83966B", +"(+ c #859A69", +"_+ c #84A365", +":+ c #88A869", +"<+ c #8CAC6D", +"[+ c #90B071", +"}+ c #91B172", +"|+ c #91B170", +"1+ c #91B26D", +"2+ c #91B26E", +"3+ c #91B16E", +"4+ c #90B16C", +"5+ c #93B370", +"6+ c #95B376", +"7+ c #96B47A", +"8+ c #99B87E", +"9+ c #9CBA80", +"0+ c #9BBA80", +"a+ c #9EBD82", +"b+ c #9FBE83", +"c+ c #A0BF84", +"d+ c #9DBB81", +"e+ c #9BBA7F", +"f+ c #9AB97E", +"g+ c #98B67D", +"h+ c #93AD79", +"i+ c #8DA874", +"j+ c #87A271", +"k+ c #849E6F", +"l+ c #849E72", +"m+ c #80996F", +"n+ c #96AE80", +"o+ c #A5BD8A", +"p+ c #A3BB88", +"q+ c #A7BF8C", +"r+ c #A6BE8C", +"s+ c #A8C08E", +"t+ c #A8C08D", +"u+ c #A8C08B", +"v+ c #A8BE8B", +"w+ c #95AA80", +"x+ c #899C7A", +"y+ c #8B9F78", +"z+ c #879C71", +"A+ c #879E71", +"B+ c #8AA86E", +"C+ c #8EAD70", +"D+ c #92B274", +"E+ c #94B776", +"F+ c #94B875", +"G+ c #93B872", +"H+ c #93B973", +"I+ c #97B976", +"J+ c #96B976", +"K+ c #98B976", +"L+ c #98BB77", +"M+ c #97B97A", +"N+ c #99BA7D", +"O+ c #9ABB7E", +"P+ c #9BBD80", +"Q+ c #9EBF82", +"R+ c #9FC082", +"S+ c #9FC183", +"T+ c #A1C284", +"U+ c #A0C184", +"V+ c #A3BF88", +"W+ c #A3C086", +"X+ c #A3C087", +"Y+ c #9FBC82", +"Z+ c #9EBC80", +"`+ c #9EBB80", +" @ c #9AB77C", +".@ c #92AF78", +"+@ c #8DA87A", +"@@ c #89A279", +"#@ c #869F74", +"$@ c #8CA378", +"%@ c #889D73", +"&@ c #9AB084", +"*@ c #A7BF8D", +"=@ c #A5BD8B", +"-@ c #A6BE87", +";@ c #A6BF87", +">@ c #A5BF87", +",@ c #A7BF89", +"'@ c #A6C087", +")@ c #93AB7E", +"!@ c #8A9E7D", +"~@ c #8FA67B", +"{@ c #849D6D", +"]@ c #88A072", +"^@ c #8BA971", +"/@ c #8FAF73", +"(@ c #92B675", +"_@ c #94BA74", +":@ c #92BC71", +"<@ c #91BE6D", +"[@ c #94BE71", +"}@ c #96BC78", +"|@ c #97BD78", +"1@ c #96BD78", +"2@ c #98BF7A", +"3@ c #99BF7A", +"4@ c #9CC27E", +"5@ c #9BC17D", +"6@ c #9DC380", +"7@ c #9EC480", +"8@ c #9EC380", +"9@ c #A1C185", +"0@ c #A1C282", +"a@ c #9DBE7E", +"b@ c #9DBE7D", +"c@ c #9CBD7B", +"d@ c #97B875", +"e@ c #92B273", +"f@ c #8CA97B", +"g@ c #88A17C", +"h@ c #879E74", +"i@ c #8DA074", +"j@ c #9BB081", +"k@ c #A7C089", +"l@ c #A5BE88", +"m@ c #A6BF86", +"n@ c #93AF6E", +"o@ c #94B06E", +"p@ c #93B06E", +"q@ c #93B070", +"r@ c #95B16F", +"s@ c #809B63", +"t@ c #758F61", +"u@ c #86A16B", +"v@ c #6F8A50", +"w@ c #728F58", +"x@ c #729757", +"y@ c #789E5B", +"z@ c #7DA75D", +"A@ c #7EAC5C", +"B@ c #7EAE5A", +"C@ c #81B259", +"D@ c #81B25D", +"E@ c #83B061", +"F@ c #83B161", +"G@ c #85B363", +"H@ c #84B363", +"I@ c #86B465", +"J@ c #86B565", +"K@ c #86B464", +"L@ c #88B666", +"M@ c #88B767", +"N@ c #8BB468", +"O@ c #8BB568", +"P@ c #8BB567", +"Q@ c #89B263", +"R@ c #87B163", +"S@ c #84AD5F", +"T@ c #7EA759", +"U@ c #7C9E59", +"V@ c #78955F", +"W@ c #728E5E", +"X@ c #748F5A", +"Y@ c #889F68", +"Z@ c #7A905E", +"`@ c #88A06A", +" # c #97B472", +".# c #97B372", +"+# c #94B06F", +"@# c #94B06D", +"## c #7A994D", +"$# c #7A9A4E", +"%# c #799A4E", +"&# c #799A4B", +"*# c #607E3B", +"=# c #537038", +"-# c #6F8E4D", +";# c #52712B", +"># c #4D6D2C", +",# c #4C752E", +"'# c #537D32", +")# c #598737", +"!# c #5D8E38", +"~# c #5E9337", +"{# c #619838", +"]# c #62993B", +"^# c #62963B", +"/# c #62973B", +"(# c #64993D", +"_# c #63993C", +":# c #65993E", +"<# c #659A3E", +"[# c #649A3D", +"}# c #669A40", +"|# c #679B40", +"1# c #679B3F", +"2# c #6A9B3B", +"3# c #6A9B3C", +"4# c #6A9B3D", +"5# c #67983C", +"6# c #65953B", +"7# c #5F9036", +"8# c #59882F", +"9# c #577B30", +"0# c #517334", +"a# c #4D6D30", +"b# c #557533", +"c# c #708C4B", +"d# c #587037", +"e# c #6B8647", +"f# c #7C9C50", +"g# c #719440", +"h# c #719540", +"i# c #71953F", +"j# c #709441", +"k# c #6F933D", +"l# c #56792E", +"m# c #496929", +"n# c #6B8D45", +"o# c #527528", +"p# c #40631C", +"q# c #406920", +"r# c #436E21", +"s# c #4A7826", +"t# c #4F8129", +"u# c #518729", +"v# c #558C2A", +"w# c #568E2B", +"x# c #568D2B", +"y# c #578F2B", +"z# c #57902C", +"A# c #59912D", +"B# c #59912C", +"C# c #59912E", +"D# c #59902D", +"E# c #5D9228", +"F# c #5C9027", +"G# c #5A8E2A", +"H# c #5A8D2C", +"I# c #56892B", +"J# c #508226", +"K# c #4A7B23", +"L# c #476E21", +"M# c #416721", +"N# c #3F631E", +"O# c #577A2F", +"P# c #6A8A42", +"Q# c #4A6529", +"R# c #5D7C38", +"S# c #709440", +"T# c #6A913A", +"U# c #6B923A", +"V# c #6A923B", +"W# c #699037", +"X# c #507528", +"Y# c #436724", +"Z# c #678C41", +"`# c #5E8533", +" $ c #42671D", +".$ c #3E631D", +"+$ c #3F671D", +"@$ c #456E20", +"#$ c #4A7823", +"$$ c #4C7D23", +"%$ c #518325", +"&$ c #528625", +"*$ c #528923", +"=$ c #548A24", +"-$ c #558C26", +";$ c #568D27", +">$ c #568C25", +",$ c #588B23", +"'$ c #578924", +")$ c #558626", +"!$ c #538328", +"~$ c #4E7D28", +"{$ c #487625", +"]$ c #437020", +"^$ c #3D671B", +"/$ c #3B621B", +"($ c #436920", +"_$ c #618538", +":$ c #66883E", +"<$ c #446126", +"[$ c #597935", +"}$ c #668E36", +"|$ c #668E35", +"1$ c #658D36", +"2$ c #648C33", +"3$ c #4B7225", +"4$ c #416522", +"5$ c #61873B", +"6$ c #658B3B", +"7$ c #52762D", +"8$ c #3E5D1B", +"9$ c #3D5E19", +"0$ c #40641B", +"a$ c #466E1E", +"b$ c #48731E", +"c$ c #4D7921", +"d$ c #4F7F21", +"e$ c #4F821F", +"f$ c #518421", +"g$ c #538622", +"h$ c #538723", +"i$ c #548722", +"j$ c #548724", +"k$ c #548723", +"l$ c #558320", +"m$ c #538122", +"n$ c #517E24", +"o$ c #4D7926", +"p$ c #477326", +"q$ c #416B22", +"r$ c #3B661D", +"s$ c #376117", +"t$ c #39611C", +"u$ c #50772D", +"v$ c #63893A", +"w$ c #60833A", +"x$ c #405E25", +"y$ c #547633", +"z$ c #628A33", +"A$ c #628A32", +"B$ c #608833", +"C$ c #638832", +"D$ c #4E6E28", +"E$ c #436023", +"F$ c #608038", +"G$ c #638835", +"H$ c #5C8334", +"I$ c #446720", +"J$ c #375A16", +"K$ c #3B5F1C", +"L$ c #3F6420", +"M$ c #42681E", +"N$ c #486F1E", +"O$ c #49761E", +"P$ c #497A21", +"Q$ c #4C7D21", +"R$ c #4E8022", +"S$ c #508122", +"T$ c #518222", +"U$ c #528423", +"V$ c #518322", +"W$ c #518324", +"X$ c #518323", +"Y$ c #4F811C", +"Z$ c #50821B", +"`$ c #50821D", +" % c #50821F", +".% c #508221", +"+% c #4F811F", +"@% c #4F8020", +"#% c #517B21", +"$% c #4F7921", +"%% c #4C7522", +"&% c #497122", +"*% c #41691F", +"=% c #3E651E", +"-% c #385F19", +";% c #355D11", +">% c #436A1E", +",% c #5C8132", +"'% c #618535", +")% c #5D7C33", +"!% c #405C1F", +"~% c #52732C", +"{% c #618A33", +"]% c #5D8630", +"^% c #5E8630", +"/% c #5E8530", +"(% c #5C832F", +"_% c #608330", +":% c #4E6A28", +"<% c #425B22", +"[% c #5F7C35", +"}% c #5E832E", +"|% c #5D8432", +"1% c #517829", +"2% c #3B6016", +"3% c #355917", +"4% c #385C1C", +"5% c #3D611B", +"6% c #40661C", +"7% c #426C1C", +"8% c #42711E", +"9% c #45751F", +"0% c #487820", +"a% c #4A7A20", +"b% c #4C7C1F", +"c% c #4D7E21", +"d% c #4D7E22", +"e% c #4B7E18", +"f% c #4B7E17", +"g% c #4B7E19", +"h% c #4B7D1B", +"i% c #4B7C1D", +"j% c #497A1E", +"k% c #49781D", +"l% c #4B721F", +"m% c #49701F", +"n% c #466C1E", +"o% c #3C611B", +"p% c #3B601B", +"q% c #365B16", +"r% c #3E6516", +"s% c #537929", +"t% c #5E8230", +"u% c #608031", +"v% c #5A792F", +"w% c #415B1A", +"x% c #507027", +"y% c #59812B", +"z% c #577E2A", +"A% c #5A7E2B", +"B% c #496523", +"C% c #3E561E", +"D% c #5A7731", +"E% c #597F29", +"F% c #59812C", +"G% c #577E29", +"H% c #4C7322", +"I% c #395D15", +"J% c #335815", +"K% c #355915", +"L% c #375C17", +"M% c #386018", +"N% c #3B6717", +"O% c #3E6B1A", +"P% c #416E1A", +"Q% c #43711C", +"R% c #46731B", +"S% c #47751A", +"T% c #48761C", +"U% c #48771D", +"V% c #467716", +"W% c #467614", +"X% c #467617", +"Y% c #467518", +"Z% c #457318", +"`% c #43711A", +" & c #416E19", +".& c #42681D", +"+& c #3F651B", +"@& c #3C611A", +"#& c #3A5F1A", +"$& c #385C19", +"%& c #345817", +"&& c #395E1A", +"*& c #4D7425", +"=& c #5A8031", +"-& c #5A7E2C", +";& c #5C7D2D", +">& c #57752C", +",& c #3D5817", +"'& c #4C6C24", +")& c #59812A", +"!& c #567E28", +"~& c #557D28", +"{& c #537B27", +"]& c #567A27", +"^& c #466120", +"/& c #3B541B", +"(& c #57742E", +"_& c #567C26", +":& c #567D28", +"<& c #537C22", +"[& c #537A24", +"}& c #486E1E", +"|& c #375D14", +"1& c #315612", +"2& c #305415", +"3& c #325916", +"4& c #355E14", +"5& c #386217", +"6& c #3A6417", +"7& c #3E6819", +"8& c #3F6A18", +"9& c #416C17", +"0& c #436E1A", +"a& c #446F1B", +"b& c #436F1B", +"c& c #456F1C", +"d& c #456F1D", +"e& c #426F16", +"f& c #436F16", +"g& c #426D16", +"h& c #416D19", +"i& c #406A18", +"j& c #3C6619", +"k& c #395D1A", +"l& c #355A17", +"m& c #325714", +"n& c #325614", +"o& c #385D1B", +"p& c #496E29", +"q& c #557C2D", +"r& c #567C2D", +"s& c #557927", +"t& c #58792A", +"u& c #547128", +"v& c #3B5615", +"w& c #496920", +"x& c #557E28", +"y& c #517923", +"z& c #527A24", +"A& c #517924", +"B& c #507623", +"C& c #547724", +"D& c #435F1D", +"E& c #3A531A", +"F& c #55722C", +"G& c #537923", +"H& c #537A25", +"I& c #517822", +"J& c #527A22", +"K& c #507822", +"L& c #486E1F", +"M& c #395E15", +"N& c #2F5311", +"O& c #2F5412", +"P& c #315813", +"Q& c #335A15", +"R& c #365D16", +"S& c #375F15", +"T& c #396015", +"U& c #3B6214", +"V& c #3C6416", +"W& c #3D6517", +"X& c #3F6719", +"Y& c #3F6716", +"Z& c #3D6616", +"`& c #3C6415", +" * c #3A6217", +".* c #395F17", +"+* c #385E17", +"@* c #345818", +"#* c #325615", +"$* c #2D510F", +"%* c #2E530F", +"&* c #395E18", +"** c #486D26", +"=* c #51762E", +"-* c #52782A", +";* c #527828", +">* c #547726", +",* c #547626", +"'* c #516F25", +")* c #395313", +"!* c #45661E", +"~* c #527A23", +"{* c #4D751F", +"]* c #4D751E", +"^* c #4C7320", +"/* c #517421", +"(* c #405C1A", +"_* c #375017", +":* c #516E28", +"<* c #4F741F", +"[* c #4E7523", +"}* c #4C7424", +"|* c #4D7521", +"1* c #4D751D", +"2* c #486F1F", +"3* c #3B6017", +"4* c #2F5411", +"5* c #2C5011", +"6* c #2C500F", +"7* c #305511", +"8* c #315611", +"9* c #335810", +"0* c #345A0F", +"a* c #355B11", +"b* c #355B12", +"c* c #375D13", +"d* c #375D12", +"e* c #355B10", +"f* c #345A12", +"g* c #335812", +"h* c #315512", +"i* c #2F5413", +"j* c #2E5212", +"k* c #2D5210", +"l* c #2C510D", +"m* c #30550F", +"n* c #3C6219", +"o* c #466D20", +"p* c #4C7324", +"q* c #4D7325", +"r* c #4C7325", +"s* c #4E7324", +"t* c #4F7321", +"u* c #517224", +"v* c #4E6C22", +"w* c #36500F", +"x* c #42631A", +"y* c #4A721C", +"z* c #4A711B", +"A* c #4A701D", +"B* c #4D711E", +"C* c #3C5A16", +"D* c #334D12", +"E* c #4D6B23", +"F* c #4A6F1A", +"G* c #4A701E", +"H* c #4A7024", +"I* c #4A701F", +"J* c #4A7119", +"K* c #487017", +"L* c #4B721C", +"M* c #476E1E", +"N* c #40661F", +"O* c #385A1D", +"P* c #2E5112", +"Q* c #2D500F", +"R* c #2B500B", +"S* c #2C500B", +"T* c #2E530B", +"U* c #2E520B", +"V* c #2E520C", +"W* c #2D520B", +"X* c #2F540D", +"Y* c #30540E", +"Z* c #30540D", +"`* c #2F530D", +" = c #2E510B", +".= c #2C4F0B", +"+= c #2C500D", +"@= c #2D5010", +"#= c #2C4E11", +"$= c #2B4F10", +"%= c #305510", +"&= c #395E17", +"*= c #43691F", +"== c #476E20", +"-= c #476E1D", +";= c #49701B", +">= c #4A711D", +",= c #4A6F22", +"'= c #497020", +")= c #4B701D", +"!= c #4E701F", +"~= c #4B6920", +"{= c #324E0C", +"]= c #3F6116", +"^= c #49721B", +"/= c #476F19", +"(= c #466E18", +"_= c #476F1A", +":= c #476E19", +"<= c #385E0E", +"[= c #2E5406", +"}= c #446B18", +"|= c #436B15", +"1= c #456D18", +"2= c #476D1B", +"3= c #476F18", +"4= c #476E1F", +"5= c #446A21", +"6= c #3D621A", +"7= c #385D14", +"8= c #30550C", +"9= c #2D5109", +"0= c #2A4F05", +"a= c #284D09", +"b= c #294D0C", +"c= c #294D0A", +"d= c #294D0B", +"e= c #2B4F0D", +"f= c #294F08", +"g= c #294D08", +"h= c #294E07", +"i= c #284D07", +"j= c #325612", +"k= c #416816", +"l= c #446C19", +"m= c #476E1A", +"n= c #476D19", +"o= c #466F18", +"p= c #486F19", +"q= c #436917", +"r= c #2E5304", +"s= c #3A600E", +"t= c #416913", +"u= c #406812", +"v= c #3C640E", +"w= c #426A14", +"x= c #436B14", +"y= c #426A17", +"z= c #42681B", +"A= c #41671A", +"B= c #3D6316", +"C= c #385E10", +"D= c #2C520C", +"E= c #2B500A", +"F= c #2E530D", +"G= c #2E5409", +"H= c #31560C", +"I= c #3A5F14", +"J= c #3D6317", +"K= c #40661A", +"L= c #42691C", +"M= c #3B630E", +"N= c #3E6610", +"O= c #3F6710", +"P= c #3F6711", +"Q= c #3E6714", +"R= c #3F6617", +"S= c #3D6415", +"T= c #406718", +"U= c #406618", +"V= c #3E6616", +"W= c #3E6515", +"X= c #3B6212", +"Y= c #3B6111", +"Z= c #3D6314", +"`= c #3D6214", +" - c #3D6412", +".- c #3E6413", +"+- c #406715", +"@- c #3E6713", +"#- c #3F6714", +"$- c #406614", +"%- c #406811", +"&- c #3D650F", +"*- c #3B630D", +"=- c #3B630F", +"-- c #3B6211", +";- c #3D6414", +">- c #3E6514", +",- c #3C6312", +"'- c #3D650C", +")- c #3D650D", +"!- c #3D640C", +"~- c #3D650E", +"{- c #3E660E", +"]- c #3E660D", +"^- c #3E660F", +"/- c #3A620C", +"(- c #3B620D", +"_- c #3B620F", +":- c #3B610B", +"<- c #3B630A", +"[- c #3B630B", +"}- c #375F09", +"|- c #375F0A", +"1- c #375F08", +"2- c #375F07", +"3- c #375F0B", +"4- c #345C06", +"5- c #345C07", +"6- c #335C07", +"7- c #355C07", +"8- c #355C05", +"9- c #355C04", +"0- c #355C06", +"a- c #355A09", +"b- c #355B0A", +"c- c #355B09", +"d- c #355B06", +"e- c #355D06", +"f- c #335C06", +"g- c #2E5704", +"h- c #305804", +"i- c #305806", +"j- c #305906", +"k- c #305704", +"l- c #305805", +"m- c #325605", +"n- c #335705", +"o- c #335605", +"p- c #325604", +"q- c #345806", +"r- c #355807", +"s- c #335706", +"t- c #335704", +"u- c #335505", +"v- c #325606", +"w- c #345906", +"x- c #335805", +"y- c #325903", +"z- c #325B01", +"A- c #325B02", +"B- c #315A02", +"C- c #2F5800", +"D- c #305901", +"E- c #305900", +"F- c #335503", +"G- c #355305", +"H- c #355404", +"I- c #2D5601", +"J- c #2E5702", +"K- c #2F5703", +"L- c #305904", +"M- c #2F5804", +"N- c #315502", +"O- c #325603", +"P- c #315503", +"Q- c #315602", +"R- c #305503", +"S- c #315504", +"T- c #305404", +"U- c #325704", +"V- c #315704", +"W- c #325502", +"X- c #305602", +"Y- c #315900", +"Z- c #315901", +"`- c #305701", +" ; c #2E5700", +".; c #2F5700", +"+; c #2E5600", +"@; c #315500", +"#; c #335501", +"$; c #335500", +"%; c #737E40", +"&; c #737D40", +"*; c #717D3E", +"=; c #727C3F", +"-; c #727D40", +";; c #747B3F", +">; c #757C40", +",; c #73793D", +"'; c #71793D", +"); c #72793D", +"!; c #71793C", +"~; c #737A3E", +"{; c #71783C", +"]; c #70773B", +"^; c #71773C", +"/; c #757C3F", +"(; c #747B3E", +"_; c #737C3C", +":; c #737D39", +"<; c #737D3A", +"[; c #727B39", +"}; c #707B38", +"|; c #717B38", +"1; c #717B37", +"2; c #717A36", +"3; c #CAAE84", +"4; c #C9AE83", +"5; c #C7AB80", +"6; c #C3A77D", +"7; c #C4A97D", +"8; c #C6AA80", +"9; c #C5A97E", +"0; c #C9AA80", +"a; c #CAAA81", +"b; c #C9A980", +"c; c #C6A67D", +"d; c #C6A57C", +"e; c #C8A87F", +"f; c #C9AA81", +"g; c #C7A77E", +"h; c #C3A37A", +"i; c #BF9F76", +"j; c #C1A178", +"k; c #C3A379", +"l; c #C2A179", +"m; c #C0A077", +"n; c #C2A279", +"o; c #C09F77", +"p; c #C0A177", +"q; c #C4A47B", +"r; c #C6A67C", +"s; c #C5A67C", +"t; c #CBAB82", +"u; c #CCAB81", +"v; c #CCAB82", +"w; c #CAAB81", +"x; c #C8A77E", +"y; c #C5A57C", +"z; c #C7A67D", +"A; c #C7A87F", +"B; c #C9A97F", +"C; c #C9A87F", +"D; c #C4A37B", +"E; c #C4A478", +"F; c #C2A273", +"G; c #C3A375", +"H; c #C4A475", +"I; c #C0A172", +"J; c #C1A171", +"K; c #C1A173", +"L; c #C1A373", +"M; c #C2A374", +"N; c #C2A373", +"O; c #CC9F6B", +"P; c #D0A370", +"Q; c #D0A36F", +"R; c #CB9E6B", +"S; c #CDA06C", +"T; c #CCA06C", +"U; c #CE9C69", +"V; c #CC9A67", +"W; c #C99765", +"X; c #CB9966", +"Y; c #C79664", +"Z; c #C49260", +"`; c #C89764", +" > c #CA9965", +".> c #C89765", +"+> c #C79563", +"@> c #C2915E", +"#> c #C08F5C", +"$> c #C3925F", +"%> c #BF8F5B", +"&> c #BD8B59", +"*> c #C3915F", +"=> c #C69462", +"-> c #C89664", +";> c #CB9A67", +">> c #CB9968", +",> c #CB9B67", +"'> c #CD9C69", +")> c #CD9B68", +"!> c #CE9D6A", +"~> c #CE9C6A", +"{> c #CA9866", +"]> c #C69562", +"^> c #C1905D", +"/> c #C2905E", +"(> c #C69461", +"_> c #CA9966", +":> c #C59461", +"<> c #C5935F", +"[> c #C28F59", +"}> c #C3915A", +"|> c #C7945E", +"1> c #C5935D", +"2> c #C08E58", +"3> c #BC8853", +"4> c #BB8654", +"5> c #BB8655", +"6> c #BA8655", +"7> c #BC8A4B", +"8> c #C1904F", +"9> c #BF8D4D", +"0> c #C19050", +"a> c #C29050", +"b> c #BE8C4C", +"c> c #C28D4E", +"d> c #C18A4C", +"e> c #BD8649", +"f> c #BD8749", +"g> c #BB8547", +"h> c #B78142", +"i> c #B88244", +"j> c #B68042", +"k> c #B98244", +"l> c #BB8447", +"m> c #BC8648", +"n> c #BA8446", +"o> c #BE874A", +"p> c #BD8648", +"q> c #B68041", +"r> c #B98445", +"s> c #BA8445", +"t> c #B88245", +"u> c #B98344", +"v> c #BE8749", +"w> c #C08A4C", +"x> c #BF894B", +"y> c #BE894B", +"z> c #C0894B", +"A> c #BF884A", +"B> c #BA8546", +"C> c #B78143", +"D> c #B88345", +"E> c #BA8346", +"F> c #B78144", +"G> c #BA8345", +"H> c #BB8546", +"I> c #BB8446", +"J> c #BE884A", +"K> c #BD8546", +"L> c #BC8342", +"M> c #BD8443", +"N> c #C08646", +"O> c #BB8342", +"P> c #B67C3B", +"Q> c #AA702F", +"R> c #A76830", +"S> c #A4622F", +"T> c #A3622F", +"U> c #B78145", +"V> c #C58E52", +"W> c #BF874B", +"X> c #BC8347", +"Y> c #B98345", +"Z> c #B88344", +"`> c #B88146", +" , c #B98146", +"., c #B98045", +"+, c #B98046", +"@, c #BB8348", +"#, c #BA8046", +"$, c #B97E44", +"%, c #BB7F45", +"&, c #B87D43", +"*, c #B87C42", +"=, c #B67B41", +"-, c #B5793E", +";, c #B3783E", +">, c #B2773C", +",, c #B07539", +"', c #AD7236", +"), c #AD7136", +"!, c #AA6E33", +"~, c #AD7237", +"{, c #AE7336", +"], c #AD7135", +"^, c #B67B3F", +"/, c #B87E41", +"(, c #B67C3F", +"_, c #B77C40", +":, c #B77D3F", +"<, c #B67D41", +"[, c #B87F42", +"}, c #B98043", +"|, c #BA8144", +"1, c #BF8449", +"2, c #BD8248", +"3, c #BF8349", +"4, c #BE8348", +"5, c #BB8145", +"6, c #B67C40", +"7, c #B4793C", +"8, c #B77B3F", +"9, c #BA7E42", +"0, c #BC8044", +"a, c #BB7F43", +"b, c #BC8145", +"c, c #B97D41", +"d, c #B6783A", +"e, c #B67636", +"f, c #B67738", +"g, c #B97A3B", +"h, c #BD7D3F", +"i, c #B9783B", +"j, c #AE6E31", +"k, c #AB6330", +"l, c #A95E2F", +"m, c #A95C2D", +"n, c #A6733B", +"o, c #BD874F", +"p, c #C48852", +"q, c #B98044", +"r, c #BD8A4B", +"s, c #C39252", +"t, c #C59557", +"u, c #C59457", +"v, c #C49255", +"w, c #C79256", +"x, c #C99257", +"y, c #C38B51", +"z, c #C58A51", +"A, c #C48853", +"B, c #C48851", +"C, c #C38752", +"D, c #C18650", +"E, c #BD814B", +"F, c #BA7F48", +"G, c #B97E46", +"H, c #B87D45", +"I, c #B47941", +"J, c #B57A42", +"K, c #B2773F", +"L, c #B37840", +"M, c #B87D41", +"N, c #BB8044", +"O, c #BE8347", +"P, c #BF8448", +"Q, c #BA7F43", +"R, c #B27C3E", +"S, c #B47E40", +"T, c #B58042", +"U, c #B68142", +"V, c #B68143", +"W, c #B98346", +"X, c #C18551", +"Y, c #C28651", +"Z, c #C0844E", +"`, c #BD8149", +" ' c #BC8147", +".' c #B57A3E", +"+' c #BB7E43", +"@' c #BF8045", +"#' c #C28449", +"$' c #BF8247", +"%' c #C08348", +"&' c #BD7F40", +"*' c #BD803A", +"=' c #BC7F3D", +"-' c #BE8140", +";' c #BB7E3F", +">' c #B4763A", +",' c #AE6F34", +"'' c #B06E35", +")' c #B67239", +"!' c #B26F36", +"~' c #7F5123", +"{' c #9C6A3D", +"]' c #B2794B", +"^' c #B27541", +"/' c #B87B44", +"(' c #BE864A", +"_' c #C28D4D", +":' c #C18C49", +"<' c #BC8643", +"[' c #BC8441", +"}' c #BE8141", +"|' c #C08243", +"1' c #C18343", +"2' c #BF8041", +"3' c #BC8144", +"4' c #BD8244", +"5' c #BD8144", +"6' c #BC8143", +"7' c #BB8042", +"8' c #B97E42", +"9' c #BA7F47", +"0' c #BD8249", +"a' c #C0854D", +"b' c #C2874F", +"c' c #C38850", +"d' c #C78C51", +"e' c #C88D51", +"f' c #C4894D", +"g' c #C08549", +"h' c #BD8246", +"i' c #BB8144", +"j' c #B77D41", +"k' c #BE8448", +"l' c #BE8446", +"m' c #BD8348", +"n' c #C0844F", +"o' c #C18550", +"p' c #BE824B", +"q' c #BF844A", +"r' c #C1874B", +"s' c #C18749", +"t' c #C08546", +"u' c #BF8145", +"v' c #C08246", +"w' c #C08245", +"x' c #C48649", +"y' c #C4864A", +"z' c #C48646", +"A' c #C38742", +"B' c #C58946", +"C' c #CA8D4C", +"D' c #C18447", +"E' c #B7793D", +"F' c #B07237", +"G' c #B27641", +"H' c #B67A48", +"I' c #B27644", +"J' c #6C4321", +"K' c #744522", +"L' c #8F5933", +"M' c #96592D", +"N' c #A0612F", +"O' c #AF7137", +"P' c #BD8245", +"Q' c #BF8C4D", +"R' c #BF8A4B", +"S' c #BA8043", +"T' c #C18649", +"U' c #C38549", +"V' c #C38647", +"W' c #C08444", +"X' c #BD8141", +"Y' c #BC803F", +"Z' c #BD7F3F", +"`' c #BE8142", +" ) c #BC8142", +".) c #BB8045", +"+) c #B87D42", +"@) c #C2874B", +"#) c #C1864A", +"$) c #B2773B", +"%) c #B6783D", +"&) c #B07136", +"*) c #B07036", +"=) c #B3743A", +"-) c #B5763B", +";) c #B7783D", +">) c #B7793F", +",) c #B47742", +"') c #B77C45", +")) c #B77C43", +"!) c #BA7F44", +"~) c #BD8345", +"{) c #BD8344", +"]) c #BA8040", +"^) c #BA7D3E", +"/) c #B67A3A", +"() c #B47638", +"_) c #B87B3C", +":) c #BB7D3F", +"<) c #BA7C3F", +"[) c #B97C3B", +"}) c #B67937", +"|) c #B37636", +"1) c #B5773A", +"2) c #AD6F34", +"3) c #A96B32", +"4) c #A4662E", +"5) c #986132", +"6) c #A16E42", +"7) c #A06C41", +"8) c #583012", +"9) c #633515", +"0) c #76401E", +"a) c #8C4E26", +"b) c #9A5A2A", +"c) c #AE6F37", +"d) c #B3763A", +"e) c #AC7C34", +"f) c #B18038", +"g) c #B17D37", +"h) c #AD7630", +"i) c #AA722C", +"j) c #A8702A", +"k) c #A96D2B", +"l) c #AF6E35", +"m) c #B37339", +"n) c #B6753C", +"o) c #B9793E", +"p) c #BB7A42", +"q) c #BD7F44", +"r) c #BD8445", +"s) c #C3884A", +"t) c #C48A4B", +"u) c #C58B4C", +"v) c #C78C4E", +"w) c #CA8F53", +"x) c #C98E52", +"y) c #C78C50", +"z) c #C68B4F", +"A) c #C58A4E", +"B) c #C8884D", +"C) c #C5854A", +"D) c #C28248", +"E) c #C07E45", +"F) c #BE7D43", +"G) c #BB7A40", +"H) c #BE7E45", +"I) c #C0854C", +"J) c #C2874C", +"K) c #C08648", +"L) c #C28849", +"M) c #C18745", +"N) c #BC823F", +"O) c #BD803F", +"P) c #BB7E3D", +"Q) c #B77A3A", +"R) c #B87B3B", +"S) c #B67939", +"T) c #B57837", +"U) c #B47739", +"V) c #BA7C40", +"W) c #B97A42", +"X) c #B0723B", +"Y) c #955621", +"Z) c #824C21", +"`) c #814F27", +" ! c #835129", +".! c #5F3210", +"+! c #6E3D19", +"@! c #804722", +"#! c #905128", +"$! c #945626", +"%! c #A16530", +"&! c #A76E36", +"*! c #B57B3D", +"=! c #BD8243", +"-! c #BD8042", +";! c #BE7D40", +">! c #C07E41", +",! c #C47F43", +"'! c #C57F45", +")! c #C17D47", +"!! c #C17F48", +"~! c #C07D46", +"{! c #BF7D46", +"]! c #BC7943", +"^! c #B8753F", +"/! c #AE7535", +"(! c #AF7535", +"_! c #B17737", +":! c #B37939", +"~ c #BA7E38", +",~ c #B97D37", +"'~ c #B57933", +")~ c #B67A34", +"!~ c #BD813B", +"~~ c #C1853F", +"{~ c #C18443", +"]~ c #C6884D", +"^~ c #CB8D52", +"/~ c #CD8E56", +"(~ c #CD8E58", +"_~ c #C0814D", +":~ c #AA6B39", +"<~ c #925222", +"[~ c #8A481A", +"}~ c #8E4C1D", +"|~ c #AE7243", +"1~ c #AC6F3F", +"2~ c #9C5D2B", +"3~ c #B27341", +"4~ c #B37745", +"5~ c #7F4717", +"6~ c #996333", +"7~ c #B48046", +"8~ c #BC864C", +"9~ c #BE864C", +"0~ c #C0874D", +"a~ c #C1874E", +"b~ c #BF864D", +"c~ c #C0844A", +"d~ c #BD813F", +"e~ c #BA7D3C", +"f~ c #BB7F3D", +"g~ c #BC803E", +"h~ c #C38644", +"i~ c #C38A49", +"j~ c #C48F4D", +"k~ c #C99353", +"l~ c #CD9656", +"m~ c #CD9756", +"n~ c #C48E4E", +"o~ c #B98342", +"p~ c #B78045", +"q~ c #BA8149", +"r~ c #B9834B", +"s~ c #B37D47", +"t~ c #AE7942", +"u~ c #AC7741", +"v~ c #AB7943", +"w~ c #AC7A44", +"x~ c #AC7942", +"y~ c #AA7842", +"z~ c #A97641", +"A~ c #AC7944", +"B~ c #A97640", +"C~ c #A7713B", +"D~ c #A9733C", +"E~ c #BF884F", +"F~ c #C99356", +"G~ c #C99553", +"H~ c #CB9653", +"I~ c #CB9751", +"J~ c #CC9351", +"K~ c #C48D4B", +"L~ c #C08746", +"M~ c #C08848", +"N~ c #C28A4B", +"O~ c #C38A4C", +"P~ c #C1884D", +"Q~ c #BC844E", +"R~ c #AF7844", +"S~ c #A46A38", +"T~ c #9C602E", +"U~ c #945320", +"V~ c #97531F", +"W~ c #A35F26", +"X~ c #B16B31", +"Y~ c #B56F34", +"Z~ c #A86332", +"`~ c #A6632F", +" { c #AC6933", +".{ c #A96933", +"+{ c #91521F", +"@{ c #854718", +"#{ c #8D4F25", +"${ c #875221", +"%{ c #85511F", +"&{ c #84501E", +"*{ c #8B5625", +"={ c #925E2D", +"-{ c #94602E", +";{ c #8C5826", +">{ c #895623", +",{ c #8F5B28", +"'{ c #8F5C29", +"){ c #8E5B28", +"!{ c #8C5725", +"~{ c #925E2C", +"{{ c #94612F", +"]{ c #93602D", +"^{ c #966331", +"/{ c #A06E3B", +"({ c #9E6A38", +"_{ c #8B5727", +":{ c #885325", +"<{ c #845225", +"[{ c #855428", +"}{ c #84562B", +"|{ c #7F532A", +"1{ c #82562F", +"2{ c #86562E", +"3{ c #85542C", +"4{ c #84532B", +"5{ c #825129", +"6{ c #7D4C24", +"7{ c #77461E", +"8{ c #6B3912", +"9{ c #633110", +"0{ c #653310", +"a{ c #7B4A22", +"b{ c #89582C", +"c{ c #956634", +"d{ c #9F6F3C", +"e{ c #9E6F39", +"f{ c #986A36", +"g{ c #8A5B28", +"h{ c #825322", +"i{ c #865728", +"j{ c #89592D", +"k{ c #8C5C30", +"l{ c #8C5D33", +"m{ c #8A5D32", +"n{ c #8A5D34", +"o{ c #8E5D31", +"p{ c #9A6232", +"q{ c #AB6A31", +"r{ c #B56E2F", +"s{ c #BC7631", +"t{ c #BF7B34", +"u{ c #BF7B35", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +". . . . . . + @ # $ % & * = - ; ; > , , ' ) ) ) ) ! ~ { { ] ^ / ( / ^ { { { { { { { { { ( ( ( ( _ : < [ } | 1 2 2 2 . . . . . . ", +"3 4 4 4 4 4 5 6 7 8 9 0 a b c d d d d d d e e e f g h i j k l m m n o p p p p p p p p p q r m s t u v w x y z A A B 5 4 4 4 4 5 ", +"C D D D E E F G H I J K L M N O P Q R R R S S S T U V W X Y Z ` ...+.@.@.@.@.@.@.@.@.#.$. .` %.&.*.=.-.;.>.,.'.'.).!.D ~.E E F ", +"{.].].^././.(._.:.<.[.}.|.1.2.3.4.5.6.6.7.7.7.8.9.0.a.b.c.d.e.f.g.h.i.j.j.j.j.j.j.j.j.j.k.g.l.m.n.o.p.q.r.s.t.u.u.v.w.].].]./.].", +"x.y.y.y.z.z.A.B.C.D.E.F.G.H.I.J.K.L.M.M.N.N.N.N.N.O.P.Q.R.S.T.U.V.W.X.Y.Y.Y.Y.Y.Y.Y.Y.X.Z.`. +.+++@+#+$+%+&+*+z.z.=+-+y.-+;+z.u.", +">+,+,+,+'+'+)+!+~+{+]+^+/+(+_+:+<+[+}+}+|+1+2+3+4+3+5+6+7+8+9+0+a+b+c+c+c+c+c+c+c+c+c+c+d+e+f+g+h+i+j+k+l+m+n+'+'+o+p+,+p+o+'+'+", +"q+q+q+r+s+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+I+I+J+K+L+M+N+O+P+Q+R+S+T+T+T+T+T+T+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@&@t+t+*@=@r+=@*@s+*@", +"-@;@;@;@;@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@3@3@3@3@3@4@4@5@6@7@7@7@7@7@8@9@T+0@a@b@c@d@e@f@g@h@n.i@j@!.!.!.!.!.k@l@m@;@", +"n@o@o@o@o@o@p@q@r@s@t@u@v@w@x@y@z@A@B@C@D@E@F@E@G@G@G@G@G@G@H@I@J@K@L@M@M@M@M@M@L@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ # # # # #.#+#@#p@", +"##$#$#$#$#$#%#%#&#*#=#-#;#>#,#'#)#!#~#{#]#^#/#/#(#(#(#(#(#(#_#:#<#[#}#|#|#|#|#|#1#2#3#4#5#6#7#8#9#0#a#b#c#d#e#f#f#f#f#f#f#$#$#$#", +"g#h#h#h#h#h#i#j#k#l#m#n#o#p#q#r#s#t#u#v#w#x#y#z#A#A#A#A#A#A#A#A#A#B#C#C#C#C#C#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#h#h#h#h#h#h#h#h#S#", +"T#U#U#U#U#U#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$;$;$;$;$;$;$;$;$;$;$;$;$;$;$;$;$>$,$'$)$!$~${$]$^$/$($_$:$<$[$U#U#U#U#U#U#U#U#U#", +"}$}$}$}$}$}$|$1$2$3$4$5$6$7$8$9$0$a$b$c$d$e$f$g$h$i$j$j$j$j$j$j$j$k$k$k$k$k$k$k$g$l$m$n$o$p$q$r$s$t$u$v$w$x$y$}$}$}$}$}$}$}$}$}$", +"z$A$z$z$z$z$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O$P$Q$R$S$T$U$V$W$W$W$W$W$X$Y$Z$`$ %.%+%@%#%$%%%&%*%=%-%;%>%,%'%)%!%~%z$z$z$z$z$z$z$A${%", +"]%^%^%^%^%^%/%(%_%:%<%[%}%|%1%2%3%4%5%6%7%8%9%0%a%b%c%c%d%d%d%d%d%c%e%f%g%h%i%j%k%l%m%n%6%o%p%q%r%s%t%u%v%w%x%^%^%^%^%^%^%^%^%^%", +"y%y%y%y%y%y%y%z%A%B%C%D%E%F%G%H%I%J%K%L%M%N%O%P%Q%R%S%T%U%U%U%U%U%U%V%W%X%Y%Z%`% &.&+&@&#&$&%&&&*&=&-&;&>&,&'&y%y%y%y%y%y%y%)&F%", +"!&!&!&!&!&!&~&{&]&^&/&(&_&:&<&[&}&|&1&2&3&4&5&6&7&8&9&0&a&a&b&c&d&c&e&f&g&h&i&7&j&K$k&l&m&n&o&p&q&r&s&t&u&v&w&!&!&!&!&!&!&!&!&x&", +"y&z&z&z&z&z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&R&S&T&U&V&W&W&W&X&X&X&Y&Z&`& *.*+*R&@*#*$*%*&***=*-*;*>*,*'*)*!*z&z&z&z&z&z&z&z&~*", +"{*{*{*{*{*{*]*^*/*(*_*:*<*[*}*|*1*{*2*3*4*5*6*7*8*9*0*a*b*b*a*c*|&|&d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*{*{*{*{*{*{*{*{*{*", +"y*y*y*y*y*y*z*A*B*C*D*E*F*G*H*I*J*K*L*M*N*O*P*Q*R*S*T*U*V*V*W*X*Y*Z*`* =.=+=@=#=$=%=&=*===-=;=>=,='=)=!=~={=]=y*y*y*y*y*y*y*y*^=", +"/=/=/=/=/=/=(=_=:=<=[=}=|=1=2=/=3=3=3=/=4=5=6=7=8=9=0=a=b=c=d=e=e=e=f=g=h=i=S*j=+*k=l=m=:=n=/=3=_=_=o=p=q=r=s=/=/=/=/=/=/=/=/=/=", +"|=|=|=|=|=|=|=t=|=u=v=t=w=w=|=|=|=|=|=x=y=z=z=z=A=B=C=9*m*D=E=F=F=V*G=H=e*I=J=K=L=|=|=|=|=|=|=|=|=|=|=|=t=M=N=|=|=|=|=|=|=|=|=|=", +"O=P=P=P=P=P=P=P=P=w=u=P=N=P=P=P=P=P=P=O=Q=R=r%S=T=U=V=R=W=X=Y=Z=Z=`= -.-+-+-@-#-$-%-u=u=N=P=P=P=P=P=P=P=P=u=P=P=P=P=P=P=P=P=P=P=", +"v=&-&-&-&-&-&-&-N=N=*-&-*-&-&-&-&-&-&-&-=-Y=X=--;->-,-v='-)-!-~-{-{-{-]-^-~-~-~-)-&-N=&-&-&-&-&-&-&-&-&-&-/-v=&-&-&-&-&-&-&-&-v=", +"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-(-_-_-_-_-_-_-:-<-<-<-<-<-<-<-[-[-[-[-[-[-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-", +"}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-|-|-|-|-|-|-1-1-1-1-1-1-2-|-3-3-3-3-3-|-1-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-}-", +"4-5-5-5-5-5-6-7-7-7-7-7-7-7-7-7-7-7-7-7-8-8-8-8-8-8-9-0-0-0-0-0-0-8-a-b-b-b-b-b-c-d-7-7-7-7-7-7-7-7-7-7-7-7-d-e-e-4-4-4-f-0-7-0-", +"g-h-i-j-k-l-l-m-n-n-o-o-o-p-q-r-q-q-q-q-s-t-n-n-n-n-n-u-o-o-u-n-n-n-n-s-s-s-s-s-v-q-r-q-q-w-w-x-o-n-n-n-n-o-y-z-A-B-C-D-E-F-G-H-", +"I-J-K-L-L-L-M-N-O-O-P-P-P-N-t-n-t-Q-O-O-R-S-S-T-p-U-U-N-P-P-R-O-O-O-O-O-O-O-O-O-N-t-n-t-V-U-U-W-O-O-O-O-O-O-X-Y-Z-`- ;.;+;@;#;$;", +"%;&;*;=;%;%;-;;;>;>;,;';);!;~;;;~;{;!;!;{;~;~;);];{;^;!;);););/;>;>;>;>;>;>;>;>;(;;;;;;;;;;;;;~;>;>;>;>;>;>;_;:;<;[;};|;|;1;1;2;", +"3;4;5;6;7;8;9;0;a;a;b;c;d;e;a;f;0;g;h;i;j;k;l;j;m;n;o;p;q;r;s;e;a;t;u;v;v;w;0;b;x;s;y;e;g;z;A;e;A;B;b;C;y;D;E;F;G;H;I;J;K;L;M;N;", +"O;P;Q;O;R;S;T;U;V;W;X;Y;Z;`; >.>W;+>@>#>$>Z;%>&>%>*>$>@>=>->->;>>>,>'>'>)>!>~>{>]>=>]>*>^>/>$>$>(>`;_>W;:>(><>[>}>|>1>2>3>4>5>6>", +"7>8>9>0>a>b>b>c>d>e>f>g>h>i>j>k>l>m>n>g>o>p>i>q>g>r>i>g>s>t>u>n>v>w>x>x>y>z>A>B>C>D>g>E>C>F>G>H>g>g>I>p>J>f>K>L>M>N>O>P>Q>R>S>T>", +"U>V>W>X>I>Y>Z>`> ,.,+,@,#,$,%,&,*,=,-,;,;,>,,,',),!,~,{,],,,^,/,(,_,:,<,[,},|,|,|,1,2,3,4,5,6,7,8,9,0,a,b,c,d,e,f,g,h,i,j,k,l,m,", +"n,o,p,%,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H,I,J,K,L,*,M,N,O,P,Q,_,R,S,T,U,V,F>W,X,Y,Z,`, '/,.'+'@'#'$'%'$'&'*'='-';'>',''')'!'", +"~'{']'^'/'('_':'<'['}'|'1'2'3'4'5'4'6'7'8'9'0'0'a'b'c'd'e'f'g'P,O,h'i'j'6,Q,k'l'm'n'o'p'q'r's't'u'v'w'v'x'y'z'A'B'C'D'E'F'G'H'I'", +"J'K'L'M'N'O'P'b>Q'R'E>S'T'U'V'W'X'Y'Z'`' )b,.)+)_,h'O,@)#)h'M,$),,^,%)&)*)=)-);)>),)')))!)~){)])^)/)()_):)<)[)})|)1)2)3)4)5)6)7)", +"8)9)0)a)b)c)d)e)f)g)h)i)j)k)l)m)m)n)o)p)q)r)t's)t)u)v)w)x)y)y)f'z)A)B)C)D)E)F)G)H)`,I)J)K)L)M)N)O)P)Q)R)R)S)T)|)U)V)W)X)Y)Z)`) !", +".!+!@!#!$!%!&!*!=!-!;!>!,!'!)!!!~!{!]!^!=)/!(!_!:!#~$~h'%~&~*~=~-~;~>~,~'~)~!~~~{~]~^~/~(~_~:~<~[~}~", +"|~1~2~3~4~5~6~7~8~9~0~a~b~c~d~e~f~='g~h~i~j~k~l~m~n~o~p~q~r~r~s~t~u~v~w~x~y~z~A~B~C~D~E~F~G~H~I~J~K~L~M~N~O~P~Q~R~S~T~U~V~W~X~Y~", +"Z~`~ {.{+{@{#{${%{&{*{={-{;{>{,{'{){!{;{~{{{]{^{/{({~{_{:{<{[{}{|{1{2{3{4{5{6{7{8{9{0{a{b{c{d{e{f{g{h{i{j{k{l{m{n{o{p{q{r{s{t{u{"}; diff --git a/demos/mobile/qtbubblelevel/main.cpp b/demos/mobile/qtbubblelevel/main.cpp new file mode 100644 index 0000000..20fe43c --- /dev/null +++ b/demos/mobile/qtbubblelevel/main.cpp @@ -0,0 +1,128 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include +#include + +#include "accelerometerfilter.h" +#include "settings.h" +#include "taskswitcher.h" + +// Lock orientation in Symbian +#ifdef Q_OS_SYMBIAN + #include + #include + #include + #include +#endif + +QTM_USE_NAMESPACE + + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +#ifdef Q_OS_SYMBIAN + // Lock orientation to landscape in Symbian + CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi()); + TRAP_IGNORE( + if (appUi) + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape); + ) +#endif + + //! [0] + QDeclarativeView view; + view.setSource(QUrl("qrc:/qml/BubbleLevel.qml")); + view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + //! [0] + + // ![1] + Settings settings; + + QAccelerometer sensor; + AccelerometerFilter filter; + sensor.addFilter(&filter); + //! [1] + + //! [2] + QObject *rootObject = dynamic_cast(view.rootObject()); + + // Associate Qt / QML signals and slots + QObject::connect(rootObject, SIGNAL(saveCorrectionAngle(const QVariant&)), + &settings, SLOT(saveCorrectionAngle(const QVariant&))); + + QObject::connect(&filter, SIGNAL(rotationChanged(const QVariant&)), + rootObject, SLOT(handleRotation(const QVariant&))); + + QObject::connect(&settings, SIGNAL(correctionAngle(const QVariant&)), + rootObject, SLOT(setCorrectionAngle(const QVariant&))); + + QObject::connect((QObject*)view.engine(), SIGNAL(quit()), + &app, SLOT(quit())); + //! [2] + + //! [3] +#ifdef Q_WS_MAEMO_5 + TaskSwitcher taskSwitcher; + + QObject::connect(rootObject, SIGNAL(minimizeApplication()), + &taskSwitcher, SLOT(minimizeApplication())); + + // Show the task switcher button + rootObject->setProperty("taskSwitcherVisible", true); +#endif + //! [3] + + //! [4] + // Read correction factor from permanent storage and emit it to QML side + settings.loadAndEmitCorrectionAngle(); + + // Begin measuring of the accelerometer sensor + sensor.start(); + //! [4] + + //! [5] +#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) + view.setGeometry(QApplication::desktop()->screenGeometry()); + view.showFullScreen(); +#else + view.setGeometry((QRect(100, 100, 800, 480))); + view.show(); +#endif + //! [5] + + return app.exec(); +} diff --git a/demos/mobile/qtbubblelevel/qml/BubbleLevel.qml b/demos/mobile/qtbubblelevel/qml/BubbleLevel.qml new file mode 100644 index 0000000..4af6a76 --- /dev/null +++ b/demos/mobile/qtbubblelevel/qml/BubbleLevel.qml @@ -0,0 +1,218 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Image { + id: bubbleLevel + + //! [0] + // Signaled when task switcher button is pressed + signal minimizeApplication() + + // Signaled when correction angle is saved + signal saveCorrectionAngle(variant angle) + + // These functions are used as Qt slots + function handleRotation(deg) { + horTube.rawangle = deg + } + + function setCorrectionAngle(deg) { + horTube.angleconstant = deg + } + + // Used to show the task switcher button in Maemo targets + property alias taskSwitcherVisible: taskSwitcher.visible + //! [0] + + anchors.fill: parent + source: "images/board.png" + smooth: true + + MouseArea { + anchors.fill: parent + onClicked: sign.frontSide = true + } + + Button { + id: taskSwitcher + + anchors { + left: parent.left + right: horTube.left + verticalCenter: horTube.verticalCenter + margins: (parent.width - (horTube.x + horTube.width)) / 4 + } + + height: width + source: "images/taskswitcher.png" + mouseAreaScale: 2 + onClicked: bubbleLevel.minimizeApplication() + visible: false + } + + Button { + id: exitButton + + anchors { + left: horTube.right + right: parent.right + verticalCenter: horTube.verticalCenter + margins: (parent.width - (horTube.x + horTube.width)) / 4 + } + + height: width + source: "images/exit.png" + mouseAreaScale: 2 + onClicked: Qt.quit() + } + + //! [1] + Tube { + id: horTube + + property real rawangle: 0 + property real angleconstant: 0 + + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width * 0.775; height: parent.height * 0.15625 + deg: rawangle - angleconstant + } + //! [1] + + Flipable { + id: sign + + property bool frontSide: true + + x: parent.width * 0.185; y: parent.height * 0.669 + width: parent.width * 0.63; height: parent.height * 0.258 + + MouseArea { + anchors.fill: parent + onClicked: sign.frontSide = !sign.frontSide + z: -1 + } + + transform: Rotation { + + origin.x: sign.width / 2; origin.y: sign.height / 2 + axis.x: 1; axis.y: 0; axis.z: 0 + angle: sign.frontSide ? 0 : 180 + + Behavior on angle { + RotationAnimation { + direction: RotationAnimation.Clockwise + easing.type: Easing.InOutCubic; duration: 300 + } + } + } + + front: Image { + anchors.fill: parent + source: "images/signwithtext.png" + smooth: true + } + + back: Image { + anchors.fill: parent + source: "images/signblank.png" + smooth: true + + Text { + id: oldValue + + anchors { + left: parent.left; leftMargin: parent.width * 0.10 + right: saveButton.left; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + + text: "Place the device on a level surface and tap Calibrate." + color: "#302020" + wrapMode: Text.WordWrap + font { bold: false; pixelSize: Math.min(parent.width, parent.height) * 0.19 } + } + + Button { + id: saveButton + + anchors { + right: parent.right; rightMargin: parent.width * 0.09 + verticalCenter: parent.verticalCenter + } + + width: parent.width * 0.25; height: parent.height * 0.65 + border { width: 2; color: "#555555" } + radius: 10 + + onClicked: { + horTube.angleconstant = horTube.rawangle + saveCorrectionAngle(horTube.angleconstant) + } + + gradient: Gradient { + GradientStop { position: 0.0; color: "#999999" } + GradientStop { position: 0.2; color: "#BBBBBB" } + GradientStop { position: 0.8; color: "#BBBBBB" } + GradientStop { position: 1.0; color: "#999999" } + } + + Text { + anchors.centerIn: parent + color: "#302020" + text: "Calibrate" + font { bold: true; pixelSize: parent.width * 0.15 } + smooth: true + } + } + } + } + + Button { + anchors { + left: sign.right + right: parent.right + verticalCenter: sign.verticalCenter + margins: (parent.width - (sign.x + sign.width)) / 4 + } + + height: width + source: "images/calibbutton.png" + mouseAreaScale: 2 + smooth: true + + onClicked: sign.frontSide = !sign.frontSide + } +} diff --git a/demos/mobile/qtbubblelevel/qml/Button.qml b/demos/mobile/qtbubblelevel/qml/Button.qml new file mode 100644 index 0000000..53dda1f --- /dev/null +++ b/demos/mobile/qtbubblelevel/qml/Button.qml @@ -0,0 +1,64 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Rectangle { + id: button + + property alias source: image.source + property alias mouseAreaScale: mouseArea.scale + + signal clicked + + width: 50; height: 50 + color: "transparent" + + Behavior on scale { NumberAnimation { duration: 50 } } + + Image { + id: image + + anchors.fill: parent + smooth: true + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + onClicked: { button.clicked() } + onEntered: { button.scale = 0.9 } + onExited: { button.scale = 1.0 } + } +} diff --git a/demos/mobile/qtbubblelevel/qml/Tube.qml b/demos/mobile/qtbubblelevel/qml/Tube.qml new file mode 100644 index 0000000..91c3198 --- /dev/null +++ b/demos/mobile/qtbubblelevel/qml/Tube.qml @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +//! [0] +Item { + id: tube + + property real deg + + Image { + id: bubble + + property real center: tube.width / 2 + property real bubbleCenter: bubble.width / 2 + + function calX() { + var newX = center + tube.deg / -20 * center + + if((newX - bubbleCenter) < 0) { + return 0 + } + else if((newX + bubbleCenter) > tube.width) { + return tube.width - 2 * bubbleCenter + } + + return newX - bubbleCenter; + } + + x: calX() + width: 0.16129032 * parent.width; height: 0.66666667 * parent.height + source: "images/bubble.png" + smooth: true + } + + Image { + anchors.horizontalCenter: parent.horizontalCenter + width: 0.36451613 * parent.width; height: 0.66666667 * parent.height + source: "images/scale.png" + } + + Image { + width: parent.width; height: 0.32 * parent.height + opacity: 0.8 + source: "images/reflection.png" + } +} +//! [0] diff --git a/demos/mobile/qtbubblelevel/qml/images/board.png b/demos/mobile/qtbubblelevel/qml/images/board.png new file mode 100644 index 0000000..aaed8d0 Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/board.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/bubble.png b/demos/mobile/qtbubblelevel/qml/images/bubble.png new file mode 100644 index 0000000..e73be9e Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/bubble.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/calibbutton.png b/demos/mobile/qtbubblelevel/qml/images/calibbutton.png new file mode 100644 index 0000000..5f84dad Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/calibbutton.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/exit.png b/demos/mobile/qtbubblelevel/qml/images/exit.png new file mode 100644 index 0000000..64a6163 Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/exit.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/reflection.png b/demos/mobile/qtbubblelevel/qml/images/reflection.png new file mode 100644 index 0000000..093781e Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/reflection.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/scale.png b/demos/mobile/qtbubblelevel/qml/images/scale.png new file mode 100644 index 0000000..c75b21e Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/scale.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/signblank.png b/demos/mobile/qtbubblelevel/qml/images/signblank.png new file mode 100644 index 0000000..03b53cc Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/signblank.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/signwithtext.png b/demos/mobile/qtbubblelevel/qml/images/signwithtext.png new file mode 100644 index 0000000..be9c050 Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/signwithtext.png differ diff --git a/demos/mobile/qtbubblelevel/qml/images/taskswitcher.png b/demos/mobile/qtbubblelevel/qml/images/taskswitcher.png new file mode 100644 index 0000000..89ff7a1 Binary files /dev/null and b/demos/mobile/qtbubblelevel/qml/images/taskswitcher.png differ diff --git a/demos/mobile/qtbubblelevel/qtbubblelevel.desktop b/demos/mobile/qtbubblelevel/qtbubblelevel.desktop new file mode 100644 index 0000000..6d83002 --- /dev/null +++ b/demos/mobile/qtbubblelevel/qtbubblelevel.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Name=QtBubbleLevel +Exec=/opt/usr/bin/qtbubblelevel +Icon=qtbubblelevel +StartupWMClass= +X-Window-Icon=qtbubblelevel +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable +Terminal=false diff --git a/demos/mobile/qtbubblelevel/qtbubblelevel.pro b/demos/mobile/qtbubblelevel/qtbubblelevel.pro new file mode 100644 index 0000000..8646308 --- /dev/null +++ b/demos/mobile/qtbubblelevel/qtbubblelevel.pro @@ -0,0 +1,61 @@ +# Copyright (c) 2011 Nokia Corporation. + +QT += core gui declarative +CONFIG += mobility +MOBILITY += sensors + +TARGET = qtbubblelevel +TEMPLATE = app + +VERSION = 1.2.0 + +HEADERS += taskswitcher.h \ + accelerometerfilter.h \ + settings.h + +SOURCES += main.cpp \ + taskswitcher.cpp \ + accelerometerfilter.cpp + +OTHER_FILES += qml/*.qml \ + qml/images/*.png + +RESOURCES = resources.qrc + +maemo5 { + BINDIR = /opt/usr/bin + DATADIR = /usr/share + DEFINES += DATADIR=\\\"$$DATADIR\\\" \ + PKGDATADIR=\\\"$$PKGDATADIR\\\" + INSTALLS += target \ + desktop \ + iconxpm \ + icon26 \ + icon40 \ + icon64 + + target.path = $$BINDIR + desktop.path = $$DATADIR/applications/hildon + desktop.files += $${TARGET}.desktop + + iconxpm.path = $$DATADIR/pixmap + iconxpm.files += icons/xpm/qtbubblelevel.xpm + + icon26.path = $$DATADIR/icons/hicolor/26x26/apps + icon26.files += icons/26x26/qtbubblelevel.png + + icon40.path = $$DATADIR/icons/hicolor/40x40/apps + icon40.files += icons/40x40/qtbubblelevel.png + + icon64.path = $$DATADIR/icons/hicolor/64x64/apps + icon64.files += icons/64x64/qtbubblelevel.png +} + +symbian { + TARGET = QtBubbleLevel + + # To lock the application to landscape orientation + LIBS += -lcone -leikcore -lavkon + + ICON = icons/bubblelevel.svg +} diff --git a/demos/mobile/qtbubblelevel/qtbubblelevel.pro.user b/demos/mobile/qtbubblelevel/qtbubblelevel.pro.user new file mode 100644 index 0000000..18f2250 --- /dev/null +++ b/demos/mobile/qtbubblelevel/qtbubblelevel.pro.user @@ -0,0 +1,382 @@ + + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/qtbubblelevel-build-desktop + 4 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/qtbubblelevel-build-desktop + 4 + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + qtbubblelevel + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qtbubblelevel.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + Qt Simulator + Qt Simulator + Qt4ProjectManager.Target.QtSimulatorTarget + 0 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/qtbubblelevel-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/qtbubblelevel-build-simulator + 6 + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + qtbubblelevel + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + qtbubblelevel.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.2 + + Remote Compiler + Remote Compiler + Qt4ProjectManager.Target.WccCompilerTarget + 0 + 0 + 0 + + + + + + Qt4ProjectManager.WccBuildStep + + + + 1 + 1 + 4_7_0_m1_0_2 + 1 + maemo5 + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/qtbubblelevel-build-remote + 7 + 12 + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + Remote Compiler - Empty Run Configuration + Qt4ProjectManager.WccRunConfiguration + qtbubblelevel.pro + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7d0e1b67-5eac-4464-8506-ed03165c2662} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/demos/mobile/qtbubblelevel/qtbubblelevel.zip b/demos/mobile/qtbubblelevel/qtbubblelevel.zip new file mode 100644 index 0000000..62f0a81 Binary files /dev/null and b/demos/mobile/qtbubblelevel/qtbubblelevel.zip differ diff --git a/demos/mobile/qtbubblelevel/resources.qrc b/demos/mobile/qtbubblelevel/resources.qrc new file mode 100644 index 0000000..8f57e82 --- /dev/null +++ b/demos/mobile/qtbubblelevel/resources.qrc @@ -0,0 +1,16 @@ + + + qml/BubbleLevel.qml + qml/Tube.qml + qml/Button.qml + qml/images/taskswitcher.png + qml/images/exit.png + qml/images/board.png + qml/images/bubble.png + qml/images/scale.png + qml/images/reflection.png + qml/images/signwithtext.png + qml/images/calibbutton.png + qml/images/signblank.png + + diff --git a/demos/mobile/qtbubblelevel/settings.h b/demos/mobile/qtbubblelevel/settings.h new file mode 100644 index 0000000..d0c5997 --- /dev/null +++ b/demos/mobile/qtbubblelevel/settings.h @@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include + +class Settings : public QObject +{ + Q_OBJECT + +public: + void loadAndEmitCorrectionAngle() { + QSettings settings("Nokia corp", "QtBubbleLevel"); + emit correctionAngle(settings.value("CorrectionAngle", "0.0f")); + } + +signals: + void correctionAngle(const QVariant &angle); + +public slots: + void saveCorrectionAngle(const QVariant &angle) { + QSettings settings("Nokia corp", "QtBubbleLevel"); + settings.setValue("CorrectionAngle", angle); + } +}; + +#endif // SETTINGS_H diff --git a/demos/mobile/qtbubblelevel/taskswitcher.cpp b/demos/mobile/qtbubblelevel/taskswitcher.cpp new file mode 100644 index 0000000..aa938ec --- /dev/null +++ b/demos/mobile/qtbubblelevel/taskswitcher.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2011 Nokia Corporation. + */ + +#include "taskswitcher.h" + +// Task Switcher for maemo +#ifdef Q_WS_MAEMO_5 + #include +#endif + + +void TaskSwitcher::minimizeApplication() +{ + //! [0] + #ifdef Q_WS_MAEMO_5 + // Uses DBus to minimize application in Maemo + QDBusConnection connection = QDBusConnection::sessionBus(); + QDBusMessage message = + QDBusMessage::createSignal("/","com.nokia.hildon_desktop", + "exit_app_view"); + connection.send(message); + #endif + //! [0] +} diff --git a/demos/mobile/qtbubblelevel/taskswitcher.h b/demos/mobile/qtbubblelevel/taskswitcher.h new file mode 100644 index 0000000..e40d227 --- /dev/null +++ b/demos/mobile/qtbubblelevel/taskswitcher.h @@ -0,0 +1,47 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef TASKSWITCHER_H +#define TASKSWITCHER_H + +#include + +class TaskSwitcher : public QObject +{ + Q_OBJECT + +public slots: + void minimizeApplication(); +}; + +#endif // TASKSWITCHER_H diff --git a/demos/mobile/quickhit/Game.js b/demos/mobile/quickhit/Game.js new file mode 100755 index 0000000..25863ad --- /dev/null +++ b/demos/mobile/quickhit/Game.js @@ -0,0 +1,173 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 levelPlugin = null + +// --------------------------------------------------------------------------- +// hideMissiles +function hideMissiles() { + missile_1.stop() + missile_1.opacity = 0; + + missile_2.stop() + missile_2.opacity = 0; + + missile_3.stop() + missile_3.opacity = 0; + + missile_4.stop() + missile_4.opacity = 0; + + missile_5.stop() + missile_5.opacity = 0; + + enemy_missile_1.opacity = 0; + enemy_missile_2.opacity = 0; +} + +// --------------------------------------------------------------------------- +// GameOver +function gameOver() { + + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + + // Delete loaded plugin level + deleteLevel() + + // Hiding + myShip.opacity = 0 + btnPause.opacity = 0 +} + +// --------------------------------------------------------------------------- +// Pause game +function pauseGame(doPause) { + missile_1.pause(doPause) + missile_2.pause(doPause) + missile_3.pause(doPause) + missile_4.pause(doPause) + missile_5.pause(doPause) + enemy_missile_1.pause(doPause) + enemy_missile_2.pause(doPause) + + if (doPause) { + btnPause.opacity = 0 + } else { + btnPause.opacity = 1 + } + + GameEngine.pauseLevel(doPause) +} + +// --------------------------------------------------------------------------- +// Fire your missile +function fireMissile(aXpox, aFromYpos, aToYpos) { + if (missile_1.opacity<1) { + missile_1.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_2.opacity<1) { + missile_2.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_3.opacity<1) { + missile_3.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_4.opacity<1) { + missile_4.fire(aXpox,aFromYpos,aToYpos) + } + else if (missile_5.opacity<1) { + missile_5.fire(aXpox,aFromYpos,aToYpos) + } +} + +// --------------------------------------------------------------------------- +// Fire enemy missile +function fireEnemyMissile(aXpox, aFromYpos, aToYpos) { + if (enemy_missile_1.opacity==0) { + enemy_missile_1.enemyFire(aXpox,aFromYpos,aToYpos) + } + else if (enemy_missile_2.opacity==0) { + enemy_missile_2.enemyFire(aXpox,aFromYpos,aToYpos) + } +} + +// --------------------------------------------------------------------------- +// Create level QML component +function createLevel() { + console.log("Creating level "+LevelPlugin.qmlRootPath()+"Level.qml") + var levelComponent = Qt.createComponent("file:/"+LevelPlugin.qmlRootPath()+"Level.qml"); + if (levelComponent.status == Component.Ready) { + if (levelPlugin) { + deleteLevel() + } + levelPlugin = levelComponent.createObject(levelId); + if (levelPlugin != null) { + console.log("Level created") + } else { + console.log("Can not create level") + messageBox.showErrorMessage("ERROR: Can not create level!",6000) + return 1 + } + } else { + console.log("Can not find level, error:"+levelComponent.errorString()) + messageBox.showErrorMessage("ERROR: Can not find level!",6000) + return 1 + } + + missile_1.createGraphicsForLevel() + missile_1.setToDefaultPos() + missile_2.createGraphicsForLevel() + missile_2.setToDefaultPos() + missile_3.createGraphicsForLevel() + missile_3.setToDefaultPos() + missile_4.createGraphicsForLevel() + missile_4.setToDefaultPos() + missile_5.createGraphicsForLevel() + missile_5.setToDefaultPos() + enemy_missile_1.createGraphicsForLevel() + enemy_missile_2.createGraphicsForLevel() + myShip.createGraphicsForLevel() + + return 0 +} + +// --------------------------------------------------------------------------- +// Delete level +function deleteLevel() { + if (levelPlugin) { + GameEngine.clearQmlObjects() + levelPlugin.destroy() + + } + levelPlugin = null; +} diff --git a/demos/mobile/quickhit/InvSounds.cpp b/demos/mobile/quickhit/InvSounds.cpp new file mode 100755 index 0000000..b598ae6 --- /dev/null +++ b/demos/mobile/quickhit/InvSounds.cpp @@ -0,0 +1,182 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "InvSounds.h" +#include +#include + +using namespace GE; + +CInvSounds::CInvSounds(QObject *parent) : QObject( parent ) +{ + m_musicInstance = 0; + m_sounds = 0; + m_internalSounds = 0; + m_soundCount = 0; + m_internalSoundCount = 0; + + enableSounds(true); + + m_audioOut = new AudioOut( this, &m_mixer ); + + enableInternalSounds(); +} + +void CInvSounds::enableSounds(bool enable) +{ + if (enable) + m_mixer.setGeneralVolume(0.2f); + else + m_mixer.setGeneralVolume(0); +} + +void CInvSounds::enableInternalSounds() +{ + disableInternalSounds(); + + // Application internal sounda + m_internalSoundPaths.append(":/sound/menu1.wav"); + m_internalSoundPaths.append(":/sound/menu2.wav"); + m_internalSoundPaths.append(":/sound/gamestart.wav"); + m_internalSoundPaths.append(":/sound/gameover.wav"); + m_internalSoundPaths.append(":/sound/youwin.wav"); + + m_internalSoundCount = m_internalSoundPaths.count(); + m_internalSounds = new CAudioBuffer*[m_internalSoundCount]; + + // Load general application sounds + for (int ff=0; ffsetLoopTimes(-1); +} + + +void CInvSounds::beginMusicOff() { + if (!m_musicInstance) return; + m_musicInstance->setLoopTimes(0); // stop when finished + m_musicInstance = 0; +}; + + +void CInvSounds::playSound(int index) { + if (index < m_soundCount && index > -1) { + m_sounds[index]->playWithMixer( m_mixer ); + } +} + +void CInvSounds::playSounds(int index, int count) +{ + if (index < m_soundCount && index > -1) { + CAudioBufferPlayInstance* i = m_sounds[index]->playWithMixer( m_mixer ); + i->setLoopTimes(count); + } +} + +void CInvSounds::playInternalSound(int index) { + if (index < m_internalSoundCount && index > -1) { + m_internalSounds[index]->playWithMixer( m_mixer ); + } +} + +void CInvSounds::playInternalSounds(int index, int count) +{ + if (index < m_internalSoundCount && index > -1) { + CAudioBufferPlayInstance* i = m_internalSounds[index]->playWithMixer( m_mixer ); + i->setLoopTimes(count); + } +} + +void CInvSounds::gameStartSound() { + CAudioBufferPlayInstance* i = m_internalSounds[2]->playWithMixer( m_mixer ); + i->setLoopTimes(2); +}; diff --git a/demos/mobile/quickhit/InvSounds.h b/demos/mobile/quickhit/InvSounds.h new file mode 100755 index 0000000..4be8863 --- /dev/null +++ b/demos/mobile/quickhit/InvSounds.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef __CINVSOUNDS__ +#define __CINVSOUNDS__ + +#include +#include + +#include "ga_src/GEAudioBuffer.h" +#include "ga_src/GEAudioOut.h" + +class CInvSounds : public QObject +{ + Q_OBJECT + +public: + CInvSounds(QObject *parent); + ~CInvSounds(); + + void enableInternalSounds(); + void enableSounds(QStringList sounds); + void disableInternalSounds(); + void disableSounds(); + + void beginMusicOn(); + void beginMusicOff(); + + void enableSounds(bool enable); + + + void gameStartSound(); + +public slots: + void playSound(int index); + void playSounds(int index, int count); + void playInternalSound(int index); + void playInternalSounds(int index, int count); + +protected: + QStringList m_soundPaths; + QStringList m_internalSoundPaths; + GE::CAudioBufferPlayInstance *m_musicInstance; + GE::CAudioMixer m_mixer; + GE::AudioOut *m_audioOut; + + GE::CAudioBuffer **m_sounds; + int m_soundCount; + + GE::CAudioBuffer **m_internalSounds; + int m_internalSoundCount; +}; + +#endif diff --git a/demos/mobile/quickhit/QuickHit.pro.user b/demos/mobile/quickhit/QuickHit.pro.user new file mode 100644 index 0000000..4713ff8 --- /dev/null +++ b/demos/mobile/quickhit/QuickHit.pro.user @@ -0,0 +1,382 @@ + + + + ProjectExplorer.Project.ActiveTarget + 2 + + + ProjectExplorer.Project.EditorSettings + + Default + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/QuickHit-build-desktop + 4 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/QuickHit-build-desktop + 4 + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + QuickHit + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + QuickHit.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.1 + + Qt Simulator + Qt Simulator + Qt4ProjectManager.Target.QtSimulatorTarget + 1 + 0 + 0 + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/QuickHit-build-simulator + 6 + 0 + true + + + + + qmake + + QtProjectManager.QMakeBuildStep + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/QuickHit-build-simulator + 6 + 0 + true + + 2 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + QuickHit + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + QuickHit.pro + false + false + + false + + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.Target.2 + + Remote Compiler + Remote Compiler + Qt4ProjectManager.Target.WccCompilerTarget + 0 + 0 + 0 + + + + + + Qt4ProjectManager.WccBuildStep + + + + 1 + 1 + 4_7_0_m1_0_2 + 1 + maemo5 + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + 0 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Remote Compiler + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/jpasion/gitorious/jpasions-qt-doc-team-qtquick/demos/mobile/QuickHit-build-remote + 7 + 12 + true + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + Remote Compiler - Empty Run Configuration + Qt4ProjectManager.WccRunConfiguration + QuickHit.pro + 3768 + true + false + + 1 + + + + ProjectExplorer.Project.TargetCount + 3 + + + ProjectExplorer.Project.Updater.EnvironmentId + {7d0e1b67-5eac-4464-8506-ed03165c2662} + + + ProjectExplorer.Project.Updater.FileVersion + 8 + + diff --git a/demos/mobile/quickhit/button.qml b/demos/mobile/quickhit/button.qml new file mode 100755 index 0000000..881a0e2 --- /dev/null +++ b/demos/mobile/quickhit/button.qml @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Item { + width: 30 + height: 30 + smooth: true + + property string buttonPath // for example "qrc:/gfx/exit.png" + property int buttonId: 0 + + signal btnClicked(int buttonId) + + property bool animationEnabled: true + + Image { + id: image + anchors.fill: parent + source: buttonPath + fillMode: Image.PreserveAspectFit + smooth: true + } + + SequentialAnimation { + id:anim + PropertyAction { target: image; property: "scale"; value:"0.7"} + PauseAnimation { duration: 200 } + PropertyAction { target: image; property: "scale"; value:"1.0"} + } + + Timer { + id: buttonPressedTimer + interval: 300; running: false; repeat: false + onTriggered: btnClicked(buttonId) + } + + MouseArea { + anchors.fill: parent + onPressed: { + if (animationEnabled && !anim.running) { + anim.restart() + } + buttonPressedTimer.restart() + } + } + +} diff --git a/demos/mobile/quickhit/debian/changelog b/demos/mobile/quickhit/debian/changelog new file mode 100755 index 0000000..226e172 --- /dev/null +++ b/demos/mobile/quickhit/debian/changelog @@ -0,0 +1,11 @@ +quickhit (1.1.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio Wed, 5 Jan 2011 10:05:04 +0200 + +quickhit (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/debian/compat b/demos/mobile/quickhit/debian/compat new file mode 100755 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/debian/control b/demos/mobile/quickhit/debian/control new file mode 100755 index 0000000..7253285 --- /dev/null +++ b/demos/mobile/quickhit/debian/control @@ -0,0 +1,11 @@ +Source: quickhit +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio +Standards-Version: 3.7.2 + +Package: quickhit +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit + Qt Quick Game example diff --git a/demos/mobile/quickhit/debian/copyright b/demos/mobile/quickhit/debian/copyright new file mode 100755 index 0000000..b0aadaf --- /dev/null +++ b/demos/mobile/quickhit/debian/copyright @@ -0,0 +1,8 @@ +This is quickhit, written and maintained by Forum Nokia Antonio Aloisio +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/debian/dirs b/demos/mobile/quickhit/debian/dirs new file mode 100755 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/debian/postinst b/demos/mobile/quickhit/debian/postinst new file mode 100755 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/debian/rules b/demos/mobile/quickhit/debian/rules new file mode 100755 index 0000000..b485428 --- /dev/null +++ b/demos/mobile/quickhit/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := quickhit + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/freesound.org.licence.txt b/demos/mobile/quickhit/freesound.org.licence.txt new file mode 100755 index 0000000..8714ea0 --- /dev/null +++ b/demos/mobile/quickhit/freesound.org.licence.txt @@ -0,0 +1,24 @@ + +Sounds were loaded from www.freesound.org under Creative Commons Sampling Plus 1.0 license. + +Sounds were created by these nicknames: HardPCM, Matt_G, klankbeeld, steveygos93, joe93barlow, ljudman, Jovica, patchen, nthompson + +78677__joe93barlow__strike2.wav +47251__nthompson__rocket.wav +3378__patchen__Rhino_03.wav +3258__Jovica__Dronetail_02.wav +30351__Matt_G__Space_Fighter_Pass.wav +32954__HardPCM__Chip054.wav +32985__HardPCM__Alarm001.wav +33245__ljudman__grenade.wav +78678__joe93barlow__swing0.wav +80401__steveygos93__Explosion2.wav +109438__klankbeeld__intro_brass_01.wav + + + + + + + + diff --git a/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp b/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp new file mode 100755 index 0000000..cb798ac --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioBuffer.cpp @@ -0,0 +1,383 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include +#include "GEAudioBuffer.h" + +using namespace GE; + + +struct SWavHeader { + char chunkID[4]; + unsigned int chunkSize; + char format[4]; + + unsigned char subchunk1id[4]; + unsigned int subchunk1size; + unsigned short audioFormat; + unsigned short nofChannels; + unsigned int sampleRate; + unsigned int byteRate; + + unsigned short blockAlign; + unsigned short bitsPerSample; + + unsigned char subchunk2id[4]; + unsigned int subchunk2size; + +}; + +CAudioBuffer::CAudioBuffer() { + m_data = 0; + m_dataLength = 0; + m_sampleFunction = 0; +}; + + +CAudioBuffer::~CAudioBuffer() { + reallocate(0); +} + +void CAudioBuffer::reallocate( int length ) { + if (m_data) delete [] ((char*)m_data); + m_dataLength = length; + if (m_dataLength>0) { + m_data = new char[ m_dataLength ]; + } else m_data = 0; +}; + + +CAudioBuffer* CAudioBuffer::loadWav( QString fileName ) { + QFile *wavFile = new QFile( fileName ); + + + if (wavFile->open(QIODevice::ReadOnly)) { + SWavHeader header; + + wavFile->read( header.chunkID, 4 ); + if (header.chunkID[0]!='R' || header.chunkID[1]!='I' || header.chunkID[2]!='F' || header.chunkID[3]!='F') return 0; // incorrect header + + wavFile->read( (char*)&header.chunkSize,4 ); + wavFile->read( (char*)&header.format,4 ); + + if (header.format[0]!='W' || header.format[1]!='A' || header.format[2]!='V' || header.format[3]!='E') return 0; // incorrect header + + wavFile->read( (char*)&header.subchunk1id,4 ); + if (header.subchunk1id[0]!='f' || header.subchunk1id[1]!='m' || header.subchunk1id[2]!='t' || header.subchunk1id[3]!=' ') return 0; // incorrect header + + wavFile->read( (char*)&header.subchunk1size,4 ); + wavFile->read( (char*)&header.audioFormat,2 ); + wavFile->read( (char*)&header.nofChannels,2 ); + wavFile->read( (char*)&header.sampleRate,4 ); + wavFile->read( (char*)&header.byteRate,4 ); + wavFile->read( (char*)&header.blockAlign,2 ); + wavFile->read( (char*)&header.bitsPerSample,2 ); + + qDebug() << fileName << " opened"; + + while (1) { + if (wavFile->read( (char*)&header.subchunk2id,4 ) != 4) return 0; + if (wavFile->read( (char*)&header.subchunk2size,4 ) != 4) return 0; + //int deb_size = header.subchunk2size; + //char tes[4]; + //memcpy(tes, header.subchunk2id, 4 ); + //if (header.subchunk2id[0]!='d' || header.subchunk2id[1]!='a' || header.subchunk2id[2]!='t' || header.subchunk2id[3]!='a') return 0; // incorrect header + if (header.subchunk2id[0]=='d' && header.subchunk2id[1]=='a' && header.subchunk2id[2]=='t' && header.subchunk2id[3]=='a') break; // found the data, chunk + // this was not the data-chunk. skip it + if (header.subchunk2size<1) return 0; // error in file + char *unused = new char[header.subchunk2size]; + wavFile->read( unused, header.subchunk2size ); + delete [] unused; + } + + + + // the data follows. + if (header.subchunk2size<1) return 0; + + CAudioBuffer *rval = new CAudioBuffer; + rval->m_nofChannels = header.nofChannels; + rval->m_bitsPerSample = header.bitsPerSample; + rval->m_samplesPerSec = header.sampleRate; + rval->m_signedData = 0; // where to know this? + rval->reallocate( header.subchunk2size ); + + wavFile->read( (char*)rval->m_data, header.subchunk2size ); + + // choose a good sampling function. + rval->m_sampleFunction = 0; + if (rval->m_nofChannels==1) { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitMono; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitMono; + } else { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitStereo; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitStereo; + } + + return rval; + + + } else { + qDebug() << fileName << " NOT opened"; + return 0; + } + + delete wavFile; +}; + + +CAudioBuffer* CAudioBuffer::loadWav( FILE *wavFile ) { + // read the header. + SWavHeader header; + fread( header.chunkID, 4, 1, wavFile ); + if (header.chunkID[0]!='R' || header.chunkID[1]!='I' || header.chunkID[2]!='F' || header.chunkID[3]!='F') return 0; // incorrect header + + fread( &header.chunkSize, 4, 1, wavFile ); + fread( header.format, 4, 1, wavFile ); + if (header.format[0]!='W' || header.format[1]!='A' || header.format[2]!='V' || header.format[3]!='E') return 0; // incorrect header + + fread( header.subchunk1id, 4, 1, wavFile ); + if (header.subchunk1id[0]!='f' || header.subchunk1id[1]!='m' || header.subchunk1id[2]!='t' || header.subchunk1id[3]!=' ') return 0; // incorrect header + + fread( &header.subchunk1size, 4, 1, wavFile ); + fread( &header.audioFormat, 2, 1, wavFile ); + fread( &header.nofChannels, 2, 1, wavFile ); + fread( &header.sampleRate, 4, 1, wavFile ); + fread( &header.byteRate, 4, 1, wavFile ); + + fread( &header.blockAlign, 2, 1, wavFile ); + fread( &header.bitsPerSample, 2, 1, wavFile ); + + fread( header.subchunk2id, 4, 1, wavFile ); + if (header.subchunk2id[0]!='d' || header.subchunk2id[1]!='a' || header.subchunk2id[2]!='t' || header.subchunk2id[3]!='a') return 0; // incorrect header + fread( &header.subchunk2size, 4, 1, wavFile ); + + + // the data follows. + if (header.subchunk2size<1) return 0; + + CAudioBuffer *rval = new CAudioBuffer; + rval->m_nofChannels = header.nofChannels; + rval->m_bitsPerSample = header.bitsPerSample; + rval->m_samplesPerSec = header.sampleRate; + rval->m_signedData = 0; // where to know this? + rval->reallocate( header.subchunk2size ); + + fread( rval->m_data, 1, header.subchunk2size, wavFile ); + + + + // choose a good sampling function. + rval->m_sampleFunction = 0; + if (rval->m_nofChannels==1) { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitMono; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitMono; + } else { + if (rval->m_bitsPerSample == 8) rval->m_sampleFunction = sampleFunction8bitStereo; + if (rval->m_bitsPerSample == 16) rval->m_sampleFunction = sampleFunction16bitStereo; + } + + return rval; +}; + + + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction8bitMono( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((unsigned char*)(abuffer->m_data))[pos]-128)<<8; +}; + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction16bitMono( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((short*)(abuffer->m_data))[pos]); +}; + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction8bitStereo( CAudioBuffer *abuffer, int pos, int channel ) { + return ((AUDIO_SAMPLE_TYPE)(((char*)(abuffer->m_data))[pos*abuffer->m_nofChannels + channel])<<8); +}; + + +AUDIO_SAMPLE_TYPE CAudioBuffer::sampleFunction16bitStereo( CAudioBuffer *abuffer, int pos, int channel ) { + return (AUDIO_SAMPLE_TYPE)(((short*)(abuffer->m_data))[pos*abuffer->m_nofChannels + channel]); +}; + +CAudioBufferPlayInstance *CAudioBuffer::playWithMixer( CAudioMixer &mixer ) { + CAudioBufferPlayInstance *i = (CAudioBufferPlayInstance*)mixer.addAudioSource( new CAudioBufferPlayInstance( this )); + return i; +}; + + +CAudioBufferPlayInstance::CAudioBufferPlayInstance() { + m_fixedPos = 0; + m_fixedInc = 0; + m_buffer = 0; + m_fixedLeftVolume = 4096; + m_fixedRightVolume = 4096; + m_destroyWhenFinished = true; + m_finished = false; +}; + +CAudioBufferPlayInstance::CAudioBufferPlayInstance( CAudioBuffer *startPlaying ) { + m_fixedPos = 0; + m_fixedInc = 0; + m_fixedLeftVolume = 4096; + m_fixedRightVolume = 4096; + m_destroyWhenFinished = true; + m_finished = false; + playBuffer( startPlaying, 1.0f, 1.0f ); +}; + +void CAudioBufferPlayInstance::playBuffer( CAudioBuffer *startPlaying, float volume, float speed, int loopTimes ) { + m_buffer = startPlaying; + m_fixedLeftVolume = (int)(4096.0f*volume); + m_fixedRightVolume = m_fixedLeftVolume; + m_fixedPos = 0; + //m_fixedInc = ( startPlaying->getSamplesPerSec() * (int)(4096.0f*speed)) / AUDIO_FREQUENCY; + setSpeed( speed ); + m_loopTimes = loopTimes; + +}; + +CAudioBufferPlayInstance::~CAudioBufferPlayInstance() { + +}; + + +void CAudioBufferPlayInstance::stop() { + m_buffer = 0; + m_finished = true; +}; + +void CAudioBufferPlayInstance::setSpeed( float speed ) { + if (!m_buffer) return; + m_fixedInc = (int)( ((float)m_buffer->getSamplesPerSec() * 4096.0f*speed) / (float)AUDIO_FREQUENCY ); +}; + +void CAudioBufferPlayInstance::setLeftVolume( float vol ) { + m_fixedLeftVolume = (int)(4096.0f*vol); +}; + +void CAudioBufferPlayInstance::setRightVolume( float vol ) { + m_fixedRightVolume = (int)(4096.0f*vol); +}; + +bool CAudioBufferPlayInstance::canBeDestroyed() { + if (m_finished==true && + m_destroyWhenFinished==true) return true; else return false; +}; + + + +// doesnt do any bound-checking Must be checked before called. +int CAudioBufferPlayInstance::mixBlock( AUDIO_SAMPLE_TYPE *target, int samplesToMix ) { + SAMPLE_FUNCTION_TYPE sampleFunction = m_buffer->getSampleFunction(); + if (!sampleFunction) return 0; // unsupported sampletype + AUDIO_SAMPLE_TYPE *t_target = target+samplesToMix*2; + int sourcepos; + //int tempCounter = 0; + + if (m_buffer->getNofChannels() == 2) { // stereo + while (target!=t_target) { + sourcepos = m_fixedPos>>12; + target[0] = (((((sampleFunction)( m_buffer, sourcepos, 0) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 0) * (m_fixedPos&4095) ) >> 12) * m_fixedLeftVolume) >> 12); + target[1] = (((((sampleFunction)( m_buffer, sourcepos, 1) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 1) * (m_fixedPos&4095) ) >> 12) * m_fixedRightVolume) >> 12); + m_fixedPos+=m_fixedInc; + target+=2; + //tempCounter++; + }; + } else { // mono + int temp; + while (target!=t_target) { + sourcepos = m_fixedPos>>12; + temp = (((sampleFunction)( m_buffer, sourcepos, 0 ) * (4096-(m_fixedPos&4095)) + (sampleFunction)( m_buffer, sourcepos+1, 0 ) * (m_fixedPos&4095) ) >> 12); + target[0] = ((temp*m_fixedLeftVolume)>>12); + target[1] = ((temp*m_fixedRightVolume)>>12); + m_fixedPos+=m_fixedInc; + target+=2; + //tempCounter++; + }; + + }; + + return samplesToMix; +}; + + + +int CAudioBufferPlayInstance::pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) { + if (!m_buffer) return 0; // no sample associated to mix.. + + int channelLength = ((m_buffer->getDataLength()) / (m_buffer->getNofChannels()*m_buffer->getBytesPerSample()))-2; + + int samplesToWrite = bufferLength/2; + int amount; + int totalMixed = 0; + + + while (samplesToWrite>0) { + int samplesLeft = channelLength - (m_fixedPos>>12); + int maxMixAmount = (int)(((long long int)(samplesLeft)<<12) / m_fixedInc ); // This is how much we can mix at least + //int maxMixAmount = (int)((float)samplesLeft / ((float)m_fixedInc/4096.0f)); + //if (maxMixAmount<1) maxMixAmount = 1; // NOTE, THIS MIGHT CAUSE PROBLEMS. NEEDS CHECKING + if (maxMixAmount>samplesToWrite) { + maxMixAmount=samplesToWrite; + } + + if (maxMixAmount>0) { + amount=mixBlock( target+totalMixed*2, maxMixAmount ); + if (amount==0) + { + break; // an error occured + } + totalMixed+=amount; + } else { + amount = 0; + m_fixedPos = channelLength<<12; + } + + + + // sample is ended,.. check the looping variables and see what to do. + if ((m_fixedPos>>12)>=channelLength) { + m_fixedPos -= (channelLength<<12); + if (m_loopTimes>0) m_loopTimes--; + if (m_loopTimes==0) { + stop(); + return totalMixed; + } + } + + samplesToWrite-=amount; + if (samplesToWrite<1) break; + }; + return totalMixed*2; +}; diff --git a/demos/mobile/quickhit/ga_src/GEAudioBuffer.h b/demos/mobile/quickhit/ga_src/GEAudioBuffer.h new file mode 100755 index 0000000..c0c8961 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioBuffer.h @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef __GE_IGA_AUDIOBUFFER__ +#define __GE_IGA_AUDIOBUFFER__ + +#include +#include "GEInterfaces.h" + + +namespace GE { + + class CAudioBufferPlayInstance; + class CAudioBuffer; // forward declaration + typedef AUDIO_SAMPLE_TYPE(*SAMPLE_FUNCTION_TYPE)(CAudioBuffer *abuffer, int pos, int channel); + + class CAudioBuffer { // container for a sound + public: + CAudioBuffer(); + virtual ~CAudioBuffer(); + + static CAudioBuffer* loadWav( QString fileName ); + static CAudioBuffer* loadWav( FILE *wavFile ); // support for stdio + void reallocate( int length ); + + + inline void* getRawData() { return m_data; } + inline int getDataLength() { return m_dataLength; } + + inline int getBytesPerSample() { return (m_bitsPerSample>>3); } + inline int getBitsPerSample() { return m_bitsPerSample; } + inline int getSamplesPerSec() { return m_samplesPerSec; } + inline short getNofChannels() { return m_nofChannels; } + inline SAMPLE_FUNCTION_TYPE getSampleFunction() { return m_sampleFunction; } + + + // static implementations of sample functions + static AUDIO_SAMPLE_TYPE sampleFunction8bitMono( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction16bitMono( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction8bitStereo( CAudioBuffer *abuffer, int pos, int channel ); + static AUDIO_SAMPLE_TYPE sampleFunction16bitStereo( CAudioBuffer *abuffer, int pos, int channel ); + + CAudioBufferPlayInstance *playWithMixer( GE::CAudioMixer &mixer ); + + protected: + SAMPLE_FUNCTION_TYPE m_sampleFunction; + short m_nofChannels; + void *m_data; + int m_dataLength; // in bytes + short m_bitsPerSample; + bool m_signedData; + int m_samplesPerSec; + }; + + + + class CAudioBufferPlayInstance : public IAudioSource { + public: + CAudioBufferPlayInstance(); + CAudioBufferPlayInstance( CAudioBuffer *start_playing ); + virtual ~CAudioBufferPlayInstance(); + void playBuffer( CAudioBuffer *startPlaying, float volume, float fixedSpeed, int loopTimes = 0 ); // looptimes -1 = loop forever + + void setSpeed( float speed ); + void setLeftVolume( float lvol ); + void setRightVolume( float rvol ); + + + inline void setLoopTimes( int ltimes ) { m_loopTimes = ltimes; } + void stop(); + + + + int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + bool canBeDestroyed(); + + bool isPlaying() { if (m_buffer) return true; else return false; } + inline bool isFinished() { return m_finished; } + inline bool destroyWhenFinished() { return m_destroyWhenFinished; } + inline void setDestroyWhenFinished( bool set ) { m_destroyWhenFinished = set; } + + protected: + int mixBlock( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + bool m_finished; + bool m_destroyWhenFinished; + int m_fixedPos; + int m_fixedInc; + + int m_fixedLeftVolume; + int m_fixedRightVolume; + int m_fixedCenter; + int m_loopTimes; + CAudioBuffer *m_buffer; + }; + +}; + + + +#endif diff --git a/demos/mobile/quickhit/ga_src/GEAudioOut.cpp b/demos/mobile/quickhit/ga_src/GEAudioOut.cpp new file mode 100755 index 0000000..74e76c5 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioOut.cpp @@ -0,0 +1,137 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include + +#include "GEAudioOut.h" + +using namespace GE; +//using namespace QTM_NAMESPACE; + +/* +#ifndef Q_OS_WIN32 +QTM_USE_NAMESPACE +#endif +*/ + +const int CHANNELS = 2; +const QString CODEC = "audio/pcm"; +const QAudioFormat::Endian BYTEORDER = QAudioFormat::LittleEndian; +const QAudioFormat::SampleType SAMTYPE = QAudioFormat::SignedInt; + + + +AudioOut::AudioOut( QObject *parent, GE::IAudioSource *source ) : QThread(parent) { // qobject + m_source = source; + QAudioFormat format; + format.setFrequency(AUDIO_FREQUENCY); + format.setChannels(CHANNELS); + format.setSampleSize(AUDIO_SAMPLE_BITS); + format.setCodec(CODEC); + format.setByteOrder(BYTEORDER); + format.setSampleType(SAMTYPE); + + QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); + if (!info.isFormatSupported(format)) + format = info.nearestFormat(format); + + + m_audioOutput = new QAudioOutput(info,format); + +#ifdef Q_WS_MAEMO_5 + m_audioOutput->setBufferSize(20000); + m_sendBufferSize = 5000; +#else + m_audioOutput->setBufferSize(16000); + m_sendBufferSize = 4000; +#endif + + m_outTarget = m_audioOutput->start(); + + + m_sendBuffer = new AUDIO_SAMPLE_TYPE[ m_sendBufferSize ]; + m_samplesMixed = 0; + + m_runstate=0; + +#ifndef Q_OS_SYMBIAN + start(); +#else + m_audioOutput->setNotifyInterval(5); + connect(m_audioOutput,SIGNAL(notify()),SLOT(audioNotify())); +#endif + +}; + + +AudioOut::~AudioOut() { + if (m_runstate==0) m_runstate = 1; + if (QThread::isRunning() == false) m_runstate = 2; + while (m_runstate!=2) { msleep(50); } // wait until the thread is finished + m_audioOutput->stop(); + delete m_audioOutput; + delete [] m_sendBuffer; +}; + + +void AudioOut::audioNotify() { + tick(); +}; + +void AudioOut::tick() { + // fill data to buffer as much as free space is available.. + int samplesToWrite = m_audioOutput->bytesFree() / (CHANNELS*AUDIO_SAMPLE_BITS/8); + samplesToWrite*=2; + + if (samplesToWrite > m_sendBufferSize) samplesToWrite = m_sendBufferSize; + if (samplesToWrite<=0) return; + int mixedSamples = m_source->pullAudio( m_sendBuffer, samplesToWrite ); + m_outTarget->write( (char*)m_sendBuffer, mixedSamples*2 ); + +}; + + +void AudioOut::run() { + if (!m_source) { m_runstate=2; return; } + int sleepTime = m_sendBufferSize * 340 / AUDIO_FREQUENCY; + if (sleepTime<2) sleepTime = 2; + + while (m_runstate==0) { + tick(); + msleep(sleepTime); + }; + m_runstate = 2; +}; + + diff --git a/demos/mobile/quickhit/ga_src/GEAudioOut.h b/demos/mobile/quickhit/ga_src/GEAudioOut.h new file mode 100755 index 0000000..78af241 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEAudioOut.h @@ -0,0 +1,82 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef __GE_QTAUDIOOUT__ +#define __GE_QTAUDIOOUT__ + +#include +#include +#include +#include +#include +#include + +#include "GEInterfaces.h" + + +class QAudioOutput; + +namespace GE { + + + + class AudioOut : public QThread { + Q_OBJECT + + public: + AudioOut(QObject *parent, GE::IAudioSource *source); + virtual ~AudioOut(); + + + + private slots: + void audioNotify(); // for internal notify "solution" + + + protected: + void tick(); + virtual void run(); // this is for the threaded mode only + + + qint64 m_samplesMixed; + + QAudioOutput *m_audioOutput; + QIODevice *m_outTarget; + GE::IAudioSource *m_source; + int m_runstate; + AUDIO_SAMPLE_TYPE *m_sendBuffer; + int m_sendBufferSize; + }; +} + +#endif diff --git a/demos/mobile/quickhit/ga_src/GEInterfaces.cpp b/demos/mobile/quickhit/ga_src/GEInterfaces.cpp new file mode 100755 index 0000000..42e9948 --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEInterfaces.cpp @@ -0,0 +1,170 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include "GEInterfaces.h" + + +using namespace GE; + +/** + * CAudioSource + * common functionality + * + */ +IAudioSource::IAudioSource() { + m_next = 0; +}; + +IAudioSource::~IAudioSource() { + + +}; + +/** + * CAudioMixer + * + */ +CAudioMixer::CAudioMixer() { + m_sourceList = 0; + m_mixingBuffer = 0; + m_mixingBufferLength = 0; + m_fixedGeneralVolume = 4096; +}; + + +CAudioMixer::~CAudioMixer() { + destroyList(); + if (m_mixingBuffer) { + delete [] m_mixingBuffer; + m_mixingBuffer = 0; + }; +}; + +void CAudioMixer::destroyList() { + m_mutex.lock(); + IAudioSource *l = m_sourceList; + while (l) { + IAudioSource *n = l->m_next; + delete l; + l = n; + }; + m_sourceList = 0; + m_mutex.unlock(); +}; + + +IAudioSource* CAudioMixer::addAudioSource( IAudioSource *source ) { + m_mutex.lock(); + source->m_next = 0; + if (m_sourceList) { + IAudioSource *l = m_sourceList; + while (l->m_next) l = l->m_next; + l->m_next = source; + } else m_sourceList = source; + m_mutex.unlock(); + return source; + +}; + + +bool CAudioMixer::removeAudioSource( IAudioSource *source ) { + return true; +}; + +void CAudioMixer::setGeneralVolume( float vol ) { + m_fixedGeneralVolume = (4096.0f*vol); +}; + +int CAudioMixer::pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) { + + if (!m_sourceList) return 0; + + m_mutex.lock(); + + + if (m_mixingBufferLengthm_next; + + // process l + int mixed = l->pullAudio( m_mixingBuffer, bufferLength ); + if (mixed>0) { + // mix to main.. + t = target; + t_target = t+mixed; + s = m_mixingBuffer; + while (t!=t_target) { + *t +=(((*s)*m_fixedGeneralVolume)>>12); + t++; + s++; + }; + }; + + + + // autodestroy + if (l->canBeDestroyed() == true) { // NOTE, IS UNDER TESTING,... MIGHT CAUSE UNPREDICTABLE CRASHING WITH SOME USE CASES!!! + if (!prev) + m_sourceList = next; + else prev->m_next = next; + delete l; + l = 0; + }; + + + + + prev = l; + l = next; + }; + m_mutex.unlock(); + return bufferLength; +}; + + + + diff --git a/demos/mobile/quickhit/ga_src/GEInterfaces.h b/demos/mobile/quickhit/ga_src/GEInterfaces.h new file mode 100755 index 0000000..b697c3f --- /dev/null +++ b/demos/mobile/quickhit/ga_src/GEInterfaces.h @@ -0,0 +1,81 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef __GE_IGA_INTERFACES__ +#define __GE_IGA_INTERFACES__ + +#include + +namespace GE { + +#define AUDIO_FREQUENCY 22050 +#define AUDIO_SAMPLE_TYPE short +#define AUDIO_SAMPLE_BITS 16 + + class IAudioSource { + public: + IAudioSource(); + virtual ~IAudioSource(); + + virtual int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ) = 0; + virtual bool canBeDestroyed() { return false; } + + IAudioSource *m_next; // for listing, do not touch if you dont know what you are doing. + }; + + + class CAudioMixer : public IAudioSource { + public: + CAudioMixer(); + virtual ~CAudioMixer(); + void destroyList(); // destroy all the sources in the list + + + IAudioSource* addAudioSource( IAudioSource *s ); // add new audio source to the list + bool removeAudioSource( IAudioSource *s ); // remove an audio source from the list + int pullAudio( AUDIO_SAMPLE_TYPE *target, int bufferLength ); + void setGeneralVolume( float vol ); + + + protected: + QMutex m_mutex; + int m_fixedGeneralVolume; + AUDIO_SAMPLE_TYPE *m_mixingBuffer; + int m_mixingBufferLength; + IAudioSource *m_sourceList; + }; + +}; + + +#endif diff --git a/demos/mobile/quickhit/game.qml b/demos/mobile/quickhit/game.qml new file mode 100755 index 0000000..44b196e --- /dev/null +++ b/demos/mobile/quickhit/game.qml @@ -0,0 +1,432 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import "Game.js" as GameScript + +Item { + id: gameArea + width: 360; height: 640 // NOTE: have to exists some default sizes + anchors.fill: parent + objectName: "gameArea" + + + // Who win, you or computer + property bool gameOverProperty: false + + // for info message to user + property variant messageBox + + // Level activated signal for Qt side to load activated level + signal levelActivated(int index) + + // Pause whole game, if level is loaded + function pauseGame() { + if (GameScript.levelPlugin) { + GameScript.pauseGame(true) + myShip.focus = false + btnPause.opacity = 0 + menu.showPauseMenu() + } + } + + // Qt side call this for QML take new level into use + function levelReadyForCreation() { + // Hide menu + menu.hideMenu() + // Show message + message.showMessage("Loading Level...",2000) + // Wait before create level + levelCreationTimer.restart() + } + + // Fires ememy missile. Function is called from Qt side + function fireEnemyMissile(aXpox, aFromYpos, aToYpos) { + GameScript.fireEnemyMissile(aXpox, aFromYpos, aToYpos) + } + + // Game Over handling. Function is called from Qt side + function gameOver(youWin) { + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + gameOverProperty = youWin + GameScript.hideMissiles() + gameOverTimer.restart() + //GameEngine.vibra() + } + + // End game and show menu + function endGame(showMessage) { + backgroundPic.opacity = 1 + // Stop GameEngine timers + GameEngine.enableEngineTimer(false) + // Do game over + GameScript.gameOver() + GameScript.hideMissiles() + // Clear GameEngine QML objects + GameEngine.clearQmlObjects() + myShip.opacity = 0 + myShip.focus = false + btnPause.opacity = 0 + idMainLogo.opacity = 1 + menu.showLevelMenu() + if (showMessage) { + message.showMessage("Game End",2000) + } + } + + // Timer for level creationing + Timer { + id: levelCreationTimer + interval: 1000; running: false; repeat: false + onTriggered: { + btnPause.opacity = 1 + myShip.opacity = 1 + myShip.focus = true + // Create new level + var ret = GameScript.createLevel() + if (ret==0) { + backgroundPic.opacity = 0 + // Find QML object for GameEngine + GameEngine.findQmlObjects() + // Enable GameEngine timer + GameEngine.enableEngineTimer(true) + } else { + // Level cannot be created! + endGame(false) + } + } + } + + // Timer for game over + Timer { + id: gameOverTimer + interval: 1500; running: false; repeat: false + onTriggered: { + backgroundPic.opacity = 1 + idMainLogo.opacity = 1 + // Do game over + GameScript.gameOver() + // Clear GameEngine QML objects + GameEngine.clearQmlObjects() + menu.showLevelMenu() + if (gameOverProperty) { + GameEngine.playInternalSound(4) + message.showMessage("Game Over, You win!",2000) + } else { + GameEngine.playInternalSounds(3,3) + message.showMessage("Game Over, You lose",2000) + } + } + } + + // Menu signal to slot connections + Connections { + target: menu + // Level selected + onLevelSelected: { + // Stop bigship animation + bigShipAnim.stop() + bigShip.opacity = 0 + // Hide logo + idMainLogo.opacity = 0 + // Signal level activated + gameArea.levelActivated(levelIndex) + } + // Level resumed selected + onResumeSelected: { + menu.hideMenu() + GameScript.pauseGame(false) + myShip.focus = true + } + } + + // This component creation completed + Component.onCompleted: { + // Show main Level selection menu + menu.showLevelMenu() + + // Start big ship animation + bigShipAnim.restart() + + // Set variable + messageBox = message + + // Play game start sound + GameEngine.gameStartSound() + + // Fade splash screen + fadeAnim.restart() + // Rotate splash logo + rotAnim.restart() + } + + + // Background image for the game + Image { + id: backgroundPic + z:1 + source: "qrc:/gfx/background2.png" + fillMode: Image.PreserveAspectCrop + smooth: true + anchors.fill: parent + } + + Image { + id: bigShip + source: "qrc:/gfx/bigship.png" + z:1.5 + smooth: true + x: width * -1 + y: parent.height * 0.55 + } + SequentialAnimation { + id: bigShipAnim; + NumberAnimation {target:bigShip; property:"x"; to:gameArea.width; easing.type: Easing.Linear; duration: 80000 } + PropertyAction {target:bigShip; properties: "opacity"; value: 0} + } + + + // Enemies grid + Item { + // This is general level QML plaseholder + // Into this is level QML created in createLevel() + id:levelId + anchors.fill: parent + z:2 + } + + Image { + id: idMainLogo + z:19 + source: "qrc:/gfx/quickhit_logo.png" + smooth: true + anchors.horizontalCenter: gameArea.horizontalCenter + y:gameArea.height / 10 * 1 + } + + // Game menu + Menu { + z:20 + id:menu + width: gameArea.width / 5 * 4 + height: gameArea.height / 10 * 4 + anchors.verticalCenter: gameArea.verticalCenter + anchors.horizontalCenter: gameArea.horizontalCenter + } + + // My ship + MyShip { + z:10 + id: myShip + opacity: 0 + } + + // Mouse area of your ship + MouseArea { + //anchors.fill: parent + width: parent.width + height: myShip.height + x:0 + y:gameArea.height - myShip.height + + drag.target: myShip + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: gameArea.width - myShip.width + + property int startPos: 0 + property int dragCount: 0 + + onPressed: { + startPos = mouseX + dragCount = 0 + } + onPositionChanged: { + //dragCount = Math.abs(mouseX-startPos) + } + onReleased: { + //if (dragCount<20) { + myShip.fire() + //} + } + } + + // Pause button + Button { + id: btnSound + z:12 + //animationEnabled: false + anchors.top: parent.top + anchors.topMargin: 10 + buttonPath: "qrc:/gfx/soundOn.png" + buttonId: 4 + width: gameArea.width / 10 + height: gameArea.width / 10 + x: gameArea.width - width - 15 + opacity: 1 + Connections { + target: btnSound + onBtnClicked: { + if (btnSound.buttonId==4) { + // Sound off + btnSound.buttonPath = "qrc:/gfx/soundOff.png" + btnSound.buttonId = 5 + GameEngine.enableSounds(false) + } else { + // Sound on + btnSound.buttonPath = "qrc:/gfx/soundOn.png" + btnSound.buttonId = 4 + GameEngine.enableSounds(true) + } + } + } + } + + // Pause button + Button { + id: btnPause + z:13 + anchors.top: parent.top + anchors.topMargin: 10 + buttonPath: "qrc:/gfx/pause.png" + buttonId: 3 + width: gameArea.width / 10 + height: gameArea.width / 10 + x: gameArea.width - width - btnPause.width - 15*2 + opacity: 0 + Connections { + target: btnPause + onBtnClicked: { + GameScript.pauseGame(true) + myShip.focus = false + btnPause.opacity = 0 + menu.showPauseMenu() + } + } + } + + + // Hidden missiles ready for to be launched + Missile { + z:3 + id: missile_1 + x:0 + y:10 + } + Missile { + z:4 + id: missile_2 + x: 20 + y:10 + } + Missile { + z:5 + id: missile_3 + x: 40 + y:10 + } + Missile { + z:6 + id: missile_4 + x: 60 + y:10 + } + Missile { + z:7 + id: missile_5 + x: 80 + y:10 + } + Missile { + z:8 + objectName: "enemy_missile" + id: enemy_missile_1 + enemyMissile: true + } + Missile { + z:9 + objectName: "enemy_missile" + id: enemy_missile_2 + enemyMissile: true + } + + // Messages to the user + Message { + id: message + z:21 + } + + + // Splach screen + Rectangle { + id: blackFace + x:-2 + y:0 + width: parent.width + 2 + height: parent.height + z:100 + color: "black" + opacity: 1 + + MouseArea { + anchors.fill: parent + onPressed: { + mouse.accepted = true + fadeAnim.stop() + blackFace.opacity = 0 + } + } + + Image { + id: idLogo + source: "qrc:/gfx/quickhit_logo.png" + smooth: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + opacity: 0 + } + NumberAnimation { id: rotAnim; target: idLogo; property: "rotation"; to: 20; duration: 9000 } + + } + // Splach screen animation + SequentialAnimation { + id: fadeAnim + PauseAnimation {duration: 1000 } + NumberAnimation {target: idLogo; property: "opacity"; from: 0; to: 1; duration: 2000 } + PauseAnimation {duration: 2000 } + NumberAnimation {target: idLogo; property: "opacity"; from: 1; to: 0; duration: 2000 } + NumberAnimation {target: blackFace; property: "opacity"; from: 1; to: 0; duration: 2000 } + } + +} diff --git a/demos/mobile/quickhit/gameengine.cpp b/demos/mobile/quickhit/gameengine.cpp new file mode 100755 index 0000000..96f16b6 --- /dev/null +++ b/demos/mobile/quickhit/gameengine.cpp @@ -0,0 +1,585 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "gameengine.h" +#include "plugins/levelplugininterface.h" +#include "InvSounds.h" + +#include +#include +#include +#include + +const int TIMER_SPEED = 80; + +GameEngine::GameEngine(QObject* parent) + :QObject(parent) +{ + m_timerId = 0; + m_doEnemyMissile = 1500 / TIMER_SPEED; + m_GameGml = 0; + m_gameLevel = 0; + + clearQmlObjects(); + + // For random + QTime time = QTime::currentTime(); + qsrand((uint)time.msec()); + + // Sound engine + m_soundEngine = new CInvSounds(this); + + // Device profile + m_silent = false; + +#ifdef Q_OS_SYMBIAN + iVibrate = CHWRMVibra::NewL(); +#endif + + // Get device profile, is it silent? +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + m_systemDeviceInfo = new QSystemDeviceInfo(this); + QObject::connect(m_systemDeviceInfo,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),this, + SLOT(currentProfileChanged(QSystemDeviceInfo::Profile))); + QSystemDeviceInfo::Profile p = m_systemDeviceInfo->currentProfile(); + if (p == QSystemDeviceInfo::SilentProfile) { + m_silent = true; + } +#endif + +} + + +GameEngine::~GameEngine() +{ +#ifdef Q_OS_SYMBIAN + delete iVibrate; +#endif + +} + +void GameEngine::gameStartSound() +{ + if (!m_silent) + m_soundEngine->gameStartSound(); +} + +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 +void GameEngine::currentProfileChanged(QSystemDeviceInfo::Profile p) +{ + if (p == QSystemDeviceInfo::SilentProfile) { + enableSounds(QVariant(false)); + } else { + enableSounds(QVariant(true)); + } +} +#endif + +void GameEngine::enableSounds(QVariant enable) +{ + m_silent = !enable.toBool(); + + if (m_silent) + this->m_soundEngine->enableSounds(false); + else + this->m_soundEngine->enableSounds(true); + +} + +QVariant GameEngine::randInt(QVariant low, QVariant high) +{ + // Random number between low and high + return qrand() % ((high.toInt() + 1) - low.toInt()) + low.toInt(); +} + +void GameEngine::setGameLevel(LevelPluginInterface* level) +{ + // Set used game level + m_gameLevel = level; + + if (m_gameLevel) { + // Set used sound from the level into sound engine + m_soundEngine->enableSounds(m_gameLevel->levelSounds()); + // Invoke QML to take new level in use + QMetaObject::invokeMethod(m_GameGml, "levelReadyForCreation", Qt::AutoConnection); + + m_doEnemyMissile = m_gameLevel->enemyFireSpeed().toInt() / TIMER_SPEED; + } +} + +void GameEngine::setPluginList(QList plugins) +{ + m_pluginList = plugins; +} + +QVariant GameEngine::pluginList() +{ + QStringList list; + QPluginLoader* loader; + foreach (loader,m_pluginList) { + QString s = loader->fileName(); + s = s.mid(s.lastIndexOf("/")+1); + s = s.left(s.lastIndexOf(".")); + s = s.toUpper(); +#ifdef Q_WS_MAEMO_5 + if (s.contains("LIB")) { + s = s.right(s.length() - (s.indexOf("LIB")+3)); + } +#endif + list.append(s); + } + return QVariant(list); +} + +void GameEngine::pauseLevel(QVariant doPause) +{ + bool enableTimer = !doPause.toBool(); + enableEngineTimer(QVariant(enableTimer)); + QMetaObject::invokeMethod(m_levelQml, "pause", Qt::AutoConnection,Q_ARG(QVariant, doPause)); +} + + +void GameEngine::findQmlObjects() +{ + if (m_GameGml) { + qDebug() << "GameEngine::findQmlObjects()"; + + // Find Missiles objects + m_missileList.clear(); + m_enemyMissileList.clear(); + findMissiles(m_GameGml); + + // Set QMLs + setLevelQml(m_GameGml->findChild("level")); + setEnemiesGridQml(m_GameGml->findChild("enemiesGrid")); + setMyShipQml(m_GameGml->findChild("myShip")); + + // Find Enemies objects + m_enemyList.clear(); + qDebug() << "GameEngine::findQmlObjects() find enemies from: level QML"; + findEnemies(m_levelQml); + + + } else { + qDebug() << "GameEngine::findQmlObjects() rootObject NULL"; + } +} + +void GameEngine::clearQmlObjects() +{ + m_missileList.clear(); + m_enemyMissileList.clear(); + m_enemyList.clear(); + m_levelQml = 0; + m_enemiesGridGml = 0; + m_myShipGml = 0; + //m_GameGml = 0; // NOTE: Do not delete this +} + + +void GameEngine::findMissiles(QObject *rootObject) +{ + if (rootObject) { + QObjectList list = rootObject->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0) { + findMissiles(item); + } else { + if (rootObject->objectName()=="missile") { + QDeclarativeItem* missile = static_cast(rootObject); + m_missileList.append(missile); + } else if (rootObject->objectName()=="enemy_missile") { + QDeclarativeItem* enemyMissile = static_cast(rootObject); + m_enemyMissileList.append(enemyMissile); + } + } + } + } else { + qDebug() << "GameEngine::findMissiles() rootObject NULL"; + } +} + +void GameEngine::findEnemies(QObject *rootObject) +{ + if (rootObject) { + QObjectList list = rootObject->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0 && item->objectName()!="enemy") { + //qDebug() << "Enemy childs founds from: " << item->objectName(); + findEnemies(item); + } else { + if (item->objectName()=="enemy") { + //qDebug() << "Enemy child founds: " << item->objectName(); + QDeclarativeItem* enemy = static_cast(item); + m_enemyList.append(enemy); + } + } + } + } else { + qDebug() << "GameEngine::findEnemies() rootObject NULL"; + } +} + +void GameEngine::setEnemiesGridQml(QObject* o) +{ + m_enemiesGridGml = static_cast(o); +} + +void GameEngine::setMyShipQml(QObject* o) +{ + m_myShipGml = static_cast(o); +} + +void GameEngine::setGameQml(QObject* o) +{ + m_GameGml = static_cast(o); +} + + +void GameEngine::timerEvent(QTimerEvent *e) +{ + if (e->timerId()==m_timerId) { + // Do hit test + doHitTest(); + + m_doEnemyMissile--; + + if (m_gameLevel && m_doEnemyMissile<0) { + m_doEnemyMissile = m_gameLevel->enemyFireSpeed().toInt() / TIMER_SPEED; + // Do emeny missile launch + doEnemyMissile(); + } + } +} + +void GameEngine::enableEngineTimer(QVariant enable) +{ + if (m_gameLevel) { + if (m_timerId==0 && enable.toBool()) { + m_timerId = QObject::startTimer(TIMER_SPEED); + } + else if (m_timerId != 0 && !enable.toBool()) { + QObject::killTimer(m_timerId); + m_timerId = 0; + } + } +} + +void GameEngine::selectVisibleEnemy(int& start, int& end) +{ + QDeclarativeItem* enemy = 0; + for (int i=0 ; iopacity()==1) { + start = i; + break; + } + } + enemy = 0; + for (int e=m_enemyList.count()-1 ; e>0 ; e--) { + enemy = m_enemyList[e]; + if (enemy->opacity()==1) { + end = e; + break; + } + } +} + +void GameEngine::doEnemyMissile() +{ + QMutexLocker locker(&m_enemyListMutex); + + QDeclarativeItem* missile = 0; + QDeclarativeItem* enemy = 0; + + // Find free missile + foreach (missile, m_enemyMissileList) { + if (missile->opacity()==0){ + // Random select enemy who fire + int start=0; int end=0; + selectVisibleEnemy(start,end); + int whoWillFire = randInt(QVariant(start),QVariant(end)).toInt(); + if (m_enemyList.count() < whoWillFire+1) + break; + + enemy = m_enemyList.at(whoWillFire); + if (enemy && enemy->opacity()==1) { + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + //qDebug() << "QMetaObject::invokeMethod() - fireEnemyMissile"; + QMetaObject::invokeMethod(m_GameGml, "fireEnemyMissile", Qt::AutoConnection, + Q_ARG(QVariant, enemyP.x()+enemy->boundingRect().width()/4), + Q_ARG(QVariant, enemyP.y()+enemy->boundingRect().height()), + Q_ARG(QVariant, m_GameGml->boundingRect().height())); + } + break; + } + } +} + +void GameEngine::doHitTest() +{ + QMutexLocker locker(&m_enemyListMutex); + + QDeclarativeItem* missile = 0; + QDeclarativeItem* enemy = 0; + + // No enemies? + if (m_enemyList.count()==0) { + enableEngineTimer(QVariant(false)); + qDebug() << "No enemies left"; + gameOver(true); + return; + } + + if (!m_myShipGml) { + return; + } + + // Check ship collision + if (m_myShipGml->opacity()==1) { + for (int e=0; eopacity()==0) { + break; + } + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + QRectF enemyR(enemyP,QSize(enemy->boundingRect().width(),enemy->boundingRect().height())); + // Collision? + if (enemyR.contains(m_myShipGml->pos())) { + enableEngineTimer(QVariant(false)); + + // Collision explosion + QPointF myP = m_myShipGml->pos(); + playSound(1); + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + m_myShipGml->setOpacity(0); + + gameOver(false); + qDebug() << "Collision"; + return; + } + // Enemy too deep? + else if (enemyR.bottomLeft().y() > m_myShipGml->pos().y()+m_myShipGml->pos().y()*0.1) { + enableEngineTimer(QVariant(false)); + + // Enemy too deep explosion + QPointF myP = m_myShipGml->pos(); + playSound(1); + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + m_myShipGml->setOpacity(0); + + gameOver(false); + qDebug() << "Enemy too deep"; + return; + } + } + } + + // Check your missiles hit to enemies + foreach (missile, m_missileList) { + if (missile->opacity()==1){ + for (int e=0; eopacity()<1) { + break; + } + QPointF missileP = missile->pos(); + missileP.setX(missileP.rx() + missile->boundingRect().width()/2); + + QPointF enemyP = enemy->pos(); + if (m_enemiesGridGml) { + enemyP += m_enemiesGridGml->pos(); + } + + QRectF r(enemyP,QSize(enemy->boundingRect().width(),enemy->boundingRect().height())); + if (r.contains(missileP)) { + // Hit ! + playSound(0); + //qDebug() << "QMetaObject::invokeMethod() - explode"; + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, enemyP.x()+enemy->boundingRect().width()/2), + Q_ARG(QVariant, enemyP.y()+enemy->boundingRect().height())); + missile->setOpacity(0); + //fastVibra(); + if (m_enemiesGridGml) { + // Set transparent placeholder for enemy when using GridView + enemy->setProperty("source",QVariant("file:/"+m_gameLevel->pathToTransparentEnemyPic().toString())); + } else { + // Hide enemy after explode + enemy->setOpacity(0); + } + + // Remove enemy from list + m_enemyList.removeAt(e); + e--; + } + enemy = 0; + } + } + } + + // Check enemies missiles hit to you + if (m_myShipGml->opacity()==1) { + foreach (missile, m_enemyMissileList) { + if (missile->opacity()==1){ + QPointF missileP = missile->pos(); + missileP.setX(missileP.rx() + missile->boundingRect().width()/2); + + QPointF myP = m_myShipGml->pos(); + + QRectF r(myP,QSize(m_myShipGml->boundingRect().width(),m_myShipGml->boundingRect().height())); + if (r.contains(missileP)) { + // Hit ! + playSound(1); + //qDebug() << "QMetaObject::invokeMethod() - explode"; + QMetaObject::invokeMethod(m_levelQml, "explode", Qt::AutoConnection, + Q_ARG(QVariant, myP.x()+m_myShipGml->boundingRect().width()/2), + Q_ARG(QVariant, myP.y()+m_myShipGml->boundingRect().height())); + missile->setOpacity(0); + m_myShipGml->setOpacity(0); + break; + } + } + } + } else { + // You was killed + enableEngineTimer(QVariant(false)); + gameOver(false); + qDebug() << "You was killed by enemy missile"; + } + +} + + +void GameEngine::playSound(QVariant index) +{ + if (!m_silent) { + int i = index.toInt(); + m_soundEngine->playSound(i); + } +} + +void GameEngine::playSounds(QVariant index, QVariant count) +{ + if (!m_silent) { + m_soundEngine->playSounds(index.toInt(),count.toInt()); + } +} + +void GameEngine::playInternalSound(QVariant index) +{ + if (!m_silent) { + m_soundEngine->playInternalSound(index.toInt()); + } +} + +void GameEngine::playInternalSounds(QVariant index, QVariant count) +{ + if (!m_silent) { + m_soundEngine->playInternalSounds(index.toInt(),count.toInt()); + } +} + +void GameEngine::gameOver(bool youWin) +{ + qDebug() << "GameEngine::gameOver() "<< youWin; + QMetaObject::invokeMethod(m_GameGml, "gameOver", Qt::AutoConnection,Q_ARG(QVariant, youWin)); +} + +void GameEngine::pauseGame() { + QMetaObject::invokeMethod(m_GameGml, "pauseGame", Qt::AutoConnection); +} + + +QVariant GameEngine::isSymbian() +{ +#ifdef Q_OS_SYMBIAN + return QVariant(true); +#else + return QVariant(false); +#endif +} + +QVariant GameEngine::isMaemo() +{ +#ifdef Q_WS_MAEMO_5 + return QVariant(true); +#else + return QVariant(false); +#endif +} + +QVariant GameEngine::isWindows() +{ +#ifdef Q_OS_WIN + return QVariant(true); +#else + return QVariant(false); +#endif +} + +void GameEngine::vibra() +{ +#ifdef Q_OS_SYMBIAN + if (iVibrate){ + TRAPD(err, iVibrate->StartVibraL(4000,KHWRMVibraMaxIntensity)); + } +#endif +} + +void GameEngine::fastVibra() +{ +#ifdef Q_OS_SYMBIAN + if (iVibrate){ + TRAPD(err, iVibrate->StartVibraL(100,KHWRMVibraMaxIntensity)); + } +#endif +} + +void GameEngine::openLink(QVariant link) +{ +QDesktopServices::openUrl(QUrl(link.toString())); +} + diff --git a/demos/mobile/quickhit/gameengine.h b/demos/mobile/quickhit/gameengine.h new file mode 100755 index 0000000..5938f76 --- /dev/null +++ b/demos/mobile/quickhit/gameengine.h @@ -0,0 +1,141 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef GAMEENGINE_H +#define GAMEENGINE_H + +#include +#include +#include +#include +#include + +#ifdef Q_OS_SYMBIAN +#include +#endif + +// QtMobility +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 +#include +QTM_USE_NAMESPACE +#endif + +class CInvSounds; +class LevelPluginInterface; +class GameEngine : public QObject +{ + Q_OBJECT + +public: + GameEngine(QObject* parent); + ~GameEngine(); + void timerEvent(QTimerEvent *); + void setGameLevel(LevelPluginInterface* level); + void setPluginList(QList plugins); + void pauseGame(); + +public: + Q_INVOKABLE void enableEngineTimer(QVariant enable); + Q_INVOKABLE QVariant randInt(QVariant low, QVariant high); + Q_INVOKABLE void enableSounds(QVariant enable); + Q_INVOKABLE void playSound(QVariant index); + Q_INVOKABLE void playSounds(QVariant index, QVariant count); + Q_INVOKABLE void playInternalSound(QVariant index); + Q_INVOKABLE void playInternalSounds(QVariant index, QVariant count); + Q_INVOKABLE QVariant pluginList(); + Q_INVOKABLE void findQmlObjects(); + Q_INVOKABLE void clearQmlObjects(); + Q_INVOKABLE void pauseLevel(QVariant doPause); + Q_INVOKABLE void gameStartSound(); + + Q_INVOKABLE QVariant isSymbian(); + Q_INVOKABLE QVariant isMaemo(); + Q_INVOKABLE QVariant isWindows(); + + Q_INVOKABLE void vibra(); + Q_INVOKABLE void fastVibra(); + + Q_INVOKABLE void openLink(QVariant link); + + +private slots: +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + void currentProfileChanged (QSystemDeviceInfo::Profile); +#endif + +public: + void setGameQml(QObject* o); + +private: + void findMissiles(QObject* rootObject); + void findEnemies(QObject* rootObject); + void setLevelQml(QObject* o) {m_levelQml = o;} + void setEnemiesGridQml(QObject* o); + void setMyShipQml(QObject* o); + void gameOver(bool youWin); + void selectVisibleEnemy(int& start, int& end); + +private: + void doHitTest(); + void doEnemyMissile(); + +private: + bool m_enableEnemyMissiles; + QMutex m_enemyListMutex; + QList m_enemyList; + QList m_missileList; + QList m_enemyMissileList; + QObject* m_levelQml; + QDeclarativeItem* m_enemiesGridGml; + QDeclarativeItem* m_myShipGml; + QDeclarativeItem* m_GameGml; + + LevelPluginInterface* m_gameLevel; + CInvSounds* m_soundEngine; + QList m_pluginList; + + int m_timerId; + int m_doEnemyMissile; + +#if defined Q_OS_SYMBIAN || defined Q_WS_MAEMO_5 + QSystemDeviceInfo* m_systemDeviceInfo; +#endif + bool m_silent; + +#ifdef Q_OS_SYMBIAN + CHWRMVibra* iVibrate; +#endif + +}; + +#endif // GAMEENGINE_H diff --git a/demos/mobile/quickhit/gfx/back.png b/demos/mobile/quickhit/gfx/back.png new file mode 100755 index 0000000..bb66f74 Binary files /dev/null and b/demos/mobile/quickhit/gfx/back.png differ diff --git a/demos/mobile/quickhit/gfx/background2.png b/demos/mobile/quickhit/gfx/background2.png new file mode 100755 index 0000000..c81875a Binary files /dev/null and b/demos/mobile/quickhit/gfx/background2.png differ diff --git a/demos/mobile/quickhit/gfx/bigship.png b/demos/mobile/quickhit/gfx/bigship.png new file mode 100755 index 0000000..b88dc32 Binary files /dev/null and b/demos/mobile/quickhit/gfx/bigship.png differ diff --git a/demos/mobile/quickhit/gfx/exit.png b/demos/mobile/quickhit/gfx/exit.png new file mode 100755 index 0000000..a45abd6 Binary files /dev/null and b/demos/mobile/quickhit/gfx/exit.png differ diff --git a/demos/mobile/quickhit/gfx/pause.png b/demos/mobile/quickhit/gfx/pause.png new file mode 100755 index 0000000..0570908 Binary files /dev/null and b/demos/mobile/quickhit/gfx/pause.png differ diff --git a/demos/mobile/quickhit/gfx/quickhit_logo.png b/demos/mobile/quickhit/gfx/quickhit_logo.png new file mode 100755 index 0000000..0b505c7 Binary files /dev/null and b/demos/mobile/quickhit/gfx/quickhit_logo.png differ diff --git a/demos/mobile/quickhit/gfx/soundOff.png b/demos/mobile/quickhit/gfx/soundOff.png new file mode 100755 index 0000000..fed8520 Binary files /dev/null and b/demos/mobile/quickhit/gfx/soundOff.png differ diff --git a/demos/mobile/quickhit/gfx/soundOn.png b/demos/mobile/quickhit/gfx/soundOn.png new file mode 100755 index 0000000..03bd80e Binary files /dev/null and b/demos/mobile/quickhit/gfx/soundOn.png differ diff --git a/demos/mobile/quickhit/icon.svg b/demos/mobile/quickhit/icon.svg new file mode 100755 index 0000000..3795e8d --- /dev/null +++ b/demos/mobile/quickhit/icon.svg @@ -0,0 +1,305 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/demos/mobile/quickhit/main.cpp b/demos/mobile/quickhit/main.cpp new file mode 100755 index 0000000..91d5bae --- /dev/null +++ b/demos/mobile/quickhit/main.cpp @@ -0,0 +1,94 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include +#include "mainwindow.h" + +// Lock S60 orientation +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#include +#endif + +#ifndef QT_NO_OPENGL + #include +#endif + + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + // Lock S60 orientation +#ifdef Q_OS_SYMBIAN + CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) { + appUi->SetOrientationL(CAknAppUi::EAppUiOrientationPortrait); + } + ); +#endif + + MainWindow w; + +#ifndef QT_NO_OPENGL + // Use QGLWidget to get the opengl support if available + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(false); + + QGLWidget *glWidget = new QGLWidget(format); + glWidget->setAutoFillBackground(false); + w.setViewport(glWidget); // ownership of glWidget is taken +#endif + + QObject *rootObject = dynamic_cast(w.rootObject()); + + // For Qt.exit() from QML + QObject::connect((QObject*)w.engine(), SIGNAL(quit()), &a, SLOT(quit())); + // Level activation signal from QML + QObject::connect(rootObject, SIGNAL(levelActivated(int)), &w, SLOT(levelActivated(int))); + +#if defined (Q_OS_SYMBIAN) || defined (Q_WS_MAEMO_5) + w.setGeometry(QApplication::desktop()->screenGeometry()); + w.showFullScreen(); +#else + w.setGeometry(100,100,360,640); + w.setFixedSize(360,640); + w.show(); +#endif + + return a.exec(); +} diff --git a/demos/mobile/quickhit/mainwindow.cpp b/demos/mobile/quickhit/mainwindow.cpp new file mode 100755 index 0000000..6929fc4 --- /dev/null +++ b/demos/mobile/quickhit/mainwindow.cpp @@ -0,0 +1,241 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "mainwindow.h" +#include "gameengine.h" +#include "plugins/levelplugininterface.h" + +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QDeclarativeView(parent) +{ + +#ifdef Q_WS_MAEMO_5 + window()->setAttribute(Qt::WA_Maemo5PortraitOrientation, true); +#endif + + // Game engine + m_gameEngine = new GameEngine(this); + + // Load all levels plugins + m_levelPlugin = 0; + loadLevelPlugins(); + + // QML main window + engine()->addImportPath("./imports"); + setResizeMode(QDeclarativeView::SizeRootObjectToView); + + // Set game engine visible to QML + rootContext()->setContextProperty("GameEngine", m_gameEngine); + + // Set QML source + setSource(QUrl("qrc:/Game.qml")); + //setSource(QUrl("../QuickHit/Game.qml")); + + // Store QML root object for game engine + QObject *ro = static_cast(rootObject()); + m_gameEngine->setGameQml(ro); + m_gameEngine->findQmlObjects(); + + // Application foreground / background event filter for filterin incoming call (window) + // when game will be paused + m_eventFilter = new MyEventFilter(this); + QObject::connect(m_eventFilter,SIGNAL(activationChangeFiltered()),this,SLOT(activationChangeFiltered())); + qApp->installEventFilter(m_eventFilter); + + // Remove context menu from the all widgets + QWidgetList widgets = QApplication::allWidgets(); + QWidget* w = 0; + foreach (w,widgets){ + w->setContextMenuPolicy(Qt::NoContextMenu); + } +} + +MainWindow::~MainWindow() +{ + for (int i=0;iunload(); + } + m_plugins.clear(); + +} + +void MainWindow::activationChangeFiltered() +{ + m_gameEngine->pauseGame(); +} + +void MainWindow::levelActivated(int index) +{ + // Set level for the game engine + createPlugin(index); + rootContext()->setContextProperty("LevelPlugin", m_levelPlugin); + m_gameEngine->setGameLevel(m_levelPlugin); +} + +void MainWindow::loadLevelPlugins() +{ +#if defined (Q_OS_SYMBIAN) + bool exists_c = loadPlugins("c", "quickhitlevels"); + bool exists_e = loadPlugins("e", "quickhitlevels"); + bool exists_f = loadPlugins("f", "quickhitlevels"); + if (exists_c || exists_e || exists_f) { + m_gameEngine->setPluginList(m_plugins); + createPlugin(); + } + else { + //QMessageBox::information(this, "QuickHit", "Could not load any of the quickhitlevels"); + } +#else + if (loadPlugins("c", "quickhitlevels")) { + m_gameEngine->setPluginList(m_plugins); + createPlugin(); + } + else { + //QMessageBox::information(this, "QuickHit", "Could not load any of the quickhitlevels"); + } + + +#endif +} + +bool MainWindow::loadPlugins(QString drive, QString pluginDir) +{ +#if defined (Q_OS_SYMBIAN) + QDir pluginsDir(drive + ":" + QLibraryInfo::location(QLibraryInfo::PluginsPath)); +#elif defined Q_OS_WIN32 + QDir pluginsDir = QDir::currentPath(); +#else + QDir pluginsDir(QLibraryInfo::location(QLibraryInfo::PluginsPath)); +#endif + pluginsDir.cd(pluginDir); + + qDebug() << "Loads plugins from : " << pluginsDir.path(); + + bool newPluginsLoaded = false; + + foreach (QString fileName, pluginsDir.entryList(QDir::Files)) + { + // Accept only plugin files +#if defined (Q_OS_SYMBIAN) + if (fileName.contains(".qtplugin",Qt::CaseInsensitive)) { +#elif defined (Q_WS_MAEMO_5) + if (fileName.contains(".so",Qt::CaseInsensitive)) { +#else + if (fileName.contains(".dll",Qt::CaseInsensitive)) { +#endif + + // Create plugin loader + QPluginLoader* pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName)); + // Load plugin + bool ret = pluginLoader->load(); + if (!ret) { + // Loading failed + qDebug() << "Could not load plugin " << fileName; + } else { + // Loading done + // Test creating plugin + QObject *plugin = 0; + LevelPluginInterface* pluginIF = 0; + plugin = pluginLoader->instance(); + pluginIF = qobject_cast (plugin); + if (pluginIF) { + qDebug() << "Plugin can be created"; + // Store loader to array + m_plugins.append(pluginLoader); + newPluginsLoaded = true; + } else { + pluginLoader->unload(); + qDebug() << "Plugin can NOT be created!"; + } + } + } + } + + return newPluginsLoaded; +} + + +void MainWindow::createPlugin(int index) +{ + if (index == -1) { + return; + } + + m_levelPlugin = 0; + + // Try to create plugin instance + QPluginLoader* pluginLoader = m_plugins[index]; + QObject *plugin = pluginLoader->instance(); + if (plugin) { + // Plugin instance created + // Cast plugin to LevelPluginInterface, that is common for all plugins + LevelPluginInterface* pluginIF = qobject_cast (plugin); + m_levelPlugin = pluginIF; + qDebug() << "Plugin created: " << index; + } + else { + qDebug() << "Creating plugin failed!"; + QMessageBox::information(this, "QuickHit", "Could not create quickhitlevels"); + } +} + +void MainWindow::printObjectTree(QObject* parent) +{ + if (parent) { + qDebug() << "className:" << parent->metaObject()->className(); + qDebug() << "objectName:" << parent->objectName(); + + QObjectList list = parent->children(); + QObject* item; + foreach (item,list) { + if (item->children().count()>0) { + qDebug() << "--Childrens found--"; + printObjectTree(item); + } else { + qDebug() << "className:" << item->metaObject()->className(); + qDebug() << "objectName:" << item->objectName(); + } + } + } else { + qDebug() << "object NULL"; + } + +} + diff --git a/demos/mobile/quickhit/mainwindow.h b/demos/mobile/quickhit/mainwindow.h new file mode 100755 index 0000000..97a4461 --- /dev/null +++ b/demos/mobile/quickhit/mainwindow.h @@ -0,0 +1,78 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "myeventfilter.h" + +class GameEngine; +class LevelPluginInterface; + +class MainWindow : public QDeclarativeView +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +public slots: + void levelActivated(int); + void activationChangeFiltered(); + +private: + void printObjectTree(QObject* parent); + void loadLevelPlugins(); + bool loadPlugins(QString drive, QString pluginDir); + void createPlugin(int index = -1); + +private: + GameEngine* m_gameEngine; + LevelPluginInterface* m_levelPlugin; + QList m_plugins; + + MyEventFilter* m_eventFilter; +}; + +#endif // MAINWINDOW_H diff --git a/demos/mobile/quickhit/menu.qml b/demos/mobile/quickhit/menu.qml new file mode 100755 index 0000000..861c9d0 --- /dev/null +++ b/demos/mobile/quickhit/menu.qml @@ -0,0 +1,156 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import "Game.js" as GameScript + + +Rectangle { + id: menu + + Text { + id: title + smooth: true + anchors.bottom: menu.top + anchors.horizontalCenter: menu.horizontalCenter + color: "red" + font.pixelSize: gameArea.width / 12 + font.bold: true + horizontalAlignment: Text.AlignHCenter + } + + border.color: "black" + border.width: 2 + radius: 8 + smooth: true + opacity: 0 // transparent by default + + color: "black" +// gradient: Gradient { +// GradientStop { position: 0.0; color: "white" } +// GradientStop { position: 1.0; color: "black" } +// } + + // Signals + signal levelSelected(int levelIndex) + signal resumeSelected() + + // Show level menu + function showLevelMenu() { + menuData.clear() + title.text = "Select Your Level" + var plugins = GameEngine.pluginList() + for (var i = 0; i < plugins.length; i++) { + menuData.append({"name": plugins[i],"type":"0"}) + } + menuData.append({"name": "About","type":"4"}) + menuData.append({"name": "Exit","type":"1"}) + menu.opacity = 0.8 + listView.focus = true + } + + function showPauseMenu() { + menuData.clear() + title.text = "Resume level?" + menuData.append({"name": "Resume","type":"2"}) + menuData.append({"name": "End Game","type":"3"}) + menu.opacity = 0.8 + listView.focus = true + } + + // Hide menu + function hideMenu() { + menu.opacity = 0 + listView.focus = false + } + + function menuItemSelected(index, type) { + switch (type) { + case "0": { + // Level selection + menu.levelSelected(index) + break; + } + case "1": { + // Exit + Qt.quit() + break; + } + case "2": { + // Resume + menu.resumeSelected() + break; + } + case "3": { + // End Game + gameArea.endGame() + break; + } + case "4": { + // Show about + gameArea.messageBox.showInfoMessage() + break; + } + default: { + break; + } + } + } + + ListModel { + id: menuData + } + + ListView { + id: listView + clip: true + anchors.fill: parent + keyNavigationWraps: true + + function doSelect() { + menu.menuItemSelected(listView.currentIndex,menuData.get(listView.currentIndex).type) + } + + model: menuData + + delegate: MenuItem { + id: menuItem + selectedItem: menuItem.ListView.isCurrentItem ? true : false + onItemSelected: { + listView.currentIndex = model.index + listView.doSelect() + } + + } + } +} diff --git a/demos/mobile/quickhit/menuitem.qml b/demos/mobile/quickhit/menuitem.qml new file mode 100755 index 0000000..7973c33 --- /dev/null +++ b/demos/mobile/quickhit/menuitem.qml @@ -0,0 +1,96 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Text { + id: menuItem + text: name + color: "white" + opacity: 1 + font.family: "Calibri" + font.pixelSize: menu.width / 8 + x: (parent.width - width )/ 2 + + property bool selectedItem: false + property int type + + signal itemSelected() + + transform: Rotation { id:rotationId; origin.x:width/2; origin.y:height/2; axis { x: 1; y: 0; z: 0 } angle: 0 } + SequentialAnimation { + id: toRotateRightAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 180; duration: 300 } + PropertyAction { target: menuItem; property: "color"; value:"red"} + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 180; to: 360; duration: 300 } + PropertyAction { target: menuItem; property: "color"; value:"white"} + } + + function selectItem(doSelect) { + if (!toRotateRightAndCenterAnim.running) { + GameEngine.playInternalSound(0) + toRotateRightAndCenterAnim.restart() + if (doSelect) { + GameEngine.playInternalSound(1) + selectionTimer.restart() + } + } + } + + Timer { + id: selectionTimer + interval: 1000; running: false; repeat: false + onTriggered: menuItem.itemSelected() + } + + MouseArea { + id: mouseArea; + anchors.fill: parent + onClicked: { + selectItem(true) + } + } + + Keys.onSpacePressed: { selectItem(true) } + Keys.onSelectPressed: { selectItem(true) } + Keys.onEnterPressed: { selectItem(true) } + Keys.onReleased: { + if (event.key == Qt.Key_Down || event.key == Qt.Key_Up) { + selectItem(false) + } + event.accepted = false + } +} + diff --git a/demos/mobile/quickhit/message.qml b/demos/mobile/quickhit/message.qml new file mode 100755 index 0000000..2ddd4a4 --- /dev/null +++ b/demos/mobile/quickhit/message.qml @@ -0,0 +1,140 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Rectangle { + id: message + border.color: "black" + border.width: 1 + radius: 8 + smooth: true + opacity: 0 // transparent = 0 by default + color: "black" + + property string txt + property int animSpeed + + function showMessage(text,speed) { + message.border.color = "black" + message.y = 50 + message.width = gameArea.width / 5 * 4 + message.height = gameArea.height / 8 * 1 + txt = text + animSpeed = speed + message.opacity = 1 + messageText.font.pixelSize = parent.width / 14 + messageAnim.restart() + } + + function showErrorMessage(text,speed) { + message.border.color = "red" + message.y = 50 + message.width = gameArea.width / 5 * 4 + message.height = gameArea.height / 8 * 1 + txt = text + animSpeed = speed + message.opacity = 1 + messageText.font.pixelSize = parent.width / 14 + messageAnim.restart() + } + + function showInfoMessage() { + message.border.color = "white" + txt = "QuickHit" + + "

" + + "Forum Nokia
" + + "Qt Quick Game Example
" + + "

" + + "

" + + "Sounds were loaded from freesound.org under Creative Commons Sampling Plus 1.0 license.
" + + "

" + + "

" + + "Sounds were created by these nicknames:
" + + "HardPCM
" + + "Matt_G
" + + "klankbeeld
" + + "steveygos93
" + + "joe93barlow
" + + "ljudman
" + + "Jovica
" + + "patchen
" + + "nthompson
" + + "

" + + animSpeed = 9000 + message.opacity = 1 + message.y = 10 + message.height = gameArea.height - message.y - 10 + message.width = gameArea.width - 20 + + messageText.font.pixelSize = parent.width / 16 + messageAnim.restart() + } + + //gradient: Gradient { + // GradientStop { position: 0.0; color: "white" } + // GradientStop { position: 1.0; color: "black" } + //} + + SequentialAnimation { + id: messageAnim + PropertyAnimation { + target: message; properties: "x"; + from: message.width*-1; to: gameArea.width; duration: animSpeed; easing.type: Easing.OutInExpo} + PropertyAction { target: message; properties: "opacity"; value: 0 } + } + + MouseArea { + anchors.fill: parent + onClicked: { + messageAnim.stop() + message.opacity = 0 + } + } + + Text { + id: messageText + anchors.fill: parent + anchors.margins: 10 + text: txt + wrapMode: Text.WordWrap + color: "white" + font.family: "Calibri" + font.pixelSize: parent.width / 14 + font.bold: true + onLinkActivated: { + GameEngine.openLink(link) + } + } +} diff --git a/demos/mobile/quickhit/missile.qml b/demos/mobile/quickhit/missile.qml new file mode 100755 index 0000000..3ff2816 --- /dev/null +++ b/demos/mobile/quickhit/missile.qml @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Item { + id: missile + objectName: "missile" + opacity: 0 // transparent by default + + property int fromYpos + property int toYpos + property variant myMissileSize + property bool enemyMissile: false + property int defaultX: 0 + property int defaultY: 0 + + function storeDefaultPos() { + defaultX = missile.x + defaultY = missile.y + } + + function setToDefaultPos() { + missile.x = defaultX + missile.y = defaultY + opacity = 0.5 + } + + function createGraphicsForLevel() { + missile.myMissileSize = LevelPlugin.graphSize(LevelPlugin.pathToMissilePic()) + missile.height = myMissileSize.height; + missile.width = myMissileSize.width; + if (missile.enemyMissile) { + missileImage.source = "file:/"+LevelPlugin.pathToEnemyMissilePic() + } else { + missileImage.source = "file:/"+LevelPlugin.pathToMissilePic() + } + } + + // Execute fire! + function fire(aXpox, aFromYpos, aToYpos) { + missile.x = aXpox - missile.width / 2 + missile.y = aFromYpos + missile.fromYpos = aFromYpos + missile.toYpos = aToYpos + missile.opacity = 1 + GameEngine.playSound(2) // NOTE: 3 for your missile sound + flying.restart() + } + + // Enemy fires! + function enemyFire(aXpox, aFromYpos, aToYpos) { + missile.x = aXpox - missile.width / 2 + missile.y = aFromYpos + missile.fromYpos = aFromYpos + missile.toYpos = aToYpos + missile.opacity = 1 + GameEngine.playSound(3) // NOTE: 3 for enemy missile sound + flyingEnemy.restart() + } + + // Stop missile + function stop() { + flying.stop() + } + + // Pause missile + function pause(doPause) { + if (doPause) { + flying.pause() + flyingEnemy.pause() + } else { + flying.resume() + flyingEnemy.resume() + } + } + + Component.onCompleted: { + if (!enemyMissile) { + storeDefaultPos() + setToDefaultPos() + } + } + + // Animates missile flying to the target + SequentialAnimation { + id: flying + PropertyAnimation {target: missile; properties: "y"; + from: fromYpos; to: toYpos; duration: 2000; easing.type: Easing.InCubic } + //PropertyAction {target: missile; properties: "opacity"; value: 0} + ScriptAction { script: setToDefaultPos() } + } + + SequentialAnimation { + id: flyingEnemy + PropertyAnimation {target: missile; properties: "y"; + from: fromYpos; to: toYpos; duration: 2000; easing.type: Easing.InCubic } + PropertyAction {target: missile; properties: "opacity"; value: 0} + } + + Image { + id: missileImage + smooth: true + } +} + diff --git a/demos/mobile/quickhit/myeventfilter.cpp b/demos/mobile/quickhit/myeventfilter.cpp new file mode 100755 index 0000000..be3aa9a --- /dev/null +++ b/demos/mobile/quickhit/myeventfilter.cpp @@ -0,0 +1,60 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#include +#include "myeventfilter.h" + +MyEventFilter::MyEventFilter(QObject *parent) : + QObject(parent) +{ +} + +MyEventFilter::~MyEventFilter() +{ +} + +bool MyEventFilter::eventFilter(QObject *obj, QEvent *event) +{ + // http://doc.trolltech.com/4.7/qevent.html#QEvent + + // QEvent::ActivationChange : The application has been made available to the user. + + if (event->type() == QEvent::ActivationChange) { + emit activationChangeFiltered(); + qDebug() << "ActivationChangeFiltered()"; + return false; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } +} diff --git a/demos/mobile/quickhit/myeventfilter.h b/demos/mobile/quickhit/myeventfilter.h new file mode 100755 index 0000000..2c1ac9c --- /dev/null +++ b/demos/mobile/quickhit/myeventfilter.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef KEYEVENTLISTENER_H +#define KEYEVENTLISTENER_H + +#include +#include + +class MyEventFilter : public QObject +{ + Q_OBJECT + +public: + MyEventFilter(QObject *parent = 0); + ~MyEventFilter(); + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +signals: + void activationChangeFiltered(); + +}; + +#endif // KEYEVENTLISTENER_H diff --git a/demos/mobile/quickhit/myship.qml b/demos/mobile/quickhit/myship.qml new file mode 100755 index 0000000..d435694 --- /dev/null +++ b/demos/mobile/quickhit/myship.qml @@ -0,0 +1,177 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import "Game.js" as GameScript + +Item { + id: myShip + objectName: "myShip" + + property variant myShipSize + property int originalY + + // Fires missile if exists + function fire() { + if (myShip.opacity==1) { + GameScript.fireMissile(myShip.x+myShip.width/2,myShip.y,myShip.height*-1) + if (myShip.y+myShip.height < gameArea.height+5) { + goDownAnim.restart() + } + } + } + + function createGraphicsForLevel() { + myShip.myShipSize = LevelPlugin.graphSize(LevelPlugin.pathToMyShipPic()) + myShip.height = myShipSize.height + myShip.width = myShipSize.width + image.source = "file:/"+LevelPlugin.pathToMyShipPic() + myShip.y = gameArea.height - myShip.height - 10 + originalY = myShip.y + myShip.x = (gameArea.width - myShip.width)/ 2 + } + + Image { + id: image + smooth: true + } + + Keys.onSpacePressed: { fire() } + Keys.onSelectPressed: { fire() } + Keys.onRightPressed: { + if (myShip.x < (gameArea.width - myShip.width - 20)) { + toRightAnim.restart() + } + } + Keys.onLeftPressed: { + if (myShip.x > 20) { + toLeftAnim.restart() + } + } + + // To right animation + PropertyAnimation { id: toRightAnim; target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x + 20; duration: 500 } + + // To left animation + PropertyAnimation { id: toLeftAnim; target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x - 20; duration: 500 } + + // Go down on fire animation + SequentialAnimation { + id: goDownAnim + NumberAnimation { target: myShip; property:"y"; from: myShip.y; to: myShip.y+5; + easing.type: Easing.Linear; duration: 200 } + NumberAnimation { target: myShip; property:"y"; from: myShip.y; to: originalY; + easing.type: Easing.Linear; duration: 200 } + } + + + /* + MouseArea { + anchors.fill: parent + drag.target: myShip + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: gameArea.width - myShip.width + onReleased: { + fire() + } + } + */ + + + /* + property bool isAutoRepeat: false + Keys.onPressed: { + if (event.key == Qt.Key_Right) { + if (event.isAutoRepeat) { + isAutoRepeat = true + toRightAnim.restart() + } else { + isAutoRepeat = false + toRotateRightAndCenterAnim.restart() + } + event.accepted = true + } + else if (event.key == Qt.Key_Left) { + if (event.isAutoRepeat) { + isAutoRepeat = true + toLeftAnim.restart() + } else { + isAutoRepeat = false + toRotateLeftAndCenterAnim.restart() + } + event.accepted = true + } + } + + Keys.onReleased: { + if (isAutoRepeat) { + toRotateRightAndCenterAnim.stop() + toRotateLeftAndCenterAnim.stop() + } else { + toRotateCenter.restart() + } + event.accepted = true + } + + // Rotation on movement animation + transform: Rotation { id:rotationId; origin.x: width/2; origin.y: height/2; axis { x: 0; y: 1; z: 0 } angle: 0 } + SequentialAnimation { + id: toRotateRightAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 30; duration: 100 } + PropertyAnimation { target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x + 20; duration: 500 } + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + } + SequentialAnimation { + id: toRotateLeftAndCenterAnim + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: -30; duration: 100 } + PropertyAnimation { target: myShip; easing.type: Easing.OutQuint; + properties: "x"; from: myShip.x; to: myShip.x - 20; duration: 500 } + PropertyAnimation { target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + } + PropertyAnimation { id: toRotateRight; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: 30; duration: 100 } + PropertyAnimation { id: toRotateCenter; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; to: 0; duration: 100 } + PropertyAnimation { id: toRotateLeft; target: rotationId; easing.type: Easing.Linear; + properties: "angle"; from: 0; to: -30; duration: 100 } +*/ + +} diff --git a/demos/mobile/quickhit/plugins/LevelOne/Level.qml b/demos/mobile/quickhit/plugins/LevelOne/Level.qml new file mode 100755 index 0000000..2f4d4d5 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/Level.qml @@ -0,0 +1,207 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import Qt.labs.particles 1.0 + +Rectangle { + id: enemies + anchors.fill: parent + color: "black" + + + // Background image for the level + Image { + id: background1 + source: "file:/"+LevelPlugin.pictureRootPath()+"background3.png" + fillMode: Image.PreserveAspectCrop + smooth: true + //anchors.fill: parent + width: parent.width + height: parent.height + } + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + function pause(doPause) { + if (doPause) { + rightLeftAnim.pause() + upToDownAnim.pause() + } else { + rightLeftAnim.resume() + upToDownAnim.resume() + } + } + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + objectName: "level" + + property int enemySpeed: LevelPlugin.enemySpeed() + property int enemyMaxWidth + + // Create enemies dynamically + function createEnemies(amount) { + var b = false; + for (var i=0;i gameArea.width) { + enemyMaxWidth = gameArea.width / (enemyCountInCol + 1); + } + else { + enemyMaxWidth = LevelPlugin.graphSize(LevelPlugin.pictureRootPath()+"enemy1.png").width; + } + } + + + Component.onCompleted: { + // Calculate enemy max width + calEnemyMaxWidth() + + // Create enemies dynamically after component created + createEnemies(LevelPlugin.enemyCount()) + + // Start animations + enemiesGrid.y = enemiesGrid.height * -1 + rightLeftAnim.restart() + upToDownAnim.restart() + + // Flying stars animation, not in Maemo + if (!GameEngine.isMaemo()) { + starBurstTimer.restart() + } + + GameEngine.playSound(4) // NOTE: Level start sound + } + + + Timer { + id: starBurstTimer + interval: starParticles.lifeSpan+GameEngine.randInt(100,2000); running: false; repeat: true + onTriggered: { + starParticles.burst(GameEngine.randInt(4,10)) + } + } + + + // Right-left animation + SequentialAnimation { + id: rightLeftAnim + loops: Animation.Infinite + NumberAnimation { target:enemiesGrid; property:"x"; from: 0; to:gameArea.width - enemiesGrid.width; easing.type: Easing.OutQuad; duration: 3000 } + NumberAnimation { target:enemiesGrid; property:"x"; to: 0; easing.type: Easing.OutQuad; duration: 3000 } + } + + // Up to down animation + PropertyAnimation { id: upToDownAnim; target:enemiesGrid; property:"y"; to: gameArea.height; + easing.type: Easing.Linear; duration: enemies.enemySpeed } + + Grid { + id: enemiesGrid + objectName: "enemiesGrid" + columns: LevelPlugin.enemyCount() / LevelPlugin.enemyRowCount() + spacing: 8 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Execute explode particle effect + function explode(x,y) { + explodeParticles.x = x + explodeParticles.y = y + explodeParticles.burst(20) + explodeParticles.opacity = 1 + } + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Explode particle effect + Particles { + id: explodeParticles + opacity: 0 + width: 1 + height: 1 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"red_fire.png" + lifeSpan: 500 + lifeSpanDeviation: 2000 + count: -1 + angle: 270 + angleDeviation: 65 + velocity: 100 + velocityDeviation: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 300 + acceleration: 50 + } + } + + Particles { + id: starParticles + y: -50 + x: 0 + width: parent.width + height: 50 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"star3.png" + lifeSpan: 3000 + count: -1 + angle: 90 + velocity: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 500 + } + } + + +} + + + + + diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/changelog b/demos/mobile/quickhit/plugins/LevelOne/debian/changelog new file mode 100755 index 0000000..de7ac98 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/changelog @@ -0,0 +1,11 @@ +levelone (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio Wed, 5 Jan 2011 10:05:04 +0200 + +levelone (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/compat b/demos/mobile/quickhit/plugins/LevelOne/debian/compat new file mode 100755 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/control b/demos/mobile/quickhit/plugins/LevelOne/debian/control new file mode 100755 index 0000000..c46afef --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/control @@ -0,0 +1,11 @@ +Source: levelone +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio +Standards-Version: 3.7.2 + +Package: levelone +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - LevelOne + QuickHit - LevelOne diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/copyright b/demos/mobile/quickhit/plugins/LevelOne/debian/copyright new file mode 100755 index 0000000..fb9e5a8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/copyright @@ -0,0 +1,8 @@ +This is qmultiwinexample, written and maintained by Forum Nokia Antonio Aloisio +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/dirs b/demos/mobile/quickhit/plugins/LevelOne/debian/dirs new file mode 100755 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/postinst b/demos/mobile/quickhit/plugins/LevelOne/debian/postinst new file mode 100755 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelOne/debian/rules b/demos/mobile/quickhit/plugins/LevelOne/debian/rules new file mode 100755 index 0000000..53a1d2e --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := levelone + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png new file mode 100755 index 0000000..c81875a Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/background3.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png new file mode 100755 index 0000000..94f149b Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy1.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png new file mode 100755 index 0000000..448f8ca Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png new file mode 100755 index 0000000..c0b28d8 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/enemy_missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png new file mode 100755 index 0000000..8401034 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png new file mode 100755 index 0000000..139aa61 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/fire2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png new file mode 100755 index 0000000..dacd610 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png new file mode 100755 index 0000000..464d603 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/red_fire.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png new file mode 100755 index 0000000..cb7851c Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/ship.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png new file mode 100755 index 0000000..f37a391 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/star3.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png new file mode 100755 index 0000000..3aa1e41 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/gfx/transparent.png differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp b/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp new file mode 100755 index 0000000..f2e27d3 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.cpp @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "levelone.h" +#include + + +LevelOne::LevelOne() +{ +} + +LevelOne::~LevelOne() +{ +} + +QString LevelOne::pathPrefix() +{ + /* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelOne::levelSounds() +{ + QStringList list; + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket_explosion.wav"); + // 1 = You explode + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/crash.wav"); + // 2 = Missile fires + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket_explosion.wav"); + // 3 = Emeny Missile fires + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/rocket.wav"); + + // Additional sounds + // Level starts + list.append(LevelOne::pathPrefix()+"quickhitdata/levelone/sound/levelonestart.wav"); + + return list; +} + +QVariant LevelOne::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelOne::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class LevelOne with the name levelplugins. +// There should be exactly one occurrence of this LevelOne macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelOne); diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.h b/demos/mobile/quickhit/plugins/LevelOne/levelone.h new file mode 100755 index 0000000..06c5203 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef LEVELONE_H +#define LEVELONE_H + +#include +#include +#include + +#include "levelplugininterface.h" + +class LevelOne : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelOne(); + ~LevelOne(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(30); } // 6x5=30 + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(6); } // 6 rows of enemies + Q_INVOKABLE QVariant enemySpeed() { return QVariant(36000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(200); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelOne::pathPrefix()+"quickhitdata/levelone/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LEVELONE_H diff --git a/demos/mobile/quickhit/plugins/LevelOne/levelone.pro b/demos/mobile/quickhit/plugins/LevelOne/levelone.pro new file mode 100755 index 0000000..fcbfc56 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelOne/levelone.pro @@ -0,0 +1,100 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = levelone.h + +SOURCES = levelone.cpp + +TARGET = $$qtLibraryTarget(levelone) + +OTHER_FILES += Level.qml + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb66 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = levelone.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/background3.png ../winscw/c/Data/gfx/background3.png" \ +"gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/enemy2.png ../winscw/c/Data/gfx/enemy2.png" \ +"gfx/red_fire.png ../winscw/c/Data/gfx/red_fire.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/star3.png ../winscw/c/Data/gfx/star3.png" \ +"sound/crash.wav ../winscw/c/Data/sound/crash.wav" \ +"sound/rocket.wav ../winscw/c/Data/sound/rocket.wav" \ +"sound/rocket_explosion.wav ../winscw/c/Data/sound/rocket_explosion.wav" \ +"sound/levelonestart.wav ../winscw/c/Data/sound/levelonestart.wav" \ +"Level.qml ../winscw/c/Data/Level.qml" + + +myQml.sources = level.qml +myQml.path = c:/System/quickhitdata/levelone +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/levelone/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/levelone/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { +# Copy level sounds and graphics into right destination +system(mkdir c:\\quickhitdata\\levelone) +system(mkdir c:\\quickhitdata\\levelone\\gfx) +system(mkdir c:\\quickhitdata\\levelone\\sound) +system(copy *.qml c:\\quickhitdata\\levelone) +system(copy gfx\\*.* c:\\quickhitdata\\levelone\\gfx) +system(copy sound\\*.* c:\\quickhitdata\\levelone\\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/levelone/ +myQml.files += Level.qml +myGraphic.path = /home/user/.quickhitdata/levelone/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/levelone/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav new file mode 100755 index 0000000..8076f0f Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/sound/crash.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav new file mode 100755 index 0000000..e9e3ac0 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/sound/levelonestart.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav new file mode 100755 index 0000000..8c0dee9 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav new file mode 100755 index 0000000..d2b451c Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelOne/sound/rocket_explosion.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog b/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog new file mode 100755 index 0000000..a5e0a1b --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/changelog @@ -0,0 +1,11 @@ +leveltemplate (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio Wed, 5 Jan 2011 10:05:04 +0200 + +leveltemplate (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat b/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat new file mode 100755 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/control b/demos/mobile/quickhit/plugins/LevelTemplate/debian/control new file mode 100755 index 0000000..68742fd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/control @@ -0,0 +1,11 @@ +Source: leveltemplate +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio +Standards-Version: 3.7.2 + +Package: leveltemplate +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - Level Template + QuickHit - Level Template diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright b/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright new file mode 100755 index 0000000..f9ee8e2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/copyright @@ -0,0 +1,8 @@ +This is leveltemplate, written and maintained by Forum Nokia Antonio Aloisio +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs b/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs new file mode 100755 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist b/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist new file mode 100755 index 0000000..f3146fa1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/levelone.tarlist @@ -0,0 +1,41 @@ +755 root root . home / +755 root root . home/maemo / +755 root root . home/maemo/quickhitdata / +755 root root . home/maemo/quickhitdata/levelone / +644 root root . home/maemo/quickhitdata/levelone/Level.qml debian/levelone/home/maemo/quickhitdata/levelone/Level.qml +755 root root . home/maemo/quickhitdata/leveltwo / +755 root root . home/maemo/quickhitdata/leveltwo/gfx / +644 root root . home/maemo/quickhitdata/leveltwo/gfx/background3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/background3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy1.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy1.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/moon.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/moon.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/ship.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/ship.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/star3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/star3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/transparent.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/transparent.png +755 root root . home/maemo/quickhitdata/leveltwo/sound / +644 root root . home/maemo/quickhitdata/leveltwo/sound/crash.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/crash.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/laser.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/laser.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav +755 root root . usr / +755 root root . usr/bin / +755 root root . usr/lib / +755 root root . usr/lib/qt4 / +755 root root . usr/lib/qt4/plugins / +755 root root . usr/lib/qt4/plugins/quickhitlevels / +644 root root . usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so debian/levelone/usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so +755 root root . usr/share / +755 root root . usr/share/applications / +755 root root . usr/share/applications/hildon / +755 root root . usr/share/doc / +755 root root . usr/share/doc/levelone / +644 root root . usr/share/doc/levelone/changelog.gz debian/levelone/usr/share/doc/levelone/changelog.gz +644 root root . usr/share/doc/levelone/copyright debian/levelone/usr/share/doc/levelone/copyright diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst b/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst new file mode 100755 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules b/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules new file mode 100755 index 0000000..7f30ca3 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := leveltemplate + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png new file mode 100755 index 0000000..8667a39 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/blue_fire.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png new file mode 100755 index 0000000..94f149b Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy1.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png new file mode 100755 index 0000000..448f8ca Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png new file mode 100755 index 0000000..c0b28d8 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/enemy_missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png new file mode 100755 index 0000000..dacd610 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png new file mode 100755 index 0000000..cb7851c Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/ship.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png new file mode 100755 index 0000000..3aa1e41 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/gfx/transparent.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp new file mode 100755 index 0000000..25a0fb7 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.cpp @@ -0,0 +1,119 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "leveltemplate.h" +#include + + +LevelTemplate::LevelTemplate() +{ +} + +LevelTemplate::~LevelTemplate() +{ +} + +QString LevelTemplate::pathPrefix() +{ +/* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelTemplate::levelSounds() +{ + QStringList list; + + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/enemy_explosion.wav"); + // 1 = You explode + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/myship_explosion.wav"); + // 2 = Missile fires + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/laser.wav"); + // 3 = Emeny Missile fires + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/rocket.wav"); + + // Additional sounds + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/enableship.wav"); + list.append(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/sound/level2.wav"); + + + return list; +} + +QVariant LevelTemplate::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelTemplate::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class level with the name levelplugins. +// There should be exactly one occurrence of this macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelTemplate); + + + + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h new file mode 100755 index 0000000..1858715 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.h @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef LevelTemplate_H +#define LevelTemplate_H + +#include +#include +#include + +// Common interface header for all level plugins +#include "levelplugininterface.h" + +// Level name +#define LEVEL_NAME "leveltemplate" + +class LevelTemplate : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelTemplate(); + ~LevelTemplate(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(1); } + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(0); } + Q_INVOKABLE QVariant enemySpeed() { return QVariant(20000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(2000); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelTemplate::pathPrefix()+"quickhitdata/"+LEVEL_NAME+"/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LevelTemplate_H diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro new file mode 100755 index 0000000..a4f5900 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/leveltemplate.pro @@ -0,0 +1,103 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = leveltemplate.h + +SOURCES = leveltemplate.cpp + +TARGET = $$qtLibraryTarget(leveltemplate) + +OTHER_FILES += qml/Level.qml \ + qml/Enemy.qml \ + qml/Level.js + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb68 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = leveltemplate.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/enemy2.png ../winscw/c/Data/gfx/enemy2.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/blue_fire.png ../winscw/c/Data/gfx/blue_fire.png" \ +"sound/enemy_explosion.wav ../winscw/c/Data/sound/enemy_explosion.wav" \ +"sound/myship_explosion.wav ../winscw/c/Data/sound/myship_explosion.wav" \ +"sound/enableship.wav ../winscw/c/Data/sound/enableship.wav" \ +"sound/laser.wav ../winscw/c/Data/sound/laser.wav" \ +"sound/level2.wav ../winscw/c/Data/sound/level2.wav" \ +"qml/Level.qml ../winscw/c/Data/Level.qml" \ +"qml/Level.js ../winscw/c/Data/Level.js" \ +"qml/Enemy.qml ../winscw/c/Data/Enemy.qml" + + +myQml.sources = qml/* +myQml.path = c:/System/quickhitdata/leveltemplate +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/leveltemplate/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/leveltemplate/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { +# Copy level sounds and graphics into right destination +system(mkdir c:\quickhitdata\leveltemplate) +system(mkdir c:\quickhitdata\leveltemplate\gfx) +system(mkdir c:\quickhitdata\leveltemplate\sound) +system(copy qml\*.* c:\quickhitdata\leveltemplate) +system(copy gfx\*.* c:\quickhitdata\leveltemplate\gfx) +system(copy sound\*.* c:\quickhitdata\leveltemplate\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/leveltemplate/ +myQml.files += qml/* +myGraphic.path = /home/user/.quickhitdata/leveltemplate/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/leveltemplate/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml new file mode 100755 index 0000000..5112799 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Enemy.qml @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Image { + id: enemy + + // *************************************************** + // *** NOTE: This "enemy "is mandatory enemy object name for all enemy QML files + objectName: "enemy" + + smooth:true + opacity: 0 // 0=hidden by default + fillMode:Image.PreserveAspectFit + source:"file:/"+LevelPlugin.pictureRootPath()+"enemy1.png" + + property int enemySpeed: LevelPlugin.enemySpeed() + + // *************************************************** + // *** NOTE: This "pause(bool)" function is mandatory for all enemies QML files + function pause(doPause) { + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js new file mode 100755 index 0000000..d3349d9 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.js @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 hiddenEnemies = new Array() + diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml new file mode 100755 index 0000000..9c67135 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTemplate/qml/Level.qml @@ -0,0 +1,96 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import Qt.labs.particles 1.0 + +// Level own JavaScript file +import "Level.js" as LevelScript + +Rectangle { + id: enemies + anchors.fill: parent + property int enemiesCreated: 0 + property int enemiesEnabled: 0 + color: "black" + + // *************************************************** + // *** NOTE: This "pause(bool)" function is mandatory for all level QML files + function pause(doPause) { + } + + // *************************************************** + // *** NOTE: Level object name "level" is mandatory for all level QML files + objectName: "level" + + // Enemy placeholder. Have to exist at least one enemy for prevent to level be stopped + Enemy { + x: parent.width / 2 + y: parent.height / 2 + opacity: 1 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Execute explode particle effect + function explode(x,y) { + explodeParticles.x = x + explodeParticles.y = y + explodeParticles.burst(20) + explodeParticles.opacity = 1 + } + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + // Explode particle effect + Particles { + id: explodeParticles + opacity: 0 + width: 1 + height: 1 + emissionRate: 0 + source: "file:/"+LevelPlugin.pictureRootPath()+"blue_fire.png" + lifeSpan: 500 + lifeSpanDeviation: 2000 + count: -1 + angle: 270 + angleDeviation: 65 + velocity: 100 + velocityDeviation: 100 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 300 + acceleration: 50 + } + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav new file mode 100755 index 0000000..8076f0f Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/crash.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav new file mode 100755 index 0000000..6fe5fe8 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enableship.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav new file mode 100755 index 0000000..fd338e6 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/enemy_explosion.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav new file mode 100755 index 0000000..c3b58b2 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/laser.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav new file mode 100755 index 0000000..24d3917 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/level2.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav new file mode 100755 index 0000000..e22d030 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/myship_explosion.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav new file mode 100755 index 0000000..8c0dee9 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav new file mode 100755 index 0000000..d2b451c Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTemplate/sound/rocket_explosion.wav differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog b/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog new file mode 100755 index 0000000..106ef66 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/changelog @@ -0,0 +1,11 @@ +leveltwo (1.1.0) unstable; urgency=low + + * Final graphics + + -- Antonio Aloisio Wed, 5 Jan 2011 10:05:04 +0200 + +leveltwo (1.0.0) unstable; urgency=low + + * First version + + -- Antonio Aloisio Tue, 19 Oct 2010 10:05:04 +0200 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/compat b/demos/mobile/quickhit/plugins/LevelTwo/debian/compat new file mode 100755 index 0000000..7f8f011 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/compat @@ -0,0 +1 @@ +7 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/control b/demos/mobile/quickhit/plugins/LevelTwo/debian/control new file mode 100755 index 0000000..8f9d05e --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/control @@ -0,0 +1,11 @@ +Source: leveltwo +Section: user/games +Priority: extra +Maintainer: Antonio Aloisio +Standards-Version: 3.7.2 + +Package: leveltwo +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: QuickHit - LevelTwo + QuickHit - LevelTwo diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright b/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright new file mode 100755 index 0000000..fb9e5a8 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/copyright @@ -0,0 +1,8 @@ +This is qmultiwinexample, written and maintained by Forum Nokia Antonio Aloisio +on Tue, 19 Oct 2010 10:05:04 +0200 + + +Copyright Holder: Nokia (c) 2010 + +License: + diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs b/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs new file mode 100755 index 0000000..80507f1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/share/applications/hildon diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist b/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist new file mode 100755 index 0000000..f3146fa1 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/levelone.tarlist @@ -0,0 +1,41 @@ +755 root root . home / +755 root root . home/maemo / +755 root root . home/maemo/quickhitdata / +755 root root . home/maemo/quickhitdata/levelone / +644 root root . home/maemo/quickhitdata/levelone/Level.qml debian/levelone/home/maemo/quickhitdata/levelone/Level.qml +755 root root . home/maemo/quickhitdata/leveltwo / +755 root root . home/maemo/quickhitdata/leveltwo/gfx / +644 root root . home/maemo/quickhitdata/leveltwo/gfx/background3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/background3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/blue_fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy1.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy1.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/enemy_missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/fire2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/fire2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/missile2.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/missile2.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/moon.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/moon.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/ship.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/ship.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/star3.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/star3.png +644 root root . home/maemo/quickhitdata/leveltwo/gfx/transparent.png debian/levelone/home/maemo/quickhitdata/leveltwo/gfx/transparent.png +755 root root . home/maemo/quickhitdata/leveltwo/sound / +644 root root . home/maemo/quickhitdata/leveltwo/sound/crash.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/crash.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/enemy_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/laser.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/laser.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/myship_explosion.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket.wav +644 root root . home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav debian/levelone/home/maemo/quickhitdata/leveltwo/sound/rocket_explosion.wav +755 root root . usr / +755 root root . usr/bin / +755 root root . usr/lib / +755 root root . usr/lib/qt4 / +755 root root . usr/lib/qt4/plugins / +755 root root . usr/lib/qt4/plugins/quickhitlevels / +644 root root . usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so debian/levelone/usr/lib/qt4/plugins/quickhitlevels/libleveltwo.so +755 root root . usr/share / +755 root root . usr/share/applications / +755 root root . usr/share/applications/hildon / +755 root root . usr/share/doc / +755 root root . usr/share/doc/levelone / +644 root root . usr/share/doc/levelone/changelog.gz debian/levelone/usr/share/doc/levelone/changelog.gz +644 root root . usr/share/doc/levelone/copyright debian/levelone/usr/share/doc/levelone/copyright diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst b/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst new file mode 100755 index 0000000..79fb6dd --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh -e + +gtk-update-icon-cache -f /usr/share/icons/hicolor + +exit 0 diff --git a/demos/mobile/quickhit/plugins/LevelTwo/debian/rules b/demos/mobile/quickhit/plugins/LevelTwo/debian/rules new file mode 100755 index 0000000..5dac6e0 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/debian/rules @@ -0,0 +1,91 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +APPNAME := leveltwo + + +configure: configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/$(APPNAME).sgml > $(APPNAME).1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$(APPNAME). + $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/$(APPNAME) install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + # dh_strip + dh_compress + dh_fixperms +# dh_perl + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png new file mode 100755 index 0000000..8fbf2f4 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png new file mode 100755 index 0000000..3a135d2 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/background_loop.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png new file mode 100755 index 0000000..8667a39 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/blue_fire.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png new file mode 100755 index 0000000..94f149b Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy1.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png new file mode 100755 index 0000000..5011d75 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/enemy_missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png new file mode 100755 index 0000000..8401034 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png new file mode 100755 index 0000000..139aa61 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/fire2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png new file mode 100755 index 0000000..86bb41b Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png new file mode 100755 index 0000000..dacd610 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/missile2.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png new file mode 100755 index 0000000..cb7851c Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/ship.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png new file mode 100755 index 0000000..70af0f3 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/star3.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png b/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png new file mode 100755 index 0000000..3aa1e41 Binary files /dev/null and b/demos/mobile/quickhit/plugins/LevelTwo/gfx/transparent.png differ diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp new file mode 100755 index 0000000..8103142 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.cpp @@ -0,0 +1,115 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 "leveltwo.h" +#include + + +LevelTwo::LevelTwo() +{ +} + +LevelTwo::~LevelTwo() +{ +} + +QString LevelTwo::pathPrefix() +{ + /* +QDir::rootPath() +For Unix operating systems this returns "/". +For Windows file systems this normally returns "c:/". +On Symbian this typically returns "c:/data", +*/ + +#ifdef Q_WS_MAEMO_5 + return "/home/user/."; +#elif defined Q_OS_WIN32 + return QDir::rootPath(); +#else + //return QDir::rootPath()+"/"; + return "c:/System/"; +#endif +} + +QStringList LevelTwo::levelSounds() +{ + QStringList list; + + + // NOTE: Mandatory sounds/indexs for the all levels + // 0 = Enemy explode + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/enemy_explosion.wav"); + // 1 = You explode + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/myship_explosion.wav"); + // 2 = Missile fires + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/laser.wav"); + // 3 = Emeny Missile fires + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/rocket.wav"); + + // Additional sounds + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/enableship.wav"); + list.append(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/sound/level2.wav"); + + + return list; +} + +QVariant LevelTwo::getData(QVariant key) +{ + QVariant ret; + switch (key.toInt()) { + case 1: { + // Any data what you need for this key + // Set your data into QVariant (ret) + break; + } + default: { + break; + } + } + return ret; +} + +QVariant LevelTwo::graphSize(QVariant pathToGraph) +{ + QVariant ret; + m_imageReader.setFileName(pathToGraph.toString()); + QSize imageSize = m_imageReader.size(); + ret.setValue(imageSize); + return ret; +} + +// This Qt macro exports the plugin class LevelTwo with the name levelplugins. +// There should be exactly one occurrence of this LevelTwo macro in a Qt plugin's source code. +Q_EXPORT_PLUGIN2(levelplugins, LevelTwo); diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h new file mode 100755 index 0000000..9b04a9d --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $QT_END_LICENSE$ + * + *****************************************************************************/ + +#ifndef LevelTwo_H +#define LevelTwo_H + +#include +#include +#include + +#include "levelplugininterface.h" + +class LevelTwo : public LevelPluginInterface +{ + Q_OBJECT + + // This macro tells Qt which interfaces the class implements. + // This is used when implementing plugins. + Q_INTERFACES(LevelPluginInterface) + +public: + LevelTwo(); + ~LevelTwo(); + + static QString pathPrefix(); + +public: // From LevelPluginInterface + + QStringList levelSounds(); + + Q_INVOKABLE QVariant getData(QVariant key); + + Q_INVOKABLE QVariant graphSize(QVariant pathToGraph); + + Q_INVOKABLE QVariant enemyCount() { return QVariant(35); } + Q_INVOKABLE QVariant enemyRowCount() { return QVariant(0); } + Q_INVOKABLE QVariant enemySpeed() { return QVariant(20000); } + Q_INVOKABLE QVariant enemyFireSpeed() { return QVariant(500); } + + // Root paths for the QML, Pictures and Sounds + Q_INVOKABLE QVariant qmlRootPath() { return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/"); } + Q_INVOKABLE QVariant pictureRootPath() { return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/"); } + + // Full paths + Q_INVOKABLE QVariant pathToTransparentEnemyPic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/transparent.png");} + Q_INVOKABLE QVariant pathToMissilePic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/missile2.png");} + Q_INVOKABLE QVariant pathToEnemyMissilePic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/enemy_missile2.png");} + Q_INVOKABLE QVariant pathToMyShipPic() {return QVariant(LevelTwo::pathPrefix()+"quickhitdata/leveltwo/gfx/ship.png");} + +protected: + QImageReader m_imageReader; +}; + +#endif // LevelTwo_H diff --git a/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro new file mode 100755 index 0000000..171ee6c --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/leveltwo.pro @@ -0,0 +1,108 @@ + +# Copyright (c) 2010 Nokia Corporation. + +TEMPLATE = lib + +#VERSION = 1.1.0 + +CONFIG += plugin + +INCLUDEPATH += ../ + +HEADERS = leveltwo.h + +SOURCES = leveltwo.cpp + +TARGET = $$qtLibraryTarget(leveltwo) + +OTHER_FILES += qml/Level.qml \ + qml/Enemy.qml \ + qml/Level.js + + +# SYMBIAN --------------------------- +symbian: { +# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files +load(data_caging_paths) + +# EPOCALLOWDLLDATA have to set true because Qt macros has initialised global data +TARGET.EPOCALLOWDLLDATA=1 +TARGET.UID3 = 0xE07dfb67 + +TARGET.CAPABILITY = NetworkServices \ + Location \ + ReadUserData \ + WriteUserData \ + LocalServices \ + UserEnvironment + +# Defines plugin stub file into Symbian .pkg package +pluginDep.sources = leveltwo.dll +pluginDep.path = $$QT_PLUGINS_BASE_DIR/quickhitlevels +DEPLOYMENT += pluginDep + +# Graphics and Sounds for the plugin +BLD_INF_RULES.prj_exports += "gfx/background2.png ../winscw/c/Data/gfx/background2.png" \ +"gfx/background_loop.png ../winscw/c/Data/gfx/background_loop.png" \ +"gfx/enemy1.png ../winscw/c/Data/gfx/enemy1.png" \ +"gfx/fire2.png ../winscw/c/Data/gfx/fire2.png" \ +"gfx/fire.png ../winscw/c/Data/gfx/fire.png" \ +"gfx/missile2.png ../winscw/c/Data/gfx/missile2.png" \ +"gfx/enemy_missile2.png ../winscw/c/Data/gfx/enemy_missile2.png" \ +"gfx/ship.png ../winscw/c/Data/gfx/ship.png" \ +"gfx/transparent.png ../winscw/c/Data/gfx/transparent.png" \ +"gfx/star3.png ../winscw/c/Data/gfx/star3.png" \ +"gfx/blue_fire.png ../winscw/c/Data/gfx/blue_fire.png" \ +"sound/enemy_explosion.wav ../winscw/c/Data/sound/enemy_explosion.wav" \ +"sound/myship_explosion.wav ../winscw/c/Data/sound/myship_explosion.wav" \ +"sound/enableship.wav ../winscw/c/Data/sound/enableship.wav" \ +"sound/laser.wav ../winscw/c/Data/sound/laser.wav" \ +"sound/level2.wav ../winscw/c/Data/sound/level2.wav" \ +"qml/Level.qml ../winscw/c/Data/Level.qml" \ +"qml/Level.js ../winscw/c/Data/Level.js" \ +"qml/Enemy.qml ../winscw/c/Data/Enemy.qml" + + +myQml.sources = qml/* +myQml.path = c:/System/quickhitdata/leveltwo +myGraphic.sources = gfx/* +myGraphic.path = c:/System/quickhitdata/leveltwo/gfx +mySound.sources = sound/* +mySound.path = c:/System/quickhitdata/leveltwo/sound +# Takes qml, graphics and sounds into Symbian SIS package file (.pkg) +DEPLOYMENT += myQml myGraphic mySound + +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +# Installs binaries +INSTALLS += target +} + +# WINDOWS --------------------------- +win32: { + +# Copy level sounds and graphics into right destination +system(mkdir c:\quickhitdata\leveltwo) +system(mkdir c:\quickhitdata\leveltwo\gfx) +system(mkdir c:\quickhitdata\leveltwo\sound) +system(copy qml\*.* c:\quickhitdata\leveltwo) +system(copy gfx\*.* c:\quickhitdata\leveltwo\gfx) +system(copy sound\*.* c:\quickhitdata\leveltwo\sound) + +# Installs binaries +target.path += $$[QT_INSTALL_PLUGINS]/quickhitlevels +INSTALLS += target +} + +# MAEMO_5 --------------------------- +maemo5: { +myQml.path = /home/user/.quickhitdata/leveltwo/ +myQml.files += qml/* +myGraphic.path = /home/user/.quickhitdata/leveltwo/gfx/ +myGraphic.files += gfx/* +mySound.path = /home/user/.quickhitdata/leveltwo/sound/ +mySound.files += sound/* + +target.path += /usr/lib/qt4/plugins/quickhitlevels +# Installs qml, binaries, sounds and graphics +INSTALLS += target myGraphic mySound myQml +} diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml b/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml new file mode 100755 index 0000000..40244c2 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Enemy.qml @@ -0,0 +1,77 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 + +Image { + id: enemy + objectName: "enemy" + smooth:true + opacity: 0 // 0=hidden by default + fillMode:Image.PreserveAspectFit + source:"file:/"+LevelPlugin.pictureRootPath()+"enemy1.png" + + property int enemySpeed: LevelPlugin.enemySpeed() + + function pause(doPause) { + if (doPause) { + upToDownAnim.pause() + rightLeftAnim.pause() + } else { + upToDownAnim.resume() + rightLeftAnim.resume() + } + } + + function startMovingAnim() { + upToDownAnim.restart() + rightLeftAnim.restart() + } + + // Right-left animation + SequentialAnimation { + id: rightLeftAnim + loops: Animation.Infinite + NumberAnimation { target:enemy; property:"x"; + to:gameArea.width - enemy.width; easing.type: Easing.OutQuad; duration: 3000 } + NumberAnimation { target:enemy; property:"x"; to:0; easing.type: Easing.OutQuad; duration: 3000 } + } + + // Up to down animation + SequentialAnimation { + id: upToDownAnim + PropertyAnimation { target:enemy; property:"y"; to: gameArea.height; + easing.type: Easing.Linear; duration: enemy.enemySpeed } + PropertyAction { target: enemy; properties: "opacity"; value: 0 } + } +} diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js new file mode 100755 index 0000000..d3349d9 --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.js @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 hiddenEnemies = new Array() + diff --git a/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml new file mode 100755 index 0000000..1f31cca --- /dev/null +++ b/demos/mobile/quickhit/plugins/LevelTwo/qml/Level.qml @@ -0,0 +1,221 @@ +/****************************************************************************** + * + * Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * Contact: Nokia Corporation (qt-info@nokia.com) + * + * $QT_BEGIN_LICENSE:BSD$ + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the author organization 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 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 Qt 4.7 +import Qt.labs.particles 1.0 +import "Level.js" as LevelScript + +Item { + id: enemies + anchors.fill: parent + + property int enemiesCreated: 0 + property int enemiesEnabled: 0 + + property int backOneTop + property int backTwoTop + + // Long background 2 + Image { + id: longBackground_2 + source: "file:/"+LevelPlugin.pictureRootPath()+"background_loop.png" + fillMode: Image.Stretch + smooth: false + width: gameArea.width + height: gameArea.height + } + + // Long background 1 + Image { + id: longBackground_1 + source: "file:/"+LevelPlugin.pictureRootPath()+"background_loop.png" + fillMode: Image.Stretch + smooth: false + width: gameArea.width + height: gameArea.height + } + + // Long background Up to down animation + ParallelAnimation { + id: backgroundAnim; + loops: Animation.Infinite + PropertyAnimation { target:longBackground_1; property:"y"; + from:backOneTop; to:gameArea.height; easing.type:Easing.Linear; duration:10000 } + PropertyAnimation { target:longBackground_2; property:"y"; + from:backTwoTop; to:backOneTop; easing.type:Easing.Linear; duration:10000 } + } + + + + // *************************************************** + // *** NOTE: This is mandatory for all level QML files + function pause(doPause) { + if (doPause) { + enemyCreationTimer.stop() + backgroundAnim.stop() + } else { + enemyCreationTimer.restart() + backgroundAnim.restart() + } + for (var i=0;i