Popup.qml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.Controls.impl
  6. import QtQuick.Controls.FluentWinUI3.impl as Impl
  7. import QtQuick.Templates as T
  8. T.Popup {
  9. id: control
  10. implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
  11. implicitContentWidth + leftPadding + rightPadding)
  12. implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
  13. implicitContentHeight + topPadding + bottomPadding)
  14. topPadding: __config.topPadding || 0
  15. bottomPadding: __config.bottomPadding || 0
  16. leftPadding: __config.leftPadding || 0
  17. rightPadding: __config.rightPadding || 0
  18. topInset: -__config.topInset || 0
  19. bottomInset: -__config.bottomInset || 0
  20. leftInset: -__config.leftInset || 0
  21. rightInset: -__config.rightInset || 0
  22. readonly property string __currentState: "normal"
  23. readonly property var __config: Config.controls.popup[__currentState] || {}
  24. readonly property bool __isHighContrast: Application.styleHints.accessibility.contrastPreference === Qt.HighContrast
  25. enter: Transition {
  26. NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; easing.type: Easing.Linear; duration: 83 }
  27. NumberAnimation { property: "scale"; from: control.modal ? 1.05 : 1; to: 1; easing.type: Easing.OutCubic; duration: 167 }
  28. }
  29. exit: Transition {
  30. NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; easing.type: Easing.Linear; duration: 83 }
  31. NumberAnimation { property: "scale"; from: 1; to: control.modal ? 1.05 : 1; easing.type: Easing.OutCubic; duration: 167 }
  32. }
  33. background: Impl.StyleImage {
  34. implicitWidth: 320
  35. implicitHeight: 72
  36. imageConfig: control.__config.background
  37. drawShadowWithinBounds: control.__isHighContrast
  38. Rectangle {
  39. implicitWidth: parent.width
  40. implicitHeight: parent.height
  41. visible: control.__isHighContrast
  42. radius: 4
  43. color: control.palette.window
  44. border.color: control.palette.text
  45. border.width: 2
  46. }
  47. }
  48. T.Overlay.modal: Rectangle {
  49. color: Color.transparent(control.palette.shadow, 0.3)
  50. }
  51. T.Overlay.modeless: Rectangle {
  52. color: "transparent"
  53. }
  54. }