DialogButtonBox.qml 1.3 KB

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