PlaylistEntry.qml 2.8 KB

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