PlayListView.qml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import QtQuick 1.0
  2. /** A view of the playlist, which consists playable songs from
  3. a playlist or folder.
  4. */
  5. ListView {
  6. objectName: "playListView"
  7. id: qmlListView
  8. Image {
  9. id: closeButton
  10. anchors.right: parent.right
  11. anchors.top: parent.top
  12. height: 32
  13. width: 32
  14. source: "qrc:/icons/close.png"
  15. MouseArea {
  16. anchors.fill: parent
  17. onClicked: mainWindow.close();
  18. }
  19. }
  20. model: playListModel
  21. interactive: true
  22. delegate: songDelegate
  23. width: parent.width
  24. height: parent.height
  25. highlightFollowsCurrentItem: true;
  26. highlight: SongItem { color: "yellow" }
  27. preferredHighlightBegin: 50;
  28. highlightRangeMode: ListView.ApplyRange
  29. Keys.onPressed: {
  30. if ((event.key == Qt.Key_Right) || (event.key == Qt.Key_Tab)) {
  31. event.accepted = true;
  32. flickableView.state = "Parentlist";
  33. }
  34. }
  35. focus: true
  36. clip: true
  37. Component {
  38. id: songDelegate
  39. Item {
  40. id: songItem;
  41. property real detailsOpacity : 0
  42. width: qmlListView.width
  43. height: 45
  44. SongItem {
  45. id: background
  46. z: -1
  47. x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
  48. border.color: "orange"
  49. // This mouse region covers the entire delegate.
  50. // When clicked it changes mode to 'Details'. If we are already
  51. // in Details mode, then we go back to regular mode.
  52. MouseArea {
  53. anchors.fill: parent
  54. onClicked : {
  55. // set a C++ property from QML
  56. mainWindow.chosenFromQML = index;
  57. songItem.state = songItem.state == ''? 'Details' : ''
  58. }
  59. }
  60. }
  61. Row {
  62. id: rowLayout
  63. x: 10; y: 10; spacing: 10
  64. height: parent.height
  65. width: parent.width
  66. Text {
  67. anchors.margins: 5
  68. wrapMode: "WordWrap"
  69. id: viewText
  70. text: name;
  71. font.pointSize: 8
  72. }
  73. }
  74. Item {
  75. id: detailsItem
  76. width: qmlListView.width;
  77. height: parent.height ;
  78. x: 10
  79. opacity: songItem.detailsOpacity
  80. Column {
  81. y: viewText.y + viewText.height + 125;
  82. WrappedText {
  83. text: "(" + Qt.formatDateTime(duration) + ") by " + artist;
  84. }
  85. WrappedText {
  86. text: "Track " + trackNr + " from " + album;
  87. }
  88. WrappedText {
  89. text: "Genre: " + genre + " Comments:" + comment;
  90. }
  91. Text {
  92. text: "Last Modified: " + lastModified;
  93. }
  94. WrappedText {
  95. text: url
  96. }
  97. }
  98. // Play button:
  99. Image {
  100. y: 20
  101. anchors.right: detailsItem.right;
  102. anchors.rightMargin: 30
  103. id: playImage
  104. source: "qrc:/icons/player_play.svgz"
  105. opacity: songItem.detailsOpacity;
  106. height: 20
  107. width: 20
  108. MouseArea {
  109. anchors.fill: parent;
  110. onClicked: {
  111. onClicked: songItem.state = '';
  112. mainWindow.playQmlSelected();
  113. }
  114. }
  115. }
  116. // Queue/Dequeue button:
  117. Image {
  118. id: queueButton
  119. anchors.right: playImage.left;
  120. anchors.bottom: playImage.bottom;
  121. opacity: songItem.detailsOpacity;
  122. height: 80
  123. width: 80
  124. source: mainWindow.positionInQueue(url) == -1 ?
  125. "qrc:/icons/enqueue.png" : "qrc:/icons/dequeue.png";
  126. MouseArea {
  127. anchors.fill: parent
  128. onClicked: {
  129. songItem.state = '';
  130. mainWindow.enqueue(url);
  131. }
  132. }
  133. }
  134. // delete button:
  135. Image {
  136. anchors.right: queueButton.left;
  137. anchors.rightMargin: 20
  138. anchors.bottom: playImage.bottom;
  139. id: deleteImage
  140. source: "qrc:/icons/delete.png";
  141. opacity: songItem.detailsOpacity;
  142. height: 64
  143. width: 64
  144. MouseArea {
  145. anchors.fill: parent;
  146. onClicked: {
  147. onClicked: songItem.state = '';
  148. playListModel.deleteTrack(index);
  149. }
  150. }
  151. }
  152. }
  153. states: State {
  154. name: "Details"
  155. // PropertyChanges { target: mainWindow; chosenFromQML: listView }
  156. // Disallow flicking while we're in detailed view
  157. PropertyChanges { target: qmlListView; interactive: false }
  158. // Move the list so that this item is at the top.
  159. PropertyChanges { target: songItem.ListView.view; explicit: true; contentY: songItem.y }
  160. PropertyChanges { target: background; color: "white" }
  161. PropertyChanges { target: playImage; width: 100; height: 100 } // Make picture bigger
  162. PropertyChanges { target: playImage; opacity: .9; x: 0 } // Make image visible.
  163. PropertyChanges { target: songItem; detailsOpacity: 1; x: 0 } // Make details visible
  164. PropertyChanges { target: songItem; height: qmlListView.height } // Fill the area with detailed view
  165. }
  166. transitions: Transition {
  167. // Make the state changes smooth
  168. ParallelAnimation {
  169. ColorAnimation { property: "color"; duration: 500 }
  170. NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" }
  171. }
  172. }
  173. }
  174. }
  175. }