ScrollBar.qml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.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. visible: control.policy !== T.ScrollBar.AlwaysOff
  14. minimumSize: orientation === Qt.Horizontal ? height / width : width / height
  15. // TODO: arrows
  16. contentItem: Rectangle {
  17. implicitWidth: control.interactive ? 12 : 6
  18. implicitHeight: control.interactive ? 12: 6
  19. color: control.pressed ? control.Universal.baseMediumColor :
  20. enabled && control.interactive && control.hovered ? control.Universal.baseMediumLowColor :
  21. control.Universal.chromeHighColor
  22. opacity: 0.0
  23. }
  24. background: Rectangle {
  25. implicitWidth: control.interactive ? 12 : 6
  26. implicitHeight: control.interactive ? 12: 6
  27. color: control.Universal.chromeLowColor
  28. visible: control.size < 1.0
  29. opacity: 0.0
  30. }
  31. states: [
  32. State {
  33. name: "active"
  34. when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)
  35. }
  36. ]
  37. transitions: [
  38. Transition {
  39. to: "active"
  40. NumberAnimation { targets: [control.contentItem, control.background]; property: "opacity"; to: 1.0 }
  41. },
  42. Transition {
  43. from: "active"
  44. SequentialAnimation {
  45. PropertyAction{ targets: [control.contentItem, control.background]; property: "opacity"; value: 1.0 }
  46. PauseAnimation { duration: 3000 }
  47. NumberAnimation { targets: [control.contentItem, control.background]; property: "opacity"; to: 0.0 }
  48. }
  49. }
  50. ]
  51. }