FluContentDialog.qml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import QtQuick.Controls
  4. import QtQuick.Window
  5. import FluentUI
  6. Popup {
  7. id: popup
  8. property string title: "Title"
  9. property string message: "Message"
  10. property string neutralText: "Neutral"
  11. property string negativeText: "Negative"
  12. property string positiveText: "Positive"
  13. signal neutralClicked
  14. signal negativeClicked
  15. signal positiveClicked
  16. enum ButtonFlag{
  17. NegativeButton=1
  18. ,NeutralButton=2
  19. ,PositiveButton=4
  20. }
  21. property int buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
  22. property var minWidth: {
  23. if(Window.window==null)
  24. return 400
  25. return Math.min(Window.window.width,400)
  26. }
  27. modal:true
  28. anchors.centerIn: Overlay.overlay
  29. closePolicy: Popup.CloseOnEscape
  30. background:Item{}
  31. enter: Transition {
  32. reversible: true
  33. NumberAnimation {
  34. properties: "opacity,scale"
  35. from:0
  36. to:1
  37. duration: 167
  38. easing.type: Easing.BezierSpline
  39. easing.bezierCurve: [ 0, 0, 0, 1 ]
  40. }
  41. }
  42. exit:Transition {
  43. NumberAnimation {
  44. properties: "opacity,scale"
  45. from:1
  46. to:0
  47. duration: 167
  48. easing.type: Easing.BezierSpline
  49. easing.bezierCurve: [ 1, 0, 0, 0 ]
  50. }
  51. }
  52. contentItem: Rectangle {
  53. id:layout_content
  54. implicitWidth:minWidth
  55. implicitHeight: text_title.height + text_message.height + layout_actions.height
  56. color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
  57. radius:5
  58. FluShadow{
  59. radius: 5
  60. }
  61. FluText{
  62. id:text_title
  63. fontStyle: FluText.TitleLarge
  64. text:title
  65. topPadding: 20
  66. leftPadding: 20
  67. rightPadding: 20
  68. wrapMode: Text.WrapAnywhere
  69. anchors{
  70. top:parent.top
  71. left: parent.left
  72. right: parent.right
  73. }
  74. }
  75. FluText{
  76. id:text_message
  77. fontStyle: FluText.Body
  78. wrapMode: Text.WrapAnywhere
  79. text:message
  80. topPadding: 14
  81. leftPadding: 20
  82. rightPadding: 20
  83. bottomPadding: 14
  84. anchors{
  85. top:text_title.bottom
  86. left: parent.left
  87. right: parent.right
  88. }
  89. }
  90. Rectangle{
  91. id:layout_actions
  92. height: 68
  93. radius: 5
  94. color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
  95. anchors{
  96. top:text_message.bottom
  97. left: parent.left
  98. right: parent.right
  99. }
  100. RowLayout{
  101. anchors
  102. {
  103. centerIn: parent
  104. margins: spacing
  105. fill: parent
  106. }
  107. spacing: 15
  108. FluButton{
  109. id:neutral_btn
  110. Layout.fillWidth: true
  111. Layout.fillHeight: true
  112. visible: popup.buttonFlags&FluContentDialog.NeutralButton
  113. text: neutralText
  114. onClicked: {
  115. popup.close()
  116. neutralClicked()
  117. }
  118. }
  119. FluButton{
  120. id:negative_btn
  121. Layout.fillWidth: true
  122. Layout.fillHeight: true
  123. visible: popup.buttonFlags&FluContentDialog.NegativeButton
  124. text: negativeText
  125. onClicked: {
  126. popup.close()
  127. negativeClicked()
  128. }
  129. }
  130. FluFilledButton{
  131. id:positive_btn
  132. Layout.fillWidth: true
  133. Layout.fillHeight: true
  134. visible: popup.buttonFlags&FluContentDialog.PositiveButton
  135. text: positiveText
  136. onClicked: {
  137. popup.close()
  138. positiveClicked()
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }