PlayerTrackInfo.qml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. import QtQuick 2.15
  2. import DMusic 1.0
  3. import "components"
  4. Item {
  5. id: root
  6. property string title: ""
  7. property string artists: ""
  8. property string comment: ""
  9. property int trackId
  10. property bool liked: false
  11. property bool isYandex: false
  12. signal toggleLiked(bool liked)
  13. Item {
  14. anchors.fill: root
  15. clip: true
  16. DText {
  17. id: _title
  18. anchors.bottom: parent.verticalCenter
  19. anchors.bottomMargin: 2
  20. text: title
  21. font.pointSize: 10.5
  22. color: Style.panel.text.color
  23. MouseArea {
  24. anchors.fill: parent
  25. enabled: root.isYandex
  26. cursorShape: enabled? Qt.PointingHandCursor : Qt.ArrowCursor
  27. hoverEnabled: true
  28. Clipboard {
  29. id: _clipboard
  30. }
  31. onClicked: _clipboard.copy(root.trackId);
  32. onEntered: _full_titleAndComment.show()
  33. onExited: _full_titleAndComment.hide()
  34. }
  35. }
  36. DText {
  37. id: _comment
  38. anchors.bottom: parent.verticalCenter
  39. anchors.bottomMargin: 2
  40. anchors.left: _title.right
  41. anchors.leftMargin: 5
  42. text: comment
  43. font.pointSize: 10.5
  44. color: Style.darkHeader? "#999999" : "#999999"
  45. MouseArea {
  46. anchors.fill: parent
  47. hoverEnabled: true
  48. onEntered: _full_titleAndComment.show()
  49. onExited: _full_titleAndComment.hide()
  50. }
  51. }
  52. DText {
  53. id: _artists
  54. anchors.top: parent.verticalCenter
  55. anchors.topMargin: 2
  56. text: artists
  57. font.pointSize: 9
  58. color: Style.darkHeader? "#CCCCCC" : "#515151"
  59. MouseArea {
  60. anchors.fill: parent
  61. hoverEnabled: true
  62. onEntered: _full_artists_box.show()
  63. onExited: _full_artists_box.hide()
  64. }
  65. }
  66. Rectangle {
  67. id: _shade_titleAndExtra
  68. width: 10
  69. height: Math.max(_title.height, _comment.height)
  70. anchors.right: parent.right
  71. anchors.verticalCenter: _title.verticalCenter
  72. OpacityAnimator {
  73. target: _shade_titleAndExtra
  74. id: _anim_shade_titleAndComment_opacity
  75. duration: 300
  76. easing.type: Easing.OutCubic
  77. }
  78. gradient: Gradient {
  79. orientation: Gradient.Horizontal
  80. GradientStop { position: 0.0; color: "transparent" }
  81. GradientStop { position: 1.0; color: Style.panel.background }
  82. }
  83. }
  84. Rectangle {
  85. id: _shade_artists
  86. width: 10
  87. height: _artists.height
  88. anchors.right: parent.right
  89. anchors.verticalCenter: _artists.verticalCenter
  90. OpacityAnimator {
  91. target: _shade_artists
  92. id: _anim_shade_artists_opacity
  93. duration: 300
  94. easing.type: Easing.OutCubic
  95. }
  96. gradient: Gradient {
  97. orientation: Gradient.Horizontal
  98. GradientStop { position: 0.0; color: "transparent" }
  99. GradientStop { position: 1.0; color: Style.panel.background }
  100. }
  101. }
  102. }
  103. PlayerControlsButton {
  104. id: _like
  105. anchors.bottom: parent.verticalCenter
  106. x: Math.round(Math.min(_title.width + (_comment.text == ""? 0 : _comment.width + 2) + 5, root.width + 2))
  107. anchors.bottomMargin: -1
  108. visible: root.isYandex
  109. icon: liked? "qrc:/resources/player/liked.svg" : "qrc:/resources/player/like.svg"
  110. onClick: toggleLiked(!liked)
  111. }
  112. Rectangle {
  113. id: _full_titleAndComment
  114. height: Math.max(_full_title.height, _full_extra.height) + 6
  115. width: _full_title.width + 5 + _full_extra.width + 5 - root.width
  116. anchors.bottom: parent.verticalCenter
  117. anchors.bottomMargin: -1
  118. x: root.width
  119. property bool showing: false
  120. clip: true
  121. opacity: 0
  122. color: Style.panel.background
  123. OpacityAnimator {
  124. target: _full_titleAndComment
  125. id: _anim_full_titleAndComment_opacity
  126. duration: 300
  127. easing.type: Easing.OutCubic
  128. }
  129. function show() {
  130. if (showing) return
  131. showing = true
  132. _anim_full_titleAndComment_opacity.from = 0
  133. _anim_full_titleAndComment_opacity.to = 1
  134. _anim_full_titleAndComment_opacity.restart()
  135. _anim_shade_titleAndComment_opacity.from = 1
  136. _anim_shade_titleAndComment_opacity.to = 0
  137. _anim_shade_titleAndComment_opacity.restart()
  138. }
  139. function hide() {
  140. if (!showing) return
  141. showing = false
  142. _anim_full_titleAndComment_opacity.from = 1
  143. _anim_full_titleAndComment_opacity.to = 0
  144. _anim_full_titleAndComment_opacity.restart()
  145. _anim_shade_titleAndComment_opacity.from = 0
  146. _anim_shade_titleAndComment_opacity.to = 1
  147. _anim_shade_titleAndComment_opacity.restart()
  148. }
  149. DText {
  150. id: _full_title
  151. anchors.verticalCenter: parent.verticalCenter
  152. x: -root.width
  153. text: title
  154. font.pointSize: 10.5
  155. color: Style.panel.text.color
  156. }
  157. DText {
  158. id: _full_extra
  159. anchors.verticalCenter: parent.verticalCenter
  160. anchors.left: _full_title.right
  161. anchors.leftMargin: 5
  162. text: comment
  163. font.pointSize: 10.5
  164. color: Style.darkHeader? "#999999" : "#999999"
  165. }
  166. }
  167. Rectangle {
  168. id: _full_artists_box
  169. height: Math.max(_full_title.height, _full_extra.height) + 3
  170. width: _full_artists.width + 5 - root.width
  171. anchors.top: parent.verticalCenter
  172. anchors.topMargin: 2
  173. x: root.width
  174. property bool showing: false
  175. clip: true
  176. opacity: 0
  177. color: Style.panel.background
  178. OpacityAnimator {
  179. target: _full_artists_box
  180. id: _anim_full_artists_opacity
  181. duration: 300
  182. easing.type: Easing.OutCubic
  183. }
  184. function show() {
  185. if (showing) return
  186. showing = true
  187. _anim_full_artists_opacity.from = 0
  188. _anim_full_artists_opacity.to = 1
  189. _anim_full_artists_opacity.restart()
  190. _anim_shade_artists_opacity.from = 1
  191. _anim_shade_artists_opacity.to = 0
  192. _anim_shade_artists_opacity.restart()
  193. }
  194. function hide() {
  195. if (!showing) return
  196. showing = false
  197. _anim_full_artists_opacity.from = 1
  198. _anim_full_artists_opacity.to = 0
  199. _anim_full_artists_opacity.restart()
  200. _anim_shade_artists_opacity.from = 0
  201. _anim_shade_artists_opacity.to = 1
  202. _anim_shade_artists_opacity.restart()
  203. }
  204. DText {
  205. id: _full_artists
  206. anchors.top: parent.top
  207. x: -root.width
  208. text: artists
  209. font.pointSize: 9
  210. color: Style.darkHeader? "#CCCCCC" : "#515151"
  211. }
  212. }
  213. }