PlayerTrackIcon.qml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import QtQuick 2.15
  2. import QtQml 2.15
  3. import DMusic 1.0
  4. import "components"
  5. Item {
  6. id: root
  7. width: 50
  8. height: 50
  9. property url src: ""
  10. RoundedImage {
  11. id: _icon
  12. source: src
  13. anchors.fill: root
  14. sourceSize.width: root.width
  15. sourceSize.height: root.height
  16. fillMode: Image.PreserveAspectCrop
  17. clip: true
  18. radius: 7.5
  19. }
  20. MouseArea {
  21. id: _mouse
  22. anchors.fill: _icon
  23. enabled: !PlayingTrackInfo.isNone
  24. cursorShape: enabled? Qt.PointingHandCursor : Qt.ArrowCursor
  25. onClicked: GlobalFocus.item = _ppc.opened? "" : "playingTrack"
  26. }
  27. PopupController {
  28. id: _ppc
  29. target: _panel
  30. opened: GlobalFocus.item == "playingTrack"
  31. Binding {
  32. target: GlobalFocus
  33. property: "item"
  34. value: ""
  35. when: PlayingTrackInfo.isNone && GlobalFocus.item == "playingTrack"
  36. restoreMode: Binding.RestoreBindingOrValue
  37. }
  38. }
  39. Shortcut {
  40. sequence: "T"
  41. onActivated: GlobalFocus.item = "search"
  42. }
  43. TrackPanel {
  44. id: _panel
  45. anchors.horizontalCenter: parent.horizontalCenter
  46. anchors.bottom: parent.top
  47. anchors.bottomMargin: 20 - _ppc.shift
  48. anchors.horizontalCenterOffset: 100
  49. triangleOffset: -anchors.horizontalCenterOffset
  50. triangleCenter: _panel.horizontalCenter
  51. ppc: _ppc
  52. }
  53. }