ScrollBar.qml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.Material
  7. T.ScrollBar {
  8. id: control
  9. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  10. implicitContentWidth + leftPadding + rightPadding)
  11. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  12. implicitContentHeight + topPadding + bottomPadding)
  13. padding: control.interactive ? 1 : 2
  14. visible: control.policy !== T.ScrollBar.AlwaysOff
  15. minimumSize: orientation === Qt.Horizontal ? height / width : width / height
  16. contentItem: Rectangle {
  17. implicitWidth: control.interactive ? 13 : 4
  18. implicitHeight: control.interactive ? 13 : 4
  19. color: control.pressed ? control.Material.scrollBarPressedColor :
  20. control.interactive && control.hovered ? control.Material.scrollBarHoveredColor : control.Material.scrollBarColor
  21. opacity: 0.0
  22. }
  23. background: Rectangle {
  24. implicitWidth: control.interactive ? 16 : 4
  25. implicitHeight: control.interactive ? 16 : 4
  26. color: "#0e000000"
  27. opacity: 0.0
  28. visible: control.interactive
  29. }
  30. states: State {
  31. name: "active"
  32. when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)
  33. }
  34. transitions: [
  35. Transition {
  36. to: "active"
  37. NumberAnimation { targets: [control.contentItem, control.background]; property: "opacity"; to: 1.0 }
  38. },
  39. Transition {
  40. from: "active"
  41. SequentialAnimation {
  42. PropertyAction{ targets: [control.contentItem, control.background]; property: "opacity"; value: 1.0 }
  43. PauseAnimation { duration: 2450 }
  44. NumberAnimation { targets: [control.contentItem, control.background]; property: "opacity"; to: 0.0 }
  45. }
  46. }
  47. ]
  48. }