SportSelector.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import Qt 4.7
  2. import "../js/FutuHeia.js" as FutuHeia
  3. Item {
  4. id: sportSelector
  5. width: screenWidth
  6. property string selectedName
  7. property int selectedId
  8. function setApiVariables(sportModelIndex) {
  9. selectedName = sportsModel.get(sportModelIndex).name;
  10. selectedId = sportsModel.get(sportModelIndex).sportId;
  11. FutuHeia.log("selectedName = " + selectedName);
  12. FutuHeia.log("selectedId = " + selectedId);
  13. }
  14. Component {
  15. id: sportSelectorItem
  16. Item {
  17. id: rect
  18. height: sportSelector.height
  19. width: 200
  20. visible: PathView.onPath
  21. opacity: PathView.transparency
  22. scale: PathView.scaling
  23. MouseArea {
  24. anchors.fill: parent
  25. onClicked: sportsView.currentIndex = index
  26. }
  27. Text {
  28. id: textItem
  29. anchors.fill: parent
  30. text: name
  31. color: PathView.isCurrentItem ? heiaYellow : heiaLightGrey
  32. anchors.horizontalCenter: parent.horizontalCenter
  33. font.family: appItem.applicationFont
  34. font.pixelSize: appItem.applicationFontSize + 10
  35. smooth: true
  36. wrapMode: Text.WordWrap
  37. horizontalAlignment: "AlignHCenter"
  38. verticalAlignment: "AlignVCenter"
  39. }
  40. transform: [
  41. Rotation {
  42. angle: PathView.angle
  43. origin.x: rect.width/2
  44. axis.x: 0; axis.y: 1; axis.z: 0
  45. }
  46. ]
  47. }
  48. }
  49. AnimatedImage {
  50. visible: appItem.loadingSports
  51. anchors.centerIn: parent;
  52. source: "loading.gif"
  53. }
  54. /*
  55. Text {
  56. visible: appItem.loadingSports
  57. text: qsTr("Getting sports...");
  58. font.family: appItem.applicationFont;
  59. font.pixelSize: appItem.applicationFontSize;
  60. anchors.centerIn: parent;
  61. color: appItem.heiaTextColor;
  62. }
  63. */
  64. PathView {
  65. visible: !appItem.loadingSports
  66. id: sportsView
  67. y: -10
  68. width: sportSelector.width
  69. height: sportSelector.height
  70. pathItemCount: 10
  71. model: sportsModel
  72. delegate: sportSelectorItem
  73. preferredHighlightBegin: 0.16
  74. preferredHighlightEnd: 0.16
  75. dragMargin: sportSelector.height/2
  76. currentIndex: 0
  77. path: Path {
  78. startX: 0
  79. startY: sportSelector.height/8
  80. PathAttribute { name: "angle"; value: -120.0 }
  81. PathAttribute { name: "scaling"; value: 0.2 }
  82. PathAttribute { name: "transparency"; value: 0.0 }
  83. PathPercent { value: 0.0 }
  84. PathQuad {x: sportSelector.width/5; y: sportSelector.height-30; controlX: 10; controlY: sportSelector.height-30}
  85. PathAttribute { name: "angle"; value: 0.0 }
  86. PathAttribute { name: "scaling"; value: 1.0 }
  87. PathAttribute { name: "transparency"; value: 1.0 }
  88. PathQuad {x: sportSelector.width/2; y: sportSelector.height/2; controlX: 2*sportSelector.width/5; controlY: sportSelector.height-30}
  89. PathAttribute { name: "angle"; value: 70.0 }
  90. PathAttribute { name: "scaling"; value: 0.44 }
  91. PathAttribute { name: "transparency"; value: 0.7 }
  92. PathPercent { value: 0.3 }
  93. PathQuad {x: sportSelector.width-sportSelector.width/5; y: sportSelector.height/2; controlX: 3*sportSelector.width/5; controlY: sportSelector.height/3}
  94. PathAttribute { name: "angle"; value: 0.0 }
  95. PathAttribute { name: "scaling"; value: 0.5 }
  96. PathAttribute { name: "transparency"; value: 0.7 }
  97. PathPercent { value: 0.65 }
  98. PathQuad {x: sportSelector.width-10; y: sportSelector.height/8; controlX: sportSelector.width; controlY: sportSelector.height/2+sportSelector.height/8}
  99. PathAttribute { name: "angle"; value: 90.0 }
  100. PathAttribute { name: "scaling"; value: 0.1 }
  101. PathAttribute { name: "transparency"; value: 0.0 }
  102. PathPercent { value: 1.0 }
  103. }
  104. onCurrentIndexChanged: setApiVariables(currentIndex)
  105. }
  106. }