Taskmini.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. FluText{
  14. id: taskName
  15. anchors{
  16. left: parent.left
  17. leftMargin: 0
  18. top: parent.top
  19. topMargin: 0
  20. }
  21. text: "taskName"
  22. font: FluTextStyle.BodyStrong
  23. }
  24. FluText{
  25. id: taskTime
  26. anchors{
  27. left: parent.left
  28. leftMargin: 0
  29. bottom: parent.bottom
  30. bottomMargin: 0
  31. }
  32. text: "2023-05-26 18:33:55"
  33. font: FluTextStyle.Caption
  34. }
  35. FluButton{
  36. id: settingButton
  37. anchors{
  38. right: parent.right
  39. rightMargin: 0
  40. verticalCenter: parent.verticalCenter
  41. }
  42. text:"setting"
  43. onClicked: {
  44. showSuccess("setting")
  45. }
  46. }
  47. // 使用这个的前提是 data 是字符串
  48. function setData(data){
  49. if(data === "{}"){ // 这个表示没有数据,是空的
  50. root.visible = false
  51. return
  52. }
  53. root.visible = true
  54. const d = JSON.parse(data)
  55. task_running.name = d["name"]
  56. task_running.nextRun = d["next_run"]
  57. }
  58. }