MainView.qml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import QtQuick 2.0
  2. import QtQuick.Particles 2.0
  3. import QtGraphicalEffects 1.0
  4. Item {
  5. id: root
  6. // Set this to blur the mainView when showing something on top of it
  7. property real blurAmount: 0
  8. // Updates the blur shader source, best called right before adding blurAmount
  9. function scheduleUpdate() {
  10. mainContentSource.scheduleUpdate();
  11. }
  12. anchors.fill: parent
  13. // Update blur shader source when width/height changes
  14. onHeightChanged: {
  15. root.scheduleUpdate();
  16. }
  17. onWidthChanged: {
  18. root.scheduleUpdate();
  19. }
  20. Item {
  21. id: mainViewArea
  22. anchors.fill: parent
  23. Background {
  24. id: background
  25. }
  26. ListView {
  27. id: listView
  28. property real globalLightPosX: lightImage.x / root.width
  29. property real globalLightPosY: lightImage.y / root.height
  30. // Normal-mapped cover shared among delegates
  31. ShaderEffectSource {
  32. id: coverNmapSource
  33. sourceItem: Image { source: "images/cover_nmap.png" }
  34. hideSource: true
  35. visible: false
  36. }
  37. anchors.fill: parent
  38. spacing: -60
  39. model: moviesModel
  40. delegate: DelegateItem {
  41. name: model.name
  42. }
  43. highlightFollowsCurrentItem: true
  44. highlightRangeMode: ListView.StrictlyEnforceRange
  45. highlightMoveDuration: 400
  46. preferredHighlightBegin: root.height * 0.5 - 140
  47. preferredHighlightEnd: root.height * 0.5 - 140
  48. cacheBuffer: 4000
  49. }
  50. Text {
  51. id: headingText
  52. anchors.top: parent.top
  53. anchors.topMargin: 30
  54. anchors.horizontalCenter: parent.horizontalCenter
  55. horizontalAlignment: Text.AlignHCenter
  56. width: 400
  57. text: "My Movies\nTop 20"
  58. style: Text.Outline
  59. styleColor: "#b0a030"
  60. color: "#d9cf9e"
  61. font.pixelSize: settings.fontL
  62. opacity: listView.atYBeginning
  63. Behavior on opacity {
  64. NumberAnimation { duration: 500; easing.type: Easing.InOutQuad }
  65. }
  66. }
  67. Text {
  68. id: titleText
  69. anchors.verticalCenter: parent.verticalCenter
  70. anchors.verticalCenterOffset: -40
  71. anchors.horizontalCenter: parent.horizontalCenter
  72. width: 180 + parent.width * 0.25
  73. wrapMode: Text.WordWrap
  74. horizontalAlignment: Text.AlignHCenter
  75. text: listView.currentIndex+1 + ". " + listView.currentItem.name
  76. color: "#ffffff"
  77. font.pixelSize: settings.fontL
  78. // Note: DropShadow contains original source also so this can be hidden
  79. visible: false
  80. Behavior on text {
  81. SequentialAnimation {
  82. ParallelAnimation {
  83. NumberAnimation { target: titleTextEffect; property: "opacity"; duration: 100; to: 0; easing.type: Easing.InOutQuad }
  84. NumberAnimation { target: titleTextEffect; property: "scale"; duration: 100; to: 0.6; easing.type: Easing.InOutQuad }
  85. }
  86. PropertyAction { target: titleText; property: "text" }
  87. ParallelAnimation {
  88. NumberAnimation { target: titleTextEffect; property: "opacity"; duration: 100; to: 1; easing.type: Easing.InOutQuad }
  89. NumberAnimation { target: titleTextEffect; property: "scale"; duration: 100; to: 1; easing.type: Easing.InOutQuad }
  90. }
  91. }
  92. }
  93. }
  94. // TODO: Check, does Dropshadow slowdown notably, does it render when text change animates?
  95. DropShadow {
  96. id: titleTextEffect
  97. anchors.fill: titleText
  98. horizontalOffset: 2
  99. verticalOffset: 2
  100. radius: 12.0
  101. samples: 16
  102. color: "#000000"
  103. source: titleText
  104. }
  105. Image {
  106. anchors.bottom: parent.bottom
  107. anchors.bottomMargin: 16
  108. anchors.horizontalCenter: parent.horizontalCenter
  109. source: "images/qt_logo.png"
  110. opacity: listView.atYEnd
  111. Behavior on opacity {
  112. NumberAnimation { duration: 500; easing.type: Easing.InOutQuad }
  113. }
  114. }
  115. // Shooting star + animation + particles
  116. AnimatedSprite {
  117. id: lightImage
  118. width: 64
  119. height: 64
  120. frameWidth: 64
  121. frameHeight: 64
  122. frameCount: 16
  123. frameRate: 15
  124. source: "images/planet_sprite.png"
  125. interpolate: true
  126. loops: Animation.Infinite
  127. visible: settings.showLighting || settings.showShootingStarParticles
  128. running: !detailsView.isShown && !infoView.isShown && (settings.showLighting || settings.showShootingStarParticles)
  129. }
  130. PathAnimation {
  131. target: lightImage
  132. duration: 5000
  133. orientation: PathAnimation.RightFirst
  134. anchorPoint: Qt.point(lightImage.width/2, lightImage.height/2)
  135. running: true
  136. paused: detailsView.isShown || infoView.isShown || (!settings.showLighting && !settings.showShootingStarParticles)
  137. loops: Animation.Infinite
  138. path: Path {
  139. id: lightAnimPath
  140. startX: root.width*0.4; startY: root.height*0.3
  141. PathCurve { x: root.width*0.8; y: root.height*0.2 }
  142. PathCurve { x: root.width*0.8; y: root.height*0.7 }
  143. PathCurve { x: root.width*0.1; y: root.height*0.6 }
  144. PathCurve { x: root.width*0.4; y: root.height*0.3 }
  145. }
  146. }
  147. ParticleSystem {
  148. anchors.fill: parent
  149. paused: detailsView.isShown || infoView.isShown
  150. // Shooting star particles
  151. ImageParticle {
  152. source: "images/particle.png"
  153. color: "#ffefaf"
  154. colorVariation: settings.showColors ? 1.0 : 0.1
  155. alpha: 0
  156. }
  157. Emitter {
  158. id: shootingStarEmitter
  159. emitRate: settings.showShootingStarParticles ? 100 : 0
  160. lifeSpan: 2000
  161. x: lightImage.x + lightImage.width/2
  162. y: lightImage.y + lightImage.height/2
  163. velocity: PointDirection {xVariation: 8; yVariation: 8;}
  164. acceleration: PointDirection {xVariation: 12; yVariation: 12;}
  165. size: 16
  166. sizeVariation: 8
  167. }
  168. Emitter {
  169. id: shootingStarBurst
  170. emitRate: 0
  171. lifeSpan: 2000
  172. x: lightImage.x + lightImage.width/2
  173. y: lightImage.y + lightImage.height/2
  174. velocity: PointDirection {xVariation: 60; yVariation: 60;}
  175. acceleration: PointDirection {xVariation: 40; yVariation: 40;}
  176. size: 24
  177. sizeVariation: 16
  178. }
  179. // Dust/Smoke particles
  180. ImageParticle {
  181. groups: ["smoke"]
  182. source: "images/smoke.png"
  183. color: "#ffffff"
  184. alpha: 0.9
  185. opacity: 0.5
  186. colorVariation: settings.showColors ? 0.5 : 0.0
  187. rotationVariation: 180
  188. }
  189. Emitter {
  190. y: root.height * 0.8
  191. anchors.horizontalCenter: parent.horizontalCenter
  192. width: 200 + parent.width * 0.3
  193. height: root.height * 0.3
  194. emitRate: settings.showFogParticles ? 20 : 0
  195. lifeSpan: 3000
  196. lifeSpanVariation: 1000
  197. group: "smoke"
  198. size: 256
  199. sizeVariation: 128
  200. acceleration: PointDirection { y: -80; xVariation: 20 }
  201. }
  202. Emitter {
  203. y: root.height * 0.9
  204. anchors.horizontalCenter: parent.horizontalCenter
  205. width: 200 + parent.width * 0.2
  206. height: root.height * 0.2
  207. emitRate: settings.showFogParticles ? 30 : 0
  208. lifeSpan: 2000
  209. group: "smoke"
  210. size: 256
  211. sizeVariation: 128
  212. acceleration: PointDirection { y: -20; xVariation: 40 }
  213. }
  214. Turbulence {
  215. groups: ["smoke"]
  216. width: parent.width
  217. height: parent.height * 0.8
  218. strength: 60
  219. }
  220. }
  221. SettingsView {
  222. id: settingsView
  223. }
  224. }
  225. FastBlur {
  226. anchors.fill: mainViewArea
  227. radius: root.blurAmount
  228. visible: root.blurAmount
  229. source: ShaderEffectSource {
  230. id: mainContentSource
  231. anchors.fill: parent
  232. sourceItem: mainViewArea
  233. hideSource: false
  234. live: false
  235. visible: root.blurAmount
  236. }
  237. }
  238. }