GroupBox.qml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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.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. spacing: 6
  16. padding: 12
  17. topPadding: Material.frameVerticalPadding + (implicitLabelWidth > 0 ? implicitLabelHeight + spacing : 0)
  18. bottomPadding: Material.frameVerticalPadding
  19. Material.roundedScale: Material.ExtraSmallScale
  20. label: Text {
  21. x: Math.max(control.leftPadding, control.Material.roundedScale)
  22. width: control.availableWidth
  23. text: control.title
  24. font: control.font
  25. color: control.enabled ? control.Material.foreground : control.Material.hintTextColor
  26. elide: Text.ElideRight
  27. verticalAlignment: Text.AlignVCenter
  28. }
  29. background: Rectangle {
  30. y: control.topPadding - control.bottomPadding
  31. width: parent.width
  32. height: parent.height - control.topPadding + control.bottomPadding
  33. radius: control.Material.roundedScale
  34. color: control.Material.elevation > 0 ? control.Material.backgroundColor : "transparent"
  35. border.color: control.Material.frameColor
  36. layer.enabled: control.enabled && control.Material.elevation > 0
  37. layer.effect: RoundedElevationEffect {
  38. elevation: control.Material.elevation
  39. roundedScale: control.background.radius
  40. }
  41. }
  42. }