SearchResult.qml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import QtQuick 2.15
  2. import QtGraphicalEffects 1.15
  3. import DMusic 1.0
  4. import "components"
  5. Rectangle {
  6. id: root
  7. height: 40
  8. property string kind // "track", "album", "artist"
  9. property url cover
  10. property string name
  11. property string comment: ""
  12. property string artist: ""
  13. property bool sellected: false
  14. property bool sellectedIn: sellected || _mouse.containsMouse
  15. signal play()
  16. color: sellectedIn? Style.panel.sellection.background : "transparent"
  17. border.width: Style.panel.sellection.border.width
  18. border.color: sellectedIn? Style.panel.sellection.border.color : "transparent"
  19. radius: 4
  20. MouseArea {
  21. id: _mouse
  22. anchors.fill: parent
  23. hoverEnabled: true
  24. onClicked: root.play()
  25. Item {
  26. anchors.centerIn: parent
  27. height: 30
  28. width: parent.width - 10
  29. clip: true
  30. Image {
  31. id: _cover
  32. visible: false
  33. width: parent.height
  34. height: width
  35. sourceSize: Qt.size(width, height)
  36. source: root.cover
  37. fillMode: Image.PreserveAspectCrop
  38. }
  39. DropShadow {
  40. anchors.fill: _roundCover
  41. radius: 4.0
  42. samples: 10
  43. transparentBorder: true
  44. color: "#40000000"
  45. source: _roundCover
  46. }
  47. RoundMask {
  48. id: _roundCover
  49. anchors.fill: _cover
  50. radius: root.kind == "artist"? _cover.width / 2 : 4
  51. source: _cover
  52. }
  53. DText {
  54. id: _name
  55. anchors.left: _roundCover.right
  56. anchors.leftMargin: 13
  57. anchors.top: artist === ""? undefined : parent.top
  58. anchors.verticalCenter: artist === ""? parent.verticalCenter : undefined
  59. font.pointSize: 9
  60. color: Style.panel.text.color
  61. text: root.name
  62. }
  63. DText {
  64. id: _kind
  65. anchors.left: _name.right
  66. anchors.leftMargin: 4
  67. anchors.verticalCenter: _name.verticalCenter
  68. font.pointSize: 9
  69. font.letterSpacing: 1
  70. color: Style.panel.text.commentColor
  71. text: root.kind == "album"? qsTr("album") : ""
  72. }
  73. DText {
  74. id: _comment
  75. anchors.left: _kind.text === ""? _name.right : _kind.right
  76. anchors.leftMargin: 4
  77. anchors.verticalCenter: _name.verticalCenter
  78. font.pointSize: 9
  79. color: Style.panel.text.commentColor
  80. text: root.comment
  81. }
  82. DText {
  83. id: _artist
  84. anchors.left: _roundCover.right
  85. anchors.leftMargin: 13
  86. anchors.bottom: parent.bottom
  87. font.pointSize: 7.5
  88. color: Style.panel.text.artistColor
  89. text: root.artist
  90. }
  91. }
  92. }
  93. }