Player.qml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import QtQuick 2.15
  2. import QtQml 2.15
  3. import DMusic 1.0
  4. import "components"
  5. Rectangle {
  6. id: root
  7. color: Style.panel.background
  8. property alias track: _track
  9. function toggleLiked() {
  10. PlayingTrackInfo.liked = !PlayingTrackInfo.liked
  11. }
  12. function next() {
  13. AudioPlayer.next()
  14. }
  15. function prev() {
  16. AudioPlayer.prev()
  17. }
  18. PlayerControls {
  19. id: _controls
  20. anchors.horizontalCenter: root.horizontalCenter
  21. y: 21
  22. playing: AudioPlayer.playing
  23. shuffle: AudioPlayer.shuffle
  24. loop: AudioPlayer.loop
  25. onPause_or_play: AudioPlayer.playing? AudioPlayer.pause() : AudioPlayer.play()
  26. onNext: AudioPlayer.next()
  27. onPrev: AudioPlayer.prev()
  28. onSetShuffle: AudioPlayer.shuffle = v
  29. onSetLoop: AudioPlayer.loop = v
  30. }
  31. PlayerLine {
  32. id: _playerLine
  33. anchors.horizontalCenter: root.horizontalCenter
  34. y: 48
  35. width: root.width / 2.7
  36. progress: PlayingTrackInfo.progress
  37. onSeek: PlayingTrackInfo.progress = progress
  38. onAppendMs: PlayingTrackInfo.positionMs += delta * 1000
  39. positionText: PlayingTrackInfo.position
  40. durationText: PlayingTrackInfo.duration
  41. }
  42. Row {
  43. spacing: 20
  44. anchors.right: root.right
  45. anchors.verticalCenter: root.verticalCenter
  46. anchors.rightMargin: 24
  47. IconButton {
  48. width: 32
  49. height: 32
  50. src: "qrc:/resources/player/debug.svg"
  51. visible: root.width >= 700
  52. onClicked: GlobalFocus.item = _dpc.opened? "" : "debug"
  53. PopupController {
  54. id: _dpc
  55. target: _debug
  56. opened: GlobalFocus.item == "debug"
  57. }
  58. DebugPanel {
  59. id: _debug
  60. anchors.right: parent.right
  61. anchors.bottom: parent.top
  62. anchors.rightMargin: -58
  63. anchors.bottomMargin: 30 - _dpc.shift
  64. triangleOffset: -73
  65. triangleCenter: _debug.right
  66. player: root
  67. }
  68. }
  69. IconButton {
  70. width: 32
  71. height: 32
  72. src: PlayingTrackInfo.saved? "qrc:/resources/player/downloaded.svg" : "qrc:/resources/player/download.svg"
  73. style: PlayingTrackInfo.saved? Style.panel.icon.accent : Style.panel.icon.normal
  74. onClicked: PlayingTrackInfo.saved? (GlobalFocus.item = _dpc2.opened? "" : "download") : PlayingTrackInfo.save()
  75. Drag.mimeData: { "text/uri-list": PlayingTrackInfo.file }
  76. Drag.active: _downloadDrag.active
  77. Drag.supportedActions: Qt.CopyAction | Qt.LinkAction
  78. Drag.dragType: Drag.Automatic
  79. DragHandler {
  80. id: _downloadDrag
  81. enabled: PlayingTrackInfo.saved
  82. target: null
  83. }
  84. Item {
  85. anchors.horizontalCenter: parent.horizontalCenter
  86. anchors.bottom: parent.verticalCenter
  87. anchors.bottomMargin: -9
  88. width: 14
  89. height: 18 * PlayingTrackInfo.saveProgress
  90. clip: true
  91. Icon {
  92. id: _downloadProgress
  93. anchors.bottom: parent.bottom
  94. width: 14
  95. height: 18
  96. src: "qrc:/resources/player/download.svg"
  97. color: Style.panel.icon.accent.color
  98. }
  99. }
  100. PopupController {
  101. id: _dpc2
  102. target: _downloadPanel
  103. opened: GlobalFocus.item == "download"
  104. Binding {
  105. target: GlobalFocus
  106. property: "item"
  107. value: ""
  108. when: !PlayingTrackInfo.saved && GlobalFocus.item == "download"
  109. restoreMode: Binding.RestoreBindingOrValue
  110. }
  111. }
  112. DownloadPanel {
  113. id: _downloadPanel
  114. anchors.horizontalCenter: parent.horizontalCenter
  115. anchors.bottom: parent.top
  116. anchors.bottomMargin: 30 - _dpc2.shift
  117. anchors.horizontalCenterOffset: -50
  118. triangleOffset: -anchors.horizontalCenterOffset
  119. triangleCenter: _downloadPanel.horizontalCenter
  120. }
  121. }
  122. VolumeControl {}
  123. }
  124. PlayerTrack {
  125. id: _track
  126. x: 8
  127. anchors.verticalCenter: root.verticalCenter
  128. width: root.width / 2 - _playerLine.leftWidth - 14 - x
  129. height: root.height
  130. icon: PlayingTrackInfo.cover
  131. title: PlayingTrackInfo.title
  132. artists: PlayingTrackInfo.artists
  133. comment: PlayingTrackInfo.comment
  134. trackId: PlayingTrackInfo.id
  135. liked: PlayingTrackInfo.liked
  136. onToggleLiked: root.toggleLiked()
  137. }
  138. }