TicketButton.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * Copyright (c) 2011-2012 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. Item {
  6. id:ticketButton
  7. property int buttonId: 0
  8. signal btnClicked(int buttonId)
  9. function sendBtnClicked()
  10. {
  11. if (buttonId != 0) {
  12. btnClicked(buttonId);
  13. }
  14. }
  15. function resetImage()
  16. {
  17. imageId2.x = 0;
  18. imageId2.y = 0;
  19. imageId2.rotation = 0;
  20. }
  21. Image {
  22. id: imageId1
  23. fillMode: Image.PreserveAspectFit
  24. smooth: true
  25. source: {
  26. if (buttonId == 1) {
  27. "qrc:/gfx/exit_full.png";
  28. }
  29. else if (buttonId == 2) {
  30. "qrc:/gfx/info_full.png";
  31. }
  32. else if (buttonId == 3) {
  33. "qrc:/gfx/save_full.png";
  34. }
  35. else {
  36. console.log("Error: No buttonId defined!");
  37. }
  38. }
  39. }
  40. Image {
  41. id: imageId2
  42. fillMode: Image.PreserveAspectFit
  43. smooth: true
  44. source: {
  45. if (buttonId == 1) {
  46. "qrc:/gfx/exit_full.png";
  47. }
  48. else if (buttonId == 2) {
  49. "qrc:/gfx/info_full.png";
  50. }
  51. else if (buttonId == 3) {
  52. "qrc:/gfx/save_full.png";
  53. }
  54. else {
  55. console.log("Error: No buttonId defined!");
  56. }
  57. }
  58. }
  59. SequentialAnimation {
  60. id:btnAnim
  61. ParallelAnimation {
  62. NumberAnimation {
  63. target: imageId2
  64. property: "rotation"
  65. to: 20
  66. duration: 800
  67. }
  68. NumberAnimation {
  69. target: imageId2
  70. property: "x"
  71. easing.type:Easing.InBack
  72. to: imageId2.x + 100
  73. duration: 800
  74. }
  75. NumberAnimation {
  76. target: imageId2
  77. property: "y"
  78. easing.type:Easing.InBack
  79. to: imageId2.y + 120
  80. duration: 800
  81. }
  82. }
  83. ScriptAction { script: sendBtnClicked(); }
  84. ScriptAction { script: resetImage(); }
  85. }
  86. MouseArea {
  87. anchors.fill: imageId1
  88. onClicked: btnAnim.restart()
  89. }
  90. }