LocalNotificationPage.qml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import Felgo
  2. import QtQuick
  3. import QtQuick.Layouts
  4. import QtQuick.Controls
  5. import "../controls"
  6. import "../common"
  7. AppPage {
  8. id: notificationPage
  9. backgroundColor: Qt.rgba(0,0,0, 0.75) // page background is translucent, we can see other items beneath the page
  10. useSafeArea: false // do not consider safe area insets of screen
  11. Connections{
  12. target: ymodem
  13. onDownloadStart: {
  14. progressBar.value = 0.0
  15. notificationtext.text = mtype
  16. notificationPage.visible = true
  17. }
  18. onProgress: {
  19. console.log("更新进度条:",val,tval)
  20. progressBar.value = val/tval*100.0
  21. process_text.text = progressBar.value.toFixed(2) + "%";
  22. }
  23. onModem_result: {
  24. if(r===0){
  25. progressBar.value = 100.0
  26. notificationtext.text += "成功"
  27. }else{
  28. notificationtext.text += "失败:" + r.toString();
  29. }
  30. }
  31. }
  32. Connections{
  33. target: curl
  34. onSglProgress:{
  35. //console.log("更新进度条:",val,timeLeft)
  36. progressBar.value = val
  37. process_text.text = val.toFixed(2) + "%";
  38. }
  39. onDownloadStart:{
  40. notificationtext.text = mtype
  41. notificationPage.visible = true
  42. }
  43. onDownloadFinished :{
  44. //notificationPage.visible = false
  45. if(result){
  46. notificationtext.text += "成功"
  47. notificationtext.color = "green"
  48. }else{
  49. notificationtext.text += "失败"
  50. notificationtext.color = "red"
  51. }
  52. }
  53. }
  54. // login form background
  55. Rectangle {
  56. id: loginForm
  57. anchors.centerIn: parent
  58. color: "white"
  59. width: content.width + dp(48)
  60. height: content.height + dp(16)
  61. radius: dp(4)
  62. }
  63. // login form content
  64. GridLayout {
  65. id: content
  66. anchors.centerIn: loginForm
  67. columnSpacing: dp(20)
  68. rowSpacing: dp(10)
  69. columns: 2
  70. // headline
  71. AppText {
  72. id: notificationtext
  73. Layout.topMargin: dp(8)
  74. Layout.bottomMargin: dp(12)
  75. Layout.columnSpan: 2
  76. Layout.alignment: Qt.AlignHCenter
  77. text: "通知"
  78. }
  79. AppText {
  80. id: process_text
  81. Layout.bottomMargin: dp(5)
  82. Layout.columnSpan: 2
  83. Layout.alignment: Qt.AlignHCenter
  84. text: ""
  85. }
  86. ProgressBar {
  87. id: progressBar
  88. implicitWidth: dp(300)
  89. from: 0.0000
  90. to: 100.0000
  91. value: 0.0
  92. }
  93. AppButton {
  94. Layout.topMargin: dp(5)
  95. text: qsTr("关闭")
  96. flat: false
  97. Layout.alignment: Qt.AlignHCenter
  98. onClicked: {
  99. progressBar.value = 0.0;
  100. notificationPage.visible = false;
  101. }
  102. }
  103. }
  104. }