StartupSplash.qml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import QtQuick
  2. import Felgo
  3. // ========== 启动过渡界面(纯色底 + "启动中...")==========
  4. // 用途:Qt 起来后、锁屏页出现之前的那一小段时间,显示纯色底 + 启动提示,
  5. // 避免"纯色空屏"看起来像卡死。
  6. //
  7. // 与上一版的差别:
  8. // · 上一版的退出条件是"最短 800ms + themeReady + navigation.count>0",任一不满足就顶到
  9. // 6 秒兜底,结果过渡界面盖住了本该立刻出现的锁屏页;
  10. // · 这里只等 themeReady(onInitTheme 在 App 创建时同步执行完,通常几十毫秒),
  11. // 最短 500ms、兜底 1.5 秒,绝不会长时间挡住界面。
  12. //
  13. // 只用 Rectangle / Text / 属性动画,不加载任何图片(res/mipmap/logo.png 是 TFLite 标志,不能用),
  14. // 不依赖 Material/控件实现差异,任何 Felgo 版本、任何设备都能稳定渲染。
  15. Item {
  16. id: splash
  17. property bool night: false // 跟随主题,夜间用深底避免"闪白"
  18. property string titleText: "植物病菌孢子捕捉分析系统"
  19. property string hintText: "启动中..." // 纯色底上的启动提示文字
  20. property string versionText: "" // 传空字符串则不显示版本
  21. readonly property color bgColor: night ? "#263238" : "#e8f5e9"
  22. readonly property color accentColor: night ? "#81c784" : "#2e7d32"
  23. readonly property color textColor: night ? "#ffffff" : "#1b1b1b"
  24. readonly property color subTextColor: night ? "#9e9e9e" : "#5f6368"
  25. readonly property color trackColor: night ? "#33ffffff" : "#26000000"
  26. // 盖住期间拦截所有触摸:过渡还没结束就点到下面的密码键盘会乱
  27. MouseArea {
  28. anchors.fill: parent
  29. }
  30. Rectangle {
  31. anchors.fill: parent
  32. color: splash.bgColor
  33. }
  34. Column {
  35. anchors.centerIn: parent
  36. width: Math.min(splash.width - dp(48), dp(560))
  37. spacing: dp(16)
  38. Text {
  39. width: parent.width
  40. text: splash.titleText
  41. color: splash.textColor
  42. font.pixelSize: dp(26)
  43. font.bold: true
  44. horizontalAlignment: Text.AlignHCenter
  45. wrapMode: Text.WordWrap
  46. }
  47. // 三点跳动:每个点错开 160ms,缩放 + 透明度同步变化
  48. Row {
  49. anchors.horizontalCenter: parent.horizontalCenter
  50. spacing: dp(12)
  51. Repeater {
  52. model: 3
  53. Rectangle {
  54. width: dp(12)
  55. height: dp(12)
  56. radius: width / 2
  57. color: splash.accentColor
  58. SequentialAnimation on opacity {
  59. loops: Animation.Infinite
  60. running: splash.visible
  61. PauseAnimation { duration: index * 160 }
  62. NumberAnimation { from: 0.25; to: 1.0; duration: 320; easing.type: Easing.OutQuad }
  63. NumberAnimation { from: 1.0; to: 0.25; duration: 320; easing.type: Easing.InQuad }
  64. }
  65. SequentialAnimation on scale {
  66. loops: Animation.Infinite
  67. running: splash.visible
  68. PauseAnimation { duration: index * 160 }
  69. NumberAnimation { from: 0.75; to: 1.15; duration: 320; easing.type: Easing.OutQuad }
  70. NumberAnimation { from: 1.15; to: 0.75; duration: 320; easing.type: Easing.InQuad }
  71. }
  72. }
  73. }
  74. }
  75. // 进度条:一段高亮块在轨道里往返,比"静止的进度"更像在推进
  76. Rectangle {
  77. id: track
  78. anchors.horizontalCenter: parent.horizontalCenter
  79. width: parent.width * 0.62
  80. height: dp(4)
  81. radius: height / 2
  82. color: splash.trackColor
  83. clip: true
  84. Rectangle {
  85. id: sweep
  86. width: track.width * 0.34
  87. height: track.height
  88. radius: track.radius
  89. color: splash.accentColor
  90. SequentialAnimation on x {
  91. loops: Animation.Infinite
  92. running: splash.visible
  93. NumberAnimation {
  94. from: 0
  95. to: track.width - sweep.width
  96. duration: 900
  97. easing.type: Easing.InOutQuad
  98. }
  99. NumberAnimation {
  100. to: 0
  101. duration: 900
  102. easing.type: Easing.InOutQuad
  103. }
  104. }
  105. }
  106. }
  107. Text {
  108. width: parent.width
  109. text: splash.hintText
  110. color: splash.subTextColor
  111. font.pixelSize: dp(16)
  112. horizontalAlignment: Text.AlignHCenter
  113. }
  114. }
  115. Text {
  116. anchors.right: parent.right
  117. anchors.bottom: parent.bottom
  118. anchors.margins: dp(12)
  119. visible: splash.versionText !== ""
  120. text: "软件版本:" + splash.versionText
  121. color: splash.subTextColor
  122. font.pixelSize: dp(12)
  123. }
  124. }