TabBar.qml 1.8 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. import QtQuick.Controls.Material.impl
  8. T.TabBar {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. implicitContentHeight + topPadding + bottomPadding)
  14. spacing: 1
  15. contentItem: ListView {
  16. model: control.contentModel
  17. currentIndex: control.currentIndex
  18. spacing: control.spacing
  19. orientation: ListView.Horizontal
  20. boundsBehavior: Flickable.StopAtBounds
  21. flickableDirection: Flickable.AutoFlickIfNeeded
  22. snapMode: ListView.SnapToItem
  23. highlightMoveDuration: 250
  24. highlightResizeDuration: 0
  25. highlightFollowsCurrentItem: true
  26. highlightRangeMode: ListView.ApplyRange
  27. preferredHighlightBegin: 48
  28. preferredHighlightEnd: width - 48
  29. highlight: Item {
  30. z: 2
  31. Rectangle {
  32. height: 2
  33. width: parent.width
  34. y: control.position === T.TabBar.Footer ? 0 : parent.height - height
  35. color: control.Material.accentColor
  36. }
  37. }
  38. }
  39. background: Rectangle {
  40. color: control.Material.backgroundColor
  41. layer.enabled: control.Material.elevation > 0
  42. layer.effect: ElevationEffect {
  43. elevation: control.Material.elevation
  44. fullWidth: true
  45. }
  46. }
  47. }