AvView.qml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /**
  2. * Copyright © 2010 Digia Plc
  3. * Copyright © 2010 Nokia Corporation
  4. *
  5. * All rights reserved.
  6. *
  7. * Nokia and Nokia Connecting People are registered trademarks of
  8. * Nokia Corporation.
  9. * Java and all Java-based marks are trademarks or registered
  10. * trademarks of
  11. * Sun Microsystems, Inc. Other product and company names
  12. * mentioned herein may be
  13. * trademarks or trade names of their respective owners.
  14. *
  15. *
  16. * Subject to the conditions below, you may, without charge:
  17. *
  18. * · Use, copy, modify and/or merge copies of this software and
  19. * associated documentation files (the "Software")
  20. *
  21. * · Publish, distribute, sub-licence and/or sell new software
  22. * derived from or incorporating the Software.
  23. *
  24. *
  25. * This file, unmodified, shall be included with all copies or
  26. * substantial portions
  27. * of the Software that are distributed in source code form.
  28. *
  29. * The Software cannot constitute the primary value of any new
  30. * software derived
  31. * from or incorporating the Software.
  32. *
  33. * Any person dealing with the Software shall not misrepresent
  34. * the source of the Software.
  35. *
  36. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  37. * KIND, EXPRESS OR IMPLIED,
  38. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  39. * MERCHANTABILITY, FITNESS FOR A
  40. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41. * AUTHORS OR COPYRIGHT
  42. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  43. * WHETHER IN AN ACTION
  44. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  45. * CONNECTION WITH THE
  46. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  47. */
  48. import Qt 4.7
  49. import "../colibri"
  50. import "../colibri/gradients"
  51. import "styles"
  52. Rectangle {
  53. id: window
  54. property CLStyle style: StyleHomeControlSystem {}
  55. property int playTime: 3*60*1000
  56. property bool musicOn: true
  57. property bool moviesOn: false
  58. property ListModel movieList: MovieList {}
  59. property ListModel musicList: MusicList {}
  60. property ListModel temp: ListModel {}
  61. property Image playImage: Image { source: "images/play_100x100.png"; width: window.width*0.04; height: window.height*0.06; smooth: true }
  62. property Image pauseImage: Image { source: "images/pause_100x100.png"; width: window.width*0.04; height: window.height*0.06; smooth: true }
  63. property Image stopImage: Image { source: "images/stop_100x100.png"; width: window.width*0.04; height: window.height*0.06; smooth: true }
  64. property Image prevImage: Image { source: "images/prev_100x120.png"; width: window.width*0.04; height: window.height*0.06; smooth: true }
  65. property Image nextImage: Image { source: "images/next_100x120.png"; width: window.width*0.04; height: window.height*0.06; smooth: true }
  66. signal closeWindow()
  67. /**
  68. * Sets random values to equalizer-histogram.
  69. */
  70. function equalizerRandomizer() {
  71. var array = new Array()
  72. for(var i=0; i<8; i++) {
  73. array[array.length] = new Array(Math.random()*100,"1")
  74. }
  75. equalizer.setValues(array);
  76. }
  77. /**
  78. * Sets zero values to equalizer-histogram.
  79. */
  80. function equalizerZeroer() {
  81. var array = new Array()
  82. for(var i=0; i<8; i++) {
  83. array[array.length] = new Array(0,"1")
  84. }
  85. equalizer.setValues(array);
  86. }
  87. /**
  88. * Function which is called when user press play-button.
  89. */
  90. function play() {
  91. timerEqualizer.running = !timerEqualizer.running;
  92. timerDuration.running = !timerDuration.running;
  93. if(timerEqualizer.running) {
  94. playCLButton.backgroundImage = pauseImage;
  95. playCLButton.backgroundImageWhenHovered = pauseImage;
  96. playCLButton.backgroundImageWhenPressed = pauseImage;
  97. } else {
  98. playCLButton.backgroundImage = playImage;
  99. playCLButton.backgroundImageWhenHovered = playImage;
  100. playCLButton.backgroundImageWhenPressed = playImage;
  101. }
  102. }
  103. /**
  104. * Function which is called when user press stop-button
  105. */
  106. function stop() {
  107. duration.setValue(0);
  108. timerEqualizer.running = false
  109. timerDuration.running = false
  110. playCLButton.backgroundImage = playImage;
  111. playCLButton.backgroundImageWhenHovered = playImage;
  112. playCLButton.backgroundImageWhenPressed = playImage;
  113. equalizerZeroer()
  114. }
  115. /**
  116. * Function is called When cover is changed in coverflow. This
  117. * Function changes information text about track (artist name, track name, album name)
  118. * @param index New selected index in coverflow
  119. * @return nothing
  120. */
  121. function coverChangedFunction(index) {
  122. duration.setValue(0);
  123. if(musicOn) {
  124. artistText.text = musicList.get(index).artist
  125. trackText.text = musicList.get(index).track
  126. albumText.text = musicList.get(index).album
  127. duration.value = 0
  128. duration.maximum = musicList.get(index).length*1000
  129. } else {
  130. artistText.text = movieList.get(index).movie
  131. trackText.text = movieList.get(index).director
  132. albumText.text = movieList.get(index).year
  133. duration.value = 0
  134. duration.maximum = movieList.get(index).length*1000
  135. }
  136. }
  137. /**
  138. * Rolls coverflow to right.
  139. */
  140. function next() {
  141. covers.next();
  142. duration.setValue(0);
  143. }
  144. /**
  145. * Rolls coverflow to left.
  146. */
  147. function previous() {
  148. covers.previous();
  149. duration.setValue(0);
  150. }
  151. /**
  152. * Functions formats time in milliseconds to minutes : seconds format.
  153. * @param durationMilliSeconds Time in milliseconds.
  154. * @return time in "minutes : seconds" -format
  155. * @example
  156. * formatDurationString(60005) -> 1:05
  157. */
  158. function formatDurationString(durationMilliSeconds) {
  159. var minutes = parseInt(durationMilliSeconds / 1000 / 60);
  160. var seconds = parseInt(durationMilliSeconds / 1000) % 60;
  161. if(seconds < 10) seconds = "0" + seconds;
  162. return minutes + ":" + seconds;
  163. }
  164. Component.onCompleted: {
  165. var array = new Array(new Array(0,"1"),new Array(0,"1"),new Array(0,"1"),new Array(0,"1"),new Array(0,"1"),new Array(0,"1"), new Array(0,"1"),new Array(0,"1"))
  166. equalizer.setValues(array);
  167. covers.imageSize = window.height*0.32
  168. covers.height = covers.imageSize
  169. }
  170. onWidthChanged: {
  171. covers.imageSize = window.height*0.32
  172. covers.height = covers.imageSize
  173. }
  174. onHeightChanged: {
  175. covers.imageSize = window.height*0.32
  176. covers.height = covers.imageSize
  177. }
  178. width: 640
  179. height: 424
  180. color: "transparent"
  181. Timer {
  182. id: timerEqualizer
  183. interval: 75; running: false; repeat: true
  184. onTriggered: {
  185. equalizerRandomizer();
  186. }
  187. }
  188. Timer {
  189. id: timerDuration
  190. interval: 1000; running: false; repeat: true
  191. onTriggered: {
  192. if(duration.value >= duration.maximum) next();
  193. duration.setValue(duration.value + interval);
  194. }
  195. }
  196. Rectangle {
  197. width:window.width*0.955
  198. height:window.height*0.924
  199. color:style.selectionColor
  200. anchors.centerIn:parent
  201. radius:7
  202. }
  203. Image {
  204. source: "images/control_bg_trans_420x275_png.png";
  205. anchors.fill: parent;
  206. smooth: true
  207. opacity:0.7
  208. }
  209. RoomExitButton {
  210. windowWidth: window.width
  211. windowHeight: window.height
  212. style: window.style
  213. onClicked: { console.log("2"); window.closeWindow(); }
  214. }
  215. CLHistogram {
  216. id: equalizer
  217. style: window.style
  218. colorWhenDefault: window.style.textColor
  219. gradientDefaultOn: false
  220. maxValue: 100
  221. anchors.horizontalCenter: parent.horizontalCenter
  222. width: window.width*0.9
  223. height: window.height*0.9
  224. opacity: 0.3
  225. y: window.height*0.06
  226. }
  227. Column {
  228. x: 0.05*window.height
  229. y: 0.05*window.height
  230. anchors.horizontalCenter: parent.horizontalCenter
  231. spacing: window.height*0.02
  232. Row {
  233. spacing: window.width*0.04
  234. Text {
  235. id: header
  236. text: "Music"
  237. font.pixelSize: 1 + Math.round( 23 * (window.height / 424) )
  238. color: window.style.textColor
  239. font.bold: true
  240. }
  241. /*CLButton { id: musicCLButton; style: window.style; text: "Music"; onClicked: selectMusic(); fontSize: window.height*0.03; selected: true; smooth: true }
  242. CLButton { id: movieCLButton; style: window.style; text: "Movies"; onClicked: selectMovie(); fontSize: window.height*0.03; smooth: true } */
  243. }
  244. Column {
  245. z:1
  246. anchors.horizontalCenter: parent.horizontalCenter
  247. spacing: window.height*0.01
  248. Text { id: artistText; font.pointSize: 0.001+window.height*0.04; anchors.horizontalCenter : parent.horizontalCenter; color: window.style.textColor }
  249. CLCarousel { id: covers; onCoverChanged: coverChangedFunction(index); coverList: musicList; imageAmount: 5; imageSize: window.height*0.5; width: window.width*0.9 }
  250. Text { id: trackText; font.pointSize: 0.001+window.height*0.04; anchors.horizontalCenter : parent.horizontalCenter; color: window.style.textColor }
  251. Text { id: albumText; font.pointSize: 0.001+window.height*0.03; anchors.horizontalCenter : parent.horizontalCenter; color: window.style.textColor }
  252. }
  253. Column {
  254. spacing: window.height*0.05
  255. Row {
  256. anchors.horizontalCenter: parent.horizontalCenter;
  257. spacing: window.width*0.04
  258. Text { text: formatDurationString(duration.value); font.pointSize: 0.001+window.height*0.04; color: window.style.textColor; anchors.verticalCenter : parent.verticalCenter }
  259. CLSlider { id: duration; style: window.style; margin: window.height*-0.04; width: window.width*0.6; height: window.height*0.03; sliderSize: window.width*0.02; minimum: 0; maximum: playTime; anchors.verticalCenter: parent.verticalCenter }
  260. Text { text: formatDurationString(duration.maximum); font.pointSize: 0.001+window.height*0.04; color: window.style.textColor; anchors.verticalCenter : parent.verticalCenter }
  261. }
  262. Row {
  263. spacing: 5
  264. anchors.horizontalCenter : parent.horizontalCenter
  265. CLButton { id: playCLButton; text: ""; style: window.style; onClicked: play(); width: window.width*0.12; height: window.height*0.12; backgroundImage: playImage; backgroundImageWhenHovered: playImage; backgroundImageWhenPressed: playImage; smooth: true }
  266. CLButton { id: stopCLButton; text: ""; onClicked: stop(); style: window.style; width: window.width*0.12; height: window.height*0.12;backgroundImage: stopImage; backgroundImageWhenHovered: stopImage; backgroundImageWhenPressed: stopImage; smooth: true }
  267. CLButton { id: previousCLButton; onClicked: previous(); text: ""; style: window.style; width: window.width*0.12; height: window.height*0.12; backgroundImage: prevImage; backgroundImageWhenHovered: prevImage; backgroundImageWhenPressed: prevImage; smooth: true }
  268. CLButton { id: nextCLButton; onClicked: next(); text: ""; style: window.style; width: window.width*0.12; height: window.height*0.12; backgroundImage: nextImage; backgroundImageWhenHovered: nextImage; backgroundImageWhenPressed: nextImage; smooth: true }
  269. }
  270. }
  271. }
  272. }