Dialog.qml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (C) 2024 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.impl
  7. import QtQuick.Effects
  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. readonly property bool __isHighContrast: Application.styleHints.accessibility.contrastPreference === Qt.HighContrast
  19. leftInset: __isHighContrast ? 0 : -32
  20. topInset: __isHighContrast ? 0 : -32
  21. rightInset: __isHighContrast ? 0 : -32
  22. bottomInset: __isHighContrast ? 0 : -32
  23. padding: 24
  24. topPadding: 12
  25. bottomPadding: 23
  26. enter: Transition {
  27. NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.Linear; duration: 83 }
  28. NumberAnimation { property: "scale"; from: control.modal ? 1.05 : 1; to: 1; easing.type: Easing.OutCubic; duration: 167 }
  29. }
  30. exit: Transition {
  31. NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.Linear; duration: 83 }
  32. NumberAnimation { property: "scale"; from: 1; to: control.modal ? 1.05 : 1; easing.type: Easing.OutCubic; duration: 167 }
  33. }
  34. background: Rectangle {
  35. color: control.__isHighContrast ? control.palette.window : "transparent"
  36. border.color: control.__isHighContrast ? control.palette.text : "transparent"
  37. border.width: 2
  38. radius: 8
  39. MultiEffect {
  40. visible: !control.__isHighContrast
  41. x: -control.leftInset
  42. y: -control.topInset
  43. width: source.width
  44. height: source.height
  45. source: Rectangle {
  46. width: control.background.width + control.leftInset + control.rightInset
  47. height: control.background.height + control.topInset + control.bottomInset
  48. color: Application.styleHints.colorScheme === Qt.Light ? "white" : Qt.tint(control.palette.window, Color.transparent("white", 0.05))
  49. border.color: "#66757575"
  50. radius: 8
  51. }
  52. shadowScale: 1
  53. shadowOpacity: 0.19
  54. shadowColor: control.palette.shadow
  55. shadowEnabled: true
  56. shadowHorizontalOffset: 0
  57. shadowVerticalOffset: 32
  58. blurMax: 64
  59. }
  60. }
  61. header: Label {
  62. text: control.title
  63. topPadding: control.padding
  64. leftPadding: control.padding
  65. rightPadding: control.padding
  66. visible: control.title && parent?.parent === Overlay.overlay
  67. elide: Label.ElideRight
  68. font.bold: true
  69. font.pixelSize: 20
  70. font.weight: Font.DemiBold
  71. }
  72. footer: DialogButtonBox {
  73. visible: count > 0
  74. leftInset: control.__isHighContrast ? 1 : 0
  75. topInset: control.__isHighContrast ? 1 : 0
  76. rightInset: control.__isHighContrast ? 1 : 0
  77. bottomInset: control.__isHighContrast ? 1 : 0
  78. }
  79. T.Overlay.modal: Rectangle {
  80. color: Color.transparent(control.palette.shadow, 0.3)
  81. }
  82. T.Overlay.modeless: Rectangle {
  83. color: "transparent"
  84. }
  85. }