ScrollView.qml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (C) 2020 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.ScrollView {
  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. // rightPadding and bottomPadding are used to make space for the scrollBars
  14. // but because we're setting them explicitly here, there will be no effect
  15. // if the user assign a value to the padding property, so we accumulate it
  16. // with the scrollbar width and height
  17. rightPadding: effectiveScrollBarWidth + padding
  18. bottomPadding: effectiveScrollBarHeight + padding
  19. // Don't set __notCustomizable here, because it would require special-casing
  20. // setFlickable's call to setContentItem.
  21. ScrollBar.vertical: ScrollBar {
  22. parent: control
  23. x: control.mirrored ? 0 : control.width - width
  24. y: 0
  25. height: control.height - (control.ScrollBar.horizontal.visible ? control.ScrollBar.horizontal.height : 0)
  26. active: control.ScrollBar.horizontal.active
  27. }
  28. ScrollBar.horizontal: ScrollBar {
  29. parent: control
  30. x: 0
  31. y: control.height - height
  32. width: control.width - (control.ScrollBar.vertical.visible ? control.ScrollBar.vertical.width : 0)
  33. active: control.ScrollBar.vertical.active
  34. }
  35. }