Dialog.qml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.Dialog {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding,
  12. implicitHeaderWidth,
  13. implicitFooterWidth)
  14. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  15. implicitContentHeight + topPadding + bottomPadding
  16. + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
  17. + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
  18. topPadding: background ? background.topPadding : 0
  19. leftPadding: background ? background.leftPadding : 0
  20. rightPadding: background ? background.rightPadding : 0
  21. bottomPadding: background ? background.bottomPadding : 0
  22. topInset: background ? -background.topInset || 0 : 0
  23. leftInset: background ? -background.leftInset || 0 : 0
  24. rightInset: background ? -background.rightInset || 0 : 0
  25. bottomInset: background ? -background.bottomInset || 0 : 0
  26. background: NinePatchImage {
  27. source: Imagine.url + "dialog-background"
  28. NinePatchImageSelector on source {
  29. states: [
  30. {"modal": control.modal},
  31. {"dim": control.dim}
  32. ]
  33. }
  34. }
  35. header: Label {
  36. text: control.title
  37. visible: parent?.parent === Overlay.overlay && control.title
  38. elide: Label.ElideRight
  39. font.bold: true
  40. padding: 12
  41. background: NinePatchImage {
  42. width: parent.width
  43. height: parent.height
  44. source: Imagine.url + "dialog-title"
  45. NinePatchImageSelector on source {
  46. states: [
  47. {"modal": control.modal},
  48. {"dim": control.dim}
  49. ]
  50. }
  51. }
  52. }
  53. footer: DialogButtonBox {
  54. visible: count > 0
  55. }
  56. T.Overlay.modal: NinePatchImage {
  57. source: Imagine.url + "dialog-overlay"
  58. NinePatchImageSelector on source {
  59. states: [
  60. {"modal": true}
  61. ]
  62. }
  63. }
  64. T.Overlay.modeless: NinePatchImage {
  65. source: Imagine.url + "dialog-overlay"
  66. NinePatchImageSelector on source {
  67. states: [
  68. {"modal": false}
  69. ]
  70. }
  71. }
  72. }