Slider.qml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.Controls.impl
  6. import QtQuick.Templates as T
  7. T.Slider {
  8. id: control
  9. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  10. implicitHandleWidth + leftPadding + rightPadding)
  11. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  12. implicitHandleHeight + topPadding + bottomPadding)
  13. padding: 6
  14. handle: Rectangle {
  15. x: control.leftPadding + (control.horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
  16. y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))
  17. implicitWidth: 28
  18. implicitHeight: 28
  19. radius: width / 2
  20. color: control.pressed ? control.palette.light : control.palette.window
  21. border.width: control.visualFocus ? 2 : 1
  22. border.color: {
  23. if (activeFocus)
  24. return control.palette.highlight
  25. else if (Qt.styleHints.accessibility.contrastPreference !== Qt.HighContrast)
  26. return control.enabled ? control.palette.mid : control.palette.midlight
  27. else
  28. return control.enabled ? control.palette.windowText : control.palette.mid
  29. }
  30. }
  31. background: Rectangle {
  32. x: control.leftPadding + (control.horizontal ? 0 : (control.availableWidth - width) / 2)
  33. y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : 0)
  34. implicitWidth: control.horizontal ? 200 : 6
  35. implicitHeight: control.horizontal ? 6 : 200
  36. width: control.horizontal ? control.availableWidth : implicitWidth
  37. height: control.horizontal ? implicitHeight : control.availableHeight
  38. radius: 3
  39. color: control.palette.midlight
  40. scale: control.horizontal && control.mirrored ? -1 : 1
  41. border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast ? 1 : 0
  42. border.color: enabled ? control.palette.dark : control.palette.mid
  43. Rectangle {
  44. y: control.horizontal ? 0 : control.visualPosition * parent.height
  45. width: control.horizontal ? control.position * parent.width : 6
  46. height: control.horizontal ? 6 : control.position * parent.height
  47. radius: 3
  48. color: control.palette.dark
  49. }
  50. }
  51. }