PlayerTrackInfo.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. states: [
  12. State {
  13. name: "hover"
  14. when: _mouse_title.containsMouse || _mouse_comment.containsMouse || _mouse_artists.containsMouse
  15. PropertyChanges {
  16. target: _fullInfo
  17. opacity: 1
  18. }
  19. PropertyChanges {
  20. target: _shade
  21. opacity: 0
  22. }
  23. }
  24. ]
  25. transitions: Transition {
  26. NumberAnimation { properties: "opacity"; duration: 250; easing.type: Easing.OutQuad; }
  27. }
  28. signal toggleLiked()
  29. Item {
  30. anchors.fill: root
  31. clip: true
  32. DText {
  33. id: _title
  34. anchors.bottom: parent.verticalCenter
  35. anchors.bottomMargin: 2
  36. text: title
  37. font.pointSize: 10.5
  38. color: Style.panel.text.color
  39. MouseArea {
  40. id: _mouse_title
  41. anchors.fill: parent
  42. enabled: root.trackId != 0
  43. cursorShape: enabled? Qt.PointingHandCursor : Qt.ArrowCursor
  44. hoverEnabled: true
  45. onClicked: Clipboard.text = root.trackId
  46. }
  47. }
  48. DText {
  49. id: _comment
  50. anchors.bottom: parent.verticalCenter
  51. anchors.bottomMargin: 2
  52. anchors.left: _title.right
  53. anchors.leftMargin: 5
  54. text: comment
  55. font.pointSize: 10.5
  56. color: Style.darkHeader? "#999999" : "#999999"
  57. MouseArea {
  58. id: _mouse_comment
  59. anchors.fill: parent
  60. hoverEnabled: true
  61. }
  62. }
  63. DText {
  64. id: _artists
  65. anchors.top: parent.verticalCenter
  66. anchors.topMargin: 2
  67. text: artists
  68. font.pointSize: 9
  69. color: Style.darkHeader? "#CCCCCC" : "#515151"
  70. MouseArea {
  71. id: _mouse_artists
  72. anchors.fill: parent
  73. hoverEnabled: true
  74. }
  75. }
  76. }
  77. Rectangle {
  78. id: _shade
  79. width: 10
  80. anchors.top: parent.top
  81. anchors.bottom: parent.bottom
  82. anchors.right: parent.right
  83. gradient: Gradient {
  84. orientation: Gradient.Horizontal
  85. GradientStop { position: 0.0; color: "transparent" }
  86. GradientStop { position: 1.0; color: Style.panel.background }
  87. }
  88. }
  89. PlayerControlsButton {
  90. id: _like
  91. anchors.bottom: parent.verticalCenter
  92. x: Math.round(Math.min(_title.width + (_comment.text == ""? 0 : _comment.width + 2) + 5, root.width + 2))
  93. anchors.bottomMargin: -1
  94. visible: PlayingTrackInfo.hasLiked
  95. icon: root.liked? "qrc:/resources/player/liked.svg" : "qrc:/resources/player/like.svg"
  96. onClick: root.toggleLiked()
  97. }
  98. Rectangle {
  99. id: _fullInfo
  100. anchors.top: parent.top
  101. anchors.bottom: parent.bottom
  102. anchors.left: parent.right
  103. width: Math.max(_full_title.width + 5 + _full_comment.width + 5 - root.width, _full_artists.width + 5 - root.width)
  104. opacity: 0
  105. color: Style.panel.background
  106. clip: true
  107. DText {
  108. id: _full_title
  109. anchors.bottom: parent.verticalCenter
  110. anchors.bottomMargin: 2
  111. x: -root.width
  112. text: title
  113. font.pointSize: 10.5
  114. color: Style.panel.text.color
  115. }
  116. DText {
  117. id: _full_comment
  118. anchors.bottom: parent.verticalCenter
  119. anchors.bottomMargin: 2
  120. anchors.left: _full_title.right
  121. anchors.leftMargin: 5
  122. text: comment
  123. font.pointSize: 10.5
  124. color: Style.darkHeader? "#999999" : "#999999"
  125. }
  126. DText {
  127. id: _full_artists
  128. anchors.top: parent.verticalCenter
  129. anchors.topMargin: 2
  130. x: -root.width
  131. text: artists
  132. font.pointSize: 9
  133. color: Style.darkHeader? "#CCCCCC" : "#515151"
  134. }
  135. }
  136. }