GroupBox.qml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.Imagine
  7. import QtQuick.Controls.Imagine.impl
  8. T.GroupBox {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding,
  12. implicitLabelWidth + leftPadding + rightPadding)
  13. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  14. implicitContentHeight + topPadding + bottomPadding)
  15. topPadding: ((background as NinePatchImage)?.topPadding ?? 0) + (implicitLabelWidth > 0 ? implicitLabelHeight + spacing : 0)
  16. leftPadding: ((background as NinePatchImage)?.leftPadding ?? 0)
  17. rightPadding: ((background as NinePatchImage)?.rightPadding ?? 0)
  18. bottomPadding: ((background as NinePatchImage)?.bottomPadding ?? 0)
  19. label: Label {
  20. width: control.width
  21. topPadding: background.topPadding
  22. leftPadding: background.leftPadding
  23. rightPadding: background.rightPadding
  24. bottomPadding: background.bottomPadding
  25. text: control.title
  26. elide: Text.ElideRight
  27. verticalAlignment: Text.AlignVCenter
  28. color: control.palette.windowText
  29. background: NinePatchImage {
  30. width: parent.width
  31. height: parent.height
  32. source: Imagine.url + "groupbox-title"
  33. NinePatchImageSelector on source {
  34. states: [
  35. {"disabled": !control.enabled},
  36. {"mirrored": control.mirrored}
  37. ]
  38. }
  39. }
  40. }
  41. background: NinePatchImage {
  42. x: -leftInset
  43. y: control.topPadding - control.bottomPadding - topInset
  44. width: control.width + leftInset + rightInset
  45. height: control.height + topInset + bottomInset - control.topPadding + control.bottomPadding
  46. source: Imagine.url + "groupbox-background"
  47. NinePatchImageSelector on source {
  48. states: [
  49. {"disabled": !control.enabled},
  50. {"mirrored": control.mirrored}
  51. ]
  52. }
  53. }
  54. }