Add.qml 4.0 KB

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