ScrollBar.qml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.impl
  7. import QtQuick.Controls.Fusion
  8. import QtQuick.Controls.Fusion.impl
  9. T.ScrollBar {
  10. id: control
  11. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  12. implicitContentWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding)
  15. padding: 2
  16. visible: control.policy !== T.ScrollBar.AlwaysOff
  17. minimumSize: orientation === Qt.Horizontal ? height / width : width / height
  18. contentItem: Rectangle {
  19. implicitWidth: control.interactive ? 6 : 2
  20. implicitHeight: control.interactive ? 6 : 2
  21. radius: width / 2
  22. opacity: 0.0
  23. color: {
  24. if (Fusion.highContrast)
  25. return control.pressed ? Fusion.highlightedOutline(control.palette) : Fusion.outline(control.palette)
  26. else
  27. return control.pressed ? control.palette.dark : control.palette.mid
  28. }
  29. states: State {
  30. name: "active"
  31. when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)
  32. PropertyChanges { control.contentItem.opacity: 0.75 }
  33. }
  34. transitions: Transition {
  35. from: "active"
  36. SequentialAnimation {
  37. PauseAnimation { duration: 450 }
  38. NumberAnimation { target: control.contentItem; duration: 200; property: "opacity"; to: 0.0 }
  39. }
  40. }
  41. }
  42. }