PlayerLineSlider.qml 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import QtQuick 2.0
  2. Rectangle {
  3. id: root
  4. height: 4
  5. property real progress: 0.3
  6. property bool sellected: _mouse.containsMouse | _mouse.pressed
  7. signal seek(real progress)
  8. color: "#404040"
  9. radius: height / 2
  10. Rectangle {
  11. id: _progress
  12. anchors.left: root.left
  13. height: root.height
  14. width: root.width * progress
  15. radius: root.radius
  16. color: sellected? "#FCE165" : "#AAAAAA"
  17. }
  18. Rectangle {
  19. id: _point
  20. visible: root.sellected
  21. width: 12
  22. height: 12
  23. radius: height / 2
  24. anchors.verticalCenter: root.verticalCenter
  25. anchors.horizontalCenter: _progress.right
  26. color: "#FFFFFF"
  27. }
  28. MouseArea {
  29. id: _mouse
  30. anchors.centerIn: root
  31. width: root.width + _point.width
  32. height: Math.max(root.height, _point.height)
  33. hoverEnabled: true
  34. onMouseXChanged: {
  35. if (pressed) {
  36. var progress = (mouseX - _point.width / 2) / root.width
  37. progress = Math.max(0, Math.min(1, progress))
  38. root.seek(progress)
  39. }
  40. }
  41. }
  42. }