DefaultGroupBox.qml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2020 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
  6. import QtQuick.Templates as T
  7. import QtQuick.NativeStyle as NativeStyle
  8. T.GroupBox {
  9. id: control
  10. readonly property bool __nativeBackground: background instanceof NativeStyle.StyleItem
  11. readonly property bool __notCustomizable: true
  12. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  13. contentWidth + leftPadding + rightPadding,
  14. implicitLabelWidth + leftPadding + rightPadding)
  15. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  16. contentHeight + topPadding + bottomPadding)
  17. label: Rectangle {
  18. color: control.palette.window
  19. property point labelPos : control.__nativeBackground
  20. ? background.labelPos
  21. : Qt.point(0,0)
  22. readonly property bool __ignoreNotCustomizable: true
  23. x: labelPos.x + background.x
  24. y: labelPos.y + background.y - (__nativeBackground ? background.groupBoxPadding.top : 0)
  25. width: children[0].implicitWidth
  26. height: children[0].implicitHeight
  27. Text {
  28. width: parent.width
  29. height: parent.height
  30. text: control.title
  31. font: control.font
  32. color: control.palette.windowText
  33. elide: Text.ElideRight
  34. verticalAlignment: Text.AlignVCenter
  35. }
  36. }
  37. leftPadding: __nativeBackground ? background.contentPadding.left : 0
  38. rightPadding: __nativeBackground ? background.contentPadding.right : 0
  39. topPadding: __nativeBackground ? background.contentPadding.top : 0
  40. bottomPadding: __nativeBackground ? background.contentPadding.bottom : 0
  41. leftInset: __nativeBackground ? background.groupBoxPadding.left : 0
  42. topInset: __nativeBackground ? background.groupBoxPadding.top : 0
  43. background: NativeStyle.GroupBox {
  44. control: control
  45. contentWidth: contentItem.implicitWidth
  46. contentHeight: contentItem.implicitHeight
  47. readonly property bool __ignoreNotCustomizable: true
  48. }
  49. }