Add.qml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. // maxLength: 20
  51. validator: RegularExpressionValidator { regularExpression: /^[a-zA-Z0-9]*$/ }
  52. }
  53. FluText{
  54. text: 'Copy from existing config'
  55. leftPadding: 6
  56. font: FluTextStyle.Caption
  57. }
  58. FComboBox{
  59. id: copyConfig
  60. width: newNameBox.width
  61. model: ["Option 1", "Option 2", "Option 3"]
  62. }
  63. }
  64. Rectangle{
  65. id:layout_actions
  66. height: 68
  67. radius: 5
  68. color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
  69. anchors{
  70. top:contextC.bottom
  71. topMargin: 12
  72. left: parent.left
  73. right: parent.right
  74. }
  75. RowLayout{
  76. anchors
  77. {
  78. centerIn: parent
  79. margins: spacing
  80. fill: parent
  81. }
  82. spacing: 15
  83. FluButton{
  84. id:neutral_btn
  85. Layout.fillWidth: true
  86. Layout.fillHeight: true
  87. visible: dialog.buttonFlags&FluContentDialog.NeutralButton
  88. text: neutralText
  89. onClicked: {
  90. dialog.close()
  91. neutralClicked()
  92. }
  93. }
  94. FluButton{
  95. id:negative_btn
  96. Layout.fillWidth: true
  97. Layout.fillHeight: true
  98. visible: dialog.buttonFlags&FluContentDialog.NegativeButton
  99. text: negativeText
  100. onClicked: {
  101. dialog.close()
  102. negativeClicked()
  103. }
  104. }
  105. FluFilledButton{
  106. id:positive_btn
  107. Layout.fillWidth: true
  108. Layout.fillHeight: true
  109. visible: dialog.buttonFlags&FluContentDialog.PositiveButton
  110. text: positiveText
  111. onClicked: {
  112. dialog.close()
  113. positiveClicked()
  114. }
  115. }
  116. }
  117. }
  118. }
  119. negativeText:"取消"
  120. buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
  121. onNegativeClicked:{
  122. showSuccess("取消创建")
  123. }
  124. positiveText:"确定"
  125. onPositiveClicked:{
  126. showSuccess("已创建")
  127. add_config.copy(newNameBox.text, copyConfig.currentText)
  128. dialog.updateScriptItems()
  129. }
  130. onOpened: {
  131. newNameBox.text = add_config.generate_script_name()
  132. copyConfig.model = add_config.all_json_file()
  133. }
  134. }