Add.qml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import QtQuick.Window
  4. import QtQuick.Controls
  5. import FluentUI
  6. import "../Global"
  7. FluContentDialog{
  8. id:dialog
  9. title:"Add new config"
  10. signal updateScriptItems
  11. contentItem: Rectangle {
  12. id:layout_content
  13. implicitWidth:minWidth
  14. implicitHeight: text_title.height + contextC.height + layout_actions.height
  15. color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1)
  16. radius:5
  17. FluShadow{
  18. radius: 5
  19. }
  20. FluText{
  21. id:text_title
  22. font: FluTextStyle.Subtitle
  23. text:title
  24. topPadding: 20
  25. leftPadding: 20
  26. rightPadding: 20
  27. wrapMode: Text.WrapAnywhere
  28. horizontalAlignment: Text.AlignHCenter
  29. anchors{
  30. top:parent.top
  31. left: parent.left
  32. right: parent.right
  33. }
  34. }
  35. Column{
  36. id: contextC
  37. anchors{
  38. horizontalCenter: parent.horizontalCenter
  39. top: text_title.bottom
  40. }
  41. spacing: 10
  42. FluText{
  43. text: 'New name'
  44. leftPadding: 6
  45. font: FluTextStyle.Caption
  46. }
  47. FluTextBox{
  48. id: newNameBox
  49. placeholderText:"推荐:oas+number"
  50. }
  51. FluText{
  52. text: 'Copy from existing config'
  53. leftPadding: 6
  54. font: FluTextStyle.Caption
  55. }
  56. FComboBox{
  57. id: copyConfig
  58. width: newNameBox.width
  59. model: ["Option 1", "Option 2", "Option 3"]
  60. }
  61. }
  62. Rectangle{
  63. id:layout_actions
  64. height: 68
  65. radius: 5
  66. color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
  67. anchors{
  68. top:contextC.bottom
  69. topMargin: 12
  70. left: parent.left
  71. right: parent.right
  72. }
  73. RowLayout{
  74. anchors
  75. {
  76. centerIn: parent
  77. margins: spacing
  78. fill: parent
  79. }
  80. spacing: 15
  81. FluButton{
  82. id:neutral_btn
  83. Layout.fillWidth: true
  84. Layout.fillHeight: true
  85. visible: dialog.buttonFlags&FluContentDialog.NeutralButton
  86. text: neutralText
  87. onClicked: {
  88. dialog.close()
  89. neutralClicked()
  90. }
  91. }
  92. FluButton{
  93. id:negative_btn
  94. Layout.fillWidth: true
  95. Layout.fillHeight: true
  96. visible: dialog.buttonFlags&FluContentDialog.NegativeButton
  97. text: negativeText
  98. onClicked: {
  99. dialog.close()
  100. negativeClicked()
  101. }
  102. }
  103. FluFilledButton{
  104. id:positive_btn
  105. Layout.fillWidth: true
  106. Layout.fillHeight: true
  107. visible: dialog.buttonFlags&FluContentDialog.PositiveButton
  108. text: positiveText
  109. onClicked: {
  110. dialog.close()
  111. positiveClicked()
  112. }
  113. }
  114. }
  115. }
  116. }
  117. negativeText:"取消"
  118. buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
  119. onNegativeClicked:{
  120. showSuccess("取消创建")
  121. }
  122. positiveText:"确定"
  123. onPositiveClicked:{
  124. showSuccess("已创建")
  125. add_config.copy(newNameBox.text, copyConfig.currentText)
  126. dialog.updateScriptItems()
  127. }
  128. onOpened: {
  129. newNameBox.text = add_config.generate_script_name()
  130. copyConfig.model = add_config.all_json_file()
  131. }
  132. }