DialogButtonBox.qml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (C) 2023 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.Universal
  7. T.DialogButtonBox {
  8. id: control
  9. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  10. (control.count === 1 ? implicitContentWidth * 2 : implicitContentWidth) + leftPadding + rightPadding)
  11. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  12. implicitContentHeight + topPadding + bottomPadding)
  13. contentWidth: (contentItem as ListView)?.contentWidth
  14. spacing: 4
  15. padding: 24
  16. topPadding: position === T.DialogButtonBox.Footer ? 6 : 24
  17. bottomPadding: position === T.DialogButtonBox.Header ? 6 : 24
  18. alignment: count === 1 ? Qt.AlignRight : undefined
  19. delegate: Button {
  20. width: control.count === 1 ? control.availableWidth / 2 : undefined
  21. }
  22. contentItem: ListView {
  23. implicitWidth: contentWidth
  24. model: control.contentModel
  25. spacing: control.spacing
  26. orientation: ListView.Horizontal
  27. boundsBehavior: Flickable.StopAtBounds
  28. snapMode: ListView.SnapToItem
  29. }
  30. background: Rectangle {
  31. implicitHeight: 32
  32. color: control.Universal.chromeMediumLowColor
  33. x: 1; y: 1
  34. width: parent.width - 2
  35. height: parent.height - 2
  36. }
  37. }