Overview.qml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4. import FluentUI
  5. Item {
  6. id: root
  7. property string configName: ""
  8. Item{
  9. id: leftScheduler
  10. width: 260
  11. anchors{
  12. left: parent.left
  13. top: parent.top
  14. bottom: parent.bottom
  15. }
  16. FluArea{
  17. id: schedulerOpen
  18. anchors.top: parent.top
  19. width: parent.width
  20. height: 50
  21. RowLayout{
  22. anchors.fill: parent
  23. FluText{
  24. text: 'Scheduler'
  25. Layout.leftMargin: 16
  26. font: FluTextStyle.Subtitle
  27. Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
  28. }
  29. FluIconButton{
  30. Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
  31. text: "Restart"
  32. iconSource: FluentIcons.RepeatAll
  33. onClicked: {
  34. showSuccess("Restart"+" "+configName)
  35. process_manager.restart(configName)
  36. textLog.text = ""
  37. }
  38. }
  39. FluToggleButton{
  40. Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
  41. Layout.rightMargin: 16
  42. text:"Start"
  43. selected: true
  44. onClicked: {
  45. selected = !selected
  46. if(selected){
  47. text = "Start"
  48. textLog.text = ""
  49. process_manager.stop_script(root.configName)
  50. }else{
  51. // 如果按键颜色变灰色
  52. text = "Stop"
  53. process_manager.start_script(root.configName)
  54. }
  55. }
  56. }
  57. }
  58. }
  59. FluArea{
  60. id: schedulerRunning
  61. anchors.top: schedulerOpen.bottom
  62. anchors.topMargin: 10
  63. width: parent.width
  64. height: 120
  65. ColumnLayout{
  66. width: parent.width
  67. spacing: 8
  68. FluText{
  69. text: 'Running'
  70. Layout.leftMargin: 16
  71. Layout.topMargin: 6
  72. font: FluTextStyle.Subtitle
  73. }
  74. Rectangle{
  75. width: schedulerRunning.width - 20
  76. height: 2
  77. Layout.alignment: Qt.AlignHCenter
  78. color: FluTheme.dark ? Qt.rgba(64/255, 68/255, 75/255, 1) : Qt.rgba(234/255, 236/255, 239/255, 1)
  79. radius: 2
  80. }
  81. Taskmini{
  82. id: task_running
  83. Layout.leftMargin: 16
  84. }
  85. }
  86. }
  87. FluArea{
  88. id: schedulerPending
  89. anchors.top: schedulerRunning.bottom
  90. anchors.topMargin: 10
  91. width: parent.width
  92. height: 240
  93. ColumnLayout{
  94. width: parent.width
  95. spacing: 8
  96. FluText{
  97. text: 'Pending'
  98. Layout.leftMargin: 16
  99. Layout.topMargin: 6
  100. font: FluTextStyle.Subtitle
  101. }
  102. Rectangle{
  103. width: schedulerRunning.width - 20
  104. height: 2
  105. Layout.alignment: Qt.AlignHCenter
  106. color: FluTheme.dark ? Qt.rgba(64/255, 68/255, 75/255, 1) : Qt.rgba(234/255, 236/255, 239/255, 1)
  107. radius: 2
  108. }
  109. Taskmini{
  110. Layout.leftMargin: 16
  111. }
  112. Taskmini{
  113. Layout.leftMargin: 16
  114. }
  115. Taskmini{
  116. Layout.leftMargin: 16
  117. }
  118. Taskmini{
  119. Layout.leftMargin: 16
  120. }
  121. }
  122. }
  123. FluArea{
  124. id: schedulerWaiting
  125. anchors.top: schedulerPending.bottom
  126. anchors.topMargin: 10
  127. anchors.bottom: parent.bottom
  128. anchors.bottomMargin: 0
  129. width: parent.width
  130. ColumnLayout{
  131. width: parent.width
  132. spacing: 8
  133. FluText{
  134. Layout.fillHeight: false
  135. text: 'Waiting'
  136. Layout.leftMargin: 16
  137. Layout.topMargin: 6
  138. font: FluTextStyle.Subtitle
  139. }
  140. Rectangle{
  141. Layout.fillHeight: false
  142. width: schedulerPending.width - 20
  143. height: 2
  144. Layout.alignment: Qt.AlignHCenter
  145. color: FluTheme.dark ? Qt.rgba(64/255, 68/255, 75/255, 1) : Qt.rgba(234/255, 236/255, 239/255, 1)
  146. radius: 2
  147. }
  148. Taskmini{
  149. Layout.leftMargin: 16
  150. Layout.fillHeight: false
  151. }
  152. }
  153. }
  154. }
  155. FluArea{
  156. id: logHeader
  157. anchors.top: parent.top
  158. anchors.left: leftScheduler.right
  159. anchors.leftMargin: 10
  160. anchors.right: parent.right
  161. height: 50
  162. RowLayout{
  163. anchors.fill: parent
  164. RowLayout.alignment: Qt.AlignRight | Qt.AlignVCenter
  165. FluText{
  166. text: 'Log'
  167. Layout.leftMargin: 16
  168. font: FluTextStyle.Subtitle
  169. Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
  170. }
  171. OverStatus{
  172. Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
  173. }
  174. FluToggleButton{
  175. Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
  176. Layout.rightMargin: 16
  177. text:"Auto Scroll On"
  178. selected: true
  179. onClicked: {
  180. selected = !selected
  181. if(selected){
  182. text = "Auto Scroll On"
  183. }else{
  184. text = "Auto Scroll Off"
  185. }
  186. }
  187. }
  188. }
  189. }
  190. FluArea{
  191. anchors.top: logHeader.bottom
  192. anchors.topMargin: 10
  193. anchors.bottom: parent.bottom
  194. anchors.left: leftScheduler.right
  195. anchors.leftMargin: 10
  196. anchors.right: parent.right
  197. FluScrollablePage{
  198. anchors.fill: parent
  199. FluText{
  200. id: textLog
  201. width: parent.width
  202. padding: 10
  203. clip: true
  204. wrapMode: Text.WordWrap // 设置自动换行模式
  205. text: ""
  206. function add_log(config, log){
  207. if(config !== root.configName){
  208. return
  209. }
  210. textLog.text += log
  211. }
  212. Component.onCompleted:{
  213. process_manager.log_signal.connect(textLog.add_log)
  214. }
  215. }}
  216. }
  217. Component.onCompleted:{
  218. process_manager.sig_update_task.connect(update_task)
  219. process_manager.sig_update_pending.connect(update_pending)
  220. process_manager.sig_update_waiting.connect(update_waiting)
  221. }
  222. function update_task(config, data){
  223. if(typeof data !== "string"){
  224. console.error("Pass an incorrect type")
  225. return
  226. }
  227. if(config !== configName){
  228. return
  229. }
  230. task_running.setData(data)
  231. }
  232. function update_pending(config, data){
  233. if(typeof data !== "string"){
  234. console.error("Pass an incorrect type")
  235. return
  236. }
  237. if(config !== configName){
  238. return
  239. }
  240. }
  241. function update_waiting(config, data){
  242. if(typeof data !== "string"){
  243. console.error("Pass an incorrect type")
  244. return
  245. }
  246. if(config !== configName){
  247. return
  248. }
  249. }
  250. }