PlayerLineSlider.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. opacity: 0.3
  28. color: "#000000"
  29. source: _point
  30. }
  31. Rectangle {
  32. id: _point
  33. visible: root.sellected
  34. width: 12
  35. height: 12
  36. radius: height / 2
  37. anchors.verticalCenter: root.verticalCenter
  38. anchors.horizontalCenter: _progress.right
  39. color: "#FFFFFF"
  40. }
  41. MouseArea {
  42. id: _mouse
  43. anchors.centerIn: root
  44. width: root.width + _point.width
  45. height: Math.max(root.height, _point.height)
  46. hoverEnabled: true
  47. onMouseXChanged: {
  48. if (pressed) {
  49. var progress = (mouseX - _point.width / 2) / root.width
  50. progress = Math.max(0, Math.min(1, progress))
  51. root.seek(progress)
  52. }
  53. }
  54. onWheel: {
  55. root.appendMs(-5 * wheel.angleDelta.y / 120)
  56. }
  57. }
  58. }