DialogButtonBox.qml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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.DialogButtonBox {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. (control.count === 1 ? implicitContentWidth * 2 : implicitContentWidth) + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. implicitContentHeight + topPadding + bottomPadding)
  14. topPadding: background ? background.topPadding : 0
  15. leftPadding: background ? background.leftPadding : 0
  16. rightPadding: background ? background.rightPadding : 0
  17. bottomPadding: background ? background.bottomPadding : 0
  18. topInset: background ? -background.topInset || 0 : 0
  19. leftInset: background ? -background.leftInset || 0 : 0
  20. rightInset: background ? -background.rightInset || 0 : 0
  21. bottomInset: background ? -background.bottomInset || 0 : 0
  22. spacing: 6
  23. delegate: Button {
  24. width: control.count === 1 ? control.availableWidth / 2 : undefined
  25. flat: true
  26. }
  27. contentItem: ListView {
  28. implicitWidth: contentWidth
  29. model: control.contentModel
  30. spacing: control.spacing
  31. orientation: ListView.Horizontal
  32. boundsBehavior: Flickable.StopAtBounds
  33. snapMode: ListView.SnapToItem
  34. }
  35. background: NinePatchImage {
  36. source: Imagine.url + "dialogbuttonbox-background"
  37. NinePatchImageSelector on source {
  38. states: [
  39. {"disabled": !control.enabled},
  40. {"mirrored": control.mirrored}
  41. ]
  42. }
  43. }
  44. }