TabBar.qml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (C) 2024 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.Controls.FluentWinUI3.impl as Impl
  7. import QtQuick.Templates as T
  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: __config.spacing || 0
  15. topPadding: __config.topPadding || 0
  16. bottomPadding: __config.bottomPadding || 0
  17. leftPadding: __config.leftPadding || 0
  18. rightPadding: __config.rightPadding || 0
  19. topInset: -__config.topInset || 0
  20. bottomInset: -__config.bottomInset || 0
  21. leftInset: -__config.leftInset || 0
  22. rightInset: -__config.rightInset || 0
  23. readonly property string __currentState: position === TabBar.Header
  24. ? (enabled ? "normal" : "disabled")
  25. : (enabled ? "normal_footer" : "disabled_footer")
  26. readonly property var __config: Config.controls.tabbar[__currentState] || {}
  27. contentItem: ListView {
  28. model: control.contentModel
  29. currentIndex: control.currentIndex
  30. spacing: control.__config.spacing
  31. orientation: ListView.Horizontal
  32. boundsBehavior: Flickable.StopAtBounds
  33. flickableDirection: Flickable.AutoFlickIfNeeded
  34. snapMode: ListView.SnapToItem
  35. highlightMoveDuration: 0
  36. highlightRangeMode: ListView.ApplyRange
  37. preferredHighlightBegin: 48
  38. preferredHighlightEnd: width - 48
  39. }
  40. background: Impl.StyleImage {
  41. imageConfig: control.__config.background
  42. }
  43. }