PlayerLineSlider.qml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import QtQuick 2.15
  2. import QtGraphicalEffects 1.15
  3. import DMusic 1.0
  4. //TODO: таймкоды
  5. Rectangle {
  6. id: root
  7. height: 4
  8. property real progress: 0.3
  9. property bool sellected: _mouse.containsMouse | _mouse.pressed
  10. signal seek(real progress)
  11. signal appendMs(real delta)
  12. color: Style.panel.item.background
  13. radius: height / 2
  14. Rectangle {
  15. id: _progress
  16. anchors.left: root.left
  17. height: root.height
  18. width: root.width * progress
  19. radius: root.radius
  20. color: sellected? Style.panel.accent : Style.panel.item.foreground
  21. }
  22. DropShadow {
  23. visible: root.sellected && Style.panel.item.dropShadow
  24. anchors.fill: _point
  25. radius: 3.0
  26. samples: 7
  27. transparentBorder: true
  28. opacity: 0.3
  29. color: "#000000"
  30. source: _point
  31. }
  32. Rectangle {
  33. id: _point
  34. visible: root.sellected
  35. width: 12
  36. height: 12
  37. radius: height / 2
  38. anchors.verticalCenter: root.verticalCenter
  39. anchors.horizontalCenter: _progress.right
  40. color: "#FFFFFF"
  41. }
  42. MouseArea {
  43. id: _mouse
  44. anchors.centerIn: root
  45. width: root.width + _point.width
  46. height: Math.max(root.height, _point.height)
  47. hoverEnabled: true
  48. onMouseXChanged: {
  49. if (pressed) {
  50. var progress = (mouseX - _point.width / 2) / root.width
  51. progress = Math.max(0, Math.min(1, progress))
  52. root.seek(progress)
  53. }
  54. }
  55. onWheel: {
  56. root.appendMs(-5 * wheel.angleDelta.y / 120)
  57. }
  58. }
  59. }