PlaylistEntry.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import QtQuick 2.15
  2. import QtGraphicalEffects 1.15
  3. import DMusic 1.0
  4. import "components"
  5. Item {
  6. id: root
  7. width: 115
  8. height: root.width + _name.height + 10
  9. property bool playing: PlayingTrackInfo.playlistId == playlistId && PlayingTrackInfo.playlistOwner == ownerId && playlistId != 0
  10. property real _anim_n: 0
  11. property real _anim2_n: 0
  12. property string title
  13. property url cover
  14. property int playlistId
  15. property int ownerId
  16. signal play()
  17. signal showOrHide()
  18. signal showFull()
  19. states: [
  20. State {
  21. name: "hover"
  22. when: (_imageMouse.containsMouse || playing) && !_playMouse.containsMouse
  23. PropertyChanges {
  24. target: root
  25. _anim_n: 1
  26. }
  27. PropertyChanges {
  28. target: _play
  29. scale: 0.8
  30. }
  31. },
  32. State {
  33. name: "hoverPlay"
  34. when: _playMouse.containsMouse
  35. PropertyChanges {
  36. target: root
  37. _anim_n: 1
  38. _anim2_n: 1
  39. }
  40. PropertyChanges {
  41. target: _play
  42. color: Style.accent
  43. scale: 1
  44. }
  45. }
  46. ]
  47. transitions: Transition {
  48. NumberAnimation { properties: "_anim_n, _anim2_n, scale"; duration: 250; easing.type: Easing.OutQuad; }
  49. ColorAnimation { target: _play; properties: "color"; duration: 250; easing.type: Easing.OutQuad; }
  50. }
  51. Image {
  52. id: _cover
  53. visible: false
  54. width: root.width
  55. height: root.width
  56. sourceSize: Qt.size(root.width, root.width)
  57. source: cover
  58. fillMode: Image.PreserveAspectCrop
  59. Rectangle {
  60. id: _hoverShadeEffect
  61. anchors.fill: parent
  62. color: "#000000"
  63. opacity: _anim_n * 0.4 + _anim2_n * 0.1
  64. }
  65. }
  66. DropShadow {
  67. anchors.fill: _roundCover
  68. radius: 8.0
  69. samples: 16
  70. transparentBorder: true
  71. color: "#40000000"
  72. source: _roundCover
  73. }
  74. RoundMask {
  75. id: _roundCover
  76. anchors.fill: _cover
  77. source: _cover
  78. MouseArea {
  79. id: _imageMouse
  80. anchors.fill: parent
  81. hoverEnabled: true
  82. cursorShape: Qt.PointingHandCursor
  83. onPressed: showOrHide()
  84. MouseArea {
  85. id: _playMouse
  86. anchors.centerIn: parent
  87. width: 30
  88. height: 30
  89. hoverEnabled: true
  90. cursorShape: Qt.PointingHandCursor
  91. onPressed: if (playing) {
  92. AudioPlayer.playing? AudioPlayer.pause() : AudioPlayer.play()
  93. } else play()
  94. }
  95. }
  96. }
  97. Icon {
  98. id: _play
  99. anchors.centerIn: _roundCover
  100. opacity: _anim_n
  101. src: (playing && AudioPlayer.playing)? "qrc:/resources/player/pause.svg" : "qrc:/resources/player/play.svg"
  102. color: "#FFFFFF"
  103. image.sourceSize: Qt.size(25, 30)
  104. scale: 0.7
  105. }
  106. DropShadow {
  107. anchors.fill: root
  108. visible: _play.visible
  109. radius: 5.0
  110. samples: 12
  111. transparentBorder: true
  112. color: "#60000000"
  113. source: _play
  114. }
  115. DText {
  116. id: _name
  117. anchors.left: root.left
  118. anchors.right: root.right
  119. anchors.top: _cover.bottom
  120. anchors.topMargin: 5
  121. font.pointSize: 10
  122. horizontalAlignment: Text.AlignHCenter
  123. wrapMode: Text.WordWrap
  124. text: title
  125. MouseArea {
  126. id: _textMouse
  127. anchors.fill: parent
  128. cursorShape: Qt.PointingHandCursor
  129. onPressed: showFull()
  130. }
  131. }
  132. }