RangeSlider.qml 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright (C) 2017 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
  3. // Qt-Security score:significant reason:default
  4. import QtQuick
  5. import QtQuick.Templates as T
  6. import QtQuick.Controls.Universal
  7. T.RangeSlider {
  8. id: control
  9. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  10. first.implicitHandleWidth + leftPadding + rightPadding,
  11. second.implicitHandleWidth + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. first.implicitHandleHeight + topPadding + bottomPadding,
  14. second.implicitHandleHeight + topPadding + bottomPadding)
  15. padding: 6
  16. first.handle: Rectangle {
  17. implicitWidth: control.horizontal ? 8 : 24
  18. implicitHeight: control.horizontal ? 24 : 8
  19. x: control.leftPadding + (control.horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
  20. y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height))
  21. radius: 4
  22. color: control.first.pressed ? control.Universal.chromeHighColor :
  23. control.first.hovered ? control.Universal.chromeAltLowColor :
  24. control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
  25. }
  26. second.handle: Rectangle {
  27. implicitWidth: control.horizontal ? 8 : 24
  28. implicitHeight: control.horizontal ? 24 : 8
  29. x: control.leftPadding + (control.horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
  30. y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height))
  31. radius: 4
  32. color: control.second.pressed ? control.Universal.chromeHighColor :
  33. control.second.hovered ? control.Universal.chromeAltLowColor :
  34. control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
  35. }
  36. background: Item {
  37. implicitWidth: control.horizontal ? 200 : 18
  38. implicitHeight: control.horizontal ? 18 : 200
  39. x: control.leftPadding + (control.horizontal ? 0 : (control.availableWidth - width) / 2)
  40. y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : 0)
  41. width: control.horizontal ? control.availableWidth : implicitWidth
  42. height: control.horizontal ? implicitHeight : control.availableHeight
  43. scale: control.horizontal && control.mirrored ? -1 : 1
  44. Rectangle {
  45. x: control.horizontal ? 0 : (parent.width - width) / 2
  46. y: control.horizontal ? (parent.height - height) / 2 : 0
  47. width: control.horizontal ? parent.width : 2 // SliderBackgroundThemeHeight
  48. height: control.vertical ? parent.height : 2 // SliderBackgroundThemeHeight
  49. color: enabled && control.hovered && !control.pressed ? control.Universal.baseMediumColor :
  50. control.enabled ? control.Universal.baseMediumLowColor : control.Universal.chromeDisabledHighColor
  51. }
  52. Rectangle {
  53. x: control.horizontal ? control.first.position * parent.width : (parent.width - width) / 2
  54. y: control.horizontal ? (parent.height - height) / 2 : control.second.visualPosition * parent.height
  55. width: control.horizontal ? control.second.position * parent.width - control.first.position * parent.width : 2 // SliderBackgroundThemeHeight
  56. height: control.vertical ? control.second.position * parent.height - control.first.position * parent.height : 2 // SliderBackgroundThemeHeight
  57. color: control.enabled ? control.Universal.accent : control.Universal.chromeDisabledHighColor
  58. }
  59. }
  60. }