TabButton.qml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.impl
  7. import QtQuick.Controls.Imagine
  8. import QtQuick.Controls.Imagine.impl
  9. T.TabButton {
  10. id: control
  11. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  12. implicitContentWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding)
  15. spacing: 6 // ###
  16. topPadding: background ? background.topPadding : 0
  17. leftPadding: background ? background.leftPadding : 0
  18. rightPadding: background ? background.rightPadding : 0
  19. bottomPadding: background ? background.bottomPadding : 0
  20. topInset: background ? -background.topInset || 0 : 0
  21. leftInset: background ? -background.leftInset || 0 : 0
  22. rightInset: background ? -background.rightInset || 0 : 0
  23. bottomInset: background ? -background.bottomInset || 0 : 0
  24. icon.width: 24
  25. icon.height: 24
  26. icon.color: control.palette.buttonText
  27. contentItem: IconLabel {
  28. spacing: control.spacing
  29. mirrored: control.mirrored
  30. display: control.display
  31. icon: control.icon
  32. text: control.text
  33. font: control.font
  34. color: control.palette.buttonText
  35. }
  36. background: NinePatchImage {
  37. source: Imagine.url + "tabbutton-background"
  38. NinePatchImageSelector on source {
  39. states: [
  40. {"disabled": !control.enabled},
  41. {"pressed": control.down},
  42. {"checked": control.checked},
  43. {"focused": control.visualFocus},
  44. {"mirrored": control.mirrored},
  45. {"hovered": control.enabled && control.hovered}
  46. ]
  47. }
  48. }
  49. }