slideshow.qml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. import Qt 4.7
  5. Rectangle {
  6. id: slideShow
  7. function initialize() { }
  8. color: "black"
  9. anchors.fill: parent
  10. // This model information might be better in XML file.
  11. ListModel {
  12. id: slidesModel
  13. ListElement {
  14. image: "../fancypicker/qtqp_back1.jpg"
  15. text1: "The Qt Quick Playground demonstrates the features of the Qt Quick"
  16. text2: "Watch specially for the animations and effects"
  17. text3: "Check also the QML source code of each demo"
  18. logo: ""
  19. }
  20. ListElement {
  21. image: "../fancypicker/qtqp_back2.jpg"
  22. text1: "Most of the code is QML"
  23. text2: "Some of the logic is made with Javascript"
  24. text3: "Added with some pieces of Qt"
  25. logo: ""
  26. }
  27. ListElement {
  28. image: "../fancypicker/qtqp_back3.jpg"
  29. text1: "Play around"
  30. text2: "Get to know what Qt Quick offers"
  31. text3: "Have fun with Qt Quick Playground!"
  32. logo: ""
  33. }
  34. ListElement {
  35. image: ""
  36. text1: ""
  37. text2: ""
  38. text3: ""
  39. logo: "Forum_Nokia_03_RGB_strap.gif"
  40. }
  41. }
  42. Component {
  43. id: delegate
  44. Item {
  45. id: slide
  46. property int fadeDuration: 2000
  47. property int textAnimationDuration: 2000
  48. property int textPixelSize: height / 15
  49. // the slide will cover whole screen
  50. width: slideShow.width + 1; height: slideShow.height
  51. Rectangle {
  52. anchors.fill: parent
  53. color: "white"
  54. Image {
  55. id: background
  56. source: image
  57. anchors.fill: parent
  58. fillMode: "Stretch"
  59. clip: true
  60. Text {
  61. id: t1
  62. Behavior on x { NumberAnimation { duration: slide.textAnimationDuration; easing.type: "OutCubic" } }
  63. x: 100
  64. anchors.top: parent.top; anchors.topMargin: parent.height / 8
  65. width: parent.width - 100
  66. wrapMode: "WordWrap"
  67. text: text1
  68. color: "white"
  69. font.bold: true
  70. font.pixelSize: slide.textPixelSize
  71. style: Text.Raised
  72. Behavior on opacity { NumberAnimation { duration: slide.fadeDuration } }
  73. opacity: 0
  74. }
  75. Text {
  76. id: t2
  77. Behavior on x { NumberAnimation { duration: slide.textAnimationDuration; easing.type: "OutCubic" } }
  78. x: 100
  79. anchors.verticalCenter: parent.verticalCenter
  80. width: parent.width - 100
  81. wrapMode: "WordWrap"
  82. text: text2
  83. color: "white"
  84. font.bold: true
  85. font.pixelSize: slide.textPixelSize
  86. style: Text.Raised
  87. Behavior on opacity { NumberAnimation { duration: slide.fadeDuration } }
  88. opacity: 0
  89. }
  90. Text {
  91. id: t3
  92. Behavior on x { NumberAnimation { duration: slide.textAnimationDuration; easing.type: "OutCubic" } }
  93. x: 100
  94. anchors.bottom: parent.bottom; anchors.bottomMargin: parent.height / 8
  95. width: parent.width - 100
  96. wrapMode: "WordWrap"
  97. text: text3
  98. color: "white"
  99. font.bold: true
  100. font.pixelSize: slide.textPixelSize
  101. style: Text.Raised
  102. Behavior on opacity { NumberAnimation { duration: slide.fadeDuration } }
  103. opacity: 0
  104. }
  105. Image {
  106. id: l
  107. source: logo
  108. width: 367; height: 149
  109. anchors.centerIn: parent
  110. }
  111. Timer {
  112. id: timer
  113. property int timerPosition: 0
  114. interval: 2000
  115. running: true
  116. repeat: true
  117. onTriggered: {
  118. timer.timerPosition = timer.timerPosition + 1
  119. if(timer.timerPosition == 1) { t1.x = 50; t1.opacity = 1.0 }
  120. else if(timer.timerPosition == 2) { t2.x = 50; t2.opacity = 2.0 }
  121. else if(timer.timerPosition == 3) { t3.x = 50; t3.opacity = 3.0 }
  122. else if(timer.timerPosition == 5) {
  123. timer.running = false
  124. t1.opacity = 0
  125. t2.opacity = 0
  126. t3.opacity = 0
  127. if(view.currentIndex == 3) {
  128. // We will close the slide show when it is done
  129. sidePanel.closeClicked()
  130. }
  131. else {
  132. view.incrementCurrentIndex() // Change the slide
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. ListView {
  142. id: view
  143. anchors.fill: parent
  144. delegate: delegate
  145. model: slidesModel
  146. snapMode: "SnapToItem"
  147. keyNavigationWraps: true
  148. orientation: "Horizontal"
  149. cacheBuffer: 0
  150. interactive: false
  151. }
  152. }