Taskmini.qml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import FluentUI
  4. // 这个组件是在总览那儿小小的显示
  5. // 任务的名称 + 时间 以及一个设置的入口
  6. Item {
  7. id: root
  8. width: 225
  9. height: 40
  10. visible: true
  11. property alias name: taskName.text
  12. property alias nextRun: taskTime.text
  13. signal click(string title)
  14. FluText{
  15. id: taskName
  16. anchors{
  17. left: parent.left
  18. leftMargin: 0
  19. top: parent.top
  20. topMargin: 0
  21. }
  22. text: "taskName"
  23. font: FluTextStyle.BodyStrong
  24. }
  25. FluText{
  26. id: taskTime
  27. anchors{
  28. left: parent.left
  29. leftMargin: 0
  30. bottom: parent.bottom
  31. bottomMargin: 0
  32. }
  33. text: "2023-05-26 18:33:55"
  34. font: FluTextStyle.Caption
  35. }
  36. FluButton{
  37. id: settingButton
  38. anchors{
  39. right: parent.right
  40. rightMargin: 0
  41. verticalCenter: parent.verticalCenter
  42. }
  43. text:"setting"
  44. onClicked: {
  45. showSuccess(name)
  46. root.click(configName)
  47. }
  48. }
  49. // 使用这个的前提是 data 是字符串
  50. function setData(data){
  51. if(data === "{}"){ // 这个表示没有数据,是空的
  52. root.visible = false
  53. return
  54. }
  55. root.visible = true
  56. const d = JSON.parse(data)
  57. task_running.name = d["name"]
  58. task_running.nextRun = d["next_run"]
  59. }
  60. }